electron-updater 6.8.6 → 6.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/AppImageUpdater.js +3 -0
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.js +3 -2
- package/out/AppUpdater.js.map +1 -1
- package/out/BaseUpdater.d.ts +6 -0
- package/out/BaseUpdater.js +15 -1
- package/out/BaseUpdater.js.map +1 -1
- package/out/LinuxUpdater.d.ts +3 -1
- package/out/LinuxUpdater.js +30 -9
- package/out/LinuxUpdater.js.map +1 -1
- package/out/MacUpdater.d.ts +5 -0
- package/out/MacUpdater.js +11 -7
- package/out/MacUpdater.js.map +1 -1
- package/out/providers/GitHubProvider.d.ts +1 -1
- package/out/providers/GitHubProvider.js +43 -5
- package/out/providers/GitHubProvider.js.map +1 -1
- package/package.json +2 -2
package/out/AppImageUpdater.js
CHANGED
|
@@ -74,6 +74,9 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
74
74
|
if (appImageFile == null) {
|
|
75
75
|
throw (0, builder_util_runtime_1.newError)("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
|
|
76
76
|
}
|
|
77
|
+
if (!path.isAbsolute(appImageFile) || appImageFile.includes("\0")) {
|
|
78
|
+
throw (0, builder_util_runtime_1.newError)(`APPIMAGE env is not a valid absolute path: "${appImageFile}"`, "ERR_UPDATER_OLD_FILE_NOT_FOUND");
|
|
79
|
+
}
|
|
77
80
|
// https://stackoverflow.com/a/1712051/1910191
|
|
78
81
|
(0, fs_1.unlinkSync)(appImageFile);
|
|
79
82
|
let destination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAClE,iDAA4C;AAC5C,uCAAgC;AAChC,2BAA+B;AAC/B,6BAA4B;AAE5B,+CAA2D;AA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AAC,CAAA;QACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAhHD,0CAgHC","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport { chmod } from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./types\"\n\nexport class AppImageUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: any) {\n super(options, app)\n }\n\n public isUpdaterActive(): boolean {\n if (process.env[\"APPIMAGE\"] == null && !this.forceDevUpdateConfig) {\n if (process.env[\"SNAP\"] == null) {\n this._logger.warn(\"APPIMAGE env is not defined, current application is not an AppImage\")\n } else {\n this._logger.info(\"SNAP env is defined, updater is disabled\")\n }\n return false\n }\n return super.isUpdaterActive()\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"AppImage\", [\"rpm\", \"deb\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"AppImage\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n const oldFile = process.env[\"APPIMAGE\"]!\n if (oldFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n }\n\n await chmod(updateFile, 0o755)\n },\n })\n }\n\n private async downloadDifferential(fileInfo: ResolvedUpdateFileInfo, oldFile: string, updateFile: string, provider: Provider<any>, downloadUpdateOptions: DownloadUpdateOptions) {\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile,\n logger: this._logger,\n newFile: updateFile,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download()\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac) we must throw error\n return process.platform === \"linux\"\n }\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const appImageFile = process.env[\"APPIMAGE\"]!\n if (appImageFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n if (!path.isAbsolute(appImageFile) || appImageFile.includes(\"\\0\")) {\n throw newError(`APPIMAGE env is not a valid absolute path: \"${appImageFile}\"`, \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n // https://stackoverflow.com/a/1712051/1910191\n unlinkSync(appImageFile)\n\n let destination: string\n const existingBaseName = path.basename(appImageFile)\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n // https://github.com/electron-userland/electron-builder/issues/2964\n // if no version in existing file name, it means that user wants to preserve current custom name\n if (path.basename(installerPath) === existingBaseName || !/\\d+\\.\\d+\\.\\d+/.test(existingBaseName)) {\n // no version in the file name, overwrite existing\n destination = appImageFile\n } else {\n destination = path.join(path.dirname(appImageFile), path.basename(installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", installerPath, destination])\n if (destination !== appImageFile) {\n this.emit(\"appimage-filename-updated\", destination)\n }\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n APPIMAGE_SILENT_INSTALL: \"true\",\n }\n\n if (options.isForceRunAfter) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.spawnLog(destination, [], env)\n } else {\n env.APPIMAGE_EXIT_AFTER_INSTALL = \"true\"\n execFileSync(destination, [], { env })\n }\n return true\n }\n}\n"]}
|
package/out/AppUpdater.js
CHANGED
|
@@ -577,8 +577,9 @@ class AppUpdater extends events_1.EventEmitter {
|
|
|
577
577
|
return path.basename(urlPath);
|
|
578
578
|
}
|
|
579
579
|
else {
|
|
580
|
-
// url like /latest
|
|
581
|
-
|
|
580
|
+
// url like /latest — use basename so a server-supplied path like "../../etc/evil"
|
|
581
|
+
// cannot escape the cache directory via path.join
|
|
582
|
+
return path.basename(taskOptions.fileInfo.info.url);
|
|
582
583
|
}
|
|
583
584
|
}
|
|
584
585
|
const downloadedUpdateHelper = await this.getOrCreateDownloadHelper();
|
package/out/AppUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppUpdater.js","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAa6B;AAC7B,mCAAoC;AACpC,2BAA4B;AAC5B,mCAAqC;AACrC,uCAA4F;AAE5F,qCAA8B;AAC9B,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAA8K;AAE9K,qEAAuF;AACvF,6DAAyD;AACzD,iEAA2F;AAC3F,iEAA6D;AAC7D,uDAAwF;AAKxF,+BAA2C;AAE3C,0GAAsG;AACtG,mCAAuJ;AAevJ,MAAsB,UAAW,SAAS,qBAAyD;IAwFjG;;OAEG;IACH,IAAI,OAAO;QACT,OAAO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QAAQ,CAAC,CAAA;YAC1F,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;gBAC5B,eAAe,GAAG,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/D,CAAC;YAED,MAAM,IAAI,6DAA6B,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;YACrI,OAAO,KAAK,CAAA;QACd,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;gBAClC,YAAY;gBACZ,MAAM,CAAC,CAAA;YACT,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAp0BD,gCAo0BC;AAUD,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,0BAA0B,GAAG,IAAA,mBAA4B,EAAC,OAAO,CAAC,CAAA;IACxE,OAAO,0BAA0B,IAAI,IAAI,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAA;AACpF,CAAC;AAED,eAAe;AACf,MAAa,UAAU;IACrB,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,OAAa;QACjB,SAAS;IACX,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import {\n AllPublishOptions,\n asArray,\n CancellationToken,\n newError,\n PublishConfiguration,\n UpdateInfo,\n UUID,\n DownloadOptions,\n CancellationError,\n ProgressInfo,\n BlockMap,\n retry,\n} from \"builder-util-runtime\"\nimport { randomBytes } from \"crypto\"\nimport { release } from \"os\"\nimport { EventEmitter } from \"events\"\nimport { mkdir, outputFile, readFile, rename, unlink, copyFile, pathExists } from \"fs-extra\"\nimport { OutgoingHttpHeaders } from \"http\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { eq as isVersionsEqual, gt as isVersionGreaterThan, lt as isVersionLessThan, parse as parseVersion, prerelease as getVersionPreleaseComponents, SemVer } from \"semver\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { createTempUpdateFile, DownloadedUpdateHelper } from \"./DownloadedUpdateHelper\"\nimport { ElectronAppAdapter } from \"./ElectronAppAdapter\"\nimport { ElectronHttpExecutor, getNetSession, LoginCallback } from \"./electronHttpExecutor\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { createClient, isUrlProbablySupportMultiRangeRequests } from \"./providerFactory\"\nimport { Provider, ProviderPlatform } from \"./providers/Provider\"\nimport type { TypedEmitter } from \"tiny-typed-emitter\"\nimport Session = Electron.Session\nimport type { AuthInfo } from \"electron\"\nimport { gunzipSync, gzipSync } from \"zlib\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { GenericDifferentialDownloader } from \"./differentialDownloader/GenericDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS, Logger, ResolvedUpdateFileInfo, UPDATE_DOWNLOADED, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from \"./types\"\nimport { VerifyUpdateSupport } from \"./main\"\n\nexport type AppUpdaterEvents = {\n error: (error: Error, message?: string) => void\n login: (info: AuthInfo, callback: LoginCallback) => void\n \"checking-for-update\": () => void\n \"update-not-available\": (info: UpdateInfo) => void\n \"update-available\": (info: UpdateInfo) => void\n \"update-downloaded\": (event: UpdateDownloadedEvent) => void\n \"download-progress\": (info: ProgressInfo) => void\n \"update-cancelled\": (info: UpdateInfo) => void\n \"appimage-filename-updated\": (path: string) => void\n}\n\nexport abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter<AppUpdaterEvents>) {\n /**\n * Whether to automatically download an update when it is found.\n * @default true\n */\n autoDownload = true\n\n /**\n * Whether to automatically install a downloaded update on app quit (if `quitAndInstall` was not called before).\n * @default true\n */\n autoInstallOnAppQuit = true\n\n /**\n * Whether to run the app after finish install when run the installer is NOT in silent mode.\n * @default true\n */\n autoRunAppAfterInstall = true\n\n /**\n * *GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.\n *\n * If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`).\n */\n allowPrerelease = false\n\n /**\n * *GitHub provider only.* Get all release notes (from current version to latest), not just the latest.\n * @default false\n */\n fullChangelog = false\n\n /**\n * Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).\n *\n * Taken in account only if channel differs (pre-release version component in terms of semantic versioning).\n *\n * @default false\n */\n allowDowngrade = false\n\n /**\n * Web installer files might not have signature verification, this switch prevents to load them unless it is needed.\n *\n * Currently false to prevent breaking the current API, but it should be changed to default true at some point that\n * breaking changes are allowed.\n *\n * @default false\n */\n disableWebInstaller = false\n\n /**\n * *NSIS only* Disable differential downloads and always perform full download of installer.\n *\n * @default false\n */\n disableDifferentialDownload = false\n\n /**\n * Allows developer to force the updater to work in \"dev\" mode, looking for \"dev-app-update.yml\" instead of \"app-update.yml\"\n * Dev: `path.join(this.app.getAppPath(), \"dev-app-update.yml\")`\n * Prod: `path.join(process.resourcesPath!, \"app-update.yml\")`\n *\n * @default false\n */\n forceDevUpdateConfig = false\n\n /**\n * The base URL of the old block map file.\n *\n * When null, the updater will use the base URL of the update file to download the update.\n * When set, the updater will use this string as the base URL of the old block map file.\n * Some servers like github cannot download the old block map file from latest release,\n * so you need to compute the old block map file base URL manually.\n *\n * @default null\n */\n public previousBlockmapBaseUrlOverride: string | null = null\n\n /**\n * The current application version.\n */\n readonly currentVersion: SemVer\n\n private _channel: string | null = null\n\n protected downloadedUpdateHelper: DownloadedUpdateHelper | null = null\n\n /**\n * Get the update channel. Doesn't return `channel` from the update configuration, only if was previously set.\n */\n get channel(): string | null {\n return this._channel\n }\n\n /**\n * Set the update channel. Overrides `channel` in the update configuration.\n *\n * `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.\n */\n set channel(value: string | null) {\n if (this._channel != null) {\n // noinspection SuspiciousTypeOfGuard\n if (typeof value !== \"string\") {\n throw newError(`Channel must be a string, but got: ${value}`, \"ERR_UPDATER_INVALID_CHANNEL\")\n } else if (value.length === 0) {\n throw newError(`Channel must be not an empty string`, \"ERR_UPDATER_INVALID_CHANNEL\")\n }\n }\n\n this._channel = value\n this.allowDowngrade = true\n }\n\n /**\n * The request headers.\n */\n requestHeaders: OutgoingHttpHeaders | null = null\n\n /**\n * Shortcut for explicitly adding auth tokens to request headers\n */\n addAuthHeader(token: string) {\n this.requestHeaders = Object.assign({}, this.requestHeaders, {\n authorization: token,\n })\n }\n\n protected _logger: Logger = console\n\n // noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n get netSession(): Session {\n return getNetSession()\n }\n\n /**\n * The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.\n * Set it to `null` if you would like to disable a logging feature.\n */\n get logger(): Logger | null {\n return this._logger\n }\n\n set logger(value: Logger | null) {\n this._logger = value == null ? new NoOpLogger() : value\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})`\n */\n readonly signals = new UpdaterSignal(this)\n\n private _appUpdateConfigPath: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * test only\n * @private\n */\n set updateConfigPath(value: string | null) {\n this.clientPromise = null\n this._appUpdateConfigPath = value\n this.configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n }\n\n protected _isUpdateSupported: VerifyUpdateSupport = updateInfo => this.checkIfUpdateSupported(updateInfo)\n\n /**\n * Allows developer to override default logic for determining if an update is supported.\n * The default logic compares the `UpdateInfo` minimum system version against the `os.release()` with `semver` package\n */\n get isUpdateSupported(): VerifyUpdateSupport {\n return this._isUpdateSupported\n }\n\n set isUpdateSupported(value: VerifyUpdateSupport) {\n if (value) {\n this._isUpdateSupported = value\n }\n }\n\n protected _isUserWithinRollout: VerifyUpdateSupport = updateInfo => this.isStagingMatch(updateInfo)\n\n /**\n * Allows developer to override default logic for determining if the user is below the rollout threshold.\n * The default logic compares the staging percentage with numerical representation of user ID.\n * An override can define custom logic, or bypass it if needed.\n */\n get isUserWithinRollout(): VerifyUpdateSupport {\n return this._isUserWithinRollout\n }\n\n set isUserWithinRollout(value: VerifyUpdateSupport) {\n if (value) {\n this._isUserWithinRollout = value\n }\n }\n\n private clientPromise: Promise<Provider<any>> | null = null\n\n protected readonly stagingUserIdPromise = new Lazy<string>(() => this.getOrCreateStagingUserId())\n\n // public, allow to read old config for anyone\n /** @internal */\n configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n\n private checkForUpdatesPromise: Promise<UpdateCheckResult> | null = null\n private downloadPromise: Promise<Array<string>> | null = null\n\n protected readonly app: AppAdapter\n\n protected updateInfoAndProvider: UpdateInfoAndProvider | null = null\n\n /** @internal */\n readonly httpExecutor: ElectronHttpExecutor\n\n protected constructor(options: AllPublishOptions | null | undefined, app?: AppAdapter) {\n super()\n\n this.on(\"error\", (error: Error) => {\n this._logger.error(`Error: ${error.stack || error.message}`)\n })\n\n if (app == null) {\n this.app = new ElectronAppAdapter()\n this.httpExecutor = new ElectronHttpExecutor((authInfo, callback) => this.emit(\"login\", authInfo, callback))\n } else {\n this.app = app\n this.httpExecutor = null as any\n }\n\n const currentVersionString = this.app.version\n const currentVersion = parseVersion(currentVersionString)\n if (currentVersion == null) {\n throw newError(`App version is not a valid semver version: \"${currentVersionString}\"`, \"ERR_UPDATER_INVALID_VERSION\")\n }\n this.currentVersion = currentVersion\n this.allowPrerelease = hasPrereleaseComponents(currentVersion)\n\n if (options != null) {\n this.setFeedURL(options)\n\n if (typeof options !== \"string\" && options.requestHeaders) {\n this.requestHeaders = options.requestHeaders\n }\n }\n }\n\n //noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n getFeedURL(): string | null | undefined {\n return \"Deprecated. Do not use it.\"\n }\n\n /**\n * Configure update provider. If value is `string`, [GenericServerOptions](https://www.electron.build/publish#genericserveroptions) will be set with value as `url`.\n * @param options If you want to override configuration in the `app-update.yml`.\n */\n setFeedURL(options: PublishConfiguration | AllPublishOptions | string) {\n const runtimeOptions = this.createProviderRuntimeOptions()\n // https://github.com/electron-userland/electron-builder/issues/1105\n let provider: Provider<any>\n if (typeof options === \"string\") {\n provider = new GenericProvider({ provider: \"generic\", url: options }, this, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: isUrlProbablySupportMultiRangeRequests(options),\n })\n } else {\n provider = createClient(options, this, runtimeOptions)\n }\n this.clientPromise = Promise.resolve(provider)\n }\n\n /**\n * Asks the server whether there is an update.\n * @returns null if the updater is disabled, otherwise info about the latest version\n */\n checkForUpdates(): Promise<UpdateCheckResult | null> {\n if (!this.isUpdaterActive()) {\n return Promise.resolve(null)\n }\n\n let checkForUpdatesPromise = this.checkForUpdatesPromise\n if (checkForUpdatesPromise != null) {\n this._logger.info(\"Checking for update (already in progress)\")\n return checkForUpdatesPromise\n }\n\n const nullizePromise = () => (this.checkForUpdatesPromise = null)\n\n this._logger.info(\"Checking for update\")\n checkForUpdatesPromise = this.doCheckForUpdates()\n .then(it => {\n nullizePromise()\n return it\n })\n .catch((e: any) => {\n nullizePromise()\n this.emit(\"error\", e, `Cannot check for updates: ${(e.stack || e).toString()}`)\n throw e\n })\n\n this.checkForUpdatesPromise = checkForUpdatesPromise\n return checkForUpdatesPromise\n }\n\n public isUpdaterActive(): boolean {\n const isEnabled = this.app.isPackaged || this.forceDevUpdateConfig\n if (!isEnabled) {\n this._logger.info(\"Skip checkForUpdates because application is not packed and dev update config is not forced\")\n return false\n }\n return true\n }\n\n // noinspection JSUnusedGlobalSymbols\n checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null> {\n return this.checkForUpdates().then(it => {\n if (!it?.downloadPromise) {\n if (this._logger.debug != null) {\n this._logger.debug(\"checkForUpdatesAndNotify called, downloadPromise is null\")\n }\n return it\n }\n\n void it.downloadPromise.then(() => {\n const notificationContent = AppUpdater.formatDownloadNotification(it.updateInfo.version, this.app.name, downloadNotification)\n new (require(\"electron\").Notification)(notificationContent).show()\n })\n\n return it\n })\n }\n\n private static formatDownloadNotification(version: string, appName: string, downloadNotification?: DownloadNotification): DownloadNotification {\n if (downloadNotification == null) {\n downloadNotification = {\n title: \"A new update is ready to install\",\n body: `{appName} version {version} has been downloaded and will be automatically installed on exit`,\n }\n }\n downloadNotification = {\n title: downloadNotification.title.replace(\"{appName}\", appName).replace(\"{version}\", version),\n body: downloadNotification.body.replace(\"{appName}\", appName).replace(\"{version}\", version),\n }\n return downloadNotification\n }\n\n private async isStagingMatch(updateInfo: UpdateInfo): Promise<boolean> {\n const rawStagingPercentage = updateInfo.stagingPercentage\n let stagingPercentage = rawStagingPercentage\n if (stagingPercentage == null) {\n return true\n }\n\n stagingPercentage = parseInt(stagingPercentage as any, 10)\n if (isNaN(stagingPercentage)) {\n this._logger.warn(`Staging percentage is NaN: ${rawStagingPercentage}`)\n return true\n }\n\n // convert from user 0-100 to internal 0-1\n stagingPercentage = stagingPercentage / 100\n\n const stagingUserId = await this.stagingUserIdPromise.value\n const val = UUID.parse(stagingUserId).readUInt32BE(12)\n const percentage = val / 0xffffffff\n this._logger.info(`Staging percentage: ${stagingPercentage}, percentage: ${percentage}, user id: ${stagingUserId}`)\n return percentage < stagingPercentage\n }\n\n private computeFinalHeaders(headers: OutgoingHttpHeaders) {\n if (this.requestHeaders != null) {\n Object.assign(headers, this.requestHeaders)\n }\n return headers\n }\n\n private async isUpdateAvailable(updateInfo: UpdateInfo): Promise<boolean> {\n const latestVersion = parseVersion(updateInfo.version)\n if (latestVersion == null) {\n throw newError(\n `This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: \"${updateInfo.version}\"`,\n \"ERR_UPDATER_INVALID_VERSION\"\n )\n }\n\n const currentVersion = this.currentVersion\n if (isVersionsEqual(latestVersion, currentVersion)) {\n return false\n }\n\n if (!(await Promise.resolve(this.isUpdateSupported(updateInfo)))) {\n return false\n }\n\n const isUserWithinRollout = await Promise.resolve(this.isUserWithinRollout(updateInfo))\n if (!isUserWithinRollout) {\n return false\n }\n\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405033227\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405030797\n const isLatestVersionNewer = isVersionGreaterThan(latestVersion, currentVersion)\n const isLatestVersionOlder = isVersionLessThan(latestVersion, currentVersion)\n\n if (isLatestVersionNewer) {\n return true\n }\n return this.allowDowngrade && isLatestVersionOlder\n }\n\n private checkIfUpdateSupported(updateInfo: UpdateInfo) {\n const minimumSystemVersion = updateInfo?.minimumSystemVersion\n const currentOSVersion = release()\n if (minimumSystemVersion) {\n try {\n if (isVersionLessThan(currentOSVersion, minimumSystemVersion)) {\n this._logger.info(`Current OS version ${currentOSVersion} is less than the minimum OS version required ${minimumSystemVersion} for version ${currentOSVersion}`)\n return false\n }\n } catch (e: any) {\n this._logger.warn(`Failed to compare current OS version(${currentOSVersion}) with minimum OS version(${minimumSystemVersion}): ${(e.message || e).toString()}`)\n }\n }\n return true\n }\n\n protected async getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider> {\n await this.app.whenReady()\n\n if (this.clientPromise == null) {\n this.clientPromise = this.configOnDisk.value.then(it => createClient(it, this, this.createProviderRuntimeOptions()))\n }\n\n const client = await this.clientPromise\n const stagingUserId = await this.stagingUserIdPromise.value\n client.setRequestHeaders(this.computeFinalHeaders({ \"x-user-staging-id\": stagingUserId }))\n return {\n info: await client.getLatestVersion(),\n provider: client,\n }\n }\n\n private createProviderRuntimeOptions() {\n return {\n isUseMultipleRangeRequest: true,\n platform: this._testOnlyOptions == null ? (process.platform as ProviderPlatform) : this._testOnlyOptions.platform,\n executor: this.httpExecutor,\n }\n }\n\n private async doCheckForUpdates(): Promise<UpdateCheckResult> {\n this.emit(\"checking-for-update\")\n\n const result = await this.getUpdateInfoAndProvider()\n const updateInfo = result.info\n if (!(await this.isUpdateAvailable(updateInfo))) {\n this._logger.info(\n `Update for version ${this.currentVersion.format()} is not available (latest version: ${updateInfo.version}, downgrade is ${\n this.allowDowngrade ? \"allowed\" : \"disallowed\"\n }).`\n )\n this.emit(\"update-not-available\", updateInfo)\n return {\n isUpdateAvailable: false,\n versionInfo: updateInfo,\n updateInfo,\n }\n }\n\n this.updateInfoAndProvider = result\n this.onUpdateAvailable(updateInfo)\n\n const cancellationToken = new CancellationToken()\n //noinspection ES6MissingAwait\n return {\n isUpdateAvailable: true,\n versionInfo: updateInfo,\n updateInfo,\n cancellationToken,\n downloadPromise: this.autoDownload ? this.downloadUpdate(cancellationToken) : null,\n }\n }\n\n protected onUpdateAvailable(updateInfo: UpdateInfo): void {\n this._logger.info(\n `Found version ${updateInfo.version} (url: ${asArray(updateInfo.files)\n .map(it => it.url)\n .join(\", \")})`\n )\n this.emit(\"update-available\", updateInfo)\n }\n\n /**\n * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.\n * @returns {Promise<Array<string>>} Paths to downloaded files.\n */\n downloadUpdate(cancellationToken: CancellationToken = new CancellationToken()): Promise<Array<string>> {\n const updateInfoAndProvider = this.updateInfoAndProvider\n if (updateInfoAndProvider == null) {\n const error = new Error(\"Please check update first\")\n this.dispatchError(error)\n return Promise.reject(error)\n }\n\n if (this.downloadPromise != null) {\n this._logger.info(\"Downloading update (already in progress)\")\n return this.downloadPromise\n }\n\n this._logger.info(\n `Downloading update from ${asArray(updateInfoAndProvider.info.files)\n .map(it => it.url)\n .join(\", \")}`\n )\n const errorHandler = (e: Error): Error => {\n // https://github.com/electron-userland/electron-builder/issues/1150#issuecomment-436891159\n if (!(e instanceof CancellationError)) {\n try {\n this.dispatchError(e)\n } catch (nestedError: any) {\n this._logger.warn(`Cannot dispatch error event: ${nestedError.stack || nestedError}`)\n }\n }\n\n return e\n }\n\n this.downloadPromise = this.doDownloadUpdate({\n updateInfoAndProvider,\n requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),\n cancellationToken,\n disableWebInstaller: this.disableWebInstaller,\n disableDifferentialDownload: this.disableDifferentialDownload,\n })\n .catch((e: any) => {\n throw errorHandler(e)\n })\n .finally(() => {\n this.downloadPromise = null\n })\n\n return this.downloadPromise\n }\n\n protected dispatchError(e: Error): void {\n this.emit(\"error\", e, (e.stack || e).toString())\n }\n\n protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void {\n this.emit(UPDATE_DOWNLOADED, event)\n }\n\n protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>\n\n /**\n * Restarts the app and installs the update after it has been downloaded.\n * It should only be called after `update-downloaded` has been emitted.\n *\n * **Note:** `autoUpdater.quitAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.\n * This is different from the normal quit event sequence.\n *\n * @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.\n * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.\n * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).\n */\n abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void\n\n private async loadUpdateConfig(): Promise<any> {\n if (this._appUpdateConfigPath == null) {\n this._appUpdateConfigPath = this.app.appUpdateConfigPath\n }\n return load(await readFile(this._appUpdateConfigPath, \"utf-8\"))\n }\n\n private computeRequestHeaders(provider: Provider<any>): OutgoingHttpHeaders {\n const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders\n if (fileExtraDownloadHeaders != null) {\n const requestHeaders = this.requestHeaders\n return requestHeaders == null\n ? fileExtraDownloadHeaders\n : {\n ...fileExtraDownloadHeaders,\n ...requestHeaders,\n }\n }\n return this.computeFinalHeaders({ accept: \"*/*\" })\n }\n\n private async getOrCreateStagingUserId(): Promise<string> {\n const file = path.join(this.app.userDataPath, \".updaterId\")\n try {\n const id = await readFile(file, \"utf-8\")\n if (UUID.check(id)) {\n return id\n } else {\n this._logger.warn(`Staging user id file exists, but content was invalid: ${id}`)\n }\n } catch (e: any) {\n if (e.code !== \"ENOENT\") {\n this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`)\n }\n }\n\n const id = UUID.v5(randomBytes(4096), UUID.OID)\n this._logger.info(`Generated new staging user ID: ${id}`)\n try {\n await outputFile(file, id)\n } catch (e: any) {\n this._logger.warn(`Couldn't write out staging user ID: ${e}`)\n }\n return id\n }\n\n /** @internal */\n get isAddNoCacheQuery(): boolean {\n const headers = this.requestHeaders\n // https://github.com/electron-userland/electron-builder/issues/3021\n if (headers == null) {\n return true\n }\n\n for (const headerName of Object.keys(headers)) {\n const s = headerName.toLowerCase()\n if (s === \"authorization\" || s === \"private-token\") {\n return false\n }\n }\n return true\n }\n\n /**\n * @private\n * @internal\n */\n _testOnlyOptions: TestOnlyUpdaterOptions | null = null\n\n private async getOrCreateDownloadHelper(): Promise<DownloadedUpdateHelper> {\n let result = this.downloadedUpdateHelper\n if (result == null) {\n const dirName = (await this.configOnDisk.value).updaterCacheDirName\n const logger = this._logger\n if (dirName == null) {\n logger.error(\"updaterCacheDirName is not specified in app-update.yml Was app build using at least electron-builder 20.34.0?\")\n }\n const cacheDir = path.join(this.app.baseCachePath, dirName || this.app.name)\n if (logger.debug != null) {\n logger.debug(`updater cache dir: ${cacheDir}`)\n }\n\n result = new DownloadedUpdateHelper(cacheDir)\n this.downloadedUpdateHelper = result\n }\n return result\n }\n\n protected async executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n const fileInfo = taskOptions.fileInfo\n const downloadOptions: DownloadOptions = {\n headers: taskOptions.downloadUpdateOptions.requestHeaders,\n cancellationToken: taskOptions.downloadUpdateOptions.cancellationToken,\n sha2: (fileInfo.info as any).sha2,\n sha512: fileInfo.info.sha512,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const updateInfo = taskOptions.downloadUpdateOptions.updateInfoAndProvider.info\n const version = updateInfo.version\n const packageInfo = fileInfo.packageInfo\n\n function getCacheUpdateFileName(): string {\n // NodeJS URL doesn't decode automatically\n const urlPath = decodeURIComponent(taskOptions.fileInfo.url.pathname)\n if (urlPath.toLowerCase().endsWith(`.${taskOptions.fileExtension.toLowerCase()}`)) {\n return path.basename(urlPath)\n } else {\n // url like /latest, generate name\n return taskOptions.fileInfo.info.url\n }\n }\n\n const downloadedUpdateHelper = await this.getOrCreateDownloadHelper()\n const cacheDir = downloadedUpdateHelper.cacheDirForPendingUpdate\n await mkdir(cacheDir, { recursive: true })\n const updateFileName = getCacheUpdateFileName()\n let updateFile = path.join(cacheDir, updateFileName)\n const packageFile = packageInfo == null ? null : path.join(cacheDir, `package-${version}${path.extname(packageInfo.path) || \".7z\"}`)\n\n const done = async (isSaveCache: boolean) => {\n await downloadedUpdateHelper.setDownloadedFile(updateFile, packageFile, updateInfo, fileInfo, updateFileName, isSaveCache)\n await taskOptions.done!({\n ...updateInfo,\n downloadedFile: updateFile,\n })\n const currentBlockMapFile = path.join(cacheDir, \"current.blockmap\")\n if (await pathExists(currentBlockMapFile)) {\n await copyFile(currentBlockMapFile, path.join(downloadedUpdateHelper.cacheDir, \"current.blockmap\"))\n }\n return packageFile == null ? [updateFile] : [updateFile, packageFile]\n }\n\n const log = this._logger\n const cachedUpdateFile = await downloadedUpdateHelper.validateDownloadedPath(updateFile, updateInfo, fileInfo, log)\n if (cachedUpdateFile != null) {\n updateFile = cachedUpdateFile\n return await done(false)\n }\n\n const removeFileIfAny = async () => {\n await downloadedUpdateHelper.clear().catch(() => {\n // ignore\n })\n return await unlink(updateFile).catch(() => {\n // ignore\n })\n }\n\n const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log)\n try {\n await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny)\n await retry(() => rename(tempUpdateFile, updateFile), {\n retries: 60,\n interval: 500,\n shouldRetry: (error: Error) => {\n if (error instanceof Error && /^EBUSY:/.test(error.message)) {\n return true\n }\n log.warn(`Cannot rename temp file to final file: ${error.message || error.stack}`)\n return false\n },\n })\n } catch (e: any) {\n await removeFileIfAny()\n\n if (e instanceof CancellationError) {\n log.info(\"cancelled\")\n this.emit(\"update-cancelled\", updateInfo)\n }\n throw e\n }\n\n log.info(`New version ${version} has been downloaded to ${updateFile}`)\n return await done(true)\n }\n protected async differentialDownloadInstaller(\n fileInfo: ResolvedUpdateFileInfo,\n downloadUpdateOptions: DownloadUpdateOptions,\n installerPath: string,\n provider: Provider<any>,\n oldInstallerFileName: string\n ): Promise<boolean> {\n try {\n if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {\n return true\n }\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const blockmapFileUrls = await provider.getBlockMapFiles(\n fileInfo.url,\n this.app.version,\n downloadUpdateOptions.updateInfoAndProvider.info.version,\n this.previousBlockmapBaseUrlOverride\n )\n this._logger.info(`Download block maps (old: \"${blockmapFileUrls[0]}\", new: ${blockmapFileUrls[1]})`)\n\n const downloadBlockMap = async (url: URL): Promise<BlockMap> => {\n const data = await this.httpExecutor.downloadToBuffer(url, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n })\n\n if (data == null || data.length === 0) {\n throw new Error(`Blockmap \"${url.href}\" is empty`)\n }\n\n try {\n return JSON.parse(gunzipSync(data).toString())\n } catch (e: any) {\n throw new Error(`Cannot parse blockmap \"${url.href}\", error: ${e}`)\n }\n }\n\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, oldInstallerFileName),\n logger: this._logger,\n newFile: installerPath,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const saveBlockMapToCacheDir = async (blockMapData: BlockMap, cacheDir: string) => {\n const blockMapFile = path.join(cacheDir, \"current.blockmap\")\n await outputFile(blockMapFile, gzipSync(JSON.stringify(blockMapData)))\n }\n\n const getBlockMapFromCacheDir = async (cacheDir: string) => {\n const blockMapFile = path.join(cacheDir, \"current.blockmap\")\n try {\n if (await pathExists(blockMapFile)) {\n return JSON.parse(gunzipSync(await readFile(blockMapFile)).toString())\n }\n } catch (e: any) {\n this._logger.warn(`Cannot parse blockmap \"${blockMapFile}\", error: ${e}`)\n }\n return null\n }\n\n const newBlockMapData = await downloadBlockMap(blockmapFileUrls[1])\n await saveBlockMapToCacheDir(newBlockMapData, this.downloadedUpdateHelper!.cacheDirForPendingUpdate)\n\n // get old blockmap from cache dir first, if not found, download it\n let oldBlockMapData = await getBlockMapFromCacheDir(this.downloadedUpdateHelper!.cacheDir)\n if (oldBlockMapData == null) {\n oldBlockMapData = await downloadBlockMap(blockmapFileUrls[0])\n }\n\n await new GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(oldBlockMapData, newBlockMapData)\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n if (this._testOnlyOptions != null) {\n // test mode\n throw e\n }\n return true\n }\n }\n}\n\nexport interface DownloadUpdateOptions {\n readonly updateInfoAndProvider: UpdateInfoAndProvider\n readonly requestHeaders: OutgoingHttpHeaders\n readonly cancellationToken: CancellationToken\n readonly disableWebInstaller?: boolean\n readonly disableDifferentialDownload?: boolean\n}\n\nfunction hasPrereleaseComponents(version: SemVer) {\n const versionPrereleaseComponent = getVersionPreleaseComponents(version)\n return versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0\n}\n\n/** @private */\nexport class NoOpLogger implements Logger {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n info(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n warn(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n error(message?: any) {\n // ignore\n }\n}\n\nexport interface UpdateInfoAndProvider {\n info: UpdateInfo\n provider: Provider<any>\n}\n\nexport interface DownloadExecutorTask {\n readonly fileExtension: string\n readonly fileInfo: ResolvedUpdateFileInfo\n readonly downloadUpdateOptions: DownloadUpdateOptions\n readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>\n\n readonly done?: (event: UpdateDownloadedEvent) => Promise<any>\n}\n\nexport interface DownloadNotification {\n body: string\n title: string\n}\n\n/** @private */\nexport interface TestOnlyUpdaterOptions {\n platform: ProviderPlatform\n\n isUseDifferentialDownload?: boolean\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AppUpdater.js","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAa6B;AAC7B,mCAAoC;AACpC,2BAA4B;AAC5B,mCAAqC;AACrC,uCAA4F;AAE5F,qCAA8B;AAC9B,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAA8K;AAE9K,qEAAuF;AACvF,6DAAyD;AACzD,iEAA2F;AAC3F,iEAA6D;AAC7D,uDAAwF;AAKxF,+BAA2C;AAE3C,0GAAsG;AACtG,mCAAuJ;AAevJ,MAAsB,UAAW,SAAS,qBAAyD;IAwFjG;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;OA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AQ,CAAC,CAAA;YAC1F,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;gBAC5B,eAAe,GAAG,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/D,CAAC;YAED,MAAM,IAAI,6DAA6B,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;YACrI,OAAO,KAAK,CAAA;QACd,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;gBAClC,YAAY;gBACZ,MAAM,CAAC,CAAA;YACT,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAr0BD,gCAq0BC;AAUD,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,0BAA0B,GAAG,IAAA,mBAA4B,EAAC,OAAO,CAAC,CAAA;IACxE,OAAO,0BAA0B,IAAI,IAAI,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAA;AACpF,CAAC;AAED,eAAe;AACf,MAAa,UAAU;IACrB,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,OAAa;QACjB,SAAS;IACX,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import {\n AllPublishOptions,\n asArray,\n CancellationToken,\n newError,\n PublishConfiguration,\n UpdateInfo,\n UUID,\n DownloadOptions,\n CancellationError,\n ProgressInfo,\n BlockMap,\n retry,\n} from \"builder-util-runtime\"\nimport { randomBytes } from \"crypto\"\nimport { release } from \"os\"\nimport { EventEmitter } from \"events\"\nimport { mkdir, outputFile, readFile, rename, unlink, copyFile, pathExists } from \"fs-extra\"\nimport { OutgoingHttpHeaders } from \"http\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { eq as isVersionsEqual, gt as isVersionGreaterThan, lt as isVersionLessThan, parse as parseVersion, prerelease as getVersionPreleaseComponents, SemVer } from \"semver\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { createTempUpdateFile, DownloadedUpdateHelper } from \"./DownloadedUpdateHelper\"\nimport { ElectronAppAdapter } from \"./ElectronAppAdapter\"\nimport { ElectronHttpExecutor, getNetSession, LoginCallback } from \"./electronHttpExecutor\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { createClient, isUrlProbablySupportMultiRangeRequests } from \"./providerFactory\"\nimport { Provider, ProviderPlatform } from \"./providers/Provider\"\nimport type { TypedEmitter } from \"tiny-typed-emitter\"\nimport Session = Electron.Session\nimport type { AuthInfo } from \"electron\"\nimport { gunzipSync, gzipSync } from \"zlib\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { GenericDifferentialDownloader } from \"./differentialDownloader/GenericDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS, Logger, ResolvedUpdateFileInfo, UPDATE_DOWNLOADED, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from \"./types\"\nimport { VerifyUpdateSupport } from \"./main\"\n\nexport type AppUpdaterEvents = {\n error: (error: Error, message?: string) => void\n login: (info: AuthInfo, callback: LoginCallback) => void\n \"checking-for-update\": () => void\n \"update-not-available\": (info: UpdateInfo) => void\n \"update-available\": (info: UpdateInfo) => void\n \"update-downloaded\": (event: UpdateDownloadedEvent) => void\n \"download-progress\": (info: ProgressInfo) => void\n \"update-cancelled\": (info: UpdateInfo) => void\n \"appimage-filename-updated\": (path: string) => void\n}\n\nexport abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter<AppUpdaterEvents>) {\n /**\n * Whether to automatically download an update when it is found.\n * @default true\n */\n autoDownload = true\n\n /**\n * Whether to automatically install a downloaded update on app quit (if `quitAndInstall` was not called before).\n * @default true\n */\n autoInstallOnAppQuit = true\n\n /**\n * Whether to run the app after finish install when run the installer is NOT in silent mode.\n * @default true\n */\n autoRunAppAfterInstall = true\n\n /**\n * *GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.\n *\n * If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`).\n */\n allowPrerelease = false\n\n /**\n * *GitHub provider only.* Get all release notes (from current version to latest), not just the latest.\n * @default false\n */\n fullChangelog = false\n\n /**\n * Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).\n *\n * Taken in account only if channel differs (pre-release version component in terms of semantic versioning).\n *\n * @default false\n */\n allowDowngrade = false\n\n /**\n * Web installer files might not have signature verification, this switch prevents to load them unless it is needed.\n *\n * Currently false to prevent breaking the current API, but it should be changed to default true at some point that\n * breaking changes are allowed.\n *\n * @default false\n */\n disableWebInstaller = false\n\n /**\n * *NSIS only* Disable differential downloads and always perform full download of installer.\n *\n * @default false\n */\n disableDifferentialDownload = false\n\n /**\n * Allows developer to force the updater to work in \"dev\" mode, looking for \"dev-app-update.yml\" instead of \"app-update.yml\"\n * Dev: `path.join(this.app.getAppPath(), \"dev-app-update.yml\")`\n * Prod: `path.join(process.resourcesPath!, \"app-update.yml\")`\n *\n * @default false\n */\n forceDevUpdateConfig = false\n\n /**\n * The base URL of the old block map file.\n *\n * When null, the updater will use the base URL of the update file to download the update.\n * When set, the updater will use this string as the base URL of the old block map file.\n * Some servers like github cannot download the old block map file from latest release,\n * so you need to compute the old block map file base URL manually.\n *\n * @default null\n */\n public previousBlockmapBaseUrlOverride: string | null = null\n\n /**\n * The current application version.\n */\n readonly currentVersion: SemVer\n\n private _channel: string | null = null\n\n protected downloadedUpdateHelper: DownloadedUpdateHelper | null = null\n\n /**\n * Get the update channel. Doesn't return `channel` from the update configuration, only if was previously set.\n */\n get channel(): string | null {\n return this._channel\n }\n\n /**\n * Set the update channel. Overrides `channel` in the update configuration.\n *\n * `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.\n */\n set channel(value: string | null) {\n if (this._channel != null) {\n // noinspection SuspiciousTypeOfGuard\n if (typeof value !== \"string\") {\n throw newError(`Channel must be a string, but got: ${value}`, \"ERR_UPDATER_INVALID_CHANNEL\")\n } else if (value.length === 0) {\n throw newError(`Channel must be not an empty string`, \"ERR_UPDATER_INVALID_CHANNEL\")\n }\n }\n\n this._channel = value\n this.allowDowngrade = true\n }\n\n /**\n * The request headers.\n */\n requestHeaders: OutgoingHttpHeaders | null = null\n\n /**\n * Shortcut for explicitly adding auth tokens to request headers\n */\n addAuthHeader(token: string) {\n this.requestHeaders = Object.assign({}, this.requestHeaders, {\n authorization: token,\n })\n }\n\n protected _logger: Logger = console\n\n // noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n get netSession(): Session {\n return getNetSession()\n }\n\n /**\n * The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.\n * Set it to `null` if you would like to disable a logging feature.\n */\n get logger(): Logger | null {\n return this._logger\n }\n\n set logger(value: Logger | null) {\n this._logger = value == null ? new NoOpLogger() : value\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})`\n */\n readonly signals = new UpdaterSignal(this)\n\n private _appUpdateConfigPath: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * test only\n * @private\n */\n set updateConfigPath(value: string | null) {\n this.clientPromise = null\n this._appUpdateConfigPath = value\n this.configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n }\n\n protected _isUpdateSupported: VerifyUpdateSupport = updateInfo => this.checkIfUpdateSupported(updateInfo)\n\n /**\n * Allows developer to override default logic for determining if an update is supported.\n * The default logic compares the `UpdateInfo` minimum system version against the `os.release()` with `semver` package\n */\n get isUpdateSupported(): VerifyUpdateSupport {\n return this._isUpdateSupported\n }\n\n set isUpdateSupported(value: VerifyUpdateSupport) {\n if (value) {\n this._isUpdateSupported = value\n }\n }\n\n protected _isUserWithinRollout: VerifyUpdateSupport = updateInfo => this.isStagingMatch(updateInfo)\n\n /**\n * Allows developer to override default logic for determining if the user is below the rollout threshold.\n * The default logic compares the staging percentage with numerical representation of user ID.\n * An override can define custom logic, or bypass it if needed.\n */\n get isUserWithinRollout(): VerifyUpdateSupport {\n return this._isUserWithinRollout\n }\n\n set isUserWithinRollout(value: VerifyUpdateSupport) {\n if (value) {\n this._isUserWithinRollout = value\n }\n }\n\n private clientPromise: Promise<Provider<any>> | null = null\n\n protected readonly stagingUserIdPromise = new Lazy<string>(() => this.getOrCreateStagingUserId())\n\n // public, allow to read old config for anyone\n /** @internal */\n configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n\n private checkForUpdatesPromise: Promise<UpdateCheckResult> | null = null\n private downloadPromise: Promise<Array<string>> | null = null\n\n protected readonly app: AppAdapter\n\n protected updateInfoAndProvider: UpdateInfoAndProvider | null = null\n\n /** @internal */\n readonly httpExecutor: ElectronHttpExecutor\n\n protected constructor(options: AllPublishOptions | null | undefined, app?: AppAdapter) {\n super()\n\n this.on(\"error\", (error: Error) => {\n this._logger.error(`Error: ${error.stack || error.message}`)\n })\n\n if (app == null) {\n this.app = new ElectronAppAdapter()\n this.httpExecutor = new ElectronHttpExecutor((authInfo, callback) => this.emit(\"login\", authInfo, callback))\n } else {\n this.app = app\n this.httpExecutor = null as any\n }\n\n const currentVersionString = this.app.version\n const currentVersion = parseVersion(currentVersionString)\n if (currentVersion == null) {\n throw newError(`App version is not a valid semver version: \"${currentVersionString}\"`, \"ERR_UPDATER_INVALID_VERSION\")\n }\n this.currentVersion = currentVersion\n this.allowPrerelease = hasPrereleaseComponents(currentVersion)\n\n if (options != null) {\n this.setFeedURL(options)\n\n if (typeof options !== \"string\" && options.requestHeaders) {\n this.requestHeaders = options.requestHeaders\n }\n }\n }\n\n //noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n getFeedURL(): string | null | undefined {\n return \"Deprecated. Do not use it.\"\n }\n\n /**\n * Configure update provider. If value is `string`, [GenericServerOptions](https://www.electron.build/publish#genericserveroptions) will be set with value as `url`.\n * @param options If you want to override configuration in the `app-update.yml`.\n */\n setFeedURL(options: PublishConfiguration | AllPublishOptions | string) {\n const runtimeOptions = this.createProviderRuntimeOptions()\n // https://github.com/electron-userland/electron-builder/issues/1105\n let provider: Provider<any>\n if (typeof options === \"string\") {\n provider = new GenericProvider({ provider: \"generic\", url: options }, this, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: isUrlProbablySupportMultiRangeRequests(options),\n })\n } else {\n provider = createClient(options, this, runtimeOptions)\n }\n this.clientPromise = Promise.resolve(provider)\n }\n\n /**\n * Asks the server whether there is an update.\n * @returns null if the updater is disabled, otherwise info about the latest version\n */\n checkForUpdates(): Promise<UpdateCheckResult | null> {\n if (!this.isUpdaterActive()) {\n return Promise.resolve(null)\n }\n\n let checkForUpdatesPromise = this.checkForUpdatesPromise\n if (checkForUpdatesPromise != null) {\n this._logger.info(\"Checking for update (already in progress)\")\n return checkForUpdatesPromise\n }\n\n const nullizePromise = () => (this.checkForUpdatesPromise = null)\n\n this._logger.info(\"Checking for update\")\n checkForUpdatesPromise = this.doCheckForUpdates()\n .then(it => {\n nullizePromise()\n return it\n })\n .catch((e: any) => {\n nullizePromise()\n this.emit(\"error\", e, `Cannot check for updates: ${(e.stack || e).toString()}`)\n throw e\n })\n\n this.checkForUpdatesPromise = checkForUpdatesPromise\n return checkForUpdatesPromise\n }\n\n public isUpdaterActive(): boolean {\n const isEnabled = this.app.isPackaged || this.forceDevUpdateConfig\n if (!isEnabled) {\n this._logger.info(\"Skip checkForUpdates because application is not packed and dev update config is not forced\")\n return false\n }\n return true\n }\n\n // noinspection JSUnusedGlobalSymbols\n checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null> {\n return this.checkForUpdates().then(it => {\n if (!it?.downloadPromise) {\n if (this._logger.debug != null) {\n this._logger.debug(\"checkForUpdatesAndNotify called, downloadPromise is null\")\n }\n return it\n }\n\n void it.downloadPromise.then(() => {\n const notificationContent = AppUpdater.formatDownloadNotification(it.updateInfo.version, this.app.name, downloadNotification)\n new (require(\"electron\").Notification)(notificationContent).show()\n })\n\n return it\n })\n }\n\n private static formatDownloadNotification(version: string, appName: string, downloadNotification?: DownloadNotification): DownloadNotification {\n if (downloadNotification == null) {\n downloadNotification = {\n title: \"A new update is ready to install\",\n body: `{appName} version {version} has been downloaded and will be automatically installed on exit`,\n }\n }\n downloadNotification = {\n title: downloadNotification.title.replace(\"{appName}\", appName).replace(\"{version}\", version),\n body: downloadNotification.body.replace(\"{appName}\", appName).replace(\"{version}\", version),\n }\n return downloadNotification\n }\n\n private async isStagingMatch(updateInfo: UpdateInfo): Promise<boolean> {\n const rawStagingPercentage = updateInfo.stagingPercentage\n let stagingPercentage = rawStagingPercentage\n if (stagingPercentage == null) {\n return true\n }\n\n stagingPercentage = parseInt(stagingPercentage as any, 10)\n if (isNaN(stagingPercentage)) {\n this._logger.warn(`Staging percentage is NaN: ${rawStagingPercentage}`)\n return true\n }\n\n // convert from user 0-100 to internal 0-1\n stagingPercentage = stagingPercentage / 100\n\n const stagingUserId = await this.stagingUserIdPromise.value\n const val = UUID.parse(stagingUserId).readUInt32BE(12)\n const percentage = val / 0xffffffff\n this._logger.info(`Staging percentage: ${stagingPercentage}, percentage: ${percentage}, user id: ${stagingUserId}`)\n return percentage < stagingPercentage\n }\n\n private computeFinalHeaders(headers: OutgoingHttpHeaders) {\n if (this.requestHeaders != null) {\n Object.assign(headers, this.requestHeaders)\n }\n return headers\n }\n\n private async isUpdateAvailable(updateInfo: UpdateInfo): Promise<boolean> {\n const latestVersion = parseVersion(updateInfo.version)\n if (latestVersion == null) {\n throw newError(\n `This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: \"${updateInfo.version}\"`,\n \"ERR_UPDATER_INVALID_VERSION\"\n )\n }\n\n const currentVersion = this.currentVersion\n if (isVersionsEqual(latestVersion, currentVersion)) {\n return false\n }\n\n if (!(await Promise.resolve(this.isUpdateSupported(updateInfo)))) {\n return false\n }\n\n const isUserWithinRollout = await Promise.resolve(this.isUserWithinRollout(updateInfo))\n if (!isUserWithinRollout) {\n return false\n }\n\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405033227\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405030797\n const isLatestVersionNewer = isVersionGreaterThan(latestVersion, currentVersion)\n const isLatestVersionOlder = isVersionLessThan(latestVersion, currentVersion)\n\n if (isLatestVersionNewer) {\n return true\n }\n return this.allowDowngrade && isLatestVersionOlder\n }\n\n private checkIfUpdateSupported(updateInfo: UpdateInfo) {\n const minimumSystemVersion = updateInfo?.minimumSystemVersion\n const currentOSVersion = release()\n if (minimumSystemVersion) {\n try {\n if (isVersionLessThan(currentOSVersion, minimumSystemVersion)) {\n this._logger.info(`Current OS version ${currentOSVersion} is less than the minimum OS version required ${minimumSystemVersion} for version ${currentOSVersion}`)\n return false\n }\n } catch (e: any) {\n this._logger.warn(`Failed to compare current OS version(${currentOSVersion}) with minimum OS version(${minimumSystemVersion}): ${(e.message || e).toString()}`)\n }\n }\n return true\n }\n\n protected async getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider> {\n await this.app.whenReady()\n\n if (this.clientPromise == null) {\n this.clientPromise = this.configOnDisk.value.then(it => createClient(it, this, this.createProviderRuntimeOptions()))\n }\n\n const client = await this.clientPromise\n const stagingUserId = await this.stagingUserIdPromise.value\n client.setRequestHeaders(this.computeFinalHeaders({ \"x-user-staging-id\": stagingUserId }))\n return {\n info: await client.getLatestVersion(),\n provider: client,\n }\n }\n\n private createProviderRuntimeOptions() {\n return {\n isUseMultipleRangeRequest: true,\n platform: this._testOnlyOptions == null ? (process.platform as ProviderPlatform) : this._testOnlyOptions.platform,\n executor: this.httpExecutor,\n }\n }\n\n private async doCheckForUpdates(): Promise<UpdateCheckResult> {\n this.emit(\"checking-for-update\")\n\n const result = await this.getUpdateInfoAndProvider()\n const updateInfo = result.info\n if (!(await this.isUpdateAvailable(updateInfo))) {\n this._logger.info(\n `Update for version ${this.currentVersion.format()} is not available (latest version: ${updateInfo.version}, downgrade is ${\n this.allowDowngrade ? \"allowed\" : \"disallowed\"\n }).`\n )\n this.emit(\"update-not-available\", updateInfo)\n return {\n isUpdateAvailable: false,\n versionInfo: updateInfo,\n updateInfo,\n }\n }\n\n this.updateInfoAndProvider = result\n this.onUpdateAvailable(updateInfo)\n\n const cancellationToken = new CancellationToken()\n //noinspection ES6MissingAwait\n return {\n isUpdateAvailable: true,\n versionInfo: updateInfo,\n updateInfo,\n cancellationToken,\n downloadPromise: this.autoDownload ? this.downloadUpdate(cancellationToken) : null,\n }\n }\n\n protected onUpdateAvailable(updateInfo: UpdateInfo): void {\n this._logger.info(\n `Found version ${updateInfo.version} (url: ${asArray(updateInfo.files)\n .map(it => it.url)\n .join(\", \")})`\n )\n this.emit(\"update-available\", updateInfo)\n }\n\n /**\n * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.\n * @returns {Promise<Array<string>>} Paths to downloaded files.\n */\n downloadUpdate(cancellationToken: CancellationToken = new CancellationToken()): Promise<Array<string>> {\n const updateInfoAndProvider = this.updateInfoAndProvider\n if (updateInfoAndProvider == null) {\n const error = new Error(\"Please check update first\")\n this.dispatchError(error)\n return Promise.reject(error)\n }\n\n if (this.downloadPromise != null) {\n this._logger.info(\"Downloading update (already in progress)\")\n return this.downloadPromise\n }\n\n this._logger.info(\n `Downloading update from ${asArray(updateInfoAndProvider.info.files)\n .map(it => it.url)\n .join(\", \")}`\n )\n const errorHandler = (e: Error): Error => {\n // https://github.com/electron-userland/electron-builder/issues/1150#issuecomment-436891159\n if (!(e instanceof CancellationError)) {\n try {\n this.dispatchError(e)\n } catch (nestedError: any) {\n this._logger.warn(`Cannot dispatch error event: ${nestedError.stack || nestedError}`)\n }\n }\n\n return e\n }\n\n this.downloadPromise = this.doDownloadUpdate({\n updateInfoAndProvider,\n requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),\n cancellationToken,\n disableWebInstaller: this.disableWebInstaller,\n disableDifferentialDownload: this.disableDifferentialDownload,\n })\n .catch((e: any) => {\n throw errorHandler(e)\n })\n .finally(() => {\n this.downloadPromise = null\n })\n\n return this.downloadPromise\n }\n\n protected dispatchError(e: Error): void {\n this.emit(\"error\", e, (e.stack || e).toString())\n }\n\n protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void {\n this.emit(UPDATE_DOWNLOADED, event)\n }\n\n protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>\n\n /**\n * Restarts the app and installs the update after it has been downloaded.\n * It should only be called after `update-downloaded` has been emitted.\n *\n * **Note:** `autoUpdater.quitAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.\n * This is different from the normal quit event sequence.\n *\n * @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.\n * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.\n * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).\n */\n abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void\n\n private async loadUpdateConfig(): Promise<any> {\n if (this._appUpdateConfigPath == null) {\n this._appUpdateConfigPath = this.app.appUpdateConfigPath\n }\n return load(await readFile(this._appUpdateConfigPath, \"utf-8\"))\n }\n\n private computeRequestHeaders(provider: Provider<any>): OutgoingHttpHeaders {\n const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders\n if (fileExtraDownloadHeaders != null) {\n const requestHeaders = this.requestHeaders\n return requestHeaders == null\n ? fileExtraDownloadHeaders\n : {\n ...fileExtraDownloadHeaders,\n ...requestHeaders,\n }\n }\n return this.computeFinalHeaders({ accept: \"*/*\" })\n }\n\n private async getOrCreateStagingUserId(): Promise<string> {\n const file = path.join(this.app.userDataPath, \".updaterId\")\n try {\n const id = await readFile(file, \"utf-8\")\n if (UUID.check(id)) {\n return id\n } else {\n this._logger.warn(`Staging user id file exists, but content was invalid: ${id}`)\n }\n } catch (e: any) {\n if (e.code !== \"ENOENT\") {\n this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`)\n }\n }\n\n const id = UUID.v5(randomBytes(4096), UUID.OID)\n this._logger.info(`Generated new staging user ID: ${id}`)\n try {\n await outputFile(file, id)\n } catch (e: any) {\n this._logger.warn(`Couldn't write out staging user ID: ${e}`)\n }\n return id\n }\n\n /** @internal */\n get isAddNoCacheQuery(): boolean {\n const headers = this.requestHeaders\n // https://github.com/electron-userland/electron-builder/issues/3021\n if (headers == null) {\n return true\n }\n\n for (const headerName of Object.keys(headers)) {\n const s = headerName.toLowerCase()\n if (s === \"authorization\" || s === \"private-token\") {\n return false\n }\n }\n return true\n }\n\n /**\n * @private\n * @internal\n */\n _testOnlyOptions: TestOnlyUpdaterOptions | null = null\n\n private async getOrCreateDownloadHelper(): Promise<DownloadedUpdateHelper> {\n let result = this.downloadedUpdateHelper\n if (result == null) {\n const dirName = (await this.configOnDisk.value).updaterCacheDirName\n const logger = this._logger\n if (dirName == null) {\n logger.error(\"updaterCacheDirName is not specified in app-update.yml Was app build using at least electron-builder 20.34.0?\")\n }\n const cacheDir = path.join(this.app.baseCachePath, dirName || this.app.name)\n if (logger.debug != null) {\n logger.debug(`updater cache dir: ${cacheDir}`)\n }\n\n result = new DownloadedUpdateHelper(cacheDir)\n this.downloadedUpdateHelper = result\n }\n return result\n }\n\n protected async executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n const fileInfo = taskOptions.fileInfo\n const downloadOptions: DownloadOptions = {\n headers: taskOptions.downloadUpdateOptions.requestHeaders,\n cancellationToken: taskOptions.downloadUpdateOptions.cancellationToken,\n sha2: (fileInfo.info as any).sha2,\n sha512: fileInfo.info.sha512,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const updateInfo = taskOptions.downloadUpdateOptions.updateInfoAndProvider.info\n const version = updateInfo.version\n const packageInfo = fileInfo.packageInfo\n\n function getCacheUpdateFileName(): string {\n // NodeJS URL doesn't decode automatically\n const urlPath = decodeURIComponent(taskOptions.fileInfo.url.pathname)\n if (urlPath.toLowerCase().endsWith(`.${taskOptions.fileExtension.toLowerCase()}`)) {\n return path.basename(urlPath)\n } else {\n // url like /latest — use basename so a server-supplied path like \"../../etc/evil\"\n // cannot escape the cache directory via path.join\n return path.basename(taskOptions.fileInfo.info.url)\n }\n }\n\n const downloadedUpdateHelper = await this.getOrCreateDownloadHelper()\n const cacheDir = downloadedUpdateHelper.cacheDirForPendingUpdate\n await mkdir(cacheDir, { recursive: true })\n const updateFileName = getCacheUpdateFileName()\n let updateFile = path.join(cacheDir, updateFileName)\n const packageFile = packageInfo == null ? null : path.join(cacheDir, `package-${version}${path.extname(packageInfo.path) || \".7z\"}`)\n\n const done = async (isSaveCache: boolean) => {\n await downloadedUpdateHelper.setDownloadedFile(updateFile, packageFile, updateInfo, fileInfo, updateFileName, isSaveCache)\n await taskOptions.done!({\n ...updateInfo,\n downloadedFile: updateFile,\n })\n const currentBlockMapFile = path.join(cacheDir, \"current.blockmap\")\n if (await pathExists(currentBlockMapFile)) {\n await copyFile(currentBlockMapFile, path.join(downloadedUpdateHelper.cacheDir, \"current.blockmap\"))\n }\n return packageFile == null ? [updateFile] : [updateFile, packageFile]\n }\n\n const log = this._logger\n const cachedUpdateFile = await downloadedUpdateHelper.validateDownloadedPath(updateFile, updateInfo, fileInfo, log)\n if (cachedUpdateFile != null) {\n updateFile = cachedUpdateFile\n return await done(false)\n }\n\n const removeFileIfAny = async () => {\n await downloadedUpdateHelper.clear().catch(() => {\n // ignore\n })\n return await unlink(updateFile).catch(() => {\n // ignore\n })\n }\n\n const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log)\n try {\n await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny)\n await retry(() => rename(tempUpdateFile, updateFile), {\n retries: 60,\n interval: 500,\n shouldRetry: (error: Error) => {\n if (error instanceof Error && /^EBUSY:/.test(error.message)) {\n return true\n }\n log.warn(`Cannot rename temp file to final file: ${error.message || error.stack}`)\n return false\n },\n })\n } catch (e: any) {\n await removeFileIfAny()\n\n if (e instanceof CancellationError) {\n log.info(\"cancelled\")\n this.emit(\"update-cancelled\", updateInfo)\n }\n throw e\n }\n\n log.info(`New version ${version} has been downloaded to ${updateFile}`)\n return await done(true)\n }\n protected async differentialDownloadInstaller(\n fileInfo: ResolvedUpdateFileInfo,\n downloadUpdateOptions: DownloadUpdateOptions,\n installerPath: string,\n provider: Provider<any>,\n oldInstallerFileName: string\n ): Promise<boolean> {\n try {\n if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {\n return true\n }\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const blockmapFileUrls = await provider.getBlockMapFiles(\n fileInfo.url,\n this.app.version,\n downloadUpdateOptions.updateInfoAndProvider.info.version,\n this.previousBlockmapBaseUrlOverride\n )\n this._logger.info(`Download block maps (old: \"${blockmapFileUrls[0]}\", new: ${blockmapFileUrls[1]})`)\n\n const downloadBlockMap = async (url: URL): Promise<BlockMap> => {\n const data = await this.httpExecutor.downloadToBuffer(url, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n })\n\n if (data == null || data.length === 0) {\n throw new Error(`Blockmap \"${url.href}\" is empty`)\n }\n\n try {\n return JSON.parse(gunzipSync(data).toString())\n } catch (e: any) {\n throw new Error(`Cannot parse blockmap \"${url.href}\", error: ${e}`)\n }\n }\n\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, oldInstallerFileName),\n logger: this._logger,\n newFile: installerPath,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const saveBlockMapToCacheDir = async (blockMapData: BlockMap, cacheDir: string) => {\n const blockMapFile = path.join(cacheDir, \"current.blockmap\")\n await outputFile(blockMapFile, gzipSync(JSON.stringify(blockMapData)))\n }\n\n const getBlockMapFromCacheDir = async (cacheDir: string) => {\n const blockMapFile = path.join(cacheDir, \"current.blockmap\")\n try {\n if (await pathExists(blockMapFile)) {\n return JSON.parse(gunzipSync(await readFile(blockMapFile)).toString())\n }\n } catch (e: any) {\n this._logger.warn(`Cannot parse blockmap \"${blockMapFile}\", error: ${e}`)\n }\n return null\n }\n\n const newBlockMapData = await downloadBlockMap(blockmapFileUrls[1])\n await saveBlockMapToCacheDir(newBlockMapData, this.downloadedUpdateHelper!.cacheDirForPendingUpdate)\n\n // get old blockmap from cache dir first, if not found, download it\n let oldBlockMapData = await getBlockMapFromCacheDir(this.downloadedUpdateHelper!.cacheDir)\n if (oldBlockMapData == null) {\n oldBlockMapData = await downloadBlockMap(blockmapFileUrls[0])\n }\n\n await new GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(oldBlockMapData, newBlockMapData)\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n if (this._testOnlyOptions != null) {\n // test mode\n throw e\n }\n return true\n }\n }\n}\n\nexport interface DownloadUpdateOptions {\n readonly updateInfoAndProvider: UpdateInfoAndProvider\n readonly requestHeaders: OutgoingHttpHeaders\n readonly cancellationToken: CancellationToken\n readonly disableWebInstaller?: boolean\n readonly disableDifferentialDownload?: boolean\n}\n\nfunction hasPrereleaseComponents(version: SemVer) {\n const versionPrereleaseComponent = getVersionPreleaseComponents(version)\n return versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0\n}\n\n/** @private */\nexport class NoOpLogger implements Logger {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n info(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n warn(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n error(message?: any) {\n // ignore\n }\n}\n\nexport interface UpdateInfoAndProvider {\n info: UpdateInfo\n provider: Provider<any>\n}\n\nexport interface DownloadExecutorTask {\n readonly fileExtension: string\n readonly fileInfo: ResolvedUpdateFileInfo\n readonly downloadUpdateOptions: DownloadUpdateOptions\n readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>\n\n readonly done?: (event: UpdateDownloadedEvent) => Promise<any>\n}\n\nexport interface DownloadNotification {\n body: string\n title: string\n}\n\n/** @private */\nexport interface TestOnlyUpdaterOptions {\n platform: ProviderPlatform\n\n isUseDifferentialDownload?: boolean\n}\n"]}
|
package/out/BaseUpdater.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare abstract class BaseUpdater extends AppUpdater {
|
|
|
12
12
|
protected abstract doInstall(options: InstallOptions): boolean;
|
|
13
13
|
install(isSilent?: boolean, isForceRunAfter?: boolean): boolean;
|
|
14
14
|
protected addQuitHandler(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Strips relative-path entries from a PATH string.
|
|
17
|
+
* Prevents PATH-poisoning where a writable directory earlier in PATH shadows
|
|
18
|
+
* a trusted package manager binary.
|
|
19
|
+
*/
|
|
20
|
+
protected sanitizeEnvPath(envPath: string): string;
|
|
15
21
|
protected spawnSyncLog(cmd: string, args?: string[], env?: {}): string;
|
|
16
22
|
/**
|
|
17
23
|
* This handles both node 8 and node 10 way of emitting error when spawning a process
|
package/out/BaseUpdater.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseUpdater = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
5
6
|
const AppUpdater_1 = require("./AppUpdater");
|
|
6
7
|
class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
7
8
|
constructor(options, app) {
|
|
@@ -87,10 +88,23 @@ class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
|
87
88
|
this.install(true, false);
|
|
88
89
|
});
|
|
89
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Strips relative-path entries from a PATH string.
|
|
93
|
+
* Prevents PATH-poisoning where a writable directory earlier in PATH shadows
|
|
94
|
+
* a trusted package manager binary.
|
|
95
|
+
*/
|
|
96
|
+
sanitizeEnvPath(envPath) {
|
|
97
|
+
return envPath
|
|
98
|
+
.split(path.delimiter)
|
|
99
|
+
.filter((dir) => path.isAbsolute(dir))
|
|
100
|
+
.join(path.delimiter);
|
|
101
|
+
}
|
|
90
102
|
spawnSyncLog(cmd, args = [], env = {}) {
|
|
103
|
+
var _a;
|
|
91
104
|
this._logger.info(`Executing: ${cmd} with args: ${args}`);
|
|
105
|
+
const mergedEnv = { ...process.env, ...env };
|
|
92
106
|
const response = (0, child_process_1.spawnSync)(cmd, args, {
|
|
93
|
-
env: { ...
|
|
107
|
+
env: { ...mergedEnv, PATH: this.sanitizeEnvPath((_a = mergedEnv.PATH) !== null && _a !== void 0 ? _a : "") },
|
|
94
108
|
encoding: "utf-8",
|
|
95
109
|
shell: true,
|
|
96
110
|
});
|
package/out/BaseUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],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dioOptions } from \"child_process\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadExecutorTask } from \"./AppUpdater\"\n\nexport abstract class BaseUpdater extends AppUpdater {\n protected quitAndInstallCalled = false\n private quitHandlerAdded = false\n\n protected constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n quitAndInstall(isSilent = false, isForceRunAfter = false): void {\n this._logger.info(`Install on explicit quitAndInstall`)\n // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app\n const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)\n if (isInstalled) {\n setImmediate(() => {\n // this event is normally emitted when calling quitAndInstall, this emulates that\n require(\"electron\").autoUpdater.emit(\"before-quit-for-update\")\n this.app.quit()\n })\n } else {\n this.quitAndInstallCalled = false\n }\n }\n\n protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n return super.executeDownload({\n ...taskOptions,\n done: event => {\n this.dispatchUpdateDownloaded(event)\n this.addQuitHandler()\n return Promise.resolve()\n },\n })\n }\n\n protected get installerPath(): string | null {\n return this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.file\n }\n\n // must be sync\n protected abstract doInstall(options: InstallOptions): boolean\n\n // must be sync (because quit even handler is not async)\n install(isSilent = false, isForceRunAfter = false): boolean {\n if (this.quitAndInstallCalled) {\n this._logger.warn(\"install call ignored: quitAndInstallCalled is set to true\")\n return false\n }\n\n const downloadedUpdateHelper = this.downloadedUpdateHelper\n const installerPath = this.installerPath\n const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo\n if (installerPath == null || downloadedFileInfo == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n\n // prevent calling several times\n this.quitAndInstallCalled = true\n\n try {\n this._logger.info(`Install: isSilent: ${isSilent}, isForceRunAfter: ${isForceRunAfter}`)\n return this.doInstall({\n isSilent,\n isForceRunAfter,\n isAdminRightsRequired: downloadedFileInfo.isAdminRightsRequired,\n })\n } catch (e: any) {\n this.dispatchError(e)\n return false\n }\n }\n\n protected addQuitHandler(): void {\n if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {\n return\n }\n\n this.quitHandlerAdded = true\n\n this.app.onQuit(exitCode => {\n if (this.quitAndInstallCalled) {\n this._logger.info(\"Update installer has already been triggered. Quitting application.\")\n return\n }\n\n if (!this.autoInstallOnAppQuit) {\n this._logger.info(\"Update will not be installed on quit because autoInstallOnAppQuit is set to false.\")\n return\n }\n\n if (exitCode !== 0) {\n this._logger.info(`Update will be not installed on quit because application is quitting with exit code ${exitCode}`)\n return\n }\n\n this._logger.info(\"Auto install update on quit\")\n this.install(true, false)\n })\n }\n\n protected spawnSyncLog(cmd: string, args: string[] = [], env = {}): string {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n const response = spawnSync(cmd, args, {\n env: { ...process.env, ...env },\n encoding: \"utf-8\",\n shell: true,\n })\n\n const { error, status, stdout, stderr } = response\n if (error != null) {\n this._logger.error(stderr)\n throw error\n } else if (status != null && status !== 0) {\n this._logger.error(stderr)\n throw new Error(`Command ${cmd} exited with code ${status}`)\n }\n\n return stdout.trim()\n }\n\n /**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n protected async spawnLog(cmd: string, args: string[] = [], env: any = undefined, stdio: StdioOptions = \"ignore\"): Promise<boolean> {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n return new Promise<boolean>((resolve, reject) => {\n try {\n const params: SpawnOptions = { stdio, env, detached: true }\n const p = spawn(cmd, args, params)\n p.on(\"error\", error => {\n reject(error)\n })\n p.unref()\n if (p.pid !== undefined) {\n resolve(true)\n }\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\nexport interface InstallOptions {\n readonly isSilent: boolean\n readonly isForceRunAfter: boolean\n readonly isAdminRightsRequired: boolean\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],"mappings":";;;AACA,iDAA4E;AAC5E,6BAA4B;AAE5B,6CAA+D;AAE/D,MAAsB,WAAY,SAAQ,uBAAU;IAIlD,YAAsB,OAAkC,EAAE,GAAgB;QACxE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAJX,yBAAoB,GAAG,KAAK,CAAA;QAC9B,qBAAgB,GAAG,KAAK,CAAA;IAIhC,CAAC;IAED,cAAc,CAAC,QAAQ,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;QACvD,+FAA+F;QAC/F,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QACpG,IAAI,WAAW,EAAE,CAAC;YAChB,YAAY,CAAC,GAAG,EAAE;gBAChB,iFAAiF;gBACjF,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;gBAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YACjB,CAAC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAA;QACnC,CAAC;IACH,CAAC;IAES,eAAe,CAAC,WAAiC;QACzD,OAAO,KAAK,CAAC,eAAe,CAAC;YAC3B,GAAG,WAAW;YACd,IAAI,EAAE,KAAK,CAAC,EAAE;gBACZ,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAA;gBACpC,IAAI,CAAC,cAAc,EAAE,CAAA;gBACrB,OAAO,O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AA;gBAC3D,MAAM,CAAC,GAAG,IAAA,qBAAK,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;gBAClC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACpB,MAAM,CAAC,KAAK,CAAC,CAAA;gBACf,CAAC,CAAC,CAAA;gBACF,CAAC,CAAC,KAAK,EAAE,CAAA;gBACT,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;oBACxB,OAAO,CAAC,IAAI,CAAC,CAAA;gBACf,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;YACf,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA9JD,kCA8JC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { spawn, SpawnOptions, spawnSync, StdioOptions } from \"child_process\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadExecutorTask } from \"./AppUpdater\"\n\nexport abstract class BaseUpdater extends AppUpdater {\n protected quitAndInstallCalled = false\n private quitHandlerAdded = false\n\n protected constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n quitAndInstall(isSilent = false, isForceRunAfter = false): void {\n this._logger.info(`Install on explicit quitAndInstall`)\n // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app\n const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)\n if (isInstalled) {\n setImmediate(() => {\n // this event is normally emitted when calling quitAndInstall, this emulates that\n require(\"electron\").autoUpdater.emit(\"before-quit-for-update\")\n this.app.quit()\n })\n } else {\n this.quitAndInstallCalled = false\n }\n }\n\n protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n return super.executeDownload({\n ...taskOptions,\n done: event => {\n this.dispatchUpdateDownloaded(event)\n this.addQuitHandler()\n return Promise.resolve()\n },\n })\n }\n\n protected get installerPath(): string | null {\n return this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.file\n }\n\n // must be sync\n protected abstract doInstall(options: InstallOptions): boolean\n\n // must be sync (because quit even handler is not async)\n install(isSilent = false, isForceRunAfter = false): boolean {\n if (this.quitAndInstallCalled) {\n this._logger.warn(\"install call ignored: quitAndInstallCalled is set to true\")\n return false\n }\n\n const downloadedUpdateHelper = this.downloadedUpdateHelper\n const installerPath = this.installerPath\n const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo\n if (installerPath == null || downloadedFileInfo == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n\n // prevent calling several times\n this.quitAndInstallCalled = true\n\n try {\n this._logger.info(`Install: isSilent: ${isSilent}, isForceRunAfter: ${isForceRunAfter}`)\n return this.doInstall({\n isSilent,\n isForceRunAfter,\n isAdminRightsRequired: downloadedFileInfo.isAdminRightsRequired,\n })\n } catch (e: any) {\n this.dispatchError(e)\n return false\n }\n }\n\n protected addQuitHandler(): void {\n if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {\n return\n }\n\n this.quitHandlerAdded = true\n\n this.app.onQuit(exitCode => {\n if (this.quitAndInstallCalled) {\n this._logger.info(\"Update installer has already been triggered. Quitting application.\")\n return\n }\n\n if (!this.autoInstallOnAppQuit) {\n this._logger.info(\"Update will not be installed on quit because autoInstallOnAppQuit is set to false.\")\n return\n }\n\n if (exitCode !== 0) {\n this._logger.info(`Update will be not installed on quit because application is quitting with exit code ${exitCode}`)\n return\n }\n\n this._logger.info(\"Auto install update on quit\")\n this.install(true, false)\n })\n }\n\n /**\n * Strips relative-path entries from a PATH string.\n * Prevents PATH-poisoning where a writable directory earlier in PATH shadows\n * a trusted package manager binary.\n */\n protected sanitizeEnvPath(envPath: string): string {\n return envPath\n .split(path.delimiter)\n .filter((dir: string) => path.isAbsolute(dir))\n .join(path.delimiter)\n }\n\n protected spawnSyncLog(cmd: string, args: string[] = [], env = {}): string {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n const mergedEnv: NodeJS.ProcessEnv = { ...process.env, ...env }\n const response = spawnSync(cmd, args, {\n env: { ...mergedEnv, PATH: this.sanitizeEnvPath(mergedEnv.PATH ?? \"\") },\n encoding: \"utf-8\",\n shell: true,\n })\n\n const { error, status, stdout, stderr } = response\n if (error != null) {\n this._logger.error(stderr)\n throw error\n } else if (status != null && status !== 0) {\n this._logger.error(stderr)\n throw new Error(`Command ${cmd} exited with code ${status}`)\n }\n\n return stdout.trim()\n }\n\n /**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n protected async spawnLog(cmd: string, args: string[] = [], env: any = undefined, stdio: StdioOptions = \"ignore\"): Promise<boolean> {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n return new Promise<boolean>((resolve, reject) => {\n try {\n const params: SpawnOptions = { stdio, env, detached: true }\n const p = spawn(cmd, args, params)\n p.on(\"error\", error => {\n reject(error)\n })\n p.unref()\n if (p.pid !== undefined) {\n resolve(true)\n }\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\nexport interface InstallOptions {\n readonly isSilent: boolean\n readonly isForceRunAfter: boolean\n readonly isAdminRightsRequired: boolean\n}\n"]}
|
package/out/LinuxUpdater.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ export declare abstract class LinuxUpdater extends BaseUpdater {
|
|
|
8
8
|
*/
|
|
9
9
|
protected isRunningAsRoot(): boolean;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Sanitizes the installer path for use with shell:true spawn calls.
|
|
12
|
+
* Backslash-escapes metacharacters that have special meaning in POSIX shell.
|
|
13
|
+
* Note: paths containing single-quotes (') are not supported.
|
|
12
14
|
*/
|
|
13
15
|
protected get installerPath(): string | null;
|
|
14
16
|
protected runCommandWithSudoIfNeeded(commandWithArgs: string[]): string;
|
package/out/LinuxUpdater.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinuxUpdater = void 0;
|
|
4
4
|
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
|
+
// Matches safe package manager names: alphanumeric, hyphens, underscores only.
|
|
6
|
+
// Rejects names with shell metacharacters that could cause command injection.
|
|
7
|
+
const SAFE_PM_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
5
8
|
class LinuxUpdater extends BaseUpdater_1.BaseUpdater {
|
|
6
9
|
constructor(options, app) {
|
|
7
10
|
super(options, app);
|
|
@@ -14,11 +17,19 @@ class LinuxUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
14
17
|
return ((_a = process.getuid) === null || _a === void 0 ? void 0 : _a.call(process)) === 0;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Sanitizes the installer path for use with shell:true spawn calls.
|
|
21
|
+
* Backslash-escapes metacharacters that have special meaning in POSIX shell.
|
|
22
|
+
* Note: paths containing single-quotes (') are not supported.
|
|
18
23
|
*/
|
|
19
24
|
get installerPath() {
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
const raw = super.installerPath;
|
|
26
|
+
if (raw == null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return raw
|
|
30
|
+
.replace(/\\/g, "\\\\") // must come first
|
|
31
|
+
.replace(/([`$!" ;|&()<>])/g, "\\$1")
|
|
32
|
+
.replace(/[\n\r]/g, "");
|
|
22
33
|
}
|
|
23
34
|
runCommandWithSudoIfNeeded(commandWithArgs) {
|
|
24
35
|
if (this.isRunningAsRoot()) {
|
|
@@ -26,7 +37,9 @@ class LinuxUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
26
37
|
return this.spawnSyncLog(commandWithArgs[0], commandWithArgs.slice(1));
|
|
27
38
|
}
|
|
28
39
|
const { name } = this.app;
|
|
29
|
-
|
|
40
|
+
// Strip characters that could break shell quoting in the sudo dialog comment string
|
|
41
|
+
const safeName = name.replace(/["`$\\!\n\r;|&<>(){}*?[\]#~]/g, "");
|
|
42
|
+
const installComment = `"${safeName} would like to update"`;
|
|
30
43
|
const sudo = this.sudoWithArgs(installComment);
|
|
31
44
|
this._logger.info(`Running as non-root user, using sudo to install: ${sudo}`);
|
|
32
45
|
let wrapper = `"`;
|
|
@@ -79,19 +92,27 @@ class LinuxUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
79
92
|
*/
|
|
80
93
|
detectPackageManager(pms) {
|
|
81
94
|
var _a;
|
|
95
|
+
let availablePMs = pms;
|
|
82
96
|
const pmOverride = (_a = process.env.ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER) === null || _a === void 0 ? void 0 : _a.trim();
|
|
83
97
|
if (pmOverride) {
|
|
84
|
-
|
|
98
|
+
if (!SAFE_PM_REGEX.test(pmOverride)) {
|
|
99
|
+
this._logger.warn(`ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER "${pmOverride}" contains unsafe characters. Ignoring override.`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
availablePMs = [pmOverride];
|
|
103
|
+
}
|
|
85
104
|
}
|
|
86
105
|
// Check for the package manager in the order of priority
|
|
87
|
-
for (const pm of
|
|
106
|
+
for (const pm of availablePMs) {
|
|
88
107
|
if (this.hasCommand(pm)) {
|
|
89
108
|
return pm;
|
|
90
109
|
}
|
|
91
110
|
}
|
|
92
|
-
// return the first package manager in the list if none are found, this will throw upstream for proper logging
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
// return the first/default package manager in the original list if none are found, this will throw upstream for proper logging
|
|
112
|
+
const searchList = pmOverride ? `ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER override "${pmOverride}", ` : "";
|
|
113
|
+
const defaultPM = pms[0];
|
|
114
|
+
this._logger.warn(`No package manager found in the list: ${searchList}${pms.join(", ")}. Utilizing default: ${defaultPM}`);
|
|
115
|
+
return defaultPM;
|
|
95
116
|
}
|
|
96
117
|
}
|
|
97
118
|
exports.LinuxUpdater = LinuxUpdater;
|
package/out/LinuxUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinuxUpdater.js","sourceRoot":"","sources":["../src/LinuxUpdater.ts"],"names":[],"mappings":";;;AAEA,+CAA2C;AAE3C,MAAsB,YAAa,SAAQ,yBAAW;IACpD,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED;;OAEG;IACO,eAAe;;QACvB,OAAO,CAAA,MAAA,OAAO,CAAC,MAAM,uDAAI,MAAK,CAAC,CAAA;IACjC,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"LinuxUpdater.js","sourceRoot":"","sources":["../src/LinuxUpdater.ts"],"names":[],"mappings":";;;AAEA,+CAA2C;AAE3C,+EAA+E;AAC/E,8EAA8E;AAC9E,MAAM,aAAa,GAAG,kBAAkB,CAAA;AAExC,MAAsB,YAAa,SAAQ,yBAAW;IACpD,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED;;OAEG;IACO,eAAe;;QACvB,OAAO,CAAA,MAAA,OAAO,CAAC,MAAM,uDAAI,MAAK,CAAC,CAAA;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAc,aAAa;QACzB,MAAM,GAAG,GAAG,KAAK,CAAC,aAAa,CAAA;QAC/B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,GAAG;aACP,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,kBAAkB;aACzC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;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AAG,CAAC,sCAAsC,0CAAE,IAAI,EAAE,CAAA;QAC7E,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,2CAA2C,UAAU,kDAAkD,CAAC,CAAA;YAC5H,CAAC;iBAAM,CAAC;gBACN,YAAY,GAAG,CAAC,UAAU,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,yDAAyD;QACzD,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;YAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC;QACD,+HAA+H;QAC/H,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,oDAAoD,UAAU,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QACxG,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,yCAAyC,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB,SAAS,EAAE,CAAC,CAAA;QAC1H,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AA/GD,oCA+GC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { BaseUpdater } from \"./BaseUpdater\"\n\n// Matches safe package manager names: alphanumeric, hyphens, underscores only.\n// Rejects names with shell metacharacters that could cause command injection.\nconst SAFE_PM_REGEX = /^[a-zA-Z0-9_-]+$/\n\nexport abstract class LinuxUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /**\n * Returns true if the current process is running as root.\n */\n protected isRunningAsRoot(): boolean {\n return process.getuid?.() === 0\n }\n\n /**\n * Sanitizes the installer path for use with shell:true spawn calls.\n * Backslash-escapes metacharacters that have special meaning in POSIX shell.\n * Note: paths containing single-quotes (') are not supported.\n */\n protected get installerPath(): string | null {\n const raw = super.installerPath\n if (raw == null) {\n return null\n }\n return raw\n .replace(/\\\\/g, \"\\\\\\\\\") // must come first\n .replace(/([`$!\" ;|&()<>])/g, \"\\\\$1\")\n .replace(/[\\n\\r]/g, \"\")\n }\n\n protected runCommandWithSudoIfNeeded(commandWithArgs: string[]) {\n if (this.isRunningAsRoot()) {\n this._logger.info(\"Running as root, no need to use sudo\")\n return this.spawnSyncLog(commandWithArgs[0], commandWithArgs.slice(1))\n }\n\n const { name } = this.app\n // Strip characters that could break shell quoting in the sudo dialog comment string\n const safeName = name.replace(/[\"`$\\\\!\\n\\r;|&<>(){}*?[\\]#~]/g, \"\")\n const installComment = `\"${safeName} would like to update\"`\n const sudo = this.sudoWithArgs(installComment)\n this._logger.info(`Running as non-root user, using sudo to install: ${sudo}`)\n let wrapper = `\"`\n // some sudo commands dont want the command to be wrapped in \" quotes\n if (/pkexec/i.test(sudo[0]) || sudo[0] === \"sudo\") {\n wrapper = \"\"\n }\n return this.spawnSyncLog(sudo[0], [...(sudo.length > 1 ? sudo.slice(1) : []), `${wrapper}/bin/bash`, \"-c\", `'${commandWithArgs.join(\" \")}'${wrapper}`])\n }\n\n protected sudoWithArgs(installComment: string): string[] {\n const sudo = this.determineSudoCommand()\n const command = [sudo]\n if (/kdesudo/i.test(sudo)) {\n command.push(\"--comment\", installComment)\n command.push(\"-c\")\n } else if (/gksudo/i.test(sudo)) {\n command.push(\"--message\", installComment)\n } else if (/pkexec/i.test(sudo)) {\n command.push(\"--disable-internal-agent\")\n }\n return command\n }\n\n protected hasCommand(cmd: string): boolean {\n try {\n this.spawnSyncLog(`command`, [\"-v\", cmd])\n return true\n } catch {\n return false\n }\n }\n\n protected determineSudoCommand(): string {\n const sudos = [\"gksudo\", \"kdesudo\", \"pkexec\", \"beesu\"]\n for (const sudo of sudos) {\n if (this.hasCommand(sudo)) {\n return sudo\n }\n }\n return \"sudo\"\n }\n\n /**\n * Detects the package manager to use based on the available commands.\n * Allows overriding the default behavior by setting the ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER environment variable.\n * If the environment variable is set, it will be used directly. (This is useful for testing each package manager logic path.)\n * Otherwise, it checks for the presence of the specified package manager commands in the order provided.\n * @param pms - An array of package manager commands to check for, in priority order.\n * @returns The detected package manager command or \"unknown\" if none are found.\n */\n protected detectPackageManager(pms: string[]): string {\n let availablePMs = pms\n const pmOverride = process.env.ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER?.trim()\n if (pmOverride) {\n if (!SAFE_PM_REGEX.test(pmOverride)) {\n this._logger.warn(`ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER \"${pmOverride}\" contains unsafe characters. Ignoring override.`)\n } else {\n availablePMs = [pmOverride]\n }\n }\n // Check for the package manager in the order of priority\n for (const pm of availablePMs) {\n if (this.hasCommand(pm)) {\n return pm\n }\n }\n // return the first/default package manager in the original list if none are found, this will throw upstream for proper logging\n const searchList = pmOverride ? `ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER override \"${pmOverride}\", ` : \"\"\n const defaultPM = pms[0]\n this._logger.warn(`No package manager found in the list: ${searchList}${pms.join(\", \")}. Utilizing default: ${defaultPM}`)\n return defaultPM\n }\n}\n"]}
|
package/out/MacUpdater.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
2
|
import { AppAdapter } from "./AppAdapter";
|
|
3
3
|
import { AppUpdater, DownloadUpdateOptions } from "./AppUpdater";
|
|
4
|
+
import { ResolvedUpdateFileInfo } from "./main";
|
|
4
5
|
export declare class MacUpdater extends AppUpdater {
|
|
5
6
|
private readonly nativeUpdater;
|
|
6
7
|
private squirrelDownloadedUpdate;
|
|
7
8
|
private server?;
|
|
8
9
|
constructor(options?: AllPublishOptions, app?: AppAdapter);
|
|
10
|
+
/** Filters update files to the appropriate architecture.
|
|
11
|
+
* On arm64 Macs (including Rosetta), arm64 files are preferred when available.
|
|
12
|
+
* On x64 Macs, arm64 files are excluded. */
|
|
13
|
+
protected static filterFilesForArch(files: ResolvedUpdateFileInfo[], isArm64Mac: boolean): ResolvedUpdateFileInfo[];
|
|
9
14
|
private debug;
|
|
10
15
|
private closeServerIfExists;
|
|
11
16
|
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
package/out/MacUpdater.js
CHANGED
|
@@ -24,6 +24,16 @@ class MacUpdater extends AppUpdater_1.AppUpdater {
|
|
|
24
24
|
this.debug("nativeUpdater.update-downloaded");
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
/** Filters update files to the appropriate architecture.
|
|
28
|
+
* On arm64 Macs (including Rosetta), arm64 files are preferred when available.
|
|
29
|
+
* On x64 Macs, arm64 files are excluded. */
|
|
30
|
+
static filterFilesForArch(files, isArm64Mac) {
|
|
31
|
+
const isArm64File = (file) => { var _a; return file.url.pathname.includes("arm64") || ((_a = file.info.url) === null || _a === void 0 ? void 0 : _a.includes("arm64")); };
|
|
32
|
+
if (isArm64Mac && files.some(isArm64File)) {
|
|
33
|
+
return files.filter(file => isArm64Mac === isArm64File(file));
|
|
34
|
+
}
|
|
35
|
+
return files.filter(file => !isArm64File(file));
|
|
36
|
+
}
|
|
27
37
|
debug(message) {
|
|
28
38
|
if (this._logger.debug != null) {
|
|
29
39
|
this._logger.debug(message);
|
|
@@ -67,13 +77,7 @@ class MacUpdater extends AppUpdater_1.AppUpdater {
|
|
|
67
77
|
}
|
|
68
78
|
isArm64Mac = isArm64Mac || process.arch === "arm64" || isRosetta;
|
|
69
79
|
// allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524
|
|
70
|
-
|
|
71
|
-
if (isArm64Mac && files.some(isArm64)) {
|
|
72
|
-
files = files.filter(file => isArm64Mac === isArm64(file));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
files = files.filter(file => !isArm64(file));
|
|
76
|
-
}
|
|
80
|
+
files = MacUpdater.filterFilesForArch(files, isArm64Mac);
|
|
77
81
|
const zipFileInfo = (0, Provider_1.findFile)(files, "zip", ["pkg", "dmg"]);
|
|
78
82
|
if (zipFileInfo == null) {
|
|
79
83
|
throw (0, builder_util_runtime_1.newError)(`ZIP file not provided: ${(0, builder_util_runtime_1.safeStringifyJson)(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND");
|
package/out/MacUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAAyD;AACzD,2BAAqC;AACrC,6BAA4B;AAC5B,+BAA4E;AAE5E,6CAAgE;AAGhE,mDAA+C;AAE/C,iDAA4C;AAC5C,mCAAoC;AAEpC,MAAa,UAAW,SAAQ,uBAAU;IAOxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAPJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAOtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC9C,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAA;YACpC,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,OAAe;QA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B,CAAC;aAAM,CAAC;YACN,sDAAsD;YACtD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;YAE/E,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC/B;;;mBAGG;gBACH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA5QD,gCA4QC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { pathExistsSync, stat, copyFile } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport * as path from \"path\"\nimport { createServer, IncomingMessage, Server, ServerResponse } from \"http\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"./main\"\nimport { UpdateDownloadedEvent } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\nimport { randomBytes } from \"crypto\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n private server?: Server\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n this.debug(\"nativeUpdater.update-downloaded\")\n })\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n private closeServerIfExists() {\n if (this.server) {\n this.debug(\"Closing proxy server\")\n this.server.close(err => {\n if (err) {\n this.debug(\"proxy server wasn't already open, probably attempted closing again as a safety check before quit\")\n }\n })\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta = false\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e: any) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n let isArm64Mac = false\n try {\n this.debug(\"Checking for arm64 in uname\")\n const result = execFileSync(\"uname\", [\"-a\"], { encoding: \"utf8\" })\n const isArm = result.includes(\"ARM\")\n log.info(`Checked 'uname -a': arm64=${isArm}`)\n isArm64Mac = isArm64Mac || isArm\n } catch (e: any) {\n log.warn(`uname shell command to check for arm64 failed: ${e}`)\n }\n\n isArm64Mac = isArm64Mac || process.arch === \"arm64\" || isRosetta\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (isArm64Mac && files.some(isArm64)) {\n files = files.filter(file => isArm64Mac === isArm64(file))\n } else {\n files = files.filter(file => !isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const CURRENT_MAC_APP_ZIP_FILE_NAME = \"update.zip\"\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: async (destinationFile, downloadOptions) => {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n const canDifferentialDownload = () => {\n if (!pathExistsSync(cachedUpdateFilePath)) {\n log.info(\"Unable to locate previous update.zip for differential download (is this first install?), falling back to full download\")\n return false\n }\n return !downloadUpdateOptions.disableDifferentialDownload\n }\n let differentialDownloadFailed = true\n if (canDifferentialDownload()) {\n differentialDownloadFailed = await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME)\n }\n\n if (differentialDownloadFailed) {\n await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n }\n },\n done: async event => {\n if (!downloadUpdateOptions.disableDifferentialDownload) {\n try {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n await copyFile(event.downloadedFile, cachedUpdateFilePath)\n } catch (error: any) {\n this._logger.warn(`Unable to copy file for caching for future differential downloads: ${error.message}`)\n }\n }\n return this.updateDownloaded(zipFileInfo, event)\n },\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.closeServerIfExists()\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n this.server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n this.server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n const getServerUrl = (s: Server): string => {\n const address = s.address()\n if (typeof address === \"string\") {\n return address\n }\n return `http://127.0.0.1:${address?.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n const pass = randomBytes(64).toString(\"base64\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\")\n const authInfo = Buffer.from(`autoupdater:${pass}`, \"ascii\")\n\n // insecure random is ok\n const fileUrl = `/${randomBytes(64).toString(\"hex\")}.zip`\n this.server!.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n // check for basic auth header\n if (!request.headers.authorization || request.headers.authorization.indexOf(\"Basic \") === -1) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"No authenthication info\")\n return\n }\n\n // verify auth credentials\n const base64Credentials = request.headers.authorization.split(\" \")[1]\n const credentials = Buffer.from(base64Credentials, \"base64\").toString(\"ascii\")\n const [username, password] = credentials.split(\":\")\n if (username !== \"autoupdater\" || password !== pass) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"Invalid authenthication credentials\")\n return\n }\n\n const data = Buffer.from(`{ \"url\": \"${getServerUrl(this.server!)}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e: any) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n\n this.server!.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl(this.server!)}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(this.server!),\n headers: {\n \"Cache-Control\": \"no-cache\",\n Authorization: `Basic ${authInfo.toString(\"base64\")}`,\n },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n private handleUpdateDownloaded() {\n if (this.autoRunAppAfterInstall) {\n this.nativeUpdater.quitAndInstall()\n } else {\n this.app.quit()\n }\n this.closeServerIfExists()\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.handleUpdateDownloaded()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => this.handleUpdateDownloaded())\n\n if (!this.autoInstallOnAppQuit) {\n /**\n * If this was not `true` previously then MacUpdater.doDownloadUpdate()\n * would not actually initiate the downloading by electron's autoUpdater\n */\n this.nativeUpdater.checkForUpdates()\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAAyD;AACzD,2BAAqC;AACrC,6BAA4B;AAC5B,+BAA4E;AAE5E,6CAAgE;AAGhE,mDAA+C;AAE/C,iDAA4C;AAC5C,mCAAoC;AAEpC,MAAa,UAAW,SAAQ,uBAAU;IAOxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO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AAC,CAAA;gBAEpC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;oBAC9B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;oBACxC,sEAAsE;oBACtE,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;gBACtC,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,EAAE,CAAC,CAAA;gBACb,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,sBAAsB;QAC5B,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAClC,4DAA4D;YAC5D,IAAI,CAAC,sBAAsB,EAAE,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,sDAAsD;YACtD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;YAE/E,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC/B;;;mBAGG;gBACH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlRD,gCAkRC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { pathExistsSync, stat, copyFile } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport * as path from \"path\"\nimport { createServer, IncomingMessage, Server, ServerResponse } from \"http\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"./main\"\nimport { UpdateDownloadedEvent } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\nimport { randomBytes } from \"crypto\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n private server?: Server\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n this.debug(\"nativeUpdater.update-downloaded\")\n })\n }\n\n /** Filters update files to the appropriate architecture.\n * On arm64 Macs (including Rosetta), arm64 files are preferred when available.\n * On x64 Macs, arm64 files are excluded. */\n protected static filterFilesForArch(files: ResolvedUpdateFileInfo[], isArm64Mac: boolean): ResolvedUpdateFileInfo[] {\n const isArm64File = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (isArm64Mac && files.some(isArm64File)) {\n return files.filter(file => isArm64Mac === isArm64File(file))\n }\n return files.filter(file => !isArm64File(file))\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n private closeServerIfExists() {\n if (this.server) {\n this.debug(\"Closing proxy server\")\n this.server.close(err => {\n if (err) {\n this.debug(\"proxy server wasn't already open, probably attempted closing again as a safety check before quit\")\n }\n })\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta = false\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e: any) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n let isArm64Mac = false\n try {\n this.debug(\"Checking for arm64 in uname\")\n const result = execFileSync(\"uname\", [\"-a\"], { encoding: \"utf8\" })\n const isArm = result.includes(\"ARM\")\n log.info(`Checked 'uname -a': arm64=${isArm}`)\n isArm64Mac = isArm64Mac || isArm\n } catch (e: any) {\n log.warn(`uname shell command to check for arm64 failed: ${e}`)\n }\n\n isArm64Mac = isArm64Mac || process.arch === \"arm64\" || isRosetta\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n files = MacUpdater.filterFilesForArch(files, isArm64Mac)\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const CURRENT_MAC_APP_ZIP_FILE_NAME = \"update.zip\"\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: async (destinationFile, downloadOptions) => {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n const canDifferentialDownload = () => {\n if (!pathExistsSync(cachedUpdateFilePath)) {\n log.info(\"Unable to locate previous update.zip for differential download (is this first install?), falling back to full download\")\n return false\n }\n return !downloadUpdateOptions.disableDifferentialDownload\n }\n let differentialDownloadFailed = true\n if (canDifferentialDownload()) {\n differentialDownloadFailed = await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME)\n }\n\n if (differentialDownloadFailed) {\n await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n }\n },\n done: async event => {\n if (!downloadUpdateOptions.disableDifferentialDownload) {\n try {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n await copyFile(event.downloadedFile, cachedUpdateFilePath)\n } catch (error: any) {\n this._logger.warn(`Unable to copy file for caching for future differential downloads: ${error.message}`)\n }\n }\n return this.updateDownloaded(zipFileInfo, event)\n },\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.closeServerIfExists()\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n this.server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n this.server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n const getServerUrl = (s: Server): string => {\n const address = s.address()\n if (typeof address === \"string\") {\n return address\n }\n return `http://127.0.0.1:${address?.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n const pass = randomBytes(64).toString(\"base64\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\")\n const authInfo = Buffer.from(`autoupdater:${pass}`, \"ascii\")\n\n // insecure random is ok\n const fileUrl = `/${randomBytes(64).toString(\"hex\")}.zip`\n this.server!.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n // check for basic auth header\n if (!request.headers.authorization || request.headers.authorization.indexOf(\"Basic \") === -1) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"No authenthication info\")\n return\n }\n\n // verify auth credentials\n const base64Credentials = request.headers.authorization.split(\" \")[1]\n const credentials = Buffer.from(base64Credentials, \"base64\").toString(\"ascii\")\n const [username, password] = credentials.split(\":\")\n if (username !== \"autoupdater\" || password !== pass) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"Invalid authenthication credentials\")\n return\n }\n\n const data = Buffer.from(`{ \"url\": \"${getServerUrl(this.server!)}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e: any) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n\n this.server!.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl(this.server!)}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(this.server!),\n headers: {\n \"Cache-Control\": \"no-cache\",\n Authorization: `Basic ${authInfo.toString(\"base64\")}`,\n },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n private handleUpdateDownloaded() {\n if (this.autoRunAppAfterInstall) {\n this.nativeUpdater.quitAndInstall()\n } else {\n this.app.quit()\n }\n this.closeServerIfExists()\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.handleUpdateDownloaded()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => this.handleUpdateDownloaded())\n\n if (!this.autoInstallOnAppQuit) {\n /**\n * If this was not `true` previously then MacUpdater.doDownloadUpdate()\n * would not actually initiate the downloading by electron's autoUpdater\n */\n this.nativeUpdater.checkForUpdates()\n }\n }\n }\n}\n"]}
|
|
@@ -25,5 +25,5 @@ export declare class GitHubProvider extends BaseGitHubProvider<GithubUpdateInfo>
|
|
|
25
25
|
resolveFiles(updateInfo: GithubUpdateInfo): Array<ResolvedUpdateFileInfo>;
|
|
26
26
|
private getBaseDownloadPath;
|
|
27
27
|
}
|
|
28
|
-
export declare function computeReleaseNotes(currentVersion: semver.SemVer, isFullChangelog: boolean, feed: XElement, latestRelease:
|
|
28
|
+
export declare function computeReleaseNotes(currentVersion: semver.SemVer, isFullChangelog: boolean, feed: XElement, latestRelease: XElement): string | Array<ReleaseNoteInfo> | null;
|
|
29
29
|
export {};
|
|
@@ -7,7 +7,7 @@ const semver = require("semver");
|
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const util_1 = require("../util");
|
|
9
9
|
const Provider_1 = require("./Provider");
|
|
10
|
-
const hrefRegExp = /\/tag\/([^/]+)$/;
|
|
10
|
+
const hrefRegExp = /\/tag\/(v?[^/]+)$/;
|
|
11
11
|
class BaseGitHubProvider extends Provider_1.Provider {
|
|
12
12
|
constructor(options, defaultHost, runtimeOptions) {
|
|
13
13
|
super({
|
|
@@ -51,6 +51,8 @@ class GitHubProvider extends BaseGitHubProvider {
|
|
|
51
51
|
if (this.updater.allowPrerelease) {
|
|
52
52
|
const currentChannel = ((_a = this.updater) === null || _a === void 0 ? void 0 : _a.channel) || ((_b = semver.prerelease(this.updater.currentVersion)) === null || _b === void 0 ? void 0 : _b[0]) || null;
|
|
53
53
|
if (currentChannel === null) {
|
|
54
|
+
// allowPrerelease=true with no explicit channel and stable current version:
|
|
55
|
+
// pick the first entry from the Atom feed, which may be a prerelease
|
|
54
56
|
// noinspection TypeScriptValidateJSTypes
|
|
55
57
|
tag = hrefRegExp.exec(latestRelease.element("link").attribute("href"))[1];
|
|
56
58
|
}
|
|
@@ -64,6 +66,9 @@ class GitHubProvider extends BaseGitHubProvider {
|
|
|
64
66
|
}
|
|
65
67
|
// This Release's Tag
|
|
66
68
|
const hrefTag = hrefElement[1];
|
|
69
|
+
if (!semver.valid(hrefTag)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
67
72
|
//Get Channel from this release's tag
|
|
68
73
|
const hrefChannel = ((_c = semver.prerelease(hrefTag)) === null || _c === void 0 ? void 0 : _c[0]) || null;
|
|
69
74
|
const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel);
|
|
@@ -72,11 +77,13 @@ class GitHubProvider extends BaseGitHubProvider {
|
|
|
72
77
|
const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha";
|
|
73
78
|
if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {
|
|
74
79
|
tag = hrefTag;
|
|
80
|
+
latestRelease = element;
|
|
75
81
|
break;
|
|
76
82
|
}
|
|
77
83
|
const isNextPreRelease = hrefChannel && hrefChannel === currentChannel;
|
|
78
84
|
if (isNextPreRelease) {
|
|
79
85
|
tag = hrefTag;
|
|
86
|
+
latestRelease = element;
|
|
80
87
|
break;
|
|
81
88
|
}
|
|
82
89
|
}
|
|
@@ -86,7 +93,11 @@ class GitHubProvider extends BaseGitHubProvider {
|
|
|
86
93
|
tag = await this.getLatestTagName(cancellationToken);
|
|
87
94
|
for (const element of feed.getElements("entry")) {
|
|
88
95
|
// noinspection TypeScriptValidateJSTypes
|
|
89
|
-
|
|
96
|
+
const hrefMatch = hrefRegExp.exec(element.element("link").attribute("href"));
|
|
97
|
+
if (hrefMatch == null) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (hrefMatch[1] === tag) {
|
|
90
101
|
latestRelease = element;
|
|
91
102
|
break;
|
|
92
103
|
}
|
|
@@ -183,11 +194,38 @@ function computeReleaseNotes(currentVersion, isFullChangelog, feed, latestReleas
|
|
|
183
194
|
if (!isFullChangelog) {
|
|
184
195
|
return getNoteValue(latestRelease);
|
|
185
196
|
}
|
|
197
|
+
const releaseVersionRegExp = /\/tag\/v?([^/]+)$/;
|
|
198
|
+
let latestVersion = undefined;
|
|
199
|
+
try {
|
|
200
|
+
latestVersion = releaseVersionRegExp.exec(latestRelease.element("link").attribute("href"))[1];
|
|
201
|
+
latestVersion = semver.valid(latestVersion) ? latestVersion : undefined;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// If we cannot parse the latest release version, return null — notes cannot be determined
|
|
205
|
+
}
|
|
206
|
+
if (latestVersion == null) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
186
209
|
const releaseNotes = [];
|
|
187
210
|
for (const release of feed.getElements("entry")) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
211
|
+
let versionRelease;
|
|
212
|
+
try {
|
|
213
|
+
const match = releaseVersionRegExp.exec(release.element("link").attribute("href"));
|
|
214
|
+
if (!match) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
versionRelease = match[1];
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
// skip non-semver tags (e.g. doc/website releases in monorepos)
|
|
223
|
+
if (!semver.valid(versionRelease)) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const isGreaterThanCurrent = semver.gt(versionRelease, currentVersion.raw);
|
|
227
|
+
const isLessOrEqualThanLatest = semver.lte(versionRelease, latestVersion);
|
|
228
|
+
if (isGreaterThanCurrent && isLessOrEqualThanLatest) {
|
|
191
229
|
releaseNotes.push({
|
|
192
230
|
version: versionRelease,
|
|
193
231
|
note: getNoteValue(release),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubProvider.js","sourceRoot":"","sources":["../../src/providers/GitHubProvider.ts"],"names":[],"mappings":";;;AAyNA,kDAiBC;AA1OD,+DAAwJ;AACxJ,iCAAgC;AAChC,6BAAyB;AAGzB,kCAAwE;AACxE,yCAA4F;AAE5F,MAAM,UAAU,GAAG,iBAAiB,CAAA;AAKpC,MAAsB,kBAAyC,SAAQ,mBAAW;IAKhF,YACqB,OAAsB,EACzC,WAAmB,EACnB,cAAsC;QAEtC,KAAK,CAAC;YACJ,GAAG,cAAc;YACjB,4BAA4B;YAC5B,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAAA;QARiB,YAAO,GAAP,OAAO,CAAe;QAUzC,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAU,EAAC,IAAA,gCAAS,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;QAC1D,MAAM,OAAO,GAAG,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAA;QAC7E,IAAI,CAAC,UAAU,GAAG,IAAA,iBAAU,EAAC,IAAA,gCAAS,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC3D,CAAC;IAES,qBAAqB,CAAC,MAAc;QAC5C,2FAA2F;QAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAC9B,OAAO,IAAI,IAAI,CAAC,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CA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EAAE,CAAA;IAC/C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAChD,yCAAyC;QACzC,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAE,CAAC,CAAC,CAAC,CAAA;QAC9F,IAAI,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC;YAC9E,YAAY,CAAC,IAAI,CAAC;gBAChB,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC;aAC5B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAC3E,CAAC","sourcesContent":["import { CancellationToken, GithubOptions, githubUrl, HttpError, newError, parseXml, ReleaseNoteInfo, UpdateInfo, XElement } from \"builder-util-runtime\"\nimport * as semver from \"semver\"\nimport { URL } from \"url\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"../types\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase } from \"../util\"\nimport { parseUpdateInfo, Provider, ProviderRuntimeOptions, resolveFiles } from \"./Provider\"\n\nconst hrefRegExp = /\\/tag\\/([^/]+)$/\n\ninterface GithubUpdateInfo extends UpdateInfo {\n tag: string\n}\nexport abstract class BaseGitHubProvider<T extends UpdateInfo> extends Provider<T> {\n // so, we don't need to parse port (because node http doesn't support host as url does)\n protected readonly baseUrl: URL\n protected readonly baseApiUrl: URL\n\n protected constructor(\n protected readonly options: GithubOptions,\n defaultHost: string,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super({\n ...runtimeOptions,\n /* because GitHib uses S3 */\n isUseMultipleRangeRequest: false,\n })\n\n this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))\n const apiHost = defaultHost === \"github.com\" ? \"api.github.com\" : defaultHost\n this.baseApiUrl = newBaseUrl(githubUrl(options, apiHost))\n }\n\n protected computeGithubBasePath(result: string): string {\n // https://github.com/electron-userland/electron-builder/issues/1903#issuecomment-320881211\n const host = this.options.host\n return host && ![\"github.com\", \"api.github.com\"].includes(host) ? `/api/v3${result}` : result\n }\n}\n\nexport class GitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {\n constructor(\n protected readonly options: GithubOptions,\n private readonly updater: AppUpdater,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super(options, \"github.com\", runtimeOptions)\n }\n\n private get channel(): string {\n const result = this.updater.channel || this.options.channel\n return result == null ? this.getDefaultChannelName() : this.getCustomChannelName(result)\n }\n\n async getLatestVersion(): Promise<GithubUpdateInfo> {\n const cancellationToken = new CancellationToken()\n\n const feedXml: string = (await this.httpRequest(\n newUrlFromBase(`${this.basePath}.atom`, this.baseUrl),\n {\n accept: \"application/xml, application/atom+xml, text/xml, */*\",\n },\n cancellationToken\n ))!\n\n const feed = parseXml(feedXml)\n // noinspection TypeScriptValidateJSTypes\n let latestRelease = feed.element(\"entry\", false, `No published versions on GitHub`)\n let tag: string | null = null\n try {\n if (this.updater.allowPrerelease) {\n const currentChannel = this.updater?.channel || (semver.prerelease(this.updater.currentVersion)?.[0] as string) || null\n\n if (currentChannel === null) {\n // noinspection TypeScriptValidateJSTypes\n tag = hrefRegExp.exec(latestRelease.element(\"link\").attribute(\"href\"))![1]\n } else {\n for (const element of feed.getElements(\"entry\")) {\n // noinspection TypeScriptValidateJSTypes\n const hrefElement = hrefRegExp.exec(element.element(\"link\").attribute(\"href\"))!\n\n // If this is null then something is wrong and skip this release\n if (hrefElement === null) {\n continue\n }\n\n // This Release's Tag\n const hrefTag = hrefElement[1]\n //Get Channel from this release's tag\n const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null\n\n const shouldFetchVersion = !currentChannel || [\"alpha\", \"beta\"].includes(currentChannel)\n const isCustomChannel = hrefChannel !== null && ![\"alpha\", \"beta\"].includes(String(hrefChannel))\n // Allow moving from alpha to beta but not down\n const channelMismatch = currentChannel === \"beta\" && hrefChannel === \"alpha\"\n\n if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {\n tag = hrefTag\n break\n }\n\n const isNextPreRelease = hrefChannel && hrefChannel === currentChannel\n if (isNextPreRelease) {\n tag = hrefTag\n break\n }\n }\n }\n } else {\n tag = await this.getLatestTagName(cancellationToken)\n for (const element of feed.getElements(\"entry\")) {\n // noinspection TypeScriptValidateJSTypes\n if (hrefRegExp.exec(element.element(\"link\").attribute(\"href\"))![1] === tag) {\n latestRelease = element\n break\n }\n }\n }\n } catch (e: any) {\n throw newError(`Cannot parse releases feed: ${e.stack || e.message},\\nXML:\\n${feedXml}`, \"ERR_UPDATER_INVALID_RELEASE_FEED\")\n }\n\n if (tag == null) {\n throw newError(`No published versions on GitHub`, \"ERR_UPDATER_NO_PUBLISHED_VERSIONS\")\n }\n\n let rawData: string\n let channelFile = \"\"\n let channelFileUrl: any = \"\"\n const fetchData = async (channelName: string) => {\n channelFile = getChannelFilename(channelName)\n channelFileUrl = newUrlFromBase(this.getBaseDownloadPath(String(tag), channelFile), this.baseUrl)\n const requestOptions = this.createRequestOptions(channelFileUrl)\n try {\n return (await this.executor.request(requestOptions, cancellationToken))!\n } catch (e: any) {\n if (e instanceof HttpError && e.statusCode === 404) {\n throw newError(`Cannot find ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n throw e\n }\n }\n\n try {\n let channel = this.channel\n if (this.updater.allowPrerelease && semver.prerelease(tag)?.[0]) {\n channel = this.getCustomChannelName(String(semver.prerelease(tag)?.[0]))\n }\n rawData = await fetchData(channel)\n } catch (e: any) {\n if (this.updater.allowPrerelease) {\n // Allow fallback to `latest.yml`\n rawData = await fetchData(this.getDefaultChannelName())\n } else {\n throw e\n }\n }\n\n const result = parseUpdateInfo(rawData, channelFile, channelFileUrl)\n if (result.releaseName == null) {\n result.releaseName = latestRelease.elementValueOrEmpty(\"title\")\n }\n\n if (result.releaseNotes == null) {\n result.releaseNotes = computeReleaseNotes(this.updater.currentVersion, this.updater.fullChangelog, feed, latestRelease)\n }\n return {\n tag: tag,\n ...result,\n }\n }\n\n private async getLatestTagName(cancellationToken: CancellationToken): Promise<string | null> {\n const options = this.options\n // do not use API for GitHub to avoid limit, only for custom host or GitHub Enterprise\n const url =\n options.host == null || options.host === \"github.com\"\n ? newUrlFromBase(`${this.basePath}/latest`, this.baseUrl)\n : new URL(`${this.computeGithubBasePath(`/repos/${options.owner}/${options.repo}/releases`)}/latest`, this.baseApiUrl)\n try {\n const rawData = await this.httpRequest(url, { Accept: \"application/json\" }, cancellationToken)\n if (rawData == null) {\n return null\n }\n\n const releaseInfo: GithubReleaseInfo = JSON.parse(rawData)\n return releaseInfo.tag_name\n } catch (e: any) {\n throw newError(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n }\n\n private get basePath(): string {\n return `/${this.options.owner}/${this.options.repo}/releases`\n }\n\n resolveFiles(updateInfo: GithubUpdateInfo): Array<ResolvedUpdateFileInfo> {\n // still replace space to - due to backward compatibility\n return resolveFiles(updateInfo, this.baseUrl, p => this.getBaseDownloadPath(updateInfo.tag, p.replace(/ /g, \"-\")))\n }\n\n private getBaseDownloadPath(tag: string, fileName: string): string {\n return `${this.basePath}/download/${tag}/${fileName}`\n }\n}\n\ninterface GithubReleaseInfo {\n readonly tag_name: string\n}\n\nfunction getNoteValue(parent: XElement): string {\n const result = parent.elementValueOrEmpty(\"content\")\n // GitHub reports empty notes as <content>No content.</content>\n return result === \"No content.\" ? \"\" : result\n}\n\nexport function computeReleaseNotes(currentVersion: semver.SemVer, isFullChangelog: boolean, feed: XElement, latestRelease: any): string | Array<ReleaseNoteInfo> | null {\n if (!isFullChangelog) {\n return getNoteValue(latestRelease)\n }\n\n const releaseNotes: Array<ReleaseNoteInfo> = []\n for (const release of feed.getElements(\"entry\")) {\n // noinspection TypeScriptValidateJSTypes\n const versionRelease = /\\/tag\\/v?([^/]+)$/.exec(release.element(\"link\").attribute(\"href\"))![1]\n if (semver.valid(versionRelease) && semver.lt(currentVersion, versionRelease)) {\n releaseNotes.push({\n version: versionRelease,\n note: getNoteValue(release),\n })\n }\n }\n return releaseNotes.sort((a, b) => semver.rcompare(a.version, b.version))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GitHubProvider.js","sourceRoot":"","sources":["../../src/providers/GitHubProvider.ts"],"names":[],"mappings":";;;AAqOA,kDA8CC;AAnRD,+DAAwJ;AACxJ,iCAAgC;AAChC,6BAAyB;AAGzB,kCAAwE;AACxE,yCAA4F;AAE5F,MAAM,UAAU,GAAG,mBAAmB,CAAA;AAKtC,MAAsB,kBAAyC,SAAQ,mBAAW;IAKhF,YACqB,OAAsB,EACzC,WAAmB,EACnB,cAAsC;QAEtC,KAAK,CAAC;YACJ,GAAG,cAAc;YACjB,4BAA4B;YAC5B,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAAA;QARiB,YAAO,GAAP,OAAO,CAAe;QAUzC,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAU,EAAC,IAAA,gCAAS,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;QAC1D,MAAM,OAAO,GAAG,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAA;QAC7E,IAAI,CAAC,UAAU,GAAG,IAAA,iBAAU,EAAC,IAAA,gCAAS,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC3D,CAAC;IAES,qBAAqB,CAAC,M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C,KAAK,EAAE,CAAC;gBACX,SAAQ;YACV,CAAC;YACD,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,SAAQ;QACV,CAAC;QACD,gEAAgE;QAChE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;YAClC,SAAQ;QACV,CAAC;QAED,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;QAC1E,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;QACzE,IAAI,oBAAoB,IAAI,uBAAuB,EAAE,CAAC;YACpD,YAAY,CAAC,IAAI,CAAC;gBAChB,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC;aAC5B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAC3E,CAAC","sourcesContent":["import { CancellationToken, GithubOptions, githubUrl, HttpError, newError, parseXml, ReleaseNoteInfo, UpdateInfo, XElement } from \"builder-util-runtime\"\nimport * as semver from \"semver\"\nimport { URL } from \"url\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"../types\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase } from \"../util\"\nimport { parseUpdateInfo, Provider, ProviderRuntimeOptions, resolveFiles } from \"./Provider\"\n\nconst hrefRegExp = /\\/tag\\/(v?[^/]+)$/\n\ninterface GithubUpdateInfo extends UpdateInfo {\n tag: string\n}\nexport abstract class BaseGitHubProvider<T extends UpdateInfo> extends Provider<T> {\n // so, we don't need to parse port (because node http doesn't support host as url does)\n protected readonly baseUrl: URL\n protected readonly baseApiUrl: URL\n\n protected constructor(\n protected readonly options: GithubOptions,\n defaultHost: string,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super({\n ...runtimeOptions,\n /* because GitHib uses S3 */\n isUseMultipleRangeRequest: false,\n })\n\n this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))\n const apiHost = defaultHost === \"github.com\" ? \"api.github.com\" : defaultHost\n this.baseApiUrl = newBaseUrl(githubUrl(options, apiHost))\n }\n\n protected computeGithubBasePath(result: string): string {\n // https://github.com/electron-userland/electron-builder/issues/1903#issuecomment-320881211\n const host = this.options.host\n return host && ![\"github.com\", \"api.github.com\"].includes(host) ? `/api/v3${result}` : result\n }\n}\n\nexport class GitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {\n constructor(\n protected readonly options: GithubOptions,\n private readonly updater: AppUpdater,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super(options, \"github.com\", runtimeOptions)\n }\n\n private get channel(): string {\n const result = this.updater.channel || this.options.channel\n return result == null ? this.getDefaultChannelName() : this.getCustomChannelName(result)\n }\n\n async getLatestVersion(): Promise<GithubUpdateInfo> {\n const cancellationToken = new CancellationToken()\n\n const feedXml: string = (await this.httpRequest(\n newUrlFromBase(`${this.basePath}.atom`, this.baseUrl),\n {\n accept: \"application/xml, application/atom+xml, text/xml, */*\",\n },\n cancellationToken\n ))!\n\n const feed = parseXml(feedXml)\n // noinspection TypeScriptValidateJSTypes\n let latestRelease = feed.element(\"entry\", false, `No published versions on GitHub`)\n let tag: string | null = null\n try {\n if (this.updater.allowPrerelease) {\n const currentChannel = this.updater?.channel || (semver.prerelease(this.updater.currentVersion)?.[0] as string) || null\n\n if (currentChannel === null) {\n // allowPrerelease=true with no explicit channel and stable current version:\n // pick the first entry from the Atom feed, which may be a prerelease\n // noinspection TypeScriptValidateJSTypes\n tag = hrefRegExp.exec(latestRelease.element(\"link\").attribute(\"href\"))![1]\n } else {\n for (const element of feed.getElements(\"entry\")) {\n // noinspection TypeScriptValidateJSTypes\n const hrefElement = hrefRegExp.exec(element.element(\"link\").attribute(\"href\"))!\n\n // If this is null then something is wrong and skip this release\n if (hrefElement === null) {\n continue\n }\n\n // This Release's Tag\n const hrefTag = hrefElement[1]\n if (!semver.valid(hrefTag)) {\n continue\n }\n\n //Get Channel from this release's tag\n const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null\n\n const shouldFetchVersion = !currentChannel || [\"alpha\", \"beta\"].includes(currentChannel)\n const isCustomChannel = hrefChannel !== null && ![\"alpha\", \"beta\"].includes(String(hrefChannel))\n // Allow moving from alpha to beta but not down\n const channelMismatch = currentChannel === \"beta\" && hrefChannel === \"alpha\"\n\n if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {\n tag = hrefTag\n latestRelease = element\n break\n }\n\n const isNextPreRelease = hrefChannel && hrefChannel === currentChannel\n if (isNextPreRelease) {\n tag = hrefTag\n latestRelease = element\n break\n }\n }\n }\n } else {\n tag = await this.getLatestTagName(cancellationToken)\n for (const element of feed.getElements(\"entry\")) {\n // noinspection TypeScriptValidateJSTypes\n const hrefMatch = hrefRegExp.exec(element.element(\"link\").attribute(\"href\"))\n if (hrefMatch == null) {\n continue\n }\n if (hrefMatch[1] === tag) {\n latestRelease = element\n break\n }\n }\n }\n } catch (e: any) {\n throw newError(`Cannot parse releases feed: ${e.stack || e.message},\\nXML:\\n${feedXml}`, \"ERR_UPDATER_INVALID_RELEASE_FEED\")\n }\n\n if (tag == null) {\n throw newError(`No published versions on GitHub`, \"ERR_UPDATER_NO_PUBLISHED_VERSIONS\")\n }\n\n let rawData: string\n let channelFile = \"\"\n let channelFileUrl: any = \"\"\n const fetchData = async (channelName: string) => {\n channelFile = getChannelFilename(channelName)\n channelFileUrl = newUrlFromBase(this.getBaseDownloadPath(String(tag), channelFile), this.baseUrl)\n const requestOptions = this.createRequestOptions(channelFileUrl)\n try {\n return (await this.executor.request(requestOptions, cancellationToken))!\n } catch (e: any) {\n if (e instanceof HttpError && e.statusCode === 404) {\n throw newError(`Cannot find ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n throw e\n }\n }\n\n try {\n let channel = this.channel\n if (this.updater.allowPrerelease && semver.prerelease(tag)?.[0]) {\n channel = this.getCustomChannelName(String(semver.prerelease(tag)?.[0]))\n }\n rawData = await fetchData(channel)\n } catch (e: any) {\n if (this.updater.allowPrerelease) {\n // Allow fallback to `latest.yml`\n rawData = await fetchData(this.getDefaultChannelName())\n } else {\n throw e\n }\n }\n\n const result = parseUpdateInfo(rawData, channelFile, channelFileUrl)\n if (result.releaseName == null) {\n result.releaseName = latestRelease.elementValueOrEmpty(\"title\")\n }\n\n if (result.releaseNotes == null) {\n result.releaseNotes = computeReleaseNotes(this.updater.currentVersion, this.updater.fullChangelog, feed, latestRelease)\n }\n return {\n tag: tag,\n ...result,\n }\n }\n\n private async getLatestTagName(cancellationToken: CancellationToken): Promise<string | null> {\n const options = this.options\n // do not use API for GitHub to avoid limit, only for custom host or GitHub Enterprise\n const url =\n options.host == null || options.host === \"github.com\"\n ? newUrlFromBase(`${this.basePath}/latest`, this.baseUrl)\n : new URL(`${this.computeGithubBasePath(`/repos/${options.owner}/${options.repo}/releases`)}/latest`, this.baseApiUrl)\n try {\n const rawData = await this.httpRequest(url, { Accept: \"application/json\" }, cancellationToken)\n if (rawData == null) {\n return null\n }\n\n const releaseInfo: GithubReleaseInfo = JSON.parse(rawData)\n return releaseInfo.tag_name\n } catch (e: any) {\n throw newError(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n }\n\n private get basePath(): string {\n return `/${this.options.owner}/${this.options.repo}/releases`\n }\n\n resolveFiles(updateInfo: GithubUpdateInfo): Array<ResolvedUpdateFileInfo> {\n // still replace space to - due to backward compatibility\n return resolveFiles(updateInfo, this.baseUrl, p => this.getBaseDownloadPath(updateInfo.tag, p.replace(/ /g, \"-\")))\n }\n\n private getBaseDownloadPath(tag: string, fileName: string): string {\n return `${this.basePath}/download/${tag}/${fileName}`\n }\n}\n\ninterface GithubReleaseInfo {\n readonly tag_name: string\n}\n\nfunction getNoteValue(parent: XElement): string {\n const result = parent.elementValueOrEmpty(\"content\")\n // GitHub reports empty notes as <content>No content.</content>\n return result === \"No content.\" ? \"\" : result\n}\n\nexport function computeReleaseNotes(currentVersion: semver.SemVer, isFullChangelog: boolean, feed: XElement, latestRelease: XElement): string | Array<ReleaseNoteInfo> | null {\n if (!isFullChangelog) {\n return getNoteValue(latestRelease)\n }\n\n const releaseVersionRegExp = /\\/tag\\/v?([^/]+)$/\n\n let latestVersion: string | undefined = undefined\n try {\n latestVersion = releaseVersionRegExp.exec(latestRelease.element(\"link\").attribute(\"href\"))![1]\n latestVersion = semver.valid(latestVersion) ? latestVersion : undefined\n } catch {\n // If we cannot parse the latest release version, return null — notes cannot be determined\n }\n\n if (latestVersion == null) {\n return null\n }\n\n const releaseNotes: Array<ReleaseNoteInfo> = []\n for (const release of feed.getElements(\"entry\")) {\n let versionRelease: string\n try {\n const match = releaseVersionRegExp.exec(release.element(\"link\").attribute(\"href\"))\n if (!match) {\n continue\n }\n versionRelease = match[1]\n } catch {\n continue\n }\n // skip non-semver tags (e.g. doc/website releases in monorepos)\n if (!semver.valid(versionRelease)) {\n continue\n }\n\n const isGreaterThanCurrent = semver.gt(versionRelease, currentVersion.raw)\n const isLessOrEqualThanLatest = semver.lte(versionRelease, latestVersion)\n if (isGreaterThanCurrent && isLessOrEqualThanLatest) {\n releaseNotes.push({\n version: versionRelease,\n note: getNoteValue(release),\n })\n }\n }\n return releaseNotes.sort((a, b) => semver.rcompare(a.version, b.version))\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-updater",
|
|
3
|
-
"version": "6.8.
|
|
3
|
+
"version": "6.8.8",
|
|
4
4
|
"description": "Cross platform updater for electron applications",
|
|
5
5
|
"main": "out/main.js",
|
|
6
6
|
"author": "Vladimir Krivosheev",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lodash.isequal": "^4.5.0",
|
|
24
24
|
"semver": "~7.7.3",
|
|
25
25
|
"tiny-typed-emitter": "^2.1.0",
|
|
26
|
-
"builder-util-runtime": "9.6.
|
|
26
|
+
"builder-util-runtime": "9.6.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/fs-extra": "9.0.13",
|