app-builder-lib 23.3.0 → 23.3.1

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.
@@ -81,19 +81,31 @@ class KeygenPublisher extends electron_publish_1.HttpPublisher {
81
81
  }
82
82
  async getOrCreateRelease() {
83
83
  try {
84
+ // First, we'll attempt to fetch the release.
84
85
  return await this.getRelease();
85
86
  }
86
87
  catch (e) {
87
- if (e.statusCode === 404) {
88
- return this.createRelease();
88
+ if (e.statusCode !== 404) {
89
+ throw e;
90
+ }
91
+ try {
92
+ // Next, if the release doesn't exist, we'll attempt to create it.
93
+ return await this.createRelease();
94
+ }
95
+ catch (e) {
96
+ if (e.statusCode !== 409 && e.statusCode !== 422) {
97
+ throw e;
98
+ }
99
+ // Lastly, when a conflict occurs (in the case of parallel uploads),
100
+ // we'll try to fetch it one last time.
101
+ return this.getRelease();
89
102
  }
90
- throw e;
91
103
  }
92
104
  }
93
105
  async getRelease() {
94
106
  const req = {
95
107
  hostname: this.hostname,
96
- path: `${this.basePath}/releases/${this.version}`,
108
+ path: `${this.basePath}/releases/${this.version}?product=${this.info.product}`,
97
109
  headers: {
98
110
  Accept: "application/vnd.api+json",
99
111
  "Keygen-Version": "1.1",
@@ -1 +1 @@
1
- {"version":3,"file":"KeygenPublisher.js","sourceRoot":"","sources":["../../src/publish/KeygenPublisher.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AACpF,wEAAgE;AAEhE,uDAAgE;AAEhE,+DAAuF;AACvF,+CAAqD;AAyErD,MAAa,eAAgB,SAAQ,gCAAa;IAShD,YAAY,OAAuB,EAAE,IAAmB,EAAE,OAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAA;QATP,iBAAY,GAAG,QAAQ,CAAA;QACvB,aAAQ,GAAG,eAAe,CAAA;QAUjC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;QACtC,IAAI,8BAAe,CAAC,KAAK,CAAC,EAAE;YAC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paces } from \"builder-util\"\nimport { httpExecutor } from \"builder-util/out/nodeHttpExecutor\"\nimport { ClientRequest, RequestOptions } from \"http\"\nimport { HttpPublisher, PublishContext } from \"electron-publish\"\nimport { KeygenOptions } from \"builder-util-runtime/out/publishOptions\"\nimport { configureRequestOptions, HttpExecutor, parseJson } from \"builder-util-runtime\"\nimport { getCompleteExtname } from \"../util/filename\"\n\ntype RecursivePartial<T> = {\n [P in keyof T]?: RecursivePartial<T[P]>\n}\n\nexport interface KeygenError {\n title: string\n detail: string\n code: string\n}\n\nexport interface KeygenRelease {\n id: string\n type: \"releases\"\n attributes: {\n name: string | null\n description: string | null\n channel: \"stable\" | \"rc\" | \"beta\" | \"alpha\" | \"dev\"\n status: \"DRAFT\" | \"PUBLISHED\" | \"YANKED\"\n tag: string\n version: string\n semver: {\n major: number\n minor: number\n patch: number\n prerelease: string | null\n build: string | null\n }\n metadata: { [s: string]: any }\n created: string\n updated: string\n yanked: string | null\n }\n relationships: {\n account: {\n data: { type: \"accounts\"; id: string }\n }\n product: {\n data: { type: \"products\"; id: string }\n }\n }\n}\n\nexport interface KeygenArtifact {\n id: string\n type: \"artifacts\"\n attributes: {\n filename: string\n filetype: string | null\n filesize: number | null\n platform: string | null\n arch: string | null\n signature: string | null\n checksum: string | null\n status: \"WAITING\" | \"UPLOADED\" | \"FAILED\" | \"YANKED\"\n metadata: { [s: string]: any }\n created: string\n updated: string\n }\n relationships: {\n account: {\n data: { type: \"accounts\"; id: string }\n }\n release: {\n data: { type: \"releases\"; id: string }\n }\n }\n links: {\n redirect: string\n }\n}\n\nexport class KeygenPublisher extends HttpPublisher {\n readonly providerName = \"keygen\"\n readonly hostname = \"api.keygen.sh\"\n\n private readonly info: KeygenOptions\n private readonly auth: string\n private readonly version: string\n private readonly basePath: string\n\n constructor(context: PublishContext, info: KeygenOptions, version: string) {\n super(context)\n\n const token = process.env.KEYGEN_TOKEN\n if (isEmptyOrSpaces(token)) {\n throw new InvalidConfigurationError(`Keygen token is not set using env \"KEYGEN_TOKEN\" (see https://www.electron.build/configuration/publish#KeygenOptions)`)\n }\n\n this.info = info\n this.auth = `Bearer ${token.trim()}`\n this.version = version\n this.basePath = `/v1/accounts/${this.info.account}`\n }\n\n protected doUpload(\n fileName: string,\n _arch: Arch,\n dataLength: number,\n requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _file: string\n ): Promise<string> {\n return HttpExecutor.retryOnServerError(async () => {\n const { data, errors } = await this.getOrCreateRelease()\n if (errors) {\n throw new Error(`Keygen - Creating release returned errors: ${JSON.stringify(errors)}`)\n }\n\n await this.uploadArtifact(data!.id, fileName, dataLength, requestProcessor)\n\n return data!.id\n })\n }\n\n private async uploadArtifact(\n releaseId: any,\n fileName: string,\n dataLength: number,\n requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void\n ): Promise<void> {\n const { data, errors } = await this.createArtifact(releaseId, fileName, dataLength)\n if (errors) {\n throw new Error(`Keygen - Creating artifact returned errors: ${JSON.stringify(errors)}`)\n }\n\n // Follow the redirect and upload directly to S3-equivalent storage provider\n const url = new URL(data!.links.redirect)\n const upload: RequestOptions = {\n hostname: url.hostname,\n path: url.pathname + url.search,\n headers: {\n \"Content-Length\": dataLength,\n },\n }\n\n await httpExecutor.doApiRequest(configureRequestOptions(upload, null, \"PUT\"), this.context.cancellationToken, requestProcessor)\n }\n\n private async createArtifact(releaseId: any, fileName: string, dataLength: number): Promise<{ data?: KeygenArtifact; errors?: KeygenError[] }> {\n const upload: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/artifacts`,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\",\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n Prefer: \"no-redirect\",\n },\n }\n\n const data: RecursivePartial<KeygenArtifact> = {\n type: \"artifacts\",\n attributes: {\n filename: fileName,\n filetype: getCompleteExtname(fileName),\n filesize: dataLength,\n platform: this.info.platform,\n },\n relationships: {\n release: {\n data: {\n type: \"releases\",\n id: releaseId,\n },\n },\n },\n }\n\n log.debug({ data: JSON.stringify(data) }, \"Keygen create artifact\")\n\n return parseJson(httpExecutor.request(configureRequestOptions(upload, this.auth, \"POST\"), this.context.cancellationToken, { data }))\n }\n\n private async getOrCreateRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n try {\n return await this.getRelease()\n } catch (e) {\n if (e.statusCode === 404) {\n return this.createRelease()\n }\n\n throw e\n }\n }\n\n private async getRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases/${this.version}`,\n headers: {\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n\n return parseJson(httpExecutor.request(configureRequestOptions(req, this.auth, \"GET\"), this.context.cancellationToken, null))\n }\n\n private async createRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases`,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\",\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n\n const data: RecursivePartial<KeygenRelease> = {\n type: \"releases\",\n attributes: {\n version: this.version,\n channel: this.info.channel || \"stable\",\n status: \"PUBLISHED\",\n },\n relationships: {\n product: {\n data: {\n type: \"products\",\n id: this.info.product,\n },\n },\n },\n }\n\n log.debug({ data: JSON.stringify(data) }, \"Keygen create release\")\n\n return parseJson(httpExecutor.request(configureRequestOptions(req, this.auth, \"POST\"), this.context.cancellationToken, { data }))\n }\n\n async deleteRelease(releaseId: string): Promise<void> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases/${releaseId}`,\n headers: {\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n await httpExecutor.request(configureRequestOptions(req, this.auth, \"DELETE\"), this.context.cancellationToken)\n }\n\n toString() {\n const { account, product, platform } = this.info\n return `Keygen (account: ${account}, product: ${product}, platform: ${platform}, version: ${this.version})`\n }\n}\n"]}
1
+ {"version":3,"file":"KeygenPublisher.js","sourceRoot":"","sources":["../../src/publish/KeygenPublisher.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AACpF,wEAAgE;AAEhE,uDAAgE;AAEhE,+DAAuF;AACvF,+CAAqD;AAyErD,MAAa,eAAgB,SAAQ,gCAAa;IAShD,YAAY,OAAuB,EAAE,IAAmB,EAAE,OAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAA;QATP,iBAAY,GAAG,QAAQ,CAAA;QACvB,aAAQ,GAAG,eAAe,CAAA;QAUjC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;QACtC,IAAI,8BAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,MAAM,IAAI,wCAAyB,CAAC,uHAAuH,CAAC,CAAA;SAC7J;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,UAAU,KAAK,CAAC,IAAI,EAAE,EAAE,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,gBAAgB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IACrD,CAAC;IAES,QAAQ,CAChB,QAAgB,EAChB,KAAW,EACX,UAAkB,EAClB,gBAAkF;IAClF,6DAA6D;IAC7D,KAAa;QAEb,OAAO,mCAAY,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;YAChD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACxD,IAAI,MAAM,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;aACxF;YAED,MAAM,IAAI,CAAC,cAAc,C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C,OAAO,CAAC,8CAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACnI,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,SAAiB;QACnC,MAAM,GAAG,GAAmB;YAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,aAAa,SAAS,EAAE;YAC9C,OAAO,EAAE;gBACP,MAAM,EAAE,0BAA0B;gBAClC,gBAAgB,EAAE,KAAK;aACxB;SACF,CAAA;QACD,MAAM,+BAAY,CAAC,OAAO,CAAC,8CAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC/G,CAAC;IAED,QAAQ;QACN,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,IAAI,CAAA;QAChD,OAAO,oBAAoB,OAAO,cAAc,OAAO,eAAe,QAAQ,cAAc,IAAI,CAAC,OAAO,GAAG,CAAA;IAC7G,CAAC;CACF;AA5LD,0CA4LC","sourcesContent":["import { Arch, InvalidConfigurationError, log, isEmptyOrSpaces } from \"builder-util\"\nimport { httpExecutor } from \"builder-util/out/nodeHttpExecutor\"\nimport { ClientRequest, RequestOptions } from \"http\"\nimport { HttpPublisher, PublishContext } from \"electron-publish\"\nimport { KeygenOptions } from \"builder-util-runtime/out/publishOptions\"\nimport { configureRequestOptions, HttpExecutor, parseJson } from \"builder-util-runtime\"\nimport { getCompleteExtname } from \"../util/filename\"\n\ntype RecursivePartial<T> = {\n [P in keyof T]?: RecursivePartial<T[P]>\n}\n\nexport interface KeygenError {\n title: string\n detail: string\n code: string\n}\n\nexport interface KeygenRelease {\n id: string\n type: \"releases\"\n attributes: {\n name: string | null\n description: string | null\n channel: \"stable\" | \"rc\" | \"beta\" | \"alpha\" | \"dev\"\n status: \"DRAFT\" | \"PUBLISHED\" | \"YANKED\"\n tag: string\n version: string\n semver: {\n major: number\n minor: number\n patch: number\n prerelease: string | null\n build: string | null\n }\n metadata: { [s: string]: any }\n created: string\n updated: string\n yanked: string | null\n }\n relationships: {\n account: {\n data: { type: \"accounts\"; id: string }\n }\n product: {\n data: { type: \"products\"; id: string }\n }\n }\n}\n\nexport interface KeygenArtifact {\n id: string\n type: \"artifacts\"\n attributes: {\n filename: string\n filetype: string | null\n filesize: number | null\n platform: string | null\n arch: string | null\n signature: string | null\n checksum: string | null\n status: \"WAITING\" | \"UPLOADED\" | \"FAILED\" | \"YANKED\"\n metadata: { [s: string]: any }\n created: string\n updated: string\n }\n relationships: {\n account: {\n data: { type: \"accounts\"; id: string }\n }\n release: {\n data: { type: \"releases\"; id: string }\n }\n }\n links: {\n redirect: string\n }\n}\n\nexport class KeygenPublisher extends HttpPublisher {\n readonly providerName = \"keygen\"\n readonly hostname = \"api.keygen.sh\"\n\n private readonly info: KeygenOptions\n private readonly auth: string\n private readonly version: string\n private readonly basePath: string\n\n constructor(context: PublishContext, info: KeygenOptions, version: string) {\n super(context)\n\n const token = process.env.KEYGEN_TOKEN\n if (isEmptyOrSpaces(token)) {\n throw new InvalidConfigurationError(`Keygen token is not set using env \"KEYGEN_TOKEN\" (see https://www.electron.build/configuration/publish#KeygenOptions)`)\n }\n\n this.info = info\n this.auth = `Bearer ${token.trim()}`\n this.version = version\n this.basePath = `/v1/accounts/${this.info.account}`\n }\n\n protected doUpload(\n fileName: string,\n _arch: Arch,\n dataLength: number,\n requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _file: string\n ): Promise<string> {\n return HttpExecutor.retryOnServerError(async () => {\n const { data, errors } = await this.getOrCreateRelease()\n if (errors) {\n throw new Error(`Keygen - Creating release returned errors: ${JSON.stringify(errors)}`)\n }\n\n await this.uploadArtifact(data!.id, fileName, dataLength, requestProcessor)\n\n return data!.id\n })\n }\n\n private async uploadArtifact(\n releaseId: any,\n fileName: string,\n dataLength: number,\n requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void\n ): Promise<void> {\n const { data, errors } = await this.createArtifact(releaseId, fileName, dataLength)\n if (errors) {\n throw new Error(`Keygen - Creating artifact returned errors: ${JSON.stringify(errors)}`)\n }\n\n // Follow the redirect and upload directly to S3-equivalent storage provider\n const url = new URL(data!.links.redirect)\n const upload: RequestOptions = {\n hostname: url.hostname,\n path: url.pathname + url.search,\n headers: {\n \"Content-Length\": dataLength,\n },\n }\n\n await httpExecutor.doApiRequest(configureRequestOptions(upload, null, \"PUT\"), this.context.cancellationToken, requestProcessor)\n }\n\n private async createArtifact(releaseId: any, fileName: string, dataLength: number): Promise<{ data?: KeygenArtifact; errors?: KeygenError[] }> {\n const upload: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/artifacts`,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\",\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n Prefer: \"no-redirect\",\n },\n }\n\n const data: RecursivePartial<KeygenArtifact> = {\n type: \"artifacts\",\n attributes: {\n filename: fileName,\n filetype: getCompleteExtname(fileName),\n filesize: dataLength,\n platform: this.info.platform,\n },\n relationships: {\n release: {\n data: {\n type: \"releases\",\n id: releaseId,\n },\n },\n },\n }\n\n log.debug({ data: JSON.stringify(data) }, \"Keygen create artifact\")\n\n return parseJson(httpExecutor.request(configureRequestOptions(upload, this.auth, \"POST\"), this.context.cancellationToken, { data }))\n }\n\n private async getOrCreateRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n try {\n // First, we'll attempt to fetch the release.\n return await this.getRelease()\n } catch (e) {\n if (e.statusCode !== 404) {\n throw e\n }\n\n try {\n // Next, if the release doesn't exist, we'll attempt to create it.\n return await this.createRelease()\n } catch (e) {\n if (e.statusCode !== 409 && e.statusCode !== 422) {\n throw e\n }\n\n // Lastly, when a conflict occurs (in the case of parallel uploads),\n // we'll try to fetch it one last time.\n return this.getRelease()\n }\n }\n }\n\n private async getRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases/${this.version}?product=${this.info.product}`,\n headers: {\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n\n return parseJson(httpExecutor.request(configureRequestOptions(req, this.auth, \"GET\"), this.context.cancellationToken, null))\n }\n\n private async createRelease(): Promise<{ data?: KeygenRelease; errors?: KeygenError[] }> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases`,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\",\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n\n const data: RecursivePartial<KeygenRelease> = {\n type: \"releases\",\n attributes: {\n version: this.version,\n channel: this.info.channel || \"stable\",\n status: \"PUBLISHED\",\n },\n relationships: {\n product: {\n data: {\n type: \"products\",\n id: this.info.product,\n },\n },\n },\n }\n\n log.debug({ data: JSON.stringify(data) }, \"Keygen create release\")\n\n return parseJson(httpExecutor.request(configureRequestOptions(req, this.auth, \"POST\"), this.context.cancellationToken, { data }))\n }\n\n async deleteRelease(releaseId: string): Promise<void> {\n const req: RequestOptions = {\n hostname: this.hostname,\n path: `${this.basePath}/releases/${releaseId}`,\n headers: {\n Accept: \"application/vnd.api+json\",\n \"Keygen-Version\": \"1.1\",\n },\n }\n await httpExecutor.request(configureRequestOptions(req, this.auth, \"DELETE\"), this.context.cancellationToken)\n }\n\n toString() {\n const { account, product, platform } = this.info\n return `Keygen (account: ${account}, product: ${product}, platform: ${platform}, version: ${this.version})`\n }\n}\n"]}
package/out/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "23.3.0";
1
+ export declare const PACKAGE_VERSION = "23.3.1";
package/out/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = "23.3.0";
4
+ exports.PACKAGE_VERSION = "23.3.1";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"23.3.0\"\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"23.3.1\"\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "app-builder-lib",
3
3
  "description": "electron-builder lib",
4
- "version": "23.3.0",
4
+ "version": "23.3.1",
5
5
  "main": "out/index.js",
6
6
  "files": [
7
7
  "out",
@@ -103,8 +103,8 @@
103
103
  "@types/js-yaml": "4.0.3",
104
104
  "@types/semver": "7.3.8",
105
105
  "@types/tar": "^6.1.1",
106
- "dmg-builder": "23.3.0",
107
- "electron-builder-squirrel-windows": "23.3.0"
106
+ "dmg-builder": "23.3.1",
107
+ "electron-builder-squirrel-windows": "23.3.1"
108
108
  },
109
109
  "//": "electron-builder-squirrel-windows and dmg-builder added as dev dep for tests (as otherwise `require` doesn't work using Yarn 2)",
110
110
  "typings": "./out/index.d.ts"