UNPKG

electron-builder

Version:

A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box

159 lines (138 loc) 7.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _bluebirdLstC; function _load_bluebirdLstC() { return _bluebirdLstC = require("bluebird-lst-c"); } var _platformPackager; function _load_platformPackager() { return _platformPackager = require("../platformPackager"); } var _metadata; function _load_metadata() { return _metadata = require("../metadata"); } var _path; function _load_path() { return _path = _interopRequireWildcard(require("path")); } var _log; function _load_log() { return _log = require("../util/log"); } var _repositoryInfo; function _load_repositoryInfo() { return _repositoryInfo = require("../repositoryInfo"); } var _binDownload; function _load_binDownload() { return _binDownload = require("../util/binDownload"); } var _squirrelPack; function _load_squirrelPack() { return _squirrelPack = require("./squirrelPack"); } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } const SW_VERSION = "1.4.4"; //noinspection SpellCheckingInspection const SW_SHA2 = "98e1d81c80d7afc1bcfb37f3b224dc4f761088506b9c28ccd72d1cf8752853ba"; class SquirrelWindowsTarget extends (_platformPackager || _load_platformPackager()).TargetEx { constructor(packager) { super("squirrel"); this.packager = packager; this.options = Object.assign({}, this.packager.platformSpecificBuildOptions, this.packager.devMetadata.build.squirrelWindows); } build(appOutDir, arch) { var _this = this; return (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () { (0, (_log || _load_log()).log)(`Building Squirrel.Windows for arch ${ (_metadata || _load_metadata()).Arch[arch] }`); if (arch === (_metadata || _load_metadata()).Arch.ia32) { (0, (_log || _load_log()).warn)("For windows consider only distributing 64-bit or use nsis target, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130"); } const appInfo = _this.packager.appInfo; const version = appInfo.version; const archSuffix = (0, (_platformPackager || _load_platformPackager()).getArchSuffix)(arch); const setupFileName = `${ appInfo.productFilename } Setup ${ version }${ archSuffix }.exe`; const installerOutDir = (_path || _load_path()).join(appOutDir, "..", `win${ (0, (_platformPackager || _load_platformPackager()).getArchSuffix)(arch) }`); const distOptions = yield _this.computeEffectiveDistOptions(); yield (0, (_squirrelPack || _load_squirrelPack()).buildInstaller)(distOptions, installerOutDir, setupFileName, _this.packager, appOutDir); _this.packager.dispatchArtifactCreated((_path || _load_path()).join(installerOutDir, setupFileName), `${ appInfo.name }-Setup-${ version }${ archSuffix }.exe`); const packagePrefix = `${ appInfo.name }-${ (0, (_squirrelPack || _load_squirrelPack()).convertVersion)(version) }-`; _this.packager.dispatchArtifactCreated((_path || _load_path()).join(installerOutDir, `${ packagePrefix }full.nupkg`)); if (distOptions.remoteReleases != null) { _this.packager.dispatchArtifactCreated((_path || _load_path()).join(installerOutDir, `${ packagePrefix }delta.nupkg`)); } _this.packager.dispatchArtifactCreated((_path || _load_path()).join(installerOutDir, "RELEASES")); })(); } computeEffectiveDistOptions() { var _this2 = this; return (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () { const packager = _this2.packager; let iconUrl = _this2.options.iconUrl || packager.devMetadata.build.iconUrl; if (iconUrl == null) { const info = yield (0, (_repositoryInfo || _load_repositoryInfo()).getRepositoryInfo)(packager.appInfo.metadata, packager.devMetadata); if (info != null) { iconUrl = `https://github.com/${ info.user }/${ info.project }/blob/master/${ packager.relativeBuildResourcesDirname }/icon.ico?raw=true`; } if (iconUrl == null) { throw new Error("iconUrl is not specified, please see https://github.com/electron-userland/electron-builder/wiki/Options#WinBuildOptions-iconUrl"); } } checkConflictingOptions(_this2.options); const appInfo = packager.appInfo; const projectUrl = yield appInfo.computePackageUrl(); const options = Object.assign({ name: appInfo.name, productName: appInfo.productName, appId: _this2.options.useAppIdAsId ? appInfo.id : appInfo.name, version: appInfo.version, description: appInfo.description, authors: appInfo.companyName, iconUrl: iconUrl, extraMetadataSpecs: projectUrl == null ? null : `\n <projectUrl>${ projectUrl }</projectUrl>`, copyright: appInfo.copyright, packageCompressionLevel: packager.devMetadata.build.compression === "store" ? 0 : 9, vendorPath: yield (0, (_binDownload || _load_binDownload()).getBinFromBintray)("Squirrel.Windows", SW_VERSION, SW_SHA2) }, _this2.options); if (options.remoteToken == null) { options.remoteToken = process.env.GH_TOKEN; } if (!("loadingGif" in options)) { const resourceList = yield packager.resourceList; if (resourceList.indexOf("install-spinner.gif") !== -1) { options.loadingGif = (_path || _load_path()).join(packager.buildResourcesDir, "install-spinner.gif"); } } if (options.remoteReleases === true) { const info = yield (0, (_repositoryInfo || _load_repositoryInfo()).getRepositoryInfo)(packager.appInfo.metadata, packager.devMetadata); if (info == null) { (0, (_log || _load_log()).warn)("remoteReleases set to true, but cannot get repository info"); } else { options.remoteReleases = `https://github.com/${ info.user }/${ info.project }`; (0, (_log || _load_log()).log)(`remoteReleases is set to ${ options.remoteReleases }`); } } return options; })(); } } exports.default = SquirrelWindowsTarget; function checkConflictingOptions(options) { for (let name of ["outputDirectory", "appDirectory", "exe", "fixUpPaths", "usePackageJson", "extraFileSpecs", "extraMetadataSpecs", "skipUpdateIcon", "setupExe"]) { if (name in options) { throw new Error(`Option ${ name } is ignored, do not specify it.`); } } if ("noMsi" in options) { (0, (_log || _load_log()).warn)(`noMsi is deprecated, please specify as "msi": true if you want to create an MSI installer`); options.msi = !options.noMsi; } const msi = options.msi; if (msi != null && typeof msi !== "boolean") { throw new Error(`msi expected to be boolean value, but string '"${ msi }"' was specified`); } } //# sourceMappingURL=squirrelWindows.js.map