electron-updater 6.8.8 → 6.8.9

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.
@@ -1,4 +1,5 @@
1
1
  import { GitlabOptions, UpdateInfo } from "builder-util-runtime";
2
+ import { OutgoingHttpHeaders, RequestOptions } from "http";
2
3
  import { URL } from "url";
3
4
  import { AppUpdater } from "../AppUpdater";
4
5
  import { ResolvedUpdateFileInfo } from "../types";
@@ -28,6 +29,7 @@ export declare class GitLabProvider extends Provider<GitlabUpdateInfo> {
28
29
  */
29
30
  private normalizeFilename;
30
31
  constructor(options: GitlabOptions, updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions);
32
+ protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions;
31
33
  private get channel();
32
34
  getLatestVersion(): Promise<GitlabUpdateInfo>;
33
35
  /**
@@ -39,6 +39,11 @@ class GitLabProvider extends Provider_1.Provider {
39
39
  const host = options.host || defaultHost;
40
40
  this.baseApiUrl = (0, util_1.newBaseUrl)(`https://${host}/api/v4`);
41
41
  }
42
+ createRequestOptions(url, headers) {
43
+ const result = super.createRequestOptions(url, headers);
44
+ result.redirect = "manual";
45
+ return result;
46
+ }
42
47
  get channel() {
43
48
  const result = this.updater.channel || this.options.channel;
44
49
  return result == null ? this.getDefaultChannelName() : this.getCustomChannelName(result);
@@ -1 +1 @@
1
- {"version":3,"file":"GitLabProvider.js","sourceRoot":"","sources":["../../src/providers/GitLabProvider.ts"],"names":[],"mappings":";;;AAAA,+DAA+J;AAC/J,6BAAyB;AACzB,aAAa;AACb,oDAAmD;AAGnD,kCAAwE;AACxE,yCAA2F;AAO3F,MAAa,cAAe,SAAQ,mBAA0B;IAK5D;;;;;;;;;;;;;OAaG;IACK,iBAAiB,CAAC,QAAgB;QACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,YACmB,OAAsB,EACtB,OAAmB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AED,OAAO;gBACL,GAAG,EAAE,IAAI,SAAG,CAAC,QAAQ,CAAC;gBACtB,IAAI,EAAE,QAAQ;aACf,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,sBAAsB,IAAI,CAAC,OAAO,CAAC,SAAS,cAAc,IAAI,CAAC,OAAO,GAAG,CAAA;IAClF,CAAC;CACF;AAhUD,wCAgUC","sourcesContent":["import { CancellationToken, GitlabOptions, HttpError, newError, UpdateFileInfo, UpdateInfo, GitlabReleaseInfo, GitlabReleaseAsset } from \"builder-util-runtime\"\nimport { URL } from \"url\"\n// @ts-ignore\nimport * as escapeRegExp from \"lodash.escaperegexp\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"../types\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase } from \"../util\"\nimport { getFileList, parseUpdateInfo, Provider, ProviderRuntimeOptions } from \"./Provider\"\n\ninterface GitlabUpdateInfo extends UpdateInfo {\n tag: string\n assets: Map<string, string> // filename -> download URL mapping\n}\n\nexport class GitLabProvider extends Provider<GitlabUpdateInfo> {\n private readonly baseApiUrl: URL\n // Cache the latest version info to avoid unnecessary HTTP requests\n private cachedLatestVersion: GitlabUpdateInfo | null = null\n\n /**\n * Normalizes filenames by replacing spaces and underscores with dashes.\n *\n * This is a workaround to handle filename formatting differences between tools:\n * - electron-builder formats filenames like \"test file.txt\" as \"test-file.txt\"\n * - GitLab may provide asset URLs using underscores, such as \"test_file.txt\"\n *\n * Because of this mismatch, we can't reliably extract the correct filename from\n * the asset path without normalization. This function ensures consistent matching\n * across different filename formats by converting all spaces and underscores to dashes.\n *\n * @param filename The filename to normalize\n * @returns The normalized filename with spaces and underscores replaced by dashes\n */\n private normalizeFilename(filename: string): string {\n return filename.replace(/ |_/g, \"-\")\n }\n\n constructor(\n private readonly options: GitlabOptions,\n private readonly updater: AppUpdater,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super({\n ...runtimeOptions,\n // GitLab might not support multiple range requests efficiently\n isUseMultipleRangeRequest: false,\n })\n\n const defaultHost = \"gitlab.com\"\n const host = options.host || defaultHost\n\n this.baseApiUrl = newBaseUrl(`https://${host}/api/v4`)\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<GitlabUpdateInfo> {\n const cancellationToken = new CancellationToken()\n\n // Get latest release from GitLab API using the permalink/latest endpoint\n const latestReleaseUrl = newUrlFromBase(`projects/${this.options.projectId}/releases/permalink/latest`, this.baseApiUrl)\n\n const header = { Accept: \"application/json\", ...this.setAuthHeaderForToken(this.options.token || null) }\n let releaseResponse: string | null\n try {\n releaseResponse = await this.httpRequest(latestReleaseUrl, header, cancellationToken)\n } catch (e: any) {\n throw newError(`Unable to find latest release on GitLab (${latestReleaseUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n\n if (!releaseResponse) {\n throw newError(\"No published releases on GitLab\", \"ERR_UPDATER_NO_PUBLISHED_VERSIONS\")\n }\n\n let latestRelease: GitlabReleaseInfo\n try {\n latestRelease = JSON.parse(releaseResponse)\n } catch (e: any) {\n throw newError(\n `Unable to parse latest release response from GitLab (${latestReleaseUrl}): response was not valid JSON: ${e.stack || e.message}`,\n \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\"\n )\n }\n\n if (latestRelease.upcoming_release) {\n throw newError(\"Latest GitLab release is scheduled but not yet published\", \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n\n const tag = latestRelease.tag_name\n\n // Look for channel file in release assets\n let rawData: string | null = null\n let channelFile = \"\"\n let channelFileUrl: URL | null = null\n\n const fetchChannelData = async (channelName: string): Promise<string> => {\n channelFile = getChannelFilename(channelName)\n\n // Find the channel file in GitLab release assets\n const channelAsset = latestRelease.assets.links.find(asset => asset.name === channelFile)\n\n if (!channelAsset) {\n throw newError(`Cannot find ${channelFile} in the latest release assets`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n\n channelFileUrl = new URL(channelAsset.direct_asset_url)\n const authHeaders = this.setAuthHeaderForToken(this.options.token || null)\n const headers = Object.keys(authHeaders).length ? authHeaders : undefined\n\n try {\n const result = await this.httpRequest(channelFileUrl, headers, cancellationToken)\n if (!result) {\n throw newError(`Empty response from ${channelFileUrl}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n return result\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 rawData = await fetchChannelData(this.channel)\n } catch (e: any) {\n // If custom channel fails, try default channel as fallback\n if (this.channel !== this.getDefaultChannelName()) {\n rawData = await fetchChannelData(this.getDefaultChannelName())\n } else {\n throw e\n }\n }\n\n if (!rawData) {\n throw newError(`Unable to parse channel data from ${channelFile}`, \"ERR_UPDATER_INVALID_UPDATE_INFO\")\n }\n\n const result = parseUpdateInfo(rawData, channelFile, channelFileUrl!)\n\n // Set release name from GitLab if not present\n if (result.releaseName == null) {\n result.releaseName = latestRelease.name\n }\n\n // Set release notes from GitLab description if not present\n if (result.releaseNotes == null) {\n result.releaseNotes = latestRelease.description || null\n }\n\n const gitlabUpdateInfo = {\n tag: tag,\n assets: this.convertAssetsToMap(latestRelease.assets),\n ...result,\n }\n\n // Cache the latest version info\n this.cachedLatestVersion = gitlabUpdateInfo\n\n return gitlabUpdateInfo\n }\n\n /**\n * Utility function to convert GitlabReleaseAsset to Map<string, string>\n * Maps asset names to their download URLs\n */\n private convertAssetsToMap(assets: GitlabReleaseAsset): Map<string, string> {\n const assetsMap = new Map<string, string>()\n for (const asset of assets.links) {\n assetsMap.set(this.normalizeFilename(asset.name), asset.direct_asset_url)\n }\n return assetsMap\n }\n\n /**\n * Find blockmap file URL in assets map for a specific filename\n */\n private findBlockMapInAssets(assets: Map<string, string>, filename: string): URL | null {\n const possibleBlockMapNames = [`${filename}.blockmap`, `${this.normalizeFilename(filename)}.blockmap`]\n\n for (const blockMapName of possibleBlockMapNames) {\n const assetUrl = assets.get(blockMapName)\n if (assetUrl) {\n return new URL(assetUrl)\n }\n }\n return null\n }\n\n private async fetchReleaseInfoByVersion(version: string): Promise<GitlabReleaseInfo | null> {\n const cancellationToken = new CancellationToken()\n\n // Try v-prefixed version first, then fallback to plain version\n const possibleReleaseIds = [`v${version}`, version]\n\n for (const releaseId of possibleReleaseIds) {\n const releaseUrl = newUrlFromBase(`projects/${this.options.projectId}/releases/${encodeURIComponent(releaseId)}`, this.baseApiUrl)\n\n try {\n const header = { Accept: \"application/json\", ...this.setAuthHeaderForToken(this.options.token || null) }\n const releaseResponse = await this.httpRequest(releaseUrl, header, cancellationToken)\n\n if (releaseResponse) {\n const release: GitlabReleaseInfo = JSON.parse(releaseResponse)\n return release\n }\n } catch (e: any) {\n // If it's a 404 error, try the next release ID format\n if (e instanceof HttpError && e.statusCode === 404) {\n continue\n }\n // For other errors, throw immediately\n throw newError(`Unable to find release ${releaseId} on GitLab (${releaseUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_RELEASE_NOT_FOUND\")\n }\n }\n\n // If we get here, none of the release ID formats worked\n throw newError(`Unable to find release with version ${version} (tried: ${possibleReleaseIds.join(\", \")}) on GitLab`, \"ERR_UPDATER_RELEASE_NOT_FOUND\")\n }\n\n private setAuthHeaderForToken(token: string | null): { [key: string]: string } {\n const headers: { [key: string]: string } = {}\n\n if (token != null) {\n // If the token starts with \"Bearer\", it is an OAuth application secret\n // Note that the original gitlab token would not start with \"Bearer\"\n // it might start with \"gloas-\", if so user needs to add \"Bearer \" prefix to the token\n if (token.startsWith(\"Bearer\")) {\n headers.authorization = token\n } else {\n headers[\"PRIVATE-TOKEN\"] = token\n }\n }\n\n return headers\n }\n\n /**\n * Get version info for blockmap files, using cache when possible\n */\n private async getVersionInfoForBlockMap(version: string): Promise<Map<string, string> | null> {\n // Check if we can use cached version info\n if (this.cachedLatestVersion && this.cachedLatestVersion.version === version) {\n return this.cachedLatestVersion.assets\n }\n\n // Fetch version info if not cached or version doesn't match\n const versionInfo = await this.fetchReleaseInfoByVersion(version)\n if (versionInfo && versionInfo.assets) {\n return this.convertAssetsToMap(versionInfo.assets)\n }\n\n return null\n }\n\n /**\n * Find blockmap URLs from version assets\n */\n private async findBlockMapUrlsFromAssets(oldVersion: string, newVersion: string, baseFilename: string): Promise<[URL | null, URL | null]> {\n let newBlockMapUrl: URL | null = null\n let oldBlockMapUrl: URL | null = null\n\n // Get new version assets\n const newVersionAssets = await this.getVersionInfoForBlockMap(newVersion)\n if (newVersionAssets) {\n newBlockMapUrl = this.findBlockMapInAssets(newVersionAssets, baseFilename)\n }\n\n // Get old version assets\n const oldVersionAssets = await this.getVersionInfoForBlockMap(oldVersion)\n if (oldVersionAssets) {\n const oldFilename = baseFilename.replace(new RegExp(escapeRegExp(newVersion), \"g\"), oldVersion)\n oldBlockMapUrl = this.findBlockMapInAssets(oldVersionAssets, oldFilename)\n }\n\n return [oldBlockMapUrl, newBlockMapUrl]\n }\n\n async getBlockMapFiles(baseUrl: URL, oldVersion: string, newVersion: string, oldBlockMapFileBaseUrl: string | null = null): Promise<URL[]> {\n // If is `project_upload`, find blockmap files from corresponding gitLab assets\n // Because each asset has an unique path that includes an identified hash code,\n // e.g. https://gitlab.com/-/project/71361100/uploads/051f27a925eaf679f2ad688105362acc/latest.yml\n if (this.options.uploadTarget === \"project_upload\") {\n // Get the base filename from the URL to find corresponding blockmap files\n const baseFilename = baseUrl.pathname.split(\"/\").pop() || \"\"\n\n // Try to find blockmap files in GitLab assets\n const [oldBlockMapUrl, newBlockMapUrl] = await this.findBlockMapUrlsFromAssets(oldVersion, newVersion, baseFilename)\n\n if (!newBlockMapUrl) {\n throw newError(`Cannot find blockmap file for ${newVersion} in GitLab assets`, \"ERR_UPDATER_BLOCKMAP_FILE_NOT_FOUND\")\n }\n\n if (!oldBlockMapUrl) {\n throw newError(`Cannot find blockmap file for ${oldVersion} in GitLab assets`, \"ERR_UPDATER_BLOCKMAP_FILE_NOT_FOUND\")\n }\n\n return [oldBlockMapUrl, newBlockMapUrl]\n } else {\n return super.getBlockMapFiles(baseUrl, oldVersion, newVersion, oldBlockMapFileBaseUrl)\n }\n }\n\n resolveFiles(updateInfo: GitlabUpdateInfo): Array<ResolvedUpdateFileInfo> {\n return getFileList(updateInfo).map((fileInfo: UpdateFileInfo) => {\n // Try both original and normalized filename formats\n const possibleNames = [\n fileInfo.url, // Original filename\n this.normalizeFilename(fileInfo.url), // Normalized filename (spaces/underscores → dashes)\n ]\n\n const matchingAssetName = possibleNames.find(name => updateInfo.assets.has(name))\n const assetUrl = matchingAssetName ? updateInfo.assets.get(matchingAssetName) : undefined\n\n if (!assetUrl) {\n throw newError(\n `Cannot find asset \"${fileInfo.url}\" in GitLab release assets. Available assets: ${Array.from(updateInfo.assets.keys()).join(\", \")}`,\n \"ERR_UPDATER_ASSET_NOT_FOUND\"\n )\n }\n\n return {\n url: new URL(assetUrl),\n info: fileInfo,\n }\n })\n }\n\n toString(): string {\n return `GitLab (projectId: ${this.options.projectId}, channel: ${this.channel})`\n }\n}\n"]}
1
+ {"version":3,"file":"GitLabProvider.js","sourceRoot":"","sources":["../../src/providers/GitLabProvider.ts"],"names":[],"mappings":";;;AAAA,+DAA+J;AAE/J,6BAAyB;AACzB,aAAa;AACb,oDAAmD;AAGnD,kCAAwE;AACxE,yCAA2F;AAO3F,MAAa,cAAe,SAAQ,mBAA0B;IAK5D;;;;;;;;;;;;;OAaG;IACK,iBAAiB,CAAC,QAAgB;QACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,YACmB,OAAsB,EACtB,OAAmB,EACpC,cAAsC;QAEtC,KAAK,CAAC;YACJ,GAAG,cAAc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iDAAiD,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACpI,6BAA6B,CAC9B,CAAA;YACH,CAAC;YAED,OAAO;gBACL,GAAG,EAAE,IAAI,SAAG,CAAC,QAAQ,CAAC;gBACtB,IAAI,EAAE,QAAQ;aACf,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,sBAAsB,IAAI,CAAC,OAAO,CAAC,SAAS,cAAc,IAAI,CAAC,OAAO,GAAG,CAAA;IAClF,CAAC;CACF;AAtUD,wCAsUC","sourcesContent":["import { CancellationToken, GitlabOptions, HttpError, newError, UpdateFileInfo, UpdateInfo, GitlabReleaseInfo, GitlabReleaseAsset } from \"builder-util-runtime\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { URL } from \"url\"\n// @ts-ignore\nimport * as escapeRegExp from \"lodash.escaperegexp\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"../types\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase } from \"../util\"\nimport { getFileList, parseUpdateInfo, Provider, ProviderRuntimeOptions } from \"./Provider\"\n\ninterface GitlabUpdateInfo extends UpdateInfo {\n tag: string\n assets: Map<string, string> // filename -> download URL mapping\n}\n\nexport class GitLabProvider extends Provider<GitlabUpdateInfo> {\n private readonly baseApiUrl: URL\n // Cache the latest version info to avoid unnecessary HTTP requests\n private cachedLatestVersion: GitlabUpdateInfo | null = null\n\n /**\n * Normalizes filenames by replacing spaces and underscores with dashes.\n *\n * This is a workaround to handle filename formatting differences between tools:\n * - electron-builder formats filenames like \"test file.txt\" as \"test-file.txt\"\n * - GitLab may provide asset URLs using underscores, such as \"test_file.txt\"\n *\n * Because of this mismatch, we can't reliably extract the correct filename from\n * the asset path without normalization. This function ensures consistent matching\n * across different filename formats by converting all spaces and underscores to dashes.\n *\n * @param filename The filename to normalize\n * @returns The normalized filename with spaces and underscores replaced by dashes\n */\n private normalizeFilename(filename: string): string {\n return filename.replace(/ |_/g, \"-\")\n }\n\n constructor(\n private readonly options: GitlabOptions,\n private readonly updater: AppUpdater,\n runtimeOptions: ProviderRuntimeOptions\n ) {\n super({\n ...runtimeOptions,\n // GitLab might not support multiple range requests efficiently\n isUseMultipleRangeRequest: false,\n })\n\n const defaultHost = \"gitlab.com\"\n const host = options.host || defaultHost\n\n this.baseApiUrl = newBaseUrl(`https://${host}/api/v4`)\n }\n\n protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {\n const result = super.createRequestOptions(url, headers)\n ;(result as any).redirect = \"manual\"\n return result\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<GitlabUpdateInfo> {\n const cancellationToken = new CancellationToken()\n\n // Get latest release from GitLab API using the permalink/latest endpoint\n const latestReleaseUrl = newUrlFromBase(`projects/${this.options.projectId}/releases/permalink/latest`, this.baseApiUrl)\n\n const header = { Accept: \"application/json\", ...this.setAuthHeaderForToken(this.options.token || null) }\n let releaseResponse: string | null\n try {\n releaseResponse = await this.httpRequest(latestReleaseUrl, header, cancellationToken)\n } catch (e: any) {\n throw newError(`Unable to find latest release on GitLab (${latestReleaseUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n\n if (!releaseResponse) {\n throw newError(\"No published releases on GitLab\", \"ERR_UPDATER_NO_PUBLISHED_VERSIONS\")\n }\n\n let latestRelease: GitlabReleaseInfo\n try {\n latestRelease = JSON.parse(releaseResponse)\n } catch (e: any) {\n throw newError(\n `Unable to parse latest release response from GitLab (${latestReleaseUrl}): response was not valid JSON: ${e.stack || e.message}`,\n \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\"\n )\n }\n\n if (latestRelease.upcoming_release) {\n throw newError(\"Latest GitLab release is scheduled but not yet published\", \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n\n const tag = latestRelease.tag_name\n\n // Look for channel file in release assets\n let rawData: string | null = null\n let channelFile = \"\"\n let channelFileUrl: URL | null = null\n\n const fetchChannelData = async (channelName: string): Promise<string> => {\n channelFile = getChannelFilename(channelName)\n\n // Find the channel file in GitLab release assets\n const channelAsset = latestRelease.assets.links.find(asset => asset.name === channelFile)\n\n if (!channelAsset) {\n throw newError(`Cannot find ${channelFile} in the latest release assets`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n\n channelFileUrl = new URL(channelAsset.direct_asset_url)\n const authHeaders = this.setAuthHeaderForToken(this.options.token || null)\n const headers = Object.keys(authHeaders).length ? authHeaders : undefined\n\n try {\n const result = await this.httpRequest(channelFileUrl, headers, cancellationToken)\n if (!result) {\n throw newError(`Empty response from ${channelFileUrl}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n return result\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 rawData = await fetchChannelData(this.channel)\n } catch (e: any) {\n // If custom channel fails, try default channel as fallback\n if (this.channel !== this.getDefaultChannelName()) {\n rawData = await fetchChannelData(this.getDefaultChannelName())\n } else {\n throw e\n }\n }\n\n if (!rawData) {\n throw newError(`Unable to parse channel data from ${channelFile}`, \"ERR_UPDATER_INVALID_UPDATE_INFO\")\n }\n\n const result = parseUpdateInfo(rawData, channelFile, channelFileUrl!)\n\n // Set release name from GitLab if not present\n if (result.releaseName == null) {\n result.releaseName = latestRelease.name\n }\n\n // Set release notes from GitLab description if not present\n if (result.releaseNotes == null) {\n result.releaseNotes = latestRelease.description || null\n }\n\n const gitlabUpdateInfo = {\n tag: tag,\n assets: this.convertAssetsToMap(latestRelease.assets),\n ...result,\n }\n\n // Cache the latest version info\n this.cachedLatestVersion = gitlabUpdateInfo\n\n return gitlabUpdateInfo\n }\n\n /**\n * Utility function to convert GitlabReleaseAsset to Map<string, string>\n * Maps asset names to their download URLs\n */\n private convertAssetsToMap(assets: GitlabReleaseAsset): Map<string, string> {\n const assetsMap = new Map<string, string>()\n for (const asset of assets.links) {\n assetsMap.set(this.normalizeFilename(asset.name), asset.direct_asset_url)\n }\n return assetsMap\n }\n\n /**\n * Find blockmap file URL in assets map for a specific filename\n */\n private findBlockMapInAssets(assets: Map<string, string>, filename: string): URL | null {\n const possibleBlockMapNames = [`${filename}.blockmap`, `${this.normalizeFilename(filename)}.blockmap`]\n\n for (const blockMapName of possibleBlockMapNames) {\n const assetUrl = assets.get(blockMapName)\n if (assetUrl) {\n return new URL(assetUrl)\n }\n }\n return null\n }\n\n private async fetchReleaseInfoByVersion(version: string): Promise<GitlabReleaseInfo | null> {\n const cancellationToken = new CancellationToken()\n\n // Try v-prefixed version first, then fallback to plain version\n const possibleReleaseIds = [`v${version}`, version]\n\n for (const releaseId of possibleReleaseIds) {\n const releaseUrl = newUrlFromBase(`projects/${this.options.projectId}/releases/${encodeURIComponent(releaseId)}`, this.baseApiUrl)\n\n try {\n const header = { Accept: \"application/json\", ...this.setAuthHeaderForToken(this.options.token || null) }\n const releaseResponse = await this.httpRequest(releaseUrl, header, cancellationToken)\n\n if (releaseResponse) {\n const release: GitlabReleaseInfo = JSON.parse(releaseResponse)\n return release\n }\n } catch (e: any) {\n // If it's a 404 error, try the next release ID format\n if (e instanceof HttpError && e.statusCode === 404) {\n continue\n }\n // For other errors, throw immediately\n throw newError(`Unable to find release ${releaseId} on GitLab (${releaseUrl}): ${e.stack || e.message}`, \"ERR_UPDATER_RELEASE_NOT_FOUND\")\n }\n }\n\n // If we get here, none of the release ID formats worked\n throw newError(`Unable to find release with version ${version} (tried: ${possibleReleaseIds.join(\", \")}) on GitLab`, \"ERR_UPDATER_RELEASE_NOT_FOUND\")\n }\n\n private setAuthHeaderForToken(token: string | null): { [key: string]: string } {\n const headers: { [key: string]: string } = {}\n\n if (token != null) {\n // If the token starts with \"Bearer\", it is an OAuth application secret\n // Note that the original gitlab token would not start with \"Bearer\"\n // it might start with \"gloas-\", if so user needs to add \"Bearer \" prefix to the token\n if (token.startsWith(\"Bearer\")) {\n headers.authorization = token\n } else {\n headers[\"PRIVATE-TOKEN\"] = token\n }\n }\n\n return headers\n }\n\n /**\n * Get version info for blockmap files, using cache when possible\n */\n private async getVersionInfoForBlockMap(version: string): Promise<Map<string, string> | null> {\n // Check if we can use cached version info\n if (this.cachedLatestVersion && this.cachedLatestVersion.version === version) {\n return this.cachedLatestVersion.assets\n }\n\n // Fetch version info if not cached or version doesn't match\n const versionInfo = await this.fetchReleaseInfoByVersion(version)\n if (versionInfo && versionInfo.assets) {\n return this.convertAssetsToMap(versionInfo.assets)\n }\n\n return null\n }\n\n /**\n * Find blockmap URLs from version assets\n */\n private async findBlockMapUrlsFromAssets(oldVersion: string, newVersion: string, baseFilename: string): Promise<[URL | null, URL | null]> {\n let newBlockMapUrl: URL | null = null\n let oldBlockMapUrl: URL | null = null\n\n // Get new version assets\n const newVersionAssets = await this.getVersionInfoForBlockMap(newVersion)\n if (newVersionAssets) {\n newBlockMapUrl = this.findBlockMapInAssets(newVersionAssets, baseFilename)\n }\n\n // Get old version assets\n const oldVersionAssets = await this.getVersionInfoForBlockMap(oldVersion)\n if (oldVersionAssets) {\n const oldFilename = baseFilename.replace(new RegExp(escapeRegExp(newVersion), \"g\"), oldVersion)\n oldBlockMapUrl = this.findBlockMapInAssets(oldVersionAssets, oldFilename)\n }\n\n return [oldBlockMapUrl, newBlockMapUrl]\n }\n\n async getBlockMapFiles(baseUrl: URL, oldVersion: string, newVersion: string, oldBlockMapFileBaseUrl: string | null = null): Promise<URL[]> {\n // If is `project_upload`, find blockmap files from corresponding gitLab assets\n // Because each asset has an unique path that includes an identified hash code,\n // e.g. https://gitlab.com/-/project/71361100/uploads/051f27a925eaf679f2ad688105362acc/latest.yml\n if (this.options.uploadTarget === \"project_upload\") {\n // Get the base filename from the URL to find corresponding blockmap files\n const baseFilename = baseUrl.pathname.split(\"/\").pop() || \"\"\n\n // Try to find blockmap files in GitLab assets\n const [oldBlockMapUrl, newBlockMapUrl] = await this.findBlockMapUrlsFromAssets(oldVersion, newVersion, baseFilename)\n\n if (!newBlockMapUrl) {\n throw newError(`Cannot find blockmap file for ${newVersion} in GitLab assets`, \"ERR_UPDATER_BLOCKMAP_FILE_NOT_FOUND\")\n }\n\n if (!oldBlockMapUrl) {\n throw newError(`Cannot find blockmap file for ${oldVersion} in GitLab assets`, \"ERR_UPDATER_BLOCKMAP_FILE_NOT_FOUND\")\n }\n\n return [oldBlockMapUrl, newBlockMapUrl]\n } else {\n return super.getBlockMapFiles(baseUrl, oldVersion, newVersion, oldBlockMapFileBaseUrl)\n }\n }\n\n resolveFiles(updateInfo: GitlabUpdateInfo): Array<ResolvedUpdateFileInfo> {\n return getFileList(updateInfo).map((fileInfo: UpdateFileInfo) => {\n // Try both original and normalized filename formats\n const possibleNames = [\n fileInfo.url, // Original filename\n this.normalizeFilename(fileInfo.url), // Normalized filename (spaces/underscores → dashes)\n ]\n\n const matchingAssetName = possibleNames.find(name => updateInfo.assets.has(name))\n const assetUrl = matchingAssetName ? updateInfo.assets.get(matchingAssetName) : undefined\n\n if (!assetUrl) {\n throw newError(\n `Cannot find asset \"${fileInfo.url}\" in GitLab release assets. Available assets: ${Array.from(updateInfo.assets.keys()).join(\", \")}`,\n \"ERR_UPDATER_ASSET_NOT_FOUND\"\n )\n }\n\n return {\n url: new URL(assetUrl),\n info: fileInfo,\n }\n })\n }\n\n toString(): string {\n return `GitLab (projectId: ${this.options.projectId}, channel: ${this.channel})`\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-updater",
3
- "version": "6.8.8",
3
+ "version": "6.8.9",
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.3"
26
+ "builder-util-runtime": "9.7.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/fs-extra": "9.0.13",