diff --git a/.gitignore b/.gitignore index 1b6220594a2..eca1a127e47 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ dist/ /test/out/**/*.map /test/test-report.xml -/packages/electron-builder/README.md \ No newline at end of file +/packages/electron-builder/README.md +/packages/electron-builder/scheme.json \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0454be706e..e2954a62adc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,10 +91,10 @@ Or you can create Node.js run configuration manually: ### Run Test using CLI ```sh -TEST_APP_TMP_DIR=/tmp/electron-builder-test ./node_modules/.bin/jest --env jest-environment-node-debug -t 'boring' '/TestFileName\.\w+$' +TEST_APP_TMP_DIR=/tmp/electron-builder-test ./node_modules/.bin/jest --env jest-environment-node-debug -t 'boring' '/oneClickInstallerTest\.\w+$' ``` -where `TEST_APP_TMP_DIR` is specified to easily inspect and use test build, `boring` is the test name and `test/out/nsisTest.js` is the path to test file. +where `TEST_APP_TMP_DIR` is specified to easily inspect and use test build, `boring` is the test name and `/oneClickInstallerTest\.\w+$` is the path to test file. Do not forget to execute `yarn compile` before run. diff --git a/appveyor.yml b/appveyor.yml index 2e2847189e5..7ba111fef9d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ cache: - '%USERPROFILE%\.electron' environment: - TEST_FILES: BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,nsisTest + TEST_FILES: BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,oneClickInstallerTest,installerTest install: - ps: Install-Product node 6 x64 diff --git a/package.json b/package.json index b84b5139388..35b67b6b5ea 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "license": "MIT", "scripts": { - "compile": "ts-babel packages/electron-builder-http packages/electron-builder-core packages/electron-builder-util packages/electron-builder-publisher packages/electron-builder packages/electron-builder-squirrel-windows packages/electron-updater packages/electron-publisher-s3 test", + "compile": "ts-babel packages/electron-builder-http packages/electron-builder-core packages/electron-builder-util packages/electron-builder-publisher packages/electron-builder packages/electron-builder-squirrel-windows packages/electron-updater packages/electron-publisher-s3 test && node ./test/vendor/yarn.js scheme", "lint": "node test/out/helpers/lint.js", "pretest": "node ./test/vendor/yarn.js compile && node ./test/vendor/yarn.js lint && node ./test/vendor/yarn.js lint-deps", "lint-deps": "node ./test/out/helpers/checkDeps.js", @@ -17,7 +17,8 @@ "test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11", "update-deps": "lerna exec -- npm-check-updates --reject 'electron-builder-http,electron-builder-util,electron-builder-core,electron-builder-publisher' -a", "set-versions": "node test/out/helpers/setVersions.js", - "npm-publish": "yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s" + "npm-publish": "yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s", + "scheme": "typescript-json-schema packages/electron-builder/tsconfig.json Config --out packages/electron-builder/scheme.json" }, "//": "repository must be specified otherwise conventional-changelog will use forked repo (currently cloned)", "repository": "electron-userland/electron-builder", @@ -82,6 +83,7 @@ "ts-babel": "^1.3.6", "tslint": "^4.4.2", "typescript": "^2.2.0", + "typescript-json-schema": "^0.9.0", "whitespace": "^2.1.0", "xml2js": "^0.4.17" }, diff --git a/packages/electron-builder-core/src/core.ts b/packages/electron-builder-core/src/core.ts index 30dd387aec9..c2050753e1a 100644 --- a/packages/electron-builder-core/src/core.ts +++ b/packages/electron-builder-core/src/core.ts @@ -91,7 +91,7 @@ export abstract class Target { } export interface TargetSpecificOptions { - /* + /** The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). */ readonly artifactName?: string | null diff --git a/packages/electron-builder-http/src/publishOptions.ts b/packages/electron-builder-http/src/publishOptions.ts index 1880f9322eb..7ec6af1ac4d 100644 --- a/packages/electron-builder-http/src/publishOptions.ts +++ b/packages/electron-builder-http/src/publishOptions.ts @@ -2,7 +2,7 @@ export type PublishProvider = "github" | "bintray" | "s3" | "generic" export type Publish = string | Array | PublishConfiguration | GithubOptions | S3Options | BintrayOptions | GenericServerOptions | Array | Array | Array | Array | Array | null -/* +/** ### `publish` Can be specified in the [config](https://github.com/electron-userland/electron-builder/wiki/Options#configuration-options) or any platform- or target- specific options. @@ -16,12 +16,12 @@ Array of option objects. Order is important — first item will be used as a def Amazon S3 — `https` must be used, so, if you use direct Amazon S3 endpoints, format `https://s3.amazonaws.com/bucket_name` [must be used](http://stackoverflow.com/a/11203685/1910191). And do not forget to make files/directories public. */ export interface PublishConfiguration { - /* + /** The provider, one of `github`, `s3`, `bintray`, `generic`. */ provider: PublishProvider - /* + /** The owner. */ owner?: string | null @@ -29,11 +29,11 @@ export interface PublishConfiguration { token?: string | null } -/* +/** ### `publish` Generic (any HTTP(S) server) */ export interface GenericServerOptions extends PublishConfiguration { - /* + /** The base url. e.g. `https://bucket_name.s3.amazonaws.com`. You can use `${os}` (expanded to `mac`, `linux` or `win` according to target platform) and `${arch}` macros. */ url: string @@ -44,18 +44,18 @@ export interface GenericServerOptions extends PublishConfiguration { channel?: string | null } -/* +/** ### `publish` Amazon S3 [Getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html). */ export interface S3Options extends PublishConfiguration { - /* + /** The bucket name. */ bucket: string - /* + /** The directory path. Defaults to `/`. */ path?: string | null @@ -70,7 +70,7 @@ export interface S3Options extends PublishConfiguration { */ acl?: "private" | "public-read" | null - /* + /** The type of storage to use for the object. One of `STANDARD`, `REDUCED_REDUNDANCY`, `STANDARD_IA`. Defaults to `STANDARD`. */ storageClass?: "STANDARD" | "REDUCED_REDUNDANCY" | "STANDARD_IA" | null @@ -100,26 +100,26 @@ export interface UpdateInfo extends VersionInfo { readonly releaseDate: string } -/* +/** ### `publish` GitHub */ export interface GithubOptions extends PublishConfiguration { - /* + /** The repository name. [Detected automatically](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#github-repository). */ repo?: string | null - /* + /** Whether to use `v`-prefixed tag name. Defaults to `true`. */ vPrefixedTagName?: boolean - /* + /** The host (including the port if need). Defaults to `github.com`. */ host?: string | null - /* + /** The protocol, one of `https` or `http`. Defaults to `https`. GitHub Publisher supports only `https`. @@ -131,21 +131,21 @@ export function githubUrl(options: GithubOptions) { return `${options.protocol || "https"}://${options.host || "github.com"}` } -/* +/** ### `publish` Bintray */ export interface BintrayOptions extends PublishConfiguration { - /* + /** The Bintray package name. */ package?: string | null - /* + /** The Bintray repository name. Defaults to `generic`. */ repo?: string | null - /* + /** The Bintray user account. Used in cases where the owner is an organization. */ user?: string | null diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts index e76ee96a934..8c2a649514d 100755 --- a/packages/electron-builder/src/metadata.ts +++ b/packages/electron-builder/src/metadata.ts @@ -15,7 +15,7 @@ export interface AsarOptions { extraMetadata?: any | null } -/* +/** ## Fields in the package.json Some standard fields should be defined in the `package.json`. @@ -27,19 +27,19 @@ export interface Metadata { readonly version?: string - /* + /** The application name. @required */ readonly name?: string - /* + /** 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 | null - /* + /** The application description. */ readonly description?: string @@ -48,14 +48,14 @@ export interface Metadata { readonly author?: AuthorMetadata - /* + /** The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)). If not specified and your project repository is public on GitHub, it will be `https://github.com/${user}/${project}` by default. */ readonly homepage?: string | null - /* + /** *linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name. */ readonly license?: string | null @@ -80,11 +80,11 @@ export interface FilePattern { filter?: Array | string } -/* +/** ## Configuration Options */ export interface Config extends PlatformSpecificBuildOptions, TargetSpecificOptions { - /* + /** The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). @@ -93,7 +93,7 @@ export interface Config extends PlatformSpecificBuildOptions, TargetSpecificOpti */ readonly appId?: string | null - /* + /** The human-readable copyright line for the app. Defaults to `Copyright © year author`. */ readonly copyright?: string | null @@ -101,7 +101,7 @@ export interface Config extends PlatformSpecificBuildOptions, TargetSpecificOpti // deprecated readonly iconUrl?: string | null - /* + /** See [AppMetadata.productName](#AppMetadata-productName). */ readonly productName?: string | null @@ -113,19 +113,19 @@ export interface Config extends PlatformSpecificBuildOptions, TargetSpecificOpti */ readonly files?: Array | string | null - /* + /** A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the project directory, when specified, copy the file or directory with matching names directly into the app's resources directory (`Contents/Resources` for MacOS, `resources` for Linux/Windows). Glob rules the same as for [files](#multiple-glob-patterns). */ readonly extraResources?: Array | FilePattern | Array | string | null - /* + /** The same as [extraResources](#Config-extraResources) but copy into the app's content directory (`Contents` for MacOS, root directory for Linux/Windows). */ readonly extraFiles?: Array | FilePattern | Array | string | null - /* + /** Whether to package the application's source code into an archive, using [Electron's archive format](http://electron.atom.io/docs/tutorial/application-packaging/). Defaults to `true`. Node modules, that must be unpacked, will be detected automatically, you don't need to explicitly set [asarUnpack](#Config-asarUnpack) - please file issue if this doesn't work. */ @@ -154,71 +154,71 @@ export interface Config extends PlatformSpecificBuildOptions, TargetSpecificOpti readonly deb?: DebOptions | null readonly snap?: SnapOptions | 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?: CompressionLevel | null - /* + /** *programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned. */ readonly afterPack?: (context: AfterPackContext) => Promise | null - /* + /** *programmatic API only* The function to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Promise must be returned. Resolving to `false` will skip dependencies install or rebuild. */ readonly beforeBuild?: (context: BeforeBuildContext) => Promise | null - /* + /** Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. */ readonly npmRebuild?: boolean - /* + /** Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. Defaults to `false`. */ readonly npmSkipBuildFromSource?: boolean - /* + /** Additional command line arguments to use when installing app native deps. Defaults to `null`. */ readonly npmArgs?: Array | string | null - /* + /** Whether to execute `node-gyp rebuild` before starting to package the app. Defaults to `false`. */ readonly nodeGypRebuild?: boolean - /* + /** The path to custom Electron build (e.g. `~/electron/out/R`). Only macOS supported, file issue if need for Linux or Windows. */ readonly electronDist?: string - /* + /** The [electron-download](https://github.com/electron-userland/electron-download#usage) options. */ readonly electronDownload?: any readonly icon?: string | null - /* + /** See [publish](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#PublishConfiguration). */ readonly publish?: Publish - /* + /** Whether to fail if application will be not signed (to prevent unsigned app if code signing configuration is not correct). */ readonly forceCodeSigning?: boolean readonly directories?: MetadataDirectories | null - /* + /** The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency. */ readonly electronVersion?: string | null - /* + /** The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName}-${version}.${ext}` (some target can have another defaults, see corresponding options). Currently supported only for `pkg`, `dmg` and `nsis`. @@ -240,7 +240,7 @@ export interface BeforeBuildContext { readonly arch: string } -/* +/** ### `fileAssociations` File Associations macOS (corresponds to [CFBundleDocumentTypes](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685)) and NSIS only. Array of option objects. @@ -248,38 +248,38 @@ export interface BeforeBuildContext { On Windows works only if [nsis.perMachine](https://github.com/electron-userland/electron-builder/wiki/Options#NsisOptions-perMachine) is set to `true`. */ export interface FileAssociation { - /* + /** The extension (minus the leading period). e.g. `png`. */ readonly ext: string | Array - /* + /** The name. e.g. `PNG`. Defaults to `ext`. */ readonly name?: string | null - /* + /** *windows-only.* The description. */ readonly description?: string | null - /* + /** The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon. */ readonly icon?: string - /* + /** *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`. */ readonly role?: string - /* + /** *macOS-only* Whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file. Corresponds to `LSTypeIsPackage`. */ readonly isPackage?: boolean } -/* +/** ### `protocols` URL Protocol Schemes Protocols to associate the app with. macOS only. @@ -287,37 +287,37 @@ export interface FileAssociation { Please note — on macOS [you need to register an `open-url` event handler](http://electron.atom.io/docs/api/app/#event-open-url-macos). */ export interface Protocol { - /* + /** The name. e.g. `IRC server URL`. */ readonly name: string - /* + /** *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. */ readonly role?: string - /* + /** The schemes. e.g. `["irc", "ircs"]`. */ readonly schemes: Array } -/* +/** ### `directories` */ export interface MetadataDirectories { - /* + /** The path to build resources, defaults to `build`. */ readonly buildResources?: string | null - /* + /** The output directory, defaults to `dist`. */ readonly output?: string | null - /* + /** The application directory (containing the application package.json), defaults to `app`, `www` or working directory. */ readonly app?: string | null diff --git a/packages/electron-builder/src/options/linuxOptions.ts b/packages/electron-builder/src/options/linuxOptions.ts index b7e661bd4d9..33f559e70ee 100644 --- a/packages/electron-builder/src/options/linuxOptions.ts +++ b/packages/electron-builder/src/options/linuxOptions.ts @@ -1,37 +1,37 @@ import { PlatformSpecificBuildOptions } from "../metadata" -/* +/** ### `linux` Linux Specific Options */ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { - /* + /** The [application category](https://specifications.freedesktop.org/menu-spec/latest/apa.html#main-category-registry). */ readonly category?: string | null - /* + /** The [package category](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Section). Not applicable for AppImage. */ readonly packageCategory?: string | null - /* + /** As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux. */ readonly description?: string | null - /* + /** Target package type: list of `AppImage`, `snap`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `AppImage`. The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default. */ readonly target?: Array | null - /* + /** The maintainer. Defaults to [author](#AppMetadata-author). */ readonly maintainer?: string | null - /* + /** The vendor. Defaults to [author](#AppMetadata-author). */ readonly vendor?: string | null @@ -47,71 +47,71 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { readonly afterInstall?: string | null readonly afterRemove?: string | null - /* + /** Package dependencies. Defaults to `["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3"]` for `deb`. */ readonly depends?: string[] | null - /* + /** The executable name. Defaults to `productName`. Cannot be specified per target, allowed only in the `linux`. */ readonly executableName?: string | null - /* + /** The path to icon set directory, relative to `build` (build resources directory). The icon filename must contain the size (e.g. 32x32.png) of the icon. By default will be generated automatically based on the macOS icns file. */ readonly icon?: string } -/* +/** ### `deb` Debian Package Specific Options */ export interface DebOptions extends LinuxBuildOptions { - /* + /** The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description). */ readonly synopsis?: string | null - /* + /** The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`. */ readonly compression?: string | null - /* + /** The [Priority](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Priority) attribute. */ readonly priority?: string | null } -/* +/** ### `snap` [Snap](http://snapcraft.io) Specific Options */ export interface SnapOptions extends LinuxBuildOptions { - /* + /** The type of confinement supported by the snap. Can be either `devmode` (i.e. this snap doesn’t support running under confinement) or `strict` (i.e. full confinement supported via interfaces). Defaults to `strict`. */ readonly confinement?: "devmode" | "strict" | null - /* + /** The 78 character long summary. Defaults to [productName](#AppMetadata-productName). */ readonly summary?: string | null - /* + /** The quality grade of the snap. It can be either `devel` (i.e. a development version of the snap, so not to be published to the “stable” or “candidate” channels) or “stable” (i.e. a stable release or release candidate, which can be released to all channels). Defaults to `stable`. */ readonly grade?: "devel" | "stable" | null - /* + /** The list of features that must be supported by the core in order for this snap to install. */ readonly assumes?: Array | null - /* + /** The list of Ubuntu packages to use that are needed to support the `app` part creation. Like `depends` for `deb`. Defaults to `["libnotify4", "libappindicator1", "libxtst6", "libnss3", "libxss1", "fontconfig-config", "gconf2", "libasound2", "pulseaudio"]`. @@ -119,7 +119,7 @@ export interface SnapOptions extends LinuxBuildOptions { */ readonly stagePackages?: Array | null - /* + /** The list of [plugs](https://snapcraft.io/docs/reference/interfaces). Defaults to `["home", "x11", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"]`. @@ -127,18 +127,18 @@ export interface SnapOptions extends LinuxBuildOptions { */ readonly plugs?: Array | null - /* + /** Specify `ubuntu-app-platform1` to use [ubuntu-app-platform](https://insights.ubuntu.com/2016/11/17/how-to-create-snap-packages-on-qt-applications/). Snap size will be greatly reduced, but it is not recommended for now because "the snaps must be connected before running uitk-gallery for the first time". */ readonly ubuntuAppPlatformContent?: string | null } -/* +/** ### `appImage` [AppImage](http://appimage.org) Specific Options */ export interface AppImageOptions extends LinuxBuildOptions { - /* + /** Whether to include required system libraries (`gconf2`, `libappindicator1`). Defaults to `false`. */ readonly includeRequiredLib?: boolean | null diff --git a/packages/electron-builder/src/options/macOptions.ts b/packages/electron-builder/src/options/macOptions.ts index ecf09ac01dd..f1b321576bb 100644 --- a/packages/electron-builder/src/options/macOptions.ts +++ b/packages/electron-builder/src/options/macOptions.ts @@ -3,11 +3,11 @@ import { TargetSpecificOptions } from "electron-builder-core" export type MacOsTargetName = "default" | "dmg" | "mas" | "pkg" | "7z" | "zip" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "dir" -/* +/** ### `mac` macOS Specific Options */ export interface MacOptions extends PlatformSpecificBuildOptions { - /* + /** The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory. For example, `"category": "public.app-category.developer-tools"` will set the application category to *Developer Tools*. @@ -16,29 +16,29 @@ export interface MacOptions extends PlatformSpecificBuildOptions { */ readonly category?: string | null - /* + /** The target package type: list of `default`, `dmg`, `mas`, `pkg`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `default` (dmg and zip for Squirrel.Mac). */ 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) instead of specifying this option. MAS installer identity is specified in the [mas](#MasBuildOptions-identity). */ readonly identity?: string | null - /* + /** The path to application icon. Defaults to `build/icon.icns` (consider using this convention instead of complicating your configuration). */ readonly icon?: string | null - /* + /** The path to entitlements file for signing the app. `build/entitlements.mac.plist` will be used if exists (it is a recommended way to set). MAS entitlements is specified in the [mas](#MasBuildOptions-entitlements). */ readonly entitlements?: string | null - /* + /** The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mac.inherit.plist` 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.entitlements.darwin.inherit.plist). @@ -46,27 +46,27 @@ export interface MacOptions extends PlatformSpecificBuildOptions { */ readonly entitlementsInherit?: string | null - /* + /** The `CFBundleVersion`. Do not use it unless [you need to](see (https://github.com/electron-userland/electron-builder/issues/565#issuecomment-230678643)). */ readonly bundleVersion?: string | null - /* + /** The bundle identifier to use in the application helper's plist. Defaults to `${appBundleIdentifier}.helper`. */ readonly helperBundleId?: string | null - /* + /** Whether to sign app for development or for distribution. One of `development`, `distribution`. Defaults to `distribution`. */ readonly type?: "distribution" | "development" | null } -/* +/** ### `pkg` macOS Product Archive Options */ export interface PkgOptions extends TargetSpecificOptions { - /* + /** The scripts directory, relative to `build` (build resources directory). Defaults to `build/pkg-scripts`. See [Scripting in installer packages](http://macinstallers.blogspot.de/2012/07/scripting-in-installer-packages.html). The scripts can be in any language so long as the files are marked executable and have the appropriate shebang indicating the path to the interpreter. @@ -78,7 +78,7 @@ export interface PkgOptions extends TargetSpecificOptions { // should be not documented, only to experiment readonly productbuild?: Array | null - /* + /** The install location. Defaults to `/Applications`. */ readonly installLocation?: string | null @@ -86,11 +86,11 @@ export interface PkgOptions extends TargetSpecificOptions { readonly identity?: string | null } -/* +/** ### `dmg` macOS DMG Options */ export interface DmgOptions extends TargetSpecificOptions { - /* + /** The path to background image (default: `build/background.tiff` or `build/background.png` if exists). The resolution of this file determines the resolution of the installer window. If background is not specified, use `window.size`. Default locations expected background size to be 540x380. @@ -98,58 +98,58 @@ export interface DmgOptions extends TargetSpecificOptions { */ readonly background?: string | null - /* + /** The background color (accepts css colors). Defaults to `#ffffff` (white) if no background image. */ readonly backgroundColor?: string | null - /* + /** The path to DMG icon (volume icon), which will be shown when mounted. Defaults to application icon (`build/icon.icns`). */ readonly icon?: string | null - /* + /** The size of all the icons inside the DMG. Defaults to 80. */ readonly iconSize?: number | null - /* + /** The size of all the icon texts inside the DMG. Defaults to 12. */ readonly iconTextSize?: number | null - /* + /** The title of the produced DMG, which will be shown when mounted (volume name). Defaults to `${productName} ${version}` Macro `${productName}`, `${version}` and `${name}` are supported. */ readonly title?: string | null - /* + /** The content — to customize icon locations. */ readonly contents?: Array - /* + /** The disk image format, one of `UDRW`, `UDRO`, `UDCO`, `UDZO`, `UDBZ`, `ULFO` (lzfse-compressed image (OS X 10.11+ only)). Defaults to `UDBZ` (bzip2-compressed image). */ readonly format?: string - /* + /** The DMG windows position and size. See [dmg.window](#DmgWindow). */ window?: DmgWindow } -/* +/** ### `dmg.window` DMG Windows Position and Size */ export interface DmgWindow { - /* + /** The X position relative to left of the screen. Defaults to 400. */ x?: number - /* + /** The Y position relative to top of the screen. Defaults to 100. */ y?: number @@ -167,24 +167,24 @@ export interface DmgContent { x: number y: number type?: "link" | "file" - /* + /** The name of the file within the DMG. Defaults to basename of `path`. */ name?: string path?: string } -/* +/** ### `mas` MAS (Mac Application Store) Specific Options */ export interface MasBuildOptions extends MacOptions { - /* + /** The path to entitlements file for signing the app. `build/entitlements.mas.plist` 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.entitlements.mas.plist). */ readonly entitlements?: string | null - /* + /** The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mas.inherit.plist` 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.entitlements.mas.inherit.plist). */ diff --git a/packages/electron-builder/src/options/winOptions.ts b/packages/electron-builder/src/options/winOptions.ts index 54411d33ae1..a7b4e6cd46f 100644 --- a/packages/electron-builder/src/options/winOptions.ts +++ b/packages/electron-builder/src/options/winOptions.ts @@ -1,10 +1,10 @@ import { PlatformSpecificBuildOptions } from "../metadata" -/* +/** ### `win` Windows Specific Options */ export interface WinBuildOptions extends PlatformSpecificBuildOptions { - /* + /** Target package type: list of `nsis`, `nsis-web` (Web installer), `appx`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `nsis`. AppX package can be built only on Windows 10. @@ -13,69 +13,69 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions { */ readonly target?: Array | null - /* + /** Array of signing algorithms used. Defaults to `['sha1', 'sha256']` For AppX `sha256` is always used. */ readonly signingHashAlgorithms?: Array | null - /* + /** The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration). */ readonly icon?: string | null - /* + /** The trademarks and registered trademarks. */ readonly legalTrademarks?: string | null - /* + /** The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason. Please see [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). */ readonly certificateFile?: string - /* + /** The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason. Please see [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). */ readonly certificatePassword?: string - /* + /** The name of the subject of the signing certificate. Required only for EV Code Signing and works only on Windows. */ readonly certificateSubjectName?: string - /* + /** The URL of the RFC 3161 time stamp server. Defaults to `http://timestamp.comodoca.com/rfc3161`. */ readonly rfc3161TimeStampServer?: string - /* + /** The URL of the time stamp server. Defaults to `http://timestamp.verisign.com/scripts/timstamp.dll`. */ readonly timeStampServer?: string - /* + /** [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided. Defaults to common name from your code signing certificate. */ readonly publisherName?: string | Array | null } -/* +/** ### `nsis` See [NSIS target notes](https://github.com/electron-userland/electron-builder/wiki/NSIS). */ export interface NsisOptions { - /* + /** One-click installation. Defaults to `true`. */ readonly oneClick?: boolean - /* + /** Defaults to `false`. If `oneClick` is `true` (default): Install per all users (per-machine). @@ -84,83 +84,83 @@ export interface NsisOptions { */ readonly perMachine?: boolean - /* + /** *boring installer only.* Allow requesting for elevation. If false, user will have to restart installer with elevated permissions. Defaults to `true`. */ readonly allowElevation?: boolean - /* + /** *boring installer only.* Whether to allow user to change installation directory. Defaults to `false`. */ readonly allowToChangeInstallationDirectory?: boolean - /* + /** *one-click installer only.* Run application after finish. Defaults to `true`. */ readonly runAfterFinish?: boolean - /* + /** See [GUID vs Application Name](https://github.com/electron-userland/electron-builder/wiki/NSIS#guid-vs-application-name). */ readonly guid?: string | null - /* + /** The path to installer icon. Defaults to `build/installerIcon.ico` or application icon. */ readonly installerIcon?: string | null - /* + /** *boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp` */ readonly installerHeader?: string | null - /* + /** *boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp` */ readonly installerSidebar?: string | null - /* + /** *boring installer only.* `MUI_UNWELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `installerSidebar` option or `build/uninstallerSidebar.bmp` or `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp` */ readonly uninstallerSidebar?: string | null - /* + /** *one-click installer only.* The path to header icon (above the progress bar), relative to the project directory. Defaults to `build/installerHeaderIcon.ico` or application icon. */ readonly installerHeaderIcon?: string | null - /* + /** The path to NSIS include script to customize installer. Defaults to `build/installer.nsh`. See [Custom NSIS script](https://github.com/electron-userland/electron-builder/wiki/NSIS#custom-nsis-script). */ readonly include?: string | null - /* + /** The path to NSIS script to customize installer. Defaults to `build/installer.nsi`. See [Custom NSIS script](https://github.com/electron-userland/electron-builder/wiki/NSIS#custom-nsis-script). */ readonly script?: string | null - /* + /** The path to EULA license file. Defaults to `build/license.rtf` or `build/license.txt`. */ readonly license?: string | null - /* + /** * [LCID Dec](https://msdn.microsoft.com/en-au/goglobal/bb964664.aspx), defaults to `1033`(`English - United States`). */ readonly language?: string | null - /* + /** *boring installer only.* Whether to create multi-language installer. Defaults to `unicode` option value. [Not all strings are translated](https://github.com/electron-userland/electron-builder/issues/646#issuecomment-238155800). */ readonly multiLanguageInstaller?: boolean - /* + /** Defaults to `true`. If `warningsAsErrors` is `true` (default): NSIS will treat warnings as errors. If `warningsAsErrors` is `false`: NSIS will allow warnings. */ readonly warningsAsErrors?: boolean - /* + /** Whether to create submenu for start menu shortcut and program files directory. Defaults to `false`. If `true`, company name will be used. Or string value. */ readonly menuCategory?: boolean | string @@ -168,27 +168,27 @@ export interface NsisOptions { // defaults to false readonly useZip?: boolean - /* + /** The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName} Setup ${version}.${ext}`. */ readonly artifactName?: string | null - /* + /** Whether to create [Unicode installer](http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode). Defaults to `true`. */ readonly unicode?: boolean - /* + /** *one-click installer only.* Whether to delete app data on uninstall. Defaults to `false`. */ readonly deleteAppDataOnUninstall?: boolean } -/* +/** ### `nsis` Web Installer Specific Options */ export interface NsisWebOptions extends NsisOptions { - /* + /** The application package download URL. Optional — by default computed using publish configuration. URL like `https://example.com/download/latest` allows web installer to be version independent (installer will download latest application package). @@ -197,19 +197,19 @@ export interface NsisWebOptions extends NsisOptions { */ readonly appPackageUrl?: string | null - /* + /** The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName} Web Setup ${version}.${ext}`. */ readonly artifactName?: string | null } -/* +/** ### `squirrelWindows` To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency. Squirrel.Windows target is maintained, but deprecated. Please use `nsis` instead. */ export interface SquirrelWindowsOptions extends WinBuildOptions { - /* + /** A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Electron icon. Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http. @@ -219,63 +219,63 @@ export interface SquirrelWindowsOptions extends WinBuildOptions { */ 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 | null - /* + /** Whether to create an MSI installer. Defaults to `false` (MSI is not created). */ readonly msi?: boolean - /* + /** A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. */ readonly remoteReleases?: string | boolean | null - /* + /** Authentication token for remote updates */ readonly remoteToken?: string | null - /* + /** Use `appId` to identify package instead of `name`. */ readonly useAppIdAsId?: boolean } -/* +/** ### `appx` Please see [Windows AppX docs](https://msdn.microsoft.com/en-us/library/windows/apps/br211453.aspx). */ export interface AppXOptions { - /* + /** The background color of the app tile. Please see [Visual Elements](https://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx). */ readonly backgroundColor?: string | null readonly makeappxArgs?: Array | null - /* + /** Describes the publisher information in a form `CN=your name exactly as in your cert`. The Publisher attribute must match the publisher subject information of the certificate used to sign a package. By default will be extracted from code sign certificate. */ readonly publisher?: string | null - /* + /** A friendly name that can be displayed to users. Corresponds to [Properties.DisplayName](https://msdn.microsoft.com/en-us/library/windows/apps/br211432.aspx). */ readonly displayName?: string | null - /* + /** A friendly name for the publisher that can be displayed to users. Corresponds to [Properties.PublisherDisplayName](https://msdn.microsoft.com/en-us/library/windows/apps/br211460.aspx). */ readonly publisherDisplayName?: string | null - /* + /** Describes the contents of the package. The Name attribute is case-sensitive. Corresponds to [Identity.Name](https://msdn.microsoft.com/en-us/library/windows/apps/br211441.aspx). */ readonly identityName?: string | null diff --git a/packages/electron-builder/src/winPackager.ts b/packages/electron-builder/src/winPackager.ts index 0da55d81a5d..354a9384ce6 100644 --- a/packages/electron-builder/src/winPackager.ts +++ b/packages/electron-builder/src/winPackager.ts @@ -74,7 +74,8 @@ export class WinPackager extends PlatformPackager { // https://github.com/digitalbazaar/forge/issues/338#issuecomment-164831585 const p12Asn1 = forge.asn1.fromDer(await readFile(cscInfo.file, "binary"), false) const p12 = (forge).pkcs12.pkcs12FromAsn1(p12Asn1, false, cscInfo.password) - publisherName = p12.getBags({bagType: forge.pki.oids.certBag})[forge.pki.oids.certBag][0].cert.subject.getField("CN").value + const bagType = (forge.pki.oids).certBag + publisherName = p12.getBags({bagType: bagType})[bagType][0].cert.subject.getField("CN").value } catch (e) { throw new Error(`Cannot extract publisher name from code signing certificate, please file issue. As workaround, set win.publisherName: ${e.stack || e}`) diff --git a/test/out/windows/__snapshots__/nsisBoring.js.snap b/test/out/windows/__snapshots__/installerTest.js.snap similarity index 100% rename from test/out/windows/__snapshots__/nsisBoring.js.snap rename to test/out/windows/__snapshots__/installerTest.js.snap diff --git a/test/out/windows/__snapshots__/nsisTest.js.snap b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap similarity index 100% rename from test/out/windows/__snapshots__/nsisTest.js.snap rename to test/out/windows/__snapshots__/oneClickInstallerTest.js.snap diff --git a/test/src/windows/nsisBoring.ts b/test/src/windows/installerTest.ts similarity index 100% rename from test/src/windows/nsisBoring.ts rename to test/src/windows/installerTest.ts diff --git a/test/src/windows/nsisTest.ts b/test/src/windows/oneClickInstallerTest.ts similarity index 100% rename from test/src/windows/nsisTest.ts rename to test/src/windows/oneClickInstallerTest.ts diff --git a/yarn.lock b/yarn.lock index 75af7b76e40..ac49bb9cd19 100644 --- a/yarn.lock +++ b/yarn.lock @@ -430,8 +430,8 @@ babel-register@^6.23.0: source-map-support "^0.4.2" babel-runtime@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611" + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" dependencies: core-js "^2.4.0" regenerator-runtime "^0.10.0" @@ -1250,7 +1250,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -1903,7 +1903,7 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.0: +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -3147,10 +3147,23 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +typescript-json-schema@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/typescript-json-schema/-/typescript-json-schema-0.9.0.tgz#09d244139d18167d4c0a179370b170dc322892b2" + dependencies: + glob "~7.1.1" + json-stable-stringify "^1.0.1" + typescript "~2.1.5" + yargs "^6.6.0" + typescript@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.0.tgz#626f2fc70087d2480f21ebb12c1888288c8614e3" +typescript@~2.1.5: + version "2.1.6" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.6.tgz#40c7e6e9e5da7961b7718b55505f9cac9487a607" + uc.micro@^1.0.1, uc.micro@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.3.tgz#7ed50d5e0f9a9fb0a573379259f2a77458d50192"