Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rewrite test in typescript #218

Merged
merged 1 commit into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
*.log
/out/
out/
npm-debug.log
dist/
/.idea/compiler.xml
Expand Down
2 changes: 2 additions & 0 deletions .idea/electron-builder.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/libraries/electron_builder_for_tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/runConfigurations/BuildTest.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/scopes/src.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/typescript-compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 23 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"version": "0.0.0-semantic-release",
"main": "out/index.js",
"scripts": {
"compile": "tsconfig -i 2 && ts-babel",
"lint": "eslint ./lib test cli.js index.js && tslint src/*",
"pretest": "npm run compile && npm run lint && npm run declaration",
"test": "node ./test/helpers/runTests.js",
"test-nix": "result=\"$(tape index.spec.js ./lib/*.spec.js ./lib/**/*.spec.js)\"; echo \"$result\" | tap-spec; echo \"$result\" | tnyan; ava",
"compile": "npm run compile-production && npm run compile-test",
"compile-production": "tsconfig -i 2 && ts-babel",
"compile-test": "tsconfig -i 2 test && ts-babel test",
"lint": "eslint ./lib cli.js index.js && tslint src/*",
"pretest": "npm run compile && npm run lint",
"test": "node ./test/out/helpers/runTests.js",
"test-nix": "tape ./lib/*.spec.js ./lib/**/*.spec.js && ava",
"test-win": "ava",
"declaration": "dts-generator --name electron-builder --out out/electron-builder.d.ts",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
Expand Down Expand Up @@ -49,11 +50,12 @@
"bugs": "https://github.com/loopline-systems/electron-builder/issues",
"homepage": "https://github.com/loopline-systems/electron-builder",
"dependencies": {
"bluebird": "^3.3.3",
"bluebird": "^3.3.4",
"command-line-args": "^2.1.6",
"electron-packager-tf": "^5.2.3",
"electron-winstaller-temp-fork": "^2.0.5-beta.3",
"fs-extra": "^0.26.5",
"fs-extra-p": "^0.1.0",
"gm": "^1.21.1",
"hosted-git-info": "^2.1.4",
"lodash.template": "^4.2.2",
Expand All @@ -69,61 +71,39 @@
"appdmg": "^0.3.6"
},
"devDependencies": {
"ava-tf": "^0.12.3",
"babel-eslint": "^6.0.0-beta.1",
"ava-tf": "^0.12.4-beta.6",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-async-to-module-method": "^6.5.2",
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.4",
"babel-plugin-transform-es2015-parameters": "^6.6.4",
"babel-plugin-transform-strict-mode": "^6.6.4",
"babel-register": "^6.6.0",
"babel-plugin-transform-es2015-parameters": "^6.6.5",
"electron-download": "^2.0.0",
"eslint": "^2.2.0",
"eslint": "^2.3.0",
"eslint-plugin-ava": "sindresorhus/eslint-plugin-ava",
"ghooks": "^1.0.3",
"json-parse-helpfulerror": "^1.0.3",
"option-chain": "^0.1.1",
"path-sort": "^0.1.0",
"plist": "^1.2.0",
"proxyquire": "^1.7.4",
"semantic-release": "^4.3.5",
"should": "^8.2.2",
"tap-nyan": "0.0.2",
"tap-spec": "^4.1.1",
"tape": "^4.5.0",
"ts-babel": "^0.4.5",
"tape": "^4.5.1",
"ts-babel": "^0.6.1",
"tsconfig-glob": "^0.4.1",
"tsd-generator": "^2.0.2",
"tslint": "^3.5.0",
"typescript": "^1.8.7",
"validate-commit-msg": "^2.2.0"
"tslint": "next",
"typescript": "1.9.0-dev.20160307",
"validate-commit-msg": "^2.3.1"
},
"babel": {
"plugins": [
"transform-es2015-parameters",
"array-includes"
],
"env": {
"test": {
"ignore": ["**/out/*.js"],
"plugins": [
[
"transform-async-to-module-method",
{
"module": "bluebird",
"method": "coroutine"
}
],
"transform-es2015-modules-commonjs",
"transform-strict-mode"
]
}
}
]
},
"ava": {
"verbose": true,
"require": [
"babel-register"
"cache": false,
"files": [
"test/out/*",
"test/old-cli-test.js",
"test/index.spec.js"
]
},
"typings": "./out/electron-builder.d.ts",
Expand Down
8 changes: 7 additions & 1 deletion src/awaiter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Promise as BluebirdPromise } from "bluebird"
import "source-map-support/register"

export function tsAwaiter(thisArg: any, _arguments: any, ignored: any, generator: Function) {
BluebirdPromise.config({
longStackTraces: true,
cancellation: true
})

export = function tsAwaiter(thisArg: any, _arguments: any, ignored: any, generator: Function) {
return BluebirdPromise.coroutine(generator).call(thisArg, _arguments)
}
5 changes: 2 additions & 3 deletions src/build-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { build } from "./builder"
import { PublishOptions } from "./gitHubPublisher"
import { commonArgs } from "./util"
import { printErrorAndExit } from "./promise"
import { tsAwaiter } from "./awaiter"
import cla = require("command-line-args")
import { readFileSync } from "fs"
import * as path from "path"

const __awaiter = tsAwaiter
Array.isArray(__awaiter)
//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

interface CliOptions extends PackagerOptions, PublishOptions {
help: boolean
Expand Down
9 changes: 4 additions & 5 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { PackagerOptions } from "./platformPackager"
import { PublishOptions, Publisher, GitHubPublisher } from "./gitHubPublisher"
import { executeFinally } from "./promise"
import { Promise as BluebirdPromise } from "bluebird"
import { tsAwaiter } from "./awaiter"
import { InfoRetriever } from "./repositoryInfo"
import { log } from "./util"

const __awaiter = tsAwaiter
Array.isArray(__awaiter)
//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

export async function createPublisher(packager: Packager, options: BuildOptions, repoSlug: InfoRetriever, isPublishOptionGuessed: boolean = false): Promise<Publisher> {
const info = await repoSlug.getInfo(packager)
Expand Down Expand Up @@ -74,13 +73,13 @@ export function build(options: BuildOptions = {}): Promise<any> {
const packager = new Packager(options, repositoryInfo)
if (options.publish != null && options.publish !== "never") {
let publisher: BluebirdPromise<Publisher> = null
packager.artifactCreated(path => {
packager.artifactCreated((file, platform) => {
if (publisher == null) {
publisher = <BluebirdPromise<Publisher>>createPublisher(packager, options, repositoryInfo, isPublishOptionGuessed)
}

if (publisher != null) {
publisher.then(it => publishTasks.push(<BluebirdPromise<any>>it.upload(path)))
publisher.then(it => publishTasks.push(<BluebirdPromise<any>>it.upload(file)))
}
})
}
Expand Down
6 changes: 2 additions & 4 deletions src/codeSign.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { exec } from "./util"
import { deleteFile } from "./promisifed-fs"
import { deleteFile } from "fs-extra-p"
import { download } from "./httpRequest"
import { tmpdir } from "os"
import * as path from "path"
import { executeFinally, all } from "./promise"
import { Promise as BluebirdPromise } from "bluebird"
import { randomBytes } from "crypto"
import { tsAwaiter } from "./awaiter"

const __awaiter = tsAwaiter
Array.isArray(__awaiter)
const __awaiter = require("./awaiter")

export interface CodeSigningInfo {
cscName: string
Expand Down
7 changes: 3 additions & 4 deletions src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import { log } from "./util"
import { basename } from "path"
import { parse as parseUrl } from "url"
import * as mime from "mime"
import { stat } from "./promisifed-fs"
import { stat } from "fs-extra-p"
import { createReadStream } from "fs"
import { gitHubRequest, HttpError, doGitHubRequest } from "./gitHubRequest"
import { Promise as BluebirdPromise } from "bluebird"
import { tsAwaiter } from "./awaiter"
import { ReadStream } from "tty"
import progressStream = require("progress-stream")
import ProgressBar = require("progress")

const __awaiter = tsAwaiter
Array.isArray(__awaiter)
//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

export interface Publisher {
upload(path: string): Promise<any>
Expand Down
3 changes: 1 addition & 2 deletions src/gitHubRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { RequestOptions } from "https"
import { IncomingMessage, ClientRequest } from "http"
import { addTimeOutHandler } from "./httpRequest"
import { Promise as BluebirdPromise } from "bluebird"
import { tsAwaiter } from "./awaiter"

const __awaiter = tsAwaiter
const __awaiter = require("./awaiter")
Array.isArray(__awaiter)

export function gitHubRequest<T>(path: string, token: string, data: { [name: string]: any; } = null, method: string = "GET"): BluebirdPromise<T> {
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import platforms = require("./platforms")
import * as path from "path"
import * as fse from "fs-extra"
import * as fs from "fs-extra-p"

export { Packager } from "./packager"
export { PackagerOptions, Platform } from "./platformPackager"

/**
* Prototype for electron-builder
Expand Down Expand Up @@ -34,9 +35,9 @@ const Builder = {

// make sure the output
// directory exists
if (!fse.existsSync(options.out)) {
if (!fs.existsSync(options.out)) {
options.log("- Output directory ´" + options.out + "´ does not exist ")
fse.mkdirsSync(options.out)
fs.mkdirsSync(options.out)
options.log(`- Created '${options.out}`)
}

Expand Down
15 changes: 7 additions & 8 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { tsAwaiter } from "./awaiter"
import { init } from "../lib/linux"
import { PlatformPackager, BuildInfo } from "./platformPackager"
import { dir as _tpmDir, Options as TmpOptions } from "tmp"
import { PlatformPackager, BuildInfo, Platform } from "./platformPackager"
import { dir as _tpmDir, TmpOptions } from "tmp"
import { exec, log } from "./util"
import { State as Gm } from "gm"

const __awaiter = tsAwaiter
const __awaiter = require("./awaiter")
Array.isArray(__awaiter)

const buildDeb = BluebirdPromise.promisify(init().build)
Expand All @@ -27,6 +26,10 @@ export class LinuxPackager extends PlatformPackager<DebOptions> {
}
}

protected get platform() {
return Platform.LINUX
}

private async computeDesktopIconPath(): Promise<Array<string>> {
const tempDir = await tmpDir({
unsafeCleanup: true,
Expand Down Expand Up @@ -59,10 +62,6 @@ export class LinuxPackager extends PlatformPackager<DebOptions> {
]
}

getBuildConfigurationKey() {
return "linux"
}

async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any> {
const specification: DebOptions = {
version: this.metadata.version,
Expand Down
18 changes: 12 additions & 6 deletions src/macPackager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { PlatformPackager, BuildInfo } from "./platformPackager"
import { PlatformPackager, BuildInfo, Platform } from "./platformPackager"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { tsAwaiter } from "./awaiter"
import { log, spawn } from "./util"
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName, sign } from "./codeSign"

const __awaiter = tsAwaiter
const __awaiter = require("./awaiter")
Array.isArray(__awaiter)

export default class MacPackager extends PlatformPackager<appdmg.Specification> {
Expand All @@ -24,8 +23,8 @@ export default class MacPackager extends PlatformPackager<appdmg.Specification>
}
}

getBuildConfigurationKey() {
return "osx"
protected get platform() {
return Platform.OSX
}

async pack(platform: string, outDir: string, appOutDir: string, arch: string): Promise<any> {
Expand Down Expand Up @@ -100,7 +99,14 @@ export default class MacPackager extends PlatformPackager<appdmg.Specification>
const appName = this.metadata.name
// -y param is important - "store symbolic links as the link instead of the referenced file"
const resultPath = `${appName}-${this.metadata.version}-mac.zip`
return spawn("zip", ["-ryXq", resultPath, appName + ".app"], {
const args = ["-ryXq", resultPath, appName + ".app"]

// todo move to options
if (process.env.TEST_MODE === "true") {
args.unshift("-0")
}

return spawn("zip", args, {
cwd: outDir,
stdio: "inherit",
})
Expand Down
Loading