diff --git a/docs/options.md b/docs/options.md index 2869b20d497..256d292f989 100644 --- a/docs/options.md +++ b/docs/options.md @@ -34,7 +34,26 @@ See [OS X options](https://www.npmjs.com/package/appdmg#json-specification) and Here documented only `electron-builder` specific options: -| Name | Description + + +# Application `package.json` +| Name | Description | --- | --- -| iconUrl
|

*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon.

Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.

-| extraResources |

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).

You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern.

If directory matched, all contents are copied. So, you can just specify `foo` to copy `/foo` directory.

May be specified in the platform options (i.e. in the `build.osx`). +| name | The application name. +| productName |

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}).

+ + +# Development `package.json` +| Name | Description +| --- | --- +| build | See [build](#BuildMetadata). + + +## `.build` +| Name | Description +| --- | --- +| iconUrl |

*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon.

Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.

+| productName | See [AppMetadata.productName](#AppMetadata-productName). +| extraResources |

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).

You can use ${os} (expanded to osx, linux or win according to current platform) and ${arch} in the pattern.

If directory matched, all contents are copied. So, you can just specify foo to copy <project_dir>/foo directory.

May be specified in the platform options (i.e. in the build.osx).

+ + diff --git a/package.json b/package.json index 068f27c2e65..a968ba5e71d 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "pre-commit": "^1.1.2", "semantic-release": "^4.3.5", "should": "^8.3.0", - "ts-babel": "^0.6.1", + "ts-babel": "^0.6.3", "tsconfig-glob": "^0.4.2", "tslint": "next", "typescript": "^1.9.0-dev.20160323", diff --git a/src/builder.ts b/src/builder.ts index d31c51ea78a..e685873d6bd 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -27,36 +27,28 @@ export async function createPublisher(packager: Packager, options: BuildOptions, export interface BuildOptions extends PackagerOptions, PublishOptions { } -export async function build(options: BuildOptions = {}): Promise { - if (options.cscLink == null) { - options.cscLink = process.env.CSC_LINK - } - if (options.csaLink == null) { - options.csaLink = process.env.CSA_LINK - } - if (options.cscKeyPassword == null) { - options.cscKeyPassword = process.env.CSC_KEY_PASSWORD - } - - if (options.githubToken == null) { - options.githubToken = process.env.GH_TOKEN || process.env.GH_TEST_TOKEN - } +export async function build(originalOptions?: BuildOptions): Promise { + const options = 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) const lifecycleEvent = process.env.npm_lifecycle_event - if (options.dist === undefined) { - options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build" - } - if (options.publish) { options.dist = true } + else if (options.dist === undefined) { + options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build" + } let isPublishOptionGuessed = false if (options.publish === undefined) { if (lifecycleEvent === "release") { options.publish = "always" } - else { + else if (options.githubToken != null) { const tag = process.env.TRAVIS_TAG || process.env.APPVEYOR_REPO_TAG_NAME || process.env.CIRCLE_TAG if (tag != null && tag.length !== 0) { log("Tag %s is defined, so artifacts will be published", tag) @@ -82,7 +74,8 @@ export async function build(options: BuildOptions = {}): Promise { } if (publisher != null) { - publisher.then(it => publishTasks.push(>it.upload(event.file, event.artifactName))) + publisher + .then(it => publishTasks.push(>it.upload(event.file, event.artifactName))) } }) } diff --git a/src/index.ts b/src/index.ts index e1a653c11a4..a92758314c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ export { Packager } from "./packager" export { PackagerOptions, ArtifactCreated } from "./platformPackager" +export { BuildOptions, build, createPublisher } from "./builder" export { AppMetadata, DevMetadata, Platform, getProductName } from "./metadata" \ No newline at end of file diff --git a/src/metadata.ts b/src/metadata.ts index 4d08ba3a363..ef4f359b69d 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -2,8 +2,8 @@ export interface Metadata { readonly repository: string | RepositoryInfo } -/* - Application `package.json` +/** + Application `package.json` */ export interface AppMetadata extends Metadata { readonly version: string @@ -14,7 +14,7 @@ export interface AppMetadata extends Metadata { readonly name: string /** - As [name](#name), but allows you to specify a product name for your executable which contains spaces and other special characters + 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 @@ -24,10 +24,13 @@ export interface AppMetadata extends Metadata { readonly author: AuthorMetadata } -/* - Development `package.json` +/** + Development `package.json` */ export interface DevMetadata extends Metadata { + /** + See [BuildMetadata](#BuildMetadata). + */ readonly build?: BuildMetadata readonly directories?: MetadataDirectories @@ -46,10 +49,21 @@ export interface MetadataDirectories { readonly buildResources?: string } +/** + Development `package.json` `.build` + */ export interface BuildMetadata { readonly "app-bundle-id": string readonly "app-category-type": string + /** + *windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon. + + Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http. + + * 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://raw.githubusercontent.com/${info.user}/${info.project}/master/build/icon.ico` by default. + */ readonly iconUrl: string /** @@ -61,6 +75,15 @@ export interface BuildMetadata { readonly win?: any, readonly linux?: any + /** + 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). + + You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern. + + If directory matched, all contents are copied. So, you can just specify `foo` to copy `/foo` directory. + + May be specified in the platform options (i.e. in the `build.osx`). + */ readonly extraResources?: Array } diff --git a/test/src/helpers/expectedContents.ts b/test/src/helpers/expectedContents.ts index 996240a1182..a289e621aa1 100755 --- a/test/src/helpers/expectedContents.ts +++ b/test/src/helpers/expectedContents.ts @@ -1,3 +1,4 @@ +//noinspection SpellCheckingInspection export const expectedLinuxContents = [ "/", "/opt/", @@ -53,6 +54,7 @@ export const expectedLinuxContents = [ "/usr/share/icons/hicolor/96x96/apps/TestApp.png" ] +//noinspection SpellCheckingInspection export const expectedWinContents = [ "lib/net45/content_resources_200_percent.pak", "lib/net45/content_shell.pak", diff --git a/tsconfig.json b/tsconfig.json index 69d296ce7c9..bca952e10bc 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "electron-builder": "out/electron-builder.d.ts", "": "test/out/electron-builder.d.ts" }, + "docs": "docs/options.md", "filesGlob": [ "src/*.ts", "lib/*.d.ts",