From d77c8da13a1e533e989f53cee3f3e63fd6761720 Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 3 May 2016 11:50:25 +0200 Subject: [PATCH] fix: check wine version Closes #352 --- .travis.yml | 13 +++- package.json | 11 +-- src/builder.ts | 16 ++-- src/codeSign.ts | 16 ++-- src/gitHubPublisher.ts | 22 +++--- src/gitHubRequest.ts | 8 +- src/httpRequest.ts | 4 +- src/install-app-deps.ts | 2 +- src/linuxPackager.ts | 12 +-- src/metadata.ts | 90 +++++++++++----------- src/osxPackager.ts | 17 ++-- src/packager.ts | 88 +++++++++++++++------ src/platformPackager.ts | 45 ++++++----- src/promise.ts | 4 +- src/repositoryInfo.ts | 14 ++-- src/util.ts | 18 ++--- src/winPackager.ts | 12 +-- test/install-linux-dependencies.sh | 8 ++ test/tsconfig.json | 4 +- tsconfig.json | 5 +- typings/asar.d.ts | 2 +- typings/compareVersions.d.ts | 5 ++ typings/lib.es2016.array.include.d.ts | 107 ++++++++++++++++++++++++++ typings/node.d.ts | 14 ++-- typings/signcode.d.ts | 8 +- 25 files changed, 359 insertions(+), 186 deletions(-) create mode 100755 test/install-linux-dependencies.sh create mode 100644 typings/compareVersions.d.ts create mode 100644 typings/lib.es2016.array.include.d.ts diff --git a/.travis.yml b/.travis.yml index 2a576eaf633..2c189a6f5ef 100755 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,10 @@ os: - osx - linux -osx_image: xcode7.3 +osx_image: xcode7 + +dist: trusty +sudo: required env: - NODE_VERSION=4 @@ -19,17 +22,21 @@ cache: addons: apt: + sources: + - mono packages: - icnsutils - graphicsmagick + - mono-devel before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gnu-tar dpkg libicns graphicsmagick git-lfs; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git lfs pull; fi - gem install --no-rdoc --no-ri fpm - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L https://github.com/github/git-lfs/releases/download/v1.1.2/git-lfs-linux-amd64-1.1.2.tar.gz | tar -xz; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git-lfs-1.1.2/git-lfs pull; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then test/install-linux-dependencies.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L https://github.com/github/git-lfs/releases/download/v1.2.0/git-lfs-linux-amd64-1.2.0.tar.gz | tar -xz; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git-lfs-1.2.0/git-lfs pull; fi install: - nvm install $NODE_VERSION diff --git a/package.json b/package.json index 392e7496cf3..a58be89fff7 100644 --- a/package.json +++ b/package.json @@ -58,12 +58,13 @@ "bluebird": "^3.3.5", "chalk": "^1.1.3", "command-line-args": "^2.1.6", + "compare-versions": "^2.0.1", "debug": "^2.2.0", "deep-assign": "^2.0.0", "electron-osx-sign-tf": "~0.5.0-beta.0", "electron-packager-tf": "^7.0.2-beta.0", "electron-winstaller-fixed": "~2.4.0-beta.1", - "fs-extra-p": "^0.4.0", + "fs-extra-p": "^1.0.0", "globby": "^4.0.0", "hosted-git-info": "^2.1.4", "image-size": "^0.5.0", @@ -75,7 +76,7 @@ "signcode-tf": "^0.5.0", "source-map-support": "^0.4.0", "tmp": "0.0.28", - "typescript": "1.9.0-dev.20160425" + "typescript": "^1.9.0-dev.20160502" }, "optionalDependencies": { "appdmg-tf": "^0.3.11" @@ -88,8 +89,8 @@ "devDependencies": { "ava-tf": "^0.12.4-beta.6", "babel-plugin-array-includes": "^2.0.3", - "babel-plugin-transform-es2015-parameters": "^6.7.0", - "babel-plugin-transform-es2015-spread": "^6.6.5", + "babel-plugin-transform-es2015-parameters": "^6.8.0", + "babel-plugin-transform-es2015-spread": "^6.8.0", "decompress-zip": "^0.3.0", "electron-download": "^2.1.2", "json-parse-helpfulerror": "^1.0.3", @@ -98,7 +99,7 @@ "pre-git": "^3.8.3", "semantic-release": "^4.3.5", "should": "^8.3.1", - "ts-babel": "^0.7.0", + "ts-babel": "^0.8.6", "tsconfig-glob": "^0.4.3", "tslint": "next", "typescript": "^1.9.0-dev.20160414" diff --git a/src/builder.ts b/src/builder.ts index 3b87a4bbe63..bd3070aef4a 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -9,7 +9,7 @@ import { log } from "./util" //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") -export async function createPublisher(packager: Packager, options: BuildOptions, repoSlug: InfoRetriever, isPublishOptionGuessed: boolean = false): Promise { +export async function createPublisher(packager: Packager, options: BuildOptions, repoSlug: InfoRetriever, isPublishOptionGuessed: boolean = false): Promise { const info = await repoSlug.getInfo(packager) if (info == null) { if (isPublishOptionGuessed) { @@ -20,7 +20,7 @@ export async function createPublisher(packager: Packager, options: BuildOptions, throw new Error("Please specify 'repository' in the dev package.json ('" + packager.devPackageFile + "')") } else { - return new GitHubPublisher(info.user, info.project, packager.metadata.version, options.githubToken, options.publish !== "onTagOrDraft") + return new GitHubPublisher(info.user, info.project, packager.metadata.version, options.githubToken!, options.publish !== "onTagOrDraft") } } @@ -28,14 +28,14 @@ export interface BuildOptions extends PackagerOptions, PublishOptions { } export async function build(originalOptions?: BuildOptions): Promise { - const options = Object.assign({ + const options: BuildOptions = Object.assign({ cscLink: process.env.CSC_LINK, csaLink: process.env.CSA_LINK, cscKeyPassword: process.env.CSC_KEY_PASSWORD, githubToken: process.env.GH_TOKEN || process.env.GH_TEST_TOKEN, }, originalOptions) - options.platform = normalizePlatforms(originalOptions.platform) + options.platform = normalizePlatforms(options.platform) const lifecycleEvent = process.env.npm_lifecycle_event if (options.publish) { @@ -69,13 +69,13 @@ export async function build(originalOptions?: BuildOptions): Promise { const repositoryInfo = new InfoRetriever() const packager = new Packager(options, repositoryInfo) if (options.publish != null && options.publish !== "never") { - let publisher: BluebirdPromise = null + let publisher: Promise | null = null packager.artifactCreated(event => { if (publisher == null) { - publisher = >createPublisher(packager, options, repositoryInfo, isPublishOptionGuessed) + publisher = createPublisher(packager, options, repositoryInfo, isPublishOptionGuessed) } - if (publisher != null) { + if (publisher) { publisher .then(it => publishTasks.push(>it.upload(event.file, event.artifactName))) } @@ -85,7 +85,7 @@ export async function build(originalOptions?: BuildOptions): Promise { await executeFinally(packager.build(), errorOccurred => { if (errorOccurred) { for (let task of publishTasks) { - task.cancel() + task!.cancel() } return BluebirdPromise.resolve(null) } diff --git a/src/codeSign.ts b/src/codeSign.ts index b3baf54e4cb..9bb5b92f003 100644 --- a/src/codeSign.ts +++ b/src/codeSign.ts @@ -12,9 +12,9 @@ const __awaiter = require("./awaiter") export interface CodeSigningInfo { name: string - keychainName?: string + keychainName?: string | null - installerName?: string + installerName?: string | null } function randomString(): string { @@ -25,7 +25,7 @@ export function generateKeychainName(): string { return "csc-" + randomString() + ".keychain" } -export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string, cscIKeyPassword?: string, csaLink?: string): Promise { +export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string | null, cscIKeyPassword?: string | null, csaLink?: string | null): Promise { const certLinks = [csaLink || "https://developer.apple.com/certificationauthority/AppleWWDRCA.cer"] if (csaLink == null) { certLinks.push("https://startssl.com/certs/sca.code2.crt", "https://startssl.com/certs/sca.code3.crt") @@ -56,14 +56,14 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass }) } -async function importCerts(keychainName: string, paths: Array, keyPasswords: Array): Promise { +async function importCerts(keychainName: string, paths: Array, keyPasswords: Array): Promise { for (let f of paths.slice(0, -keyPasswords.length)) { - await exec("security", ["import", f, "-k", keychainName, "-T", "/usr/bin/codesign"]) + await exec("security", ["import", f!, "-k", keychainName, "-T", "/usr/bin/codesign"]) } const namePromises: Array> = [] for (let i = paths.length - keyPasswords.length, j = 0; i < paths.length; i++, j++) { - const password = keyPasswords[j] + const password = keyPasswords[j]! const certPath = paths[i] await exec("security", ["import", certPath, "-k", keychainName, "-T", "/usr/bin/codesign", "-T", "/usr/bin/productbuild", "-P", password]) @@ -81,12 +81,12 @@ async function importCerts(keychainName: string, paths: Array, keyPasswo function extractCommonName(password: string, certPath: string): BluebirdPromise { return exec("openssl", ["pkcs12", "-nokeys", "-nodes", "-passin", "pass:" + password, "-nomacver", "-clcerts", "-in", certPath]) .then(result => { - const match = result[0].toString().match(/^subject.*\/CN=([^\/\n]+)/m) + const match = | null>(result[0].toString().match(/^subject.*\/CN=([^\/\n]+)/m)) if (match == null || match[1] == null) { throw new Error("Cannot extract common name from p12") } else { - return match[1] + return match[1]! } }) } diff --git a/src/gitHubPublisher.ts b/src/gitHubPublisher.ts index 7e714827c09..fcabf919eb4 100644 --- a/src/gitHubPublisher.ts +++ b/src/gitHubPublisher.ts @@ -19,19 +19,19 @@ export interface Publisher { } export interface PublishOptions { - publish?: "onTag" | "onTagOrDraft" | "always" | "never" - githubToken?: string + publish?: "onTag" | "onTagOrDraft" | "always" | "never" | null + githubToken?: string | null } export class GitHubPublisher implements Publisher { private tag: string private _releasePromise: BluebirdPromise - get releasePromise(): Promise { + get releasePromise(): Promise { return this._releasePromise } - constructor(private owner: string, private repo: string, version: string, private token: string, private createReleaseIfNotExists: boolean = true) { + constructor(private owner: string, private repo: string, version: string, private token: string | null, private createReleaseIfNotExists: boolean = true) { if (token == null || token.length === 0) { throw new Error("GitHub Personal Access Token is not specified") } @@ -40,12 +40,12 @@ export class GitHubPublisher implements Publisher { this._releasePromise = >this.init() } - private async init(): Promise { + private async init(): Promise { // we don't use "Get a release by tag name" because "tag name" means existing git tag, but we draft release and don't create git tag const releases = await gitHubRequest>(`/repos/${this.owner}/${this.repo}/releases`, this.token) for (let release of releases) { - if (release.tag_name === this.tag) { - if (!release.draft) { + if (release!.tag_name === this.tag) { + if (!release!.draft) { if (this.createReleaseIfNotExists) { throw new Error("Release must be a draft") } @@ -53,7 +53,7 @@ export class GitHubPublisher implements Publisher { return null } } - return release + return release! } } @@ -70,7 +70,7 @@ export class GitHubPublisher implements Publisher { const fileName = artifactName || basename(file) const release = await this.releasePromise if (release == null) { - return null + return } const parsedUrl = parseUrl(release.upload_url.substring(0, release.upload_url.indexOf("{")) + "?name=" + fileName) @@ -113,8 +113,8 @@ export class GitHubPublisher implements Publisher { log("Artifact %s already exists, overwrite one", fileName) const assets = await gitHubRequest>(`/repos/${this.owner}/${this.repo}/releases/${release.id}/assets`, this.token) for (let asset of assets) { - if (asset.name === fileName) { - await gitHubRequest(`/repos/${this.owner}/${this.repo}/releases/assets/${asset.id}`, this.token, null, "DELETE") + if (asset!.name === fileName) { + await gitHubRequest(`/repos/${this.owner}/${this.repo}/releases/assets/${asset!.id}`, this.token, null, "DELETE") continue uploadAttempt } } diff --git a/src/gitHubRequest.ts b/src/gitHubRequest.ts index 4e4f1fca786..99cc04c7644 100644 --- a/src/gitHubRequest.ts +++ b/src/gitHubRequest.ts @@ -7,7 +7,7 @@ import { Promise as BluebirdPromise } from "bluebird" const __awaiter = require("./awaiter") Array.isArray(__awaiter) -export function gitHubRequest(path: string, token: string, data: { [name: string]: any; } = null, method: string = "GET"): BluebirdPromise { +export function gitHubRequest(path: string, token: string | null, data: { [name: string]: any; } | null = null, method: string = "GET"): BluebirdPromise { const options: any = { hostname: "api.github.com", path: path, @@ -27,7 +27,7 @@ export function gitHubRequest(path: string, token: string, data: { [name: str return doGitHubRequest(options, token, it => it.end(encodedData)) } -export function doGitHubRequest(options: RequestOptions, token: string, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): BluebirdPromise { +export function doGitHubRequest(options: RequestOptions, token: string | null, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): BluebirdPromise { if (token != null) { (options.headers).authorization = "token " + token } @@ -80,12 +80,12 @@ Please double check that your GitHub Token is correct. Due to security reasons G addTimeOutHandler(request, reject) request.on("error", reject) requestProcessor(request, reject) - onCancel(() => request.abort()) + onCancel!(() => request.abort()) }) } export class HttpError extends Error { constructor(public response: IncomingMessage, public description: any = null) { - super(response.statusCode + " " + response.statusMessage + (description == null ? "" : ("\n" + JSON.stringify(description, null, " "))) + "\nHeaders: " + JSON.stringify(response.headers, null, " ")) + super(response.statusCode + " " + response.statusMessage + (description == null ? "" : ("\n" + JSON.stringify(description, null, " "))) + "\nHeaders: " + JSON.stringify(response.headers, null, " ")) } } \ No newline at end of file diff --git a/src/httpRequest.ts b/src/httpRequest.ts index d185170f415..40f66cc798b 100644 --- a/src/httpRequest.ts +++ b/src/httpRequest.ts @@ -13,10 +13,10 @@ function _download(url: string, destination: string, callback: (error: Error) => doDownload(url, destination, 0, callback) } -export function addTimeOutHandler(request: ClientRequest, callback: (error: Error | string) => void) { +export function addTimeOutHandler(request: ClientRequest, callback: (error: Error) => void) { request.on("socket", function (socket: Socket) { socket.setTimeout(60 * 1000, () => { - callback("Request timed out") + callback(new Error("Request timed out")) request.abort() }) }) diff --git a/src/install-app-deps.ts b/src/install-app-deps.ts index 4293144cf30..3c28ea53497 100644 --- a/src/install-app-deps.ts +++ b/src/install-app-deps.ts @@ -18,7 +18,7 @@ const devPackageFile = path.join(projectDir, "package.json") async function main() { const devMetadata: DevMetadata = await readPackageJson(devPackageFile) const results: Array = await BluebirdPromise.all([ - computeDefaultAppDirectory(projectDir, use(devMetadata.directories, it => it.app) || args.appDir), + computeDefaultAppDirectory(projectDir, use(devMetadata.directories, it => it!.app) || args.appDir), getElectronVersion(devMetadata, devPackageFile) ]) diff --git a/src/linuxPackager.ts b/src/linuxPackager.ts index 48584d12f2c..bdaa8b69c4d 100755 --- a/src/linuxPackager.ts +++ b/src/linuxPackager.ts @@ -72,11 +72,11 @@ Icon=${this.metadata.name} const mappings: Array = [] const pngIconsDir = path.join(this.buildResourcesDir, "icons") for (let file of (await readdir(pngIconsDir))) { - if (file.endsWith(".png") || file.endsWith(".PNG")) { + if (file!.endsWith(".png") || file!.endsWith(".PNG")) { // If parseInt encounters a character that is not a numeral in the specified radix, // it returns the integer value parsed up to that point try { - const size = parseInt(file, 10) + const size = parseInt(file!, 10) if (size > 0) { mappings.push(`${pngIconsDir}/${file}=/usr/share/icons/hicolor/${size}x${size}/apps/${this.metadata.name}.png`) } @@ -194,13 +194,13 @@ Icon=${this.metadata.name} "--url", projectUrl, ] - use(this.metadata.license || this.devMetadata.license, it => args.push("--license", it)) - use(this.computeBuildNumber(), it => args.push("--iteration", it)) + use(this.metadata.license || this.devMetadata.license, it => args.push("--license", it!)) + use(this.computeBuildNumber(), it => args.push("--iteration", it!)) - use(options.fpm, it => args.push(...it)) + use(options.fpm, it => args.push(...it)) args.push(`${appOutDir}/=/opt/${this.appName}`) - args.push(...(await this.packageFiles)) + args.push(...(await this.packageFiles)!) await exec("fpm", args) return destination } diff --git a/src/metadata.ts b/src/metadata.ts index c7d42d910a7..2b758711cf1 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -1,5 +1,5 @@ export interface Metadata { - readonly repository?: string | RepositoryInfo + readonly repository?: string | RepositoryInfo | null } /* @@ -17,14 +17,14 @@ export interface AppMetadata extends Metadata { As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}). */ - readonly productName?: string + readonly productName?: string | null /* The application description. */ readonly description: string - readonly main?: string + readonly main?: string | null readonly author: AuthorMetadata @@ -33,12 +33,12 @@ export interface AppMetadata extends Metadata { If not specified and your project repository is public on GitHub, it will be `https://github.com/${user}/${project}` by default. */ - readonly homepage?: string + readonly homepage?: string | null /* *linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name. */ - readonly license?: string + readonly license?: string | null } /* @@ -51,15 +51,15 @@ export interface DevMetadata extends Metadata { readonly build: BuildMetadata // deprecated - readonly homepage?: string + readonly homepage?: string | null // deprecated - readonly license?: string + readonly license?: string | null /* See [.directories](#MetadataDirectories) */ - readonly directories?: MetadataDirectories + readonly directories?: MetadataDirectories | null } export interface RepositoryInfo { @@ -78,7 +78,7 @@ export interface BuildMetadata { /* *OS X-only.* The app bundle ID. See [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070). */ - readonly "app-bundle-id"?: string + readonly "app-bundle-id"?: string | null /* *OS X-only.* The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory. @@ -86,7 +86,7 @@ export interface BuildMetadata { Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8). */ - readonly "app-category-type"?: string + readonly "app-category-type"?: string | null /* Whether to package the application's source code into an archive, using [Electron's archive format](https://github.com/electron/asar). Defaults to `true`. @@ -95,12 +95,12 @@ export interface BuildMetadata { readonly asar?: boolean // deprecated - readonly iconUrl?: string + readonly iconUrl?: string | null /* See [AppMetadata.productName](#AppMetadata-productName). */ - readonly productName?: string + readonly productName?: string | null /** A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app's directory (`Contents/Resources` for OS X). @@ -111,34 +111,34 @@ export interface BuildMetadata { May be specified in the platform options (i.e. in the `build.osx`). */ - readonly extraResources?: Array + readonly extraResources?: Array | null /* See [.build.osx](#OsXBuildOptions). */ - readonly osx?: OsXBuildOptions + readonly osx?: OsXBuildOptions | null /* See [.build.mas](#MasBuildOptions). */ - readonly mas?: MasBuildOptions + readonly mas?: MasBuildOptions | null /** See [.build.win](#LinuxBuildOptions). */ - readonly win?: any, + readonly win?: WinBuildOptions | null /* See [.build.linux](#LinuxBuildOptions). */ - readonly linux?: LinuxBuildOptions + readonly linux?: LinuxBuildOptions | null /* The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly. */ - readonly compression?: "store" | "normal" | "maximum" + readonly compression?: "store" | "normal" | "maximum" | null - readonly "build-version"?: string + readonly "build-version"?: string | null } /* @@ -150,29 +150,29 @@ export interface OsXBuildOptions extends PlatformSpecificBuildOptions { /* The path to icon, which will be shown when mounted (default: `build/icon.icns`). */ - readonly icon?: string + readonly icon?: string | null /* The path to background (default: `build/background.png`). The resolution of this file determines the resolution of the installer window. */ - readonly background?: string + readonly background?: string | null /* Target package type: list of `default`, `dmg`, `zip`, `mas`, `7z`. Defaults to `default` (dmg and zip for Squirrel.Mac). */ - readonly target?: Array + readonly target?: Array | null /* The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). MAS installer identity is specified in the [.build.mas](#MasBuildOptions-identity). */ - readonly identity?: string + readonly identity?: string | null /* The path to entitlements file for signing the app. `build/osx.entitlements` will be used if exists (it is a recommended way to set). MAS entitlements is specified in the [.build.mas](#MasBuildOptions-entitlements). */ - readonly entitlements?: string + readonly entitlements?: string | null /* The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/osx.inherit.entitlements` will be used if exists (it is a recommended way to set). @@ -180,7 +180,7 @@ export interface OsXBuildOptions extends PlatformSpecificBuildOptions { This option only applies when signing with `entitlements` provided. */ - readonly entitlementsInherit?: string + readonly entitlementsInherit?: string | null } /* @@ -192,19 +192,19 @@ export interface MasBuildOptions extends OsXBuildOptions { /* The name of certificate to use when signing. Consider using environment variables [CSC_INSTALLER_LINK or CSC_INSTALLER_NAME](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). */ - readonly identity?: string + readonly identity?: string | null /* The path to entitlements file for signing the app. `build/mas.entitlements` will be used if exists (it is a recommended way to set). Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.mas.entitlements). */ - readonly entitlements?: string + readonly entitlements?: string | null /* The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/mas.inherit.entitlements` will be used if exists (it is a recommended way to set). Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.mas.inherit.entitlements). */ - readonly entitlementsInherit?: string + readonly entitlementsInherit?: string | null } /* @@ -222,13 +222,13 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions { * If you don't plan to build windows installer, you can omit it. * If your project repository is public on GitHub, it will be `https://github.com/${u}/${p}/blob/master/build/icon.ico?raw=true` by default. */ - readonly iconUrl?: string + readonly iconUrl?: string | null /* The path to a .gif file to display during install. `build/install-spinner.gif` will be used if exists (it is a recommended way to set) (otherwise [default](https://github.com/electron/windows-installer/blob/master/resources/install-spinner.gif)). */ - readonly loadingGif?: string + readonly loadingGif?: string | null /* Whether to create an MSI installer. Defaults to `true` (MSI is not created). @@ -238,12 +238,12 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions { /* A URL to your existing updates. If given, these will be downloaded to create delta updates. */ - readonly remoteReleases?: string + readonly remoteReleases?: string | null /* Authentication token for remote updates */ - readonly remoteToken?: string + readonly remoteToken?: string | null } /* @@ -253,36 +253,36 @@ export interface LinuxBuildOptions { /* As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux. */ - description?: string + description?: string | null /* *deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description). */ - synopsis?: string + synopsis?: string | null /* The maintainer. Defaults to [author](#AppMetadata-author). */ - maintainer?: string + maintainer?: string | null /* The vendor. Defaults to [author](#AppMetadata-author). */ - vendor?: string + vendor?: string | null // should be not documented, only to experiment - fpm?: string[] + fpm?: Array | null //.desktop file template - desktop?: string + desktop?: string | null - afterInstall?: string - afterRemove?: string + afterInstall?: string | null + afterRemove?: string | null /* *deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`). */ - readonly compression?: string + readonly compression?: string | null } /* @@ -292,21 +292,21 @@ export interface MetadataDirectories { /* The path to build resources, default `build`. */ - readonly buildResources?: string + readonly buildResources?: string | null /* The output directory, default `dist`. */ - readonly output?: string + readonly output?: string | null /* The application directory (containing the application package.json), default `app`, `www` or working directory. */ - readonly app?: string + readonly app?: string | null } export interface PlatformSpecificBuildOptions { - readonly extraResources?: Array + readonly extraResources?: Array | null } export class Platform { diff --git a/src/osxPackager.ts b/src/osxPackager.ts index f98ce191224..bcfaa6756d4 100644 --- a/src/osxPackager.ts +++ b/src/osxPackager.ts @@ -13,7 +13,7 @@ import { readdir } from "fs-extra-p" const __awaiter = require("./awaiter") export default class OsXPackager extends PlatformPackager { - codeSigningInfo: Promise + codeSigningInfo: Promise readonly targets: Array @@ -50,7 +50,7 @@ export default class OsXPackager extends PlatformPackager { async pack(outDir: string, arch: string, postAsyncTasks: Array>): Promise { const packOptions = this.computePackOptions(outDir, arch) - let nonMasPromise: Promise = null + let nonMasPromise: Promise | null = null if (this.targets.length > 1 || this.targets[0] !== "mas") { const appOutDir = this.computeAppOutDir(outDir, arch) nonMasPromise = this.doPack(packOptions, outDir, appOutDir, arch, this.customBuildOptions) @@ -71,7 +71,7 @@ export default class OsXPackager extends PlatformPackager { } } - private async sign(appOutDir: string, masOptions: MasBuildOptions): Promise { + private async sign(appOutDir: string, masOptions: MasBuildOptions | null): Promise { let codeSigningInfo = await this.codeSigningInfo if (codeSigningInfo == null) { codeSigningInfo = { @@ -80,12 +80,13 @@ export default class OsXPackager extends PlatformPackager { } } - if (codeSigningInfo.name == null) { + const identity = codeSigningInfo.name + if (identity == null) { log("App is not signed: CSC_LINK or CSC_NAME are not specified") return } - log(`Signing app (${codeSigningInfo.name})`) + log(`Signing app (${identity})`) const baseSignOptions: BaseSignOptions = { app: path.join(appOutDir, this.appName + ".app"), @@ -96,7 +97,7 @@ export default class OsXPackager extends PlatformPackager { } const signOptions = Object.assign({ - identity: codeSigningInfo.name, + identity: identity, }, (this.devMetadata.build)["osx-sign"], baseSignOptions) const resourceList = await this.resourceList @@ -189,7 +190,7 @@ export default class OsXPackager extends PlatformPackager { } if (debug.enabled) { - debug(`appdmg: ${JSON.stringify(dmgOptions, null, 2)}`) + debug(`appdmg: ${JSON.stringify(dmgOptions, null, 2)}`) } const emitter = require("appdmg-tf")(dmgOptions) @@ -208,7 +209,7 @@ export default class OsXPackager extends PlatformPackager { for (let target of this.targets) { if (target !== "mas" && target !== "dmg") { - const format = target === "default" ? "zip" : target + const format = target === "default" ? "zip" : target! log("Creating OS X " + format) // for default we use mac to be compatible with Squirrel.Mac const classifier = target === "default" ? "mac" : "osx" diff --git a/src/packager.ts b/src/packager.ts index 184227a1774..325cde45b3c 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -1,5 +1,8 @@ import * as path from "path" -import { computeDefaultAppDirectory, installDependencies, log, getElectronVersion, readPackageJson, use, warn } from "./util" +import { + computeDefaultAppDirectory, installDependencies, log, getElectronVersion, readPackageJson, use, warn, + exec +} from "./util" import { all, executeFinally } from "./promise" import { EventEmitter } from "events" import { Promise as BluebirdPromise } from "bluebird" @@ -11,6 +14,7 @@ import { WinPackager } from "./winPackager" import * as errorMessages from "./errorMessages" import * as util from "util" import deepAssign = require("deep-assign") +import compareVersions = require("compare-versions") //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -33,7 +37,7 @@ export class Packager implements BuildInfo { readonly eventEmitter = new EventEmitter() //noinspection JSUnusedGlobalSymbols - constructor(public options: PackagerOptions, public repositoryInfo: InfoRetriever = null) { + constructor(public options: PackagerOptions, public repositoryInfo: InfoRetriever | null = null) { this.projectDir = options.projectDir == null ? process.cwd() : path.resolve(options.projectDir) } @@ -48,10 +52,10 @@ export class Packager implements BuildInfo { async build(): Promise { const devPackageFile = this.devPackageFile - const platforms = this.options.platform + const platforms = this.options.platform! this.devMetadata = deepAssign(await readPackageJson(devPackageFile), this.options.devMetadata) - this.appDir = await computeDefaultAppDirectory(this.projectDir, use(this.devMetadata.directories, it => it.app) || this.options.appDir) + this.appDir = await computeDefaultAppDirectory(this.projectDir, use(this.devMetadata.directories, it => it!.app) || this.options.appDir) this.isTwoPackageJsonProjectLayoutUsed = this.appDir !== this.projectDir @@ -68,14 +72,27 @@ export class Packager implements BuildInfo { private async doBuild(platforms: Array, cleanupTasks: Array<() => Promise>): Promise { const distTasks: Array> = [] - const outDir = path.resolve(this.projectDir, use(this.devMetadata.directories, it => it.output) || "dist") + const outDir = path.resolve(this.projectDir, use(this.devMetadata.directories, it => it!.output) || "dist") + // custom packager - don't check wine + let checkWine = this.options.platformPackagerFactory == null for (let platform of platforms) { - const helper = this.createHelper(platform, cleanupTasks) - for (let arch of normalizeArchs(platform, this.options.arch)) { - await this.installAppDependencies(platform, arch) + let wineCheck: Promise | null = null + if (checkWine && process.platform !== "win32" && platform === Platform.WINDOWS) { + wineCheck = exec("wine", ["--version"]) + } + + const helper = this.createHelper(platform!, cleanupTasks) + for (let arch of normalizeArchs(platform!, this.options.arch)) { + await this.installAppDependencies(platform!, arch!) + + if (checkWine && wineCheck != null) { + checkWine = false + checkWineVersion(wineCheck) + } + // electron-packager uses productName in the directory name - await helper.pack(outDir, arch, distTasks)} + await helper.pack(outDir, arch!, distTasks)} } return await BluebirdPromise.all(distTasks) @@ -83,7 +100,7 @@ export class Packager implements BuildInfo { private createHelper(platform: Platform, cleanupTasks: Array<() => Promise>): PlatformPackager { if (this.options.platformPackagerFactory != null) { - return this.options.platformPackagerFactory(this, platform, cleanupTasks) + return this.options.platformPackagerFactory!(this, platform, cleanupTasks) } switch (platform) { @@ -113,13 +130,13 @@ export class Packager implements BuildInfo { } const appMetadata = this.metadata - if (appMetadata.name == null) { + if (appMetadata.name == null) { reportError("name") } - else if (appMetadata.description == null) { + else if (appMetadata.description == null) { reportError("description") } - else if (appMetadata.version == null) { + else if (appMetadata.version == null) { reportError("version") } else if ((appMetadata) !== this.devMetadata) { @@ -135,15 +152,15 @@ export class Packager implements BuildInfo { } } - if (this.devMetadata.build == null) { + if (this.devMetadata.build == null) { throw new Error(util.format(errorMessages.buildIsMissed, devAppPackageFile)) } else { const author = appMetadata.author - if (author == null) { + if (author == null) { reportError("author") } - else if (this.options.dist && author.email == null && platforms.includes(Platform.LINUX)) { + else if (this.options.dist && author.email == null && platforms.includes(Platform.LINUX)) { throw new Error(util.format(errorMessages.authorEmailIsMissed, appPackageFile)) } } @@ -166,7 +183,7 @@ export class Packager implements BuildInfo { } } -export function normalizeArchs(platform: Platform, arch?: string) { +export function normalizeArchs(platform: Platform, arch?: string | n) { if (platform === Platform.OSX) { return ["x64"] } @@ -175,9 +192,9 @@ export function normalizeArchs(platform: Platform, arch?: string) { } } -export function normalizePlatforms(rawPlatforms: Array | string | Platform): Array { - const platforms = rawPlatforms == null || Array.isArray(rawPlatforms) ? (>rawPlatforms) : [rawPlatforms] - if (platforms == null || platforms.length === 0) { +export function normalizePlatforms(rawPlatforms: Array | string | Platform | n): Array { + const platforms = rawPlatforms == null || Array.isArray(rawPlatforms) ? (>rawPlatforms) : [rawPlatforms] + if (platforms == null || platforms.length === 0) { return [Platform.fromString(process.platform)] } else if (platforms[0] === "all") { @@ -193,14 +210,41 @@ export function normalizePlatforms(rawPlatforms: Array | stri } } else { - return platforms.map(it => it instanceof Platform ? it : Platform.fromString(it)) + return platforms.map(it => it instanceof Platform ? it : Platform.fromString(it!)) } } function checkConflictingOptions(options: any) { for (let name of ["all", "out", "tmpdir", "version", "platform", "dir", "arch"]) { - if (name in options) { + if (name! in options) { throw new Error(`Option ${name} is ignored, do not specify it.`) } } +} + +async function checkWineVersion(checkPromise: Promise) { + function wineError(prefix: string): string { + return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "os-x")}` + } + + let wineVersion: string + try { + wineVersion = (await checkPromise)[0].toString().trim() + } + catch (e) { + if (e.code === "ENOENT") { + throw new Error(wineError("wine is required")) + } + else { + throw new Error("Cannot check wine version: " + e) + } + } + + if (wineVersion.startsWith("wine-")) { + wineVersion = wineVersion.substring("wine-".length) + } + + if (compareVersions(wineVersion, "1.8") === -1) { + throw new Error(wineError(`wine 1.8+ is required, but your version is ${wineVersion}`)) + } } \ No newline at end of file diff --git a/src/platformPackager.ts b/src/platformPackager.ts index 2b9a5bc384e..17da810a952 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -18,28 +18,28 @@ const __awaiter = require("./awaiter") const pack = BluebirdPromise.promisify(packager) export interface PackagerOptions { - arch?: string + arch?: string | null - dist?: boolean - githubToken?: string + dist?: boolean | null + githubToken?: string | null - sign?: string + sign?: string | null - platform?: Array + platform?: Array | null // deprecated - appDir?: string + appDir?: string | null - projectDir?: string + projectDir?: string | null - cscLink?: string - csaLink?: string - cscKeyPassword?: string + cscLink?: string | null + csaLink?: string | null + cscKeyPassword?: string | null - cscInstallerLink?: string - cscInstallerKeyPassword?: string + cscInstallerLink?: string | null + cscInstallerKeyPassword?: string | null - platformPackagerFactory?: (packager: Packager, platform: Platform, cleanupTasks: Array<() => Promise>) => PlatformPackager + platformPackagerFactory?: ((packager: Packager, platform: Platform, cleanupTasks: Array<() => Promise>) => PlatformPackager) | n /** * The same as [development package.json](https://github.com/electron-userland/electron-builder/wiki/Options#development-packagejson). @@ -59,7 +59,7 @@ export interface BuildInfo extends ProjectMetadataProvider { electronVersion: string - repositoryInfo: InfoRetriever + repositoryInfo: InfoRetriever | n eventEmitter: EventEmitter } @@ -90,7 +90,7 @@ export abstract class PlatformPackager } protected get relativeBuildResourcesDirname() { - return use(this.devMetadata.directories, it => it.buildResources) || "build" + return use(this.devMetadata.directories, it => it!.buildResources) || "build" } protected computeAppOutDir(outDir: string, arch: string): string { @@ -110,7 +110,7 @@ export abstract class PlatformPackager return this.doPack(this.computePackOptions(outDir, arch), outDir, appOutDir, arch, this.customBuildOptions, postAsyncTasks) } - protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: string, customBuildOptions: DC, postAsyncTasks: Array> = null) { + protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: string, customBuildOptions: DC, postAsyncTasks: Array> | null = null) { await this.packApp(options, appOutDir) await this.copyExtraResources(appOutDir, arch, customBuildOptions) if (postAsyncTasks != null && this.options.dist) { @@ -157,12 +157,12 @@ export abstract class PlatformPackager protected async packApp(options: ElectronPackagerOptions, appOutDir: string): Promise { await pack(options) - await this.sanityCheckPackage(appOutDir, options.asar) + await this.sanityCheckPackage(appOutDir, options.asar) } private getExtraResources(arch: string, customBuildOptions: DC): Promise> { const buildMetadata: any = this.devMetadata.build - let extraResources: Array = buildMetadata == null ? null : buildMetadata.extraResources + let extraResources: Array | n = buildMetadata == null ? null : buildMetadata.extraResources const platformSpecificExtraResources = customBuildOptions.extraResources if (platformSpecificExtraResources != null) { @@ -189,7 +189,7 @@ export abstract class PlatformPackager protected abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise - protected async computePackageUrl(): Promise { + protected async computePackageUrl(): Promise { const url = this.metadata.homepage || this.devMetadata.homepage if (url != null) { return url @@ -204,7 +204,7 @@ export abstract class PlatformPackager return null } - protected computeBuildNumber(): string { + protected computeBuildNumber(): string | null { return this.devMetadata.build["build-version"] || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_NUMBER } @@ -217,8 +217,7 @@ export abstract class PlatformPackager const resourcesDir = this.platform === Platform.OSX ? this.getOSXResourcesDir(appOutDir) : path.join(appOutDir, "resources") if (isAsar) { try { - const fsAsar = statFile(path.join(resourcesDir, "app.asar"), relativeFile) - return fsAsar != null + return statFile(path.join(resourcesDir, "app.asar"), relativeFile) != null } catch (e) { // asar throws error on access to undefined object (info.link) @@ -255,7 +254,7 @@ export interface ArtifactCreated { readonly platform: Platform } -export function normalizeTargets(targets: Array | string): Array { +export function normalizeTargets(targets: Array | string | null | undefined): Array | null { if (targets == null) { return null } diff --git a/src/promise.ts b/src/promise.ts index 254431b8f3c..ce01543693c 100644 --- a/src/promise.ts +++ b/src/promise.ts @@ -5,7 +5,7 @@ import { red } from "chalk" const __awaiter = require("./awaiter") export function printErrorAndExit(error: Error) { - console.error(red(error.stack.toString() || error.message || error.toString())) + console.error(red((error.stack || error).toString())) process.exit(-1) } @@ -41,7 +41,7 @@ export class NestedError extends Error { let i = 1 for (let error of errors) { const prefix = "Error #" + i++ + " " - m += "\n\n" + prefix + "-".repeat(80) + "\n" + error.stack + m += "\n\n" + prefix + "-".repeat(80) + "\n" + error!.stack } super(m) } diff --git a/src/repositoryInfo.ts b/src/repositoryInfo.ts index 4cd4ee6005d..e93e625de22 100644 --- a/src/repositoryInfo.ts +++ b/src/repositoryInfo.ts @@ -17,9 +17,9 @@ export interface RepositorySlug { } export class InfoRetriever { - _info: Promise + _info: Promise | null - getInfo(provider?: ProjectMetadataProvider): Promise { + getInfo(provider?: ProjectMetadataProvider): Promise { if (this._info == null) { this._info = getInfo(provider) } @@ -27,8 +27,8 @@ export class InfoRetriever { } } -async function getGitUrlFromGitConfig(): Promise { - let data: string = null +async function getGitUrlFromGitConfig(): Promise { + let data: string | null = null try { data = await readFile(path.join(".git", "config"), "utf8") } @@ -55,13 +55,13 @@ async function getGitUrlFromGitConfig(): Promise { return null } -async function getInfo(provider?: ProjectMetadataProvider): Promise { +async function getInfo(provider?: ProjectMetadataProvider | null): Promise { const repo = provider == null ? null : (provider.devMetadata.repository || provider.metadata.repository) if (repo == null) { let url = process.env.TRAVIS_REPO_SLUG if (url == null) { - const user: string = process.env.APPVEYOR_ACCOUNT_NAME || process.env.CIRCLE_PROJECT_USERNAME - const project: string = process.env.APPVEYOR_PROJECT_NAME || process.env.CIRCLE_PROJECT_REPONAME + const user: string | null = process.env.APPVEYOR_ACCOUNT_NAME || process.env.CIRCLE_PROJECT_USERNAME + const project: string | null = process.env.APPVEYOR_PROJECT_NAME || process.env.CIRCLE_PROJECT_REPONAME if (user != null && project != null) { return { user: user, diff --git a/src/util.ts b/src/util.ts index 902d4d3490b..414515ace88 100644 --- a/src/util.ts +++ b/src/util.ts @@ -3,7 +3,7 @@ import { Promise as BluebirdPromise } from "bluebird" import readPackageJsonAsync = require("read-package-json") import * as os from "os" import * as path from "path" -import { readJson, stat } from "fs-extra-p" +import { readJson, stat, Stats } from "fs-extra-p" import { yellow } from "chalk" import debugFactory = require("debug") import { Debugger } from "~debug/node" @@ -71,9 +71,9 @@ export interface SpawnOptions extends BaseExecOptions { detached?: boolean } -export function exec(file: string, args?: string[], options?: ExecOptions): BluebirdPromise { +export function exec(file: string, args?: Array | null, options?: ExecOptions): BluebirdPromise { if (debug.enabled) { - debug(`Executing ${file} ${args.join(" ")}`) + debug(`Executing ${file} ${args == null ? "" : args.join(" ")}`) } return new BluebirdPromise((resolve, reject) => { @@ -96,9 +96,9 @@ export function exec(file: string, args?: string[], options?: ExecOptions): Blue }) } -export function spawn(command: string, args?: string[], options?: SpawnOptions): BluebirdPromise { +export function spawn(command: string, args?: Array | null, options?: SpawnOptions): BluebirdPromise { if (debug.enabled) { - debug(`Spawning ${command} ${args.join(" ")}`) + debug(`Spawning ${command} ${args == null ? "" : args.join(" ")}`) } return new BluebirdPromise((resolve, reject) => { @@ -118,7 +118,7 @@ export async function getElectronVersion(packageData: any, packageJsonPath: stri } const devDependencies = packageData.devDependencies - let electronPrebuiltDep: string = devDependencies == null ? null : devDependencies["electron-prebuilt"] + let electronPrebuiltDep = devDependencies == null ? null : devDependencies["electron-prebuilt"] if (electronPrebuiltDep == null) { const dependencies = packageData.dependencies electronPrebuiltDep = dependencies == null ? null : dependencies["electron-prebuilt"] @@ -132,7 +132,7 @@ export async function getElectronVersion(packageData: any, packageJsonPath: stri return firstChar === "^" || firstChar === "~" ? electronPrebuiltDep.substring(1) : electronPrebuiltDep } -export async function statOrNull(file: string) { +export async function statOrNull(file: string): Promise { try { return await stat(file) } @@ -146,7 +146,7 @@ export async function statOrNull(file: string) { } } -export async function computeDefaultAppDirectory(projectDir: string, userAppDir: string): Promise { +export async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | null | undefined): Promise { if (userAppDir != null) { const absolutePath = path.join(projectDir, userAppDir) const stat = await statOrNull(absolutePath) @@ -169,6 +169,6 @@ export async function computeDefaultAppDirectory(projectDir: string, userAppDir: return projectDir } -export function use(value: T, task: (it: T) => R): R { +export function use(value: T | null, task: (it: T) => R): R | null { return value == null ? null : task(value) } \ No newline at end of file diff --git a/src/winPackager.ts b/src/winPackager.ts index 4ad8518c330..eebcb8bc8c2 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -11,11 +11,11 @@ import { sign } from "signcode-tf" const __awaiter = require("./awaiter") export class WinPackager extends PlatformPackager { - certFilePromise: Promise + certFilePromise: Promise - extraNuGetFileSources: Promise> + extraNuGetFileSources: Promise> | null - loadingGifStat: Promise + loadingGifStat: Promise | null readonly iconPath: Promise @@ -93,7 +93,7 @@ export class WinPackager extends PlatformPackager { log(`Signing ${filename}`) await BluebirdPromise.promisify(sign)({ path: path.join(appOutDir, filename), - cert: await this.certFilePromise, + cert: (await this.certFilePromise)!, password: this.options.cscKeyPassword, name: this.appName, site: await this.computePackageUrl(), @@ -208,7 +208,7 @@ async function checkIcon(file: string): Promise { const sizes = parseIco(buffer) for (let size of sizes) { - if (size.w >= 256 && size.h >= 256) { + if (size!.w >= 256 && size!.h >= 256) { return } } @@ -247,7 +247,7 @@ export function computeDistOut(outDir: string, arch: string): string { function checkConflictingOptions(options: any) { for (let name of ["outputDirectory", "appDirectory", "exe", "fixUpPaths", "usePackageJson", "extraFileSpecs", "extraMetadataSpecs", "skipUpdateIcon", "setupExe"]) { - if (name in options) { + if (name! in options) { throw new Error(`Option ${name} is ignored, do not specify it.`) } } diff --git a/test/install-linux-dependencies.sh b/test/install-linux-dependencies.sh new file mode 100755 index 00000000000..5f92b4355c4 --- /dev/null +++ b/test/install-linux-dependencies.sh @@ -0,0 +1,8 @@ +wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + +sudo dpkg --add-architecture i386 + +sudo add-apt-repository ppa:wine/wine-builds -y +sudo apt-get update + +sudo apt-get install -y winehq-devel \ No newline at end of file diff --git a/test/tsconfig.json b/test/tsconfig.json index b1da0dd092a..049003bd3ab 100755 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -20,7 +20,6 @@ "!../typings/browser/**/*.d.ts", "!../typings/browser.d.ts", "!../typings/main.d.ts", - "../node_modules/typescript/lib/lib.es7.d.ts", "src/**/*.ts", "../node_modules/fs-extra-p/index.d.ts", "../node_modules/fs-extra-p/bluebird.d.ts", @@ -31,11 +30,13 @@ "../typings/appdmg.d.ts", "../typings/asar.d.ts", "../typings/command-line-args.d.ts", + "../typings/compareVersions.d.ts", "../typings/deep-assign.d.ts", "../typings/electron-packager.d.ts", "../typings/gh-api.d.ts", "../typings/globby.d.ts", "../typings/hosted-git-info.d.ts", + "../typings/lib.es2016.array.include.d.ts", "../typings/main/ambient/mime/mime.d.ts", "../typings/main/ambient/progress/progress.d.ts", "../typings/main/ambient/tmp/tmp.d.ts", @@ -52,7 +53,6 @@ "typings/path-sort.d.ts", "typings/plist.d.ts", "typings/should.d.ts", - "../node_modules/typescript/lib/lib.es7.d.ts", "../node_modules/fs-extra-p/index.d.ts", "../node_modules/fs-extra-p/bluebird.d.ts", "out/electron-builder.d.ts", diff --git a/tsconfig.json b/tsconfig.json index fd9f6ccd57e..99b6504084a 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "inlineSources": true, "sourceMap": true, "noImplicitReturns": true, + "strictNullChecks": true, "noEmitHelpers": true, "noFallthroughCasesInSwitch": true }, @@ -25,7 +26,6 @@ "!typings/browser/**/*.d.ts", "!typings/browser.d.ts", "!typings/main.d.ts", - "node_modules/typescript/lib/lib.es7.d.ts", "node_modules/fs-extra-p/index.d.ts", "node_modules/7zip-bin/index.d.ts", "node_modules/fs-extra-p/bluebird.d.ts", @@ -35,11 +35,13 @@ "typings/appdmg.d.ts", "typings/asar.d.ts", "typings/command-line-args.d.ts", + "typings/compareVersions.d.ts", "typings/deep-assign.d.ts", "typings/electron-packager.d.ts", "typings/gh-api.d.ts", "typings/globby.d.ts", "typings/hosted-git-info.d.ts", + "typings/lib.es2016.array.include.d.ts", "typings/main/ambient/mime/mime.d.ts", "typings/main/ambient/progress/progress.d.ts", "typings/main/ambient/tmp/tmp.d.ts", @@ -50,7 +52,6 @@ "typings/progress-stream.d.ts", "typings/read-package-json.d.ts", "typings/signcode.d.ts", - "node_modules/typescript/lib/lib.es7.d.ts", "node_modules/fs-extra-p/index.d.ts", "node_modules/7zip-bin/index.d.ts", "node_modules/fs-extra-p/bluebird.d.ts", diff --git a/typings/asar.d.ts b/typings/asar.d.ts index 85ba24efb64..81dd3b932a1 100644 --- a/typings/asar.d.ts +++ b/typings/asar.d.ts @@ -7,5 +7,5 @@ declare module "asar" { export function listPackage(archive: string): Array // followLinks defaults to true - export function statFile(archive: string, filename: string, followLinks?: boolean): Info + export function statFile(archive: string, filename: string, followLinks?: boolean): Info | null } \ No newline at end of file diff --git a/typings/compareVersions.d.ts b/typings/compareVersions.d.ts new file mode 100644 index 00000000000..53e3e6e3547 --- /dev/null +++ b/typings/compareVersions.d.ts @@ -0,0 +1,5 @@ +declare module "compare-versions" { + function compareVersions(a: string, b: string): number + + export = compareVersions +} \ No newline at end of file diff --git a/typings/lib.es2016.array.include.d.ts b/typings/lib.es2016.array.include.d.ts new file mode 100644 index 00000000000..cc957a64c42 --- /dev/null +++ b/typings/lib.es2016.array.include.d.ts @@ -0,0 +1,107 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +// TS is ugly outdated monstrous language (dream about Kotlin) +type n = null | undefined + +interface Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} \ No newline at end of file diff --git a/typings/node.d.ts b/typings/node.d.ts index 76c5d1cc349..696e68fd0a2 100644 --- a/typings/node.d.ts +++ b/typings/node.d.ts @@ -920,7 +920,7 @@ declare module "child_process" { unref(): void; } - export function spawn(command: string, args?: string[], options?: { + export function spawn(command: string, args?: string[] | null | undefined, options?: { cwd?: string; stdio?: any; custom?: any; @@ -936,13 +936,13 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + }, callback?: (error: Error | null, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function execFile(file: string, - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], options?: { + callback?: (error: Error | null, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[] | null | undefined, + callback?: (error: Error | null, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[] | null | undefined, options?: { cwd?: string; stdio?: any; customFds?: any; @@ -951,7 +951,7 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + }, callback?: (error: Error | null, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; diff --git a/typings/signcode.d.ts b/typings/signcode.d.ts index 3a42b6772c5..930b847ea2b 100644 --- a/typings/signcode.d.ts +++ b/typings/signcode.d.ts @@ -2,12 +2,12 @@ declare module "signcode-tf" { export interface SignOptions { path: string cert: string - name?: string + name?: string | null password: string - site?: string - hash?: Array + site?: string | null + hash?: Array | null overwrite?: boolean } - export function sign(options: SignOptions, callback: (error: Error) => void): void + export function sign(options: SignOptions, callback: (error: Error | null) => void): void } \ No newline at end of file