electron-updater 6.4.0-alpha.2 → 6.4.0-alpha.3
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.d.ts +1 -0
- package/out/AppImageUpdater.js +24 -22
- package/out/AppImageUpdater.js.map +1 -1
- package/package.json +1 -1
package/out/AppImageUpdater.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export declare class AppImageUpdater extends BaseUpdater {
|
|
|
6
6
|
isUpdaterActive(): boolean;
|
|
7
7
|
/*** @private */
|
|
8
8
|
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
|
9
|
+
private downloadDifferential;
|
|
9
10
|
protected doInstall(options: InstallOptions): boolean;
|
|
10
11
|
}
|
package/out/AppImageUpdater.js
CHANGED
|
@@ -39,34 +39,36 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
39
39
|
if (oldFile == null) {
|
|
40
40
|
throw (0, builder_util_runtime_1.newError)("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const downloadOptions = {
|
|
45
|
-
newUrl: fileInfo.url,
|
|
46
|
-
oldFile,
|
|
47
|
-
logger: this._logger,
|
|
48
|
-
newFile: updateFile,
|
|
49
|
-
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
|
|
50
|
-
requestHeaders: downloadUpdateOptions.requestHeaders,
|
|
51
|
-
cancellationToken: downloadUpdateOptions.cancellationToken,
|
|
52
|
-
};
|
|
53
|
-
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
|
|
54
|
-
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
|
|
55
|
-
}
|
|
56
|
-
await new FileWithEmbeddedBlockMapDifferentialDownloader_1.FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download();
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`);
|
|
60
|
-
// during test (developer machine mac) we must throw error
|
|
61
|
-
isDownloadFull = process.platform === "linux";
|
|
62
|
-
}
|
|
63
|
-
if (isDownloadFull) {
|
|
42
|
+
if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {
|
|
64
43
|
await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
|
|
65
44
|
}
|
|
66
45
|
await (0, fs_extra_1.chmod)(updateFile, 0o755);
|
|
67
46
|
},
|
|
68
47
|
});
|
|
69
48
|
}
|
|
49
|
+
async downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions) {
|
|
50
|
+
try {
|
|
51
|
+
const downloadOptions = {
|
|
52
|
+
newUrl: fileInfo.url,
|
|
53
|
+
oldFile,
|
|
54
|
+
logger: this._logger,
|
|
55
|
+
newFile: updateFile,
|
|
56
|
+
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
|
|
57
|
+
requestHeaders: downloadUpdateOptions.requestHeaders,
|
|
58
|
+
cancellationToken: downloadUpdateOptions.cancellationToken,
|
|
59
|
+
};
|
|
60
|
+
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
|
|
61
|
+
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
|
|
62
|
+
}
|
|
63
|
+
await new FileWithEmbeddedBlockMapDifferentialDownloader_1.FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download();
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`);
|
|
68
|
+
// during test (developer machine mac) we must throw error
|
|
69
|
+
return process.platform === "linux";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
70
72
|
doInstall(options) {
|
|
71
73
|
const appImageFile = process.env["APPIMAGE"];
|
|
72
74
|
if (appImageFile == null) {
|
|
@@ -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;AAE3D,4IAAwI;AACxI,
|
|
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;AAE3D,4IAAwI;AACxI,iCAAkE;AAClE,mDAAyD;AAEzD,MAAa,eAAgB,SAAQ,yBAAW;IAC9C,YAAY,OAAkC,EAAE,GAAS;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAEM,eAAe;QACpB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAA;YAC1F,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;YAC/D,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,KAAK,CAAC,eAAe,EAAE,CAAA;IAChC,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,E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AI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;QAC3F,CAAC;QAED,IAAA,4BAAY,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;QAC9D,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;QACrD,CAAC;QAED,MAAM,GAAG,GAAsB;YAC7B,GAAG,OAAO,CAAC,GAAG;YACd,uBAAuB,EAAE,MAAM;SAChC,CAAA;QAED,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAA;YACxC,IAAA,4BAAY,EAAC,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAxGD,0CAwGC","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 { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./main\"\nimport { findFile, Provider } from \"./providers/Provider\"\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) {\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\n // https://stackoverflow.com/a/1712051/1910191\n unlinkSync(appImageFile)\n\n let destination: string\n const existingBaseName = path.basename(appImageFile)\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(options.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(options.installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", options.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"]}
|