app-builder-lib 25.0.0-alpha.1 → 25.0.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.
@@ -31,10 +31,16 @@ class AsarPackager {
31
31
  }
32
32
  await (0, promises_1.mkdir)(path.dirname(this.outFile), { recursive: true });
33
33
  const unpackedFileIndexMap = new Map();
34
- for (const fileSet of fileSets) {
34
+ const orderedFileSets = [
35
+ // Write dependencies first to minimize offset changes to asar header
36
+ ...fileSets.slice(1),
37
+ // Finish with the app files that change most often
38
+ fileSets[0],
39
+ ].map(orderFileSet);
40
+ for (const fileSet of orderedFileSets) {
35
41
  unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info));
36
42
  }
37
- await this.writeAsarFile(fileSets, unpackedFileIndexMap);
43
+ await this.writeAsarFile(orderedFileSets, unpackedFileIndexMap);
38
44
  }
39
45
  async createPackageFromFiles(fileSet, packager) {
40
46
  const metadata = fileSet.metadata;
@@ -238,4 +244,47 @@ function copyFileOrData(fileCopier, data, source, destination, stats) {
238
244
  return (0, promises_1.writeFile)(destination, data);
239
245
  }
240
246
  }
247
+ function orderFileSet(fileSet) {
248
+ const sortedFileEntries = Array.from(fileSet.files.entries());
249
+ sortedFileEntries.sort(([, a], [, b]) => {
250
+ if (a === b) {
251
+ return 0;
252
+ }
253
+ // Place addons last because their signature change
254
+ const isAAddon = a.endsWith(".node");
255
+ const isBAddon = b.endsWith(".node");
256
+ if (isAAddon && !isBAddon) {
257
+ return 1;
258
+ }
259
+ if (isBAddon && !isAAddon) {
260
+ return -1;
261
+ }
262
+ // Otherwise order by name
263
+ return a < b ? -1 : 1;
264
+ });
265
+ let transformedFiles;
266
+ if (fileSet.transformedFiles) {
267
+ transformedFiles = new Map();
268
+ const indexMap = new Map();
269
+ for (const [newIndex, [oldIndex]] of sortedFileEntries.entries()) {
270
+ indexMap.set(oldIndex, newIndex);
271
+ }
272
+ for (const [oldIndex, value] of fileSet.transformedFiles) {
273
+ const newIndex = indexMap.get(oldIndex);
274
+ if (newIndex === undefined) {
275
+ const file = fileSet.files[oldIndex];
276
+ throw new Error(`Internal error: ${file} was lost while ordering asar`);
277
+ }
278
+ transformedFiles.set(newIndex, value);
279
+ }
280
+ }
281
+ const { src, destination, metadata } = fileSet;
282
+ return {
283
+ src,
284
+ destination,
285
+ metadata,
286
+ files: sortedFileEntries.map(([, file]) => file),
287
+ transformedFiles,
288
+ };
289
+ }
241
290
  //# sourceMappingURL=asarUtil.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asarUtil.js","sourceRoot":"","sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AACpD,4CAA2E;AAC3E,2BAAwE;AACxE,0CAAwD;AACxD,6BAA4B;AAI5B,yDAA2E;AAC3E,iCAA6C;AAC7C,2CAAwD;AACxD,qDAAqD;AAErD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE5C,gBAAgB;AAChB,MAAa,YAAY;IAKvB,YACmB,GAAW,EACX,WAAmB,EACnB,OAAoB,EACpB,aAA4B;QAH5B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAe;QAR9B,OAAE,GAAG,IAAI,qBAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAUhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACjD,IAAI,CAAC,YAAY,GAAG,GAAG,IAAI,CAAC,OAAO,WAAW,CAAA;IAChD,CAAC;IAED,kGAAkG;IAClG,KAAK,CAAC,IAAI,CAAC,QAAgC,EAAE,QAA+B;QAC1E,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAClC,kHAAkH;YAClH,MAAM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9C,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAkB,EAAE,CAAA;IACrC,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAA;IAC9B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACtB,OAAO,IAAI,CAAC,CAAA;QACd,CAAC;IACH,CAAC;IACD,kBAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,EAAE,EAAE,gCAAgC,CAAC,CAAA;IAC3F,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,UAAsB,EAAE,IAAwC,EAAE,MAAc,EAAE,WAAmB,EAAE,KAAY;IACzI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;SAAM,CAAC;QACN,OAAO,IAAA,oBAAS,EAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;AACH,CAAC","sourcesContent":["import { AsyncTaskManager, log } from \"builder-util\"\nimport { FileCopier, Filter, MAX_FILE_REQUESTS } from \"builder-util/out/fs\"\nimport { symlink, createReadStream, createWriteStream, Stats } from \"fs\"\nimport { writeFile, readFile, mkdir } from \"fs/promises\"\nimport * as path from \"path\"\nimport { AsarOptions } from \"../options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"../packager\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { getDestinationPath, ResolvedFileSet } from \"../util/appFileCopier\"\nimport { AsarFilesystem, Node } from \"./asar\"\nimport { hashFile, hashFileContents } from \"./integrity\"\nimport { detectUnpackedDirs } from \"./unpackDetector\"\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pickle = require(\"chromium-pickle-js\")\n\n/** @internal */\nexport class AsarPackager {\n private readonly fs = new AsarFilesystem(this.src)\n private readonly outFile: string\n private readonly unpackedDest: string\n\n constructor(\n private readonly src: string,\n private readonly destination: string,\n private readonly options: AsarOptions,\n private readonly unpackPattern: Filter | null\n ) {\n this.outFile = path.join(destination, \"app.asar\")\n this.unpackedDest = `${this.outFile}.unpacked`\n }\n\n // sort files to minimize file change (i.e. asar file is not changed dramatically on small change)\n async pack(fileSets: Array<ResolvedFileSet>, packager: PlatformPackager<any>) {\n if (this.options.ordering != null) {\n // ordering doesn't support transformed files, but ordering is not used functionality - wait user report to fix it\n await order(fileSets[0].files, this.options.ordering, fileSets[0].src)\n }\n await mkdir(path.dirname(this.outFile), { recursive: true })\n const unpackedFileIndexMap = new Map<ResolvedFileSet, Set<number>>()\n for (const fileSet of fileSets) {\n unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info))\n }\n await this.writeAsarFile(fileSets, unpackedFileIndexMap)\n }\n\n private async createPackageFromFiles(fileSet: ResolvedFileSet, packager: Packager) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const unpackedDirs = new Set<string>()\n const rootForAppFilesWithoutAsar = path.join(this.destination, \"app\")\n\n if (this.options.smartUnpack !== false) {\n await detectUnpackedDirs(fileSet, unpackedDirs, this.unpackedDest, rootForAppFilesWithoutAsar)\n }\n\n const dirToCreateForUnpackedFiles = new Set<string>(unpackedDirs)\n\n const correctDirNodeUnpackedFlag = async (filePathInArchive: string, dirNode: Node) => {\n for (const dir of unpackedDirs) {\n if (filePathInArchive.length > dir.length + 2 && filePathInArchive[dir.length] === path.sep && filePathInArchive.startsWith(dir)) {\n dirNode.unpacked = true\n unpackedDirs.add(filePathInArchive)\n // not all dirs marked as unpacked after first iteration - because node module dir can be marked as unpacked after processing node module dir content\n // e.g. node-notifier/example/advanced.js processed, but only on process vendor/terminal-notifier.app module will be marked as unpacked\n await mkdir(path.join(this.unpackedDest, filePathInArchive), { recursive: true })\n break\n }\n }\n }\n\n const transformedFiles = fileSet.transformedFiles\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const fileCopier = new FileCopier()\n\n let currentDirNode: Node | null = null\n let currentDirPath: string | null = null\n\n const unpackedFileIndexSet = new Set<number>()\n\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const file = fileSet.files[i]\n const stat = metadata.get(file)\n if (stat == null) {\n continue\n }\n\n const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet))\n\n if (stat.isSymbolicLink()) {\n const s = stat as any\n this.fs.getOrCreateNode(pathInArchive).link = s.relativeLink\n s.pathInArchive = pathInArchive\n unpackedFileIndexSet.add(i)\n continue\n }\n\n let fileParent = path.dirname(pathInArchive)\n if (fileParent === \".\") {\n fileParent = \"\"\n }\n\n if (currentDirPath !== fileParent) {\n if (fileParent.startsWith(\"..\")) {\n throw new Error(`Internal error: path must not start with \"..\": ${fileParent}`)\n }\n\n currentDirPath = fileParent\n currentDirNode = this.fs.getOrCreateNode(fileParent)\n // do not check for root\n if (fileParent !== \"\" && !currentDirNode.unpacked) {\n if (unpackedDirs.has(fileParent)) {\n currentDirNode.unpacked = true\n } else {\n await correctDirNodeUnpackedFlag(fileParent, currentDirNode)\n }\n }\n }\n\n const dirNode = currentDirNode!\n const newData = transformedFiles == null ? undefined : transformedFiles.get(i)\n const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat))\n const integrity = newData === undefined ? await hashFile(file) : hashFileContents(newData)\n this.fs.addFileNode(file, dirNode, newData == undefined ? stat.size : Buffer.byteLength(newData), isUnpacked, stat, integrity)\n if (isUnpacked) {\n if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) {\n dirToCreateForUnpackedFiles.add(fileParent)\n await mkdir(path.join(this.unpackedDest, fileParent), { recursive: true })\n }\n\n const unpackedFile = path.join(this.unpackedDest, pathInArchive)\n taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n\n unpackedFileIndexSet.add(i)\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n return unpackedFileIndexSet\n }\n\n private writeAsarFile(fileSets: Array<ResolvedFileSet>, unpackedFileIndexMap: Map<ResolvedFileSet, Set<number>>): Promise<any> {\n return new Promise((resolve, reject) => {\n const headerPickle = pickle.createEmpty()\n headerPickle.writeString(JSON.stringify(this.fs.header))\n const headerBuf = headerPickle.toBuffer()\n\n const sizePickle = pickle.createEmpty()\n sizePickle.writeUInt32(headerBuf.length)\n\n const sizeBuf = sizePickle.toBuffer()\n const writeStream = createWriteStream(this.outFile)\n writeStream.on(\"error\", reject)\n writeStream.on(\"close\", resolve)\n writeStream.write(sizeBuf)\n\n let fileSetIndex = 0\n\n let files = fileSets[0].files\n let metadata = fileSets[0].metadata\n let transformedFiles = fileSets[0].transformedFiles\n let unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[0])!\n const w = (index: number) => {\n while (true) {\n if (index >= files.length) {\n if (++fileSetIndex >= fileSets.length) {\n writeStream.end()\n return\n } else {\n files = fileSets[fileSetIndex].files\n metadata = fileSets[fileSetIndex].metadata\n transformedFiles = fileSets[fileSetIndex].transformedFiles\n unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[fileSetIndex])!\n index = 0\n }\n }\n\n if (!unpackedFileIndexSet.has(index)) {\n break\n } else {\n const stat = metadata.get(files[index])\n if (stat != null && stat.isSymbolicLink()) {\n symlink((stat as any).linkRelativeToFile, path.join(this.unpackedDest, (stat as any).pathInArchive), () => w(index + 1))\n return\n }\n }\n index++\n }\n\n const data = transformedFiles == null ? null : transformedFiles.get(index)\n const file = files[index]\n if (data !== null && data !== undefined) {\n writeStream.write(data, () => w(index + 1))\n return\n }\n\n // https://github.com/yarnpkg/yarn/pull/3539\n const stat = metadata.get(file)\n if (stat != null && stat.size < 2 * 1024 * 1024) {\n readFile(file)\n .then(it => {\n writeStream.write(it, () => w(index + 1))\n })\n .catch((e: any) => reject(`Cannot read file ${file}: ${e.stack || e}`))\n } else {\n const readStream = createReadStream(file)\n readStream.on(\"error\", reject)\n readStream.once(\"end\", () => w(index + 1))\n readStream.on(\"open\", () => {\n readStream.pipe(writeStream, {\n end: false,\n })\n })\n }\n }\n\n writeStream.write(headerBuf, () => w(0))\n })\n }\n}\n\nasync function order(filenames: Array<string>, orderingFile: string, src: string) {\n const orderingFiles = (await readFile(orderingFile, \"utf8\")).split(\"\\n\").map(line => {\n if (line.indexOf(\":\") !== -1) {\n line = line.split(\":\").pop()!\n }\n line = line.trim()\n if (line[0] === \"/\") {\n line = line.slice(1)\n }\n return line\n })\n\n const ordering: Array<string> = []\n for (const file of orderingFiles) {\n const pathComponents = file.split(path.sep)\n for (const pathComponent of pathComponents) {\n ordering.push(path.join(src, pathComponent))\n }\n }\n\n const sortedFiles: Array<string> = []\n let missing = 0\n const total = filenames.length\n for (const file of ordering) {\n if (!sortedFiles.includes(file) && filenames.includes(file)) {\n sortedFiles.push(file)\n }\n }\n for (const file of filenames) {\n if (!sortedFiles.includes(file)) {\n sortedFiles.push(file)\n missing += 1\n }\n }\n log.info({ coverage: ((total - missing) / total) * 100 }, \"ordering files in ASAR archive\")\n return sortedFiles\n}\n\nfunction copyFileOrData(fileCopier: FileCopier, data: string | Buffer | undefined | null, source: string, destination: string, stats: Stats) {\n if (data == null) {\n return fileCopier.copy(source, destination, stats)\n } else {\n return writeFile(destination, data)\n }\n}\n"]}
1
+ {"version":3,"file":"asarUtil.js","sourceRoot":"","sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AACpD,4CAA2E;AAC3E,2BAAwE;AACxE,0CAAwD;AACxD,6BAA4B;AAI5B,yDAA2E;AAC3E,iCAA6C;AAC7C,2CAAwD;AACxD,qDAAqD;AAErD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE5C,gBAAgB;AAChB,MAAa,YAAY;IAKvB,YACmB,GAAW,EACX,WAAmB,EACnB,OAAoB,EACpB,aAA4B;QAH5B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAe;QAR9B,OAAE,GAAG,IAAI,qBAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAUhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACjD,IAAI,CAAC,YAAY,GAAG,GAAG,IAAI,CAAC,OAAO,WAAW,CAAA;IAChD,CAAC;IAED,kGAAkG;IAClG,KAAK,CAAC,IAAI,CAAC,QAAgC,EAAE,QAA+B;QAC1E,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAClC,kHAAkH;YAClH,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,IAAA,gBAAK,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC5D,MAAM,oBA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Q,EAAE,KAAK,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAE9C,OAAO;QACL,GAAG;QACH,WAAW;QACX,QAAQ;QACR,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;QAChD,gBAAgB;KACjB,CAAA;AACH,CAAC","sourcesContent":["import { AsyncTaskManager, log } from \"builder-util\"\nimport { FileCopier, Filter, MAX_FILE_REQUESTS } from \"builder-util/out/fs\"\nimport { symlink, createReadStream, createWriteStream, Stats } from \"fs\"\nimport { writeFile, readFile, mkdir } from \"fs/promises\"\nimport * as path from \"path\"\nimport { AsarOptions } from \"../options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"../packager\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { getDestinationPath, ResolvedFileSet } from \"../util/appFileCopier\"\nimport { AsarFilesystem, Node } from \"./asar\"\nimport { hashFile, hashFileContents } from \"./integrity\"\nimport { detectUnpackedDirs } from \"./unpackDetector\"\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pickle = require(\"chromium-pickle-js\")\n\n/** @internal */\nexport class AsarPackager {\n private readonly fs = new AsarFilesystem(this.src)\n private readonly outFile: string\n private readonly unpackedDest: string\n\n constructor(\n private readonly src: string,\n private readonly destination: string,\n private readonly options: AsarOptions,\n private readonly unpackPattern: Filter | null\n ) {\n this.outFile = path.join(destination, \"app.asar\")\n this.unpackedDest = `${this.outFile}.unpacked`\n }\n\n // sort files to minimize file change (i.e. asar file is not changed dramatically on small change)\n async pack(fileSets: Array<ResolvedFileSet>, packager: PlatformPackager<any>) {\n if (this.options.ordering != null) {\n // ordering doesn't support transformed files, but ordering is not used functionality - wait user report to fix it\n await order(fileSets[0].files, this.options.ordering, fileSets[0].src)\n }\n await mkdir(path.dirname(this.outFile), { recursive: true })\n const unpackedFileIndexMap = new Map<ResolvedFileSet, Set<number>>()\n const orderedFileSets = [\n // Write dependencies first to minimize offset changes to asar header\n ...fileSets.slice(1),\n\n // Finish with the app files that change most often\n fileSets[0],\n ].map(orderFileSet)\n\n for (const fileSet of orderedFileSets) {\n unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info))\n }\n await this.writeAsarFile(orderedFileSets, unpackedFileIndexMap)\n }\n\n private async createPackageFromFiles(fileSet: ResolvedFileSet, packager: Packager) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const unpackedDirs = new Set<string>()\n const rootForAppFilesWithoutAsar = path.join(this.destination, \"app\")\n\n if (this.options.smartUnpack !== false) {\n await detectUnpackedDirs(fileSet, unpackedDirs, this.unpackedDest, rootForAppFilesWithoutAsar)\n }\n\n const dirToCreateForUnpackedFiles = new Set<string>(unpackedDirs)\n\n const correctDirNodeUnpackedFlag = async (filePathInArchive: string, dirNode: Node) => {\n for (const dir of unpackedDirs) {\n if (filePathInArchive.length > dir.length + 2 && filePathInArchive[dir.length] === path.sep && filePathInArchive.startsWith(dir)) {\n dirNode.unpacked = true\n unpackedDirs.add(filePathInArchive)\n // not all dirs marked as unpacked after first iteration - because node module dir can be marked as unpacked after processing node module dir content\n // e.g. node-notifier/example/advanced.js processed, but only on process vendor/terminal-notifier.app module will be marked as unpacked\n await mkdir(path.join(this.unpackedDest, filePathInArchive), { recursive: true })\n break\n }\n }\n }\n\n const transformedFiles = fileSet.transformedFiles\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const fileCopier = new FileCopier()\n\n let currentDirNode: Node | null = null\n let currentDirPath: string | null = null\n\n const unpackedFileIndexSet = new Set<number>()\n\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const file = fileSet.files[i]\n const stat = metadata.get(file)\n if (stat == null) {\n continue\n }\n\n const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet))\n\n if (stat.isSymbolicLink()) {\n const s = stat as any\n this.fs.getOrCreateNode(pathInArchive).link = s.relativeLink\n s.pathInArchive = pathInArchive\n unpackedFileIndexSet.add(i)\n continue\n }\n\n let fileParent = path.dirname(pathInArchive)\n if (fileParent === \".\") {\n fileParent = \"\"\n }\n\n if (currentDirPath !== fileParent) {\n if (fileParent.startsWith(\"..\")) {\n throw new Error(`Internal error: path must not start with \"..\": ${fileParent}`)\n }\n\n currentDirPath = fileParent\n currentDirNode = this.fs.getOrCreateNode(fileParent)\n // do not check for root\n if (fileParent !== \"\" && !currentDirNode.unpacked) {\n if (unpackedDirs.has(fileParent)) {\n currentDirNode.unpacked = true\n } else {\n await correctDirNodeUnpackedFlag(fileParent, currentDirNode)\n }\n }\n }\n\n const dirNode = currentDirNode!\n const newData = transformedFiles == null ? undefined : transformedFiles.get(i)\n const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat))\n const integrity = newData === undefined ? await hashFile(file) : hashFileContents(newData)\n this.fs.addFileNode(file, dirNode, newData == undefined ? stat.size : Buffer.byteLength(newData), isUnpacked, stat, integrity)\n if (isUnpacked) {\n if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) {\n dirToCreateForUnpackedFiles.add(fileParent)\n await mkdir(path.join(this.unpackedDest, fileParent), { recursive: true })\n }\n\n const unpackedFile = path.join(this.unpackedDest, pathInArchive)\n taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n\n unpackedFileIndexSet.add(i)\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n return unpackedFileIndexSet\n }\n\n private writeAsarFile(fileSets: Array<ResolvedFileSet>, unpackedFileIndexMap: Map<ResolvedFileSet, Set<number>>): Promise<any> {\n return new Promise((resolve, reject) => {\n const headerPickle = pickle.createEmpty()\n headerPickle.writeString(JSON.stringify(this.fs.header))\n const headerBuf = headerPickle.toBuffer()\n\n const sizePickle = pickle.createEmpty()\n sizePickle.writeUInt32(headerBuf.length)\n\n const sizeBuf = sizePickle.toBuffer()\n const writeStream = createWriteStream(this.outFile)\n writeStream.on(\"error\", reject)\n writeStream.on(\"close\", resolve)\n writeStream.write(sizeBuf)\n\n let fileSetIndex = 0\n\n let files = fileSets[0].files\n let metadata = fileSets[0].metadata\n let transformedFiles = fileSets[0].transformedFiles\n let unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[0])!\n const w = (index: number) => {\n while (true) {\n if (index >= files.length) {\n if (++fileSetIndex >= fileSets.length) {\n writeStream.end()\n return\n } else {\n files = fileSets[fileSetIndex].files\n metadata = fileSets[fileSetIndex].metadata\n transformedFiles = fileSets[fileSetIndex].transformedFiles\n unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[fileSetIndex])!\n index = 0\n }\n }\n\n if (!unpackedFileIndexSet.has(index)) {\n break\n } else {\n const stat = metadata.get(files[index])\n if (stat != null && stat.isSymbolicLink()) {\n symlink((stat as any).linkRelativeToFile, path.join(this.unpackedDest, (stat as any).pathInArchive), () => w(index + 1))\n return\n }\n }\n index++\n }\n\n const data = transformedFiles == null ? null : transformedFiles.get(index)\n const file = files[index]\n if (data !== null && data !== undefined) {\n writeStream.write(data, () => w(index + 1))\n return\n }\n\n // https://github.com/yarnpkg/yarn/pull/3539\n const stat = metadata.get(file)\n if (stat != null && stat.size < 2 * 1024 * 1024) {\n readFile(file)\n .then(it => {\n writeStream.write(it, () => w(index + 1))\n })\n .catch((e: any) => reject(`Cannot read file ${file}: ${e.stack || e}`))\n } else {\n const readStream = createReadStream(file)\n readStream.on(\"error\", reject)\n readStream.once(\"end\", () => w(index + 1))\n readStream.on(\"open\", () => {\n readStream.pipe(writeStream, {\n end: false,\n })\n })\n }\n }\n\n writeStream.write(headerBuf, () => w(0))\n })\n }\n}\n\nasync function order(filenames: Array<string>, orderingFile: string, src: string) {\n const orderingFiles = (await readFile(orderingFile, \"utf8\")).split(\"\\n\").map(line => {\n if (line.indexOf(\":\") !== -1) {\n line = line.split(\":\").pop()!\n }\n line = line.trim()\n if (line[0] === \"/\") {\n line = line.slice(1)\n }\n return line\n })\n\n const ordering: Array<string> = []\n for (const file of orderingFiles) {\n const pathComponents = file.split(path.sep)\n for (const pathComponent of pathComponents) {\n ordering.push(path.join(src, pathComponent))\n }\n }\n\n const sortedFiles: Array<string> = []\n let missing = 0\n const total = filenames.length\n for (const file of ordering) {\n if (!sortedFiles.includes(file) && filenames.includes(file)) {\n sortedFiles.push(file)\n }\n }\n for (const file of filenames) {\n if (!sortedFiles.includes(file)) {\n sortedFiles.push(file)\n missing += 1\n }\n }\n log.info({ coverage: ((total - missing) / total) * 100 }, \"ordering files in ASAR archive\")\n return sortedFiles\n}\n\nfunction copyFileOrData(fileCopier: FileCopier, data: string | Buffer | undefined | null, source: string, destination: string, stats: Stats) {\n if (data == null) {\n return fileCopier.copy(source, destination, stats)\n } else {\n return writeFile(destination, data)\n }\n}\n\nfunction orderFileSet(fileSet: ResolvedFileSet): ResolvedFileSet {\n const sortedFileEntries = Array.from(fileSet.files.entries())\n\n sortedFileEntries.sort(([, a], [, b]) => {\n if (a === b) {\n return 0\n }\n\n // Place addons last because their signature change\n const isAAddon = a.endsWith(\".node\")\n const isBAddon = b.endsWith(\".node\")\n if (isAAddon && !isBAddon) {\n return 1\n }\n if (isBAddon && !isAAddon) {\n return -1\n }\n\n // Otherwise order by name\n return a < b ? -1 : 1\n })\n\n let transformedFiles: Map<number, string | Buffer> | undefined\n if (fileSet.transformedFiles) {\n transformedFiles = new Map()\n\n const indexMap = new Map<number, number>()\n for (const [newIndex, [oldIndex]] of sortedFileEntries.entries()) {\n indexMap.set(oldIndex, newIndex)\n }\n\n for (const [oldIndex, value] of fileSet.transformedFiles) {\n const newIndex = indexMap.get(oldIndex)\n if (newIndex === undefined) {\n const file = fileSet.files[oldIndex]\n throw new Error(`Internal error: ${file} was lost while ordering asar`)\n }\n\n transformedFiles.set(newIndex, value)\n }\n }\n\n const { src, destination, metadata } = fileSet\n\n return {\n src,\n destination,\n metadata,\n files: sortedFileEntries.map(([, file]) => file),\n transformedFiles,\n }\n}\n"]}
@@ -122,7 +122,7 @@ export interface Configuration extends PlatformSpecificBuildOptions {
122
122
  */
123
123
  readonly npmRebuild?: boolean;
124
124
  /**
125
- * Use `legacy` app-builder binary for installing native dependencies, or @electron/rebuild in `sequential` or `parallel` compilation modes.
125
+ * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.
126
126
  * @default legacy
127
127
  */
128
128
  readonly nativeRebuilder?: "legacy" | "sequential" | "parallel" | null;
@@ -249,6 +249,11 @@ export interface Configuration extends PlatformSpecificBuildOptions {
249
249
  * @default true
250
250
  */
251
251
  readonly removePackageKeywords?: boolean;
252
+ /**
253
+ * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
254
+ * @default false
255
+ */
256
+ readonly disableSanityCheckAsar?: boolean;
252
257
  }
253
258
  interface PackContext {
254
259
  readonly outDir: string;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface Configuration extends PlatformSpecificBuildOptions {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n readonly directories?: MetadataDirectories | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to include *all* of the submodules node_modules directories\n * @default false\n */\n includeSubNodeModules?: boolean\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or @electron/rebuild in `sequential` or `parallel` compilation modes.\n * @default legacy\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string)\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * The function (or path to file or module id) to be [run before pack](#beforepack)\n */\n readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n */\n readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n */\n readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n */\n readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n */\n readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).\n */\n readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null\n /**\n * MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: ((path: string) => void | boolean) | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n}\n\ninterface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](/file-patterns#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface Configuration extends PlatformSpecificBuildOptions {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n readonly directories?: MetadataDirectories | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to include *all* of the submodules node_modules directories\n * @default false\n */\n includeSubNodeModules?: boolean\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.\n * @default legacy\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string)\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * The function (or path to file or module id) to be [run before pack](#beforepack)\n */\n readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n */\n readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n */\n readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n */\n readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n */\n readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).\n */\n readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null\n /**\n * MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: ((path: string) => void | boolean) | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n\n /**\n * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)\n * @default false\n */\n readonly disableSanityCheckAsar?: boolean\n}\n\ninterface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](/file-patterns#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n"]}
@@ -19,4 +19,8 @@ export interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetS
19
19
  * Any additional arguments to be passed to the WiX installer compiler, such as `["-ext", "WixUtilExtension"]`
20
20
  */
21
21
  readonly additionalWixArgs?: Array<string> | null;
22
+ /**
23
+ * Any additional arguments to be passed to the light.ext, such as `["-cultures:ja-jp"]`
24
+ */
25
+ readonly additionalLightArgs?: Array<string> | null;
22
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MsiOptions.js","sourceRoot":"","sources":["../../src/options/MsiOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetSpecificOptions } from \"../core\"\nimport { CommonWindowsInstallerConfiguration } from \"./CommonWindowsInstallerConfiguration\"\n\nexport interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetSpecificOptions {\n /**\n * One-click installation.\n * @default true\n */\n readonly oneClick?: boolean\n\n /**\n * The [upgrade code](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx). Optional, by default generated using app id.\n */\n readonly upgradeCode?: string | null\n\n /**\n * If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings.\n * @default true\n */\n readonly warningsAsErrors?: boolean\n\n /**\n * Any additional arguments to be passed to the WiX installer compiler, such as `[\"-ext\", \"WixUtilExtension\"]`\n */\n readonly additionalWixArgs?: Array<string> | null\n}\n"]}
1
+ {"version":3,"file":"MsiOptions.js","sourceRoot":"","sources":["../../src/options/MsiOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetSpecificOptions } from \"../core\"\nimport { CommonWindowsInstallerConfiguration } from \"./CommonWindowsInstallerConfiguration\"\n\nexport interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetSpecificOptions {\n /**\n * One-click installation.\n * @default true\n */\n readonly oneClick?: boolean\n\n /**\n * The [upgrade code](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx). Optional, by default generated using app id.\n */\n readonly upgradeCode?: string | null\n\n /**\n * If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings.\n * @default true\n */\n readonly warningsAsErrors?: boolean\n\n /**\n * Any additional arguments to be passed to the WiX installer compiler, such as `[\"-ext\", \"WixUtilExtension\"]`\n */\n readonly additionalWixArgs?: Array<string> | null\n\n /**\n * Any additional arguments to be passed to the light.ext, such as `[\"-cultures:ja-jp\"]`\n */\n readonly additionalLightArgs?: Array<string> | null\n}\n"]}
@@ -127,17 +127,17 @@ export interface MacConfiguration extends PlatformSpecificBuildOptions {
127
127
  */
128
128
  readonly hardenedRuntime?: boolean;
129
129
  /**
130
- * Whether to let @electron/osx-sign validate the signing or not.
130
+ * Whether to let `@electron/osx-sign` validate the signing or not.
131
131
  * @default false
132
132
  */
133
133
  readonly gatekeeperAssess?: boolean;
134
134
  /**
135
- * Whether to let @electron/osx-sign verify the contents or not.
135
+ * Whether to let `@electron/osx-sign` verify the contents or not.
136
136
  * @default true
137
137
  */
138
138
  readonly strictVerify?: boolean;
139
139
  /**
140
- * Whether to enable entitlements automation from @electron/osx-sign.
140
+ * Whether to enable entitlements automation from `@electron/osx-sign`.
141
141
  * @default true
142
142
  */
143
143
  readonly preAutoEntitlements?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"macOptions.js","sourceRoot":"","sources":["../../src/options/macOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { PlatformSpecificBuildOptions, TargetConfiguration, TargetSpecificOptions } from \"../index\"\nimport { CustomMacSign } from \"../macPackager\"\n\nexport type MacOsTargetName = \"default\" | \"dmg\" | \"mas\" | \"mas-dev\" | \"pkg\" | \"7z\" | \"zip\" | \"tar.xz\" | \"tar.lz\" | \"tar.gz\" | \"tar.bz2\" | \"dir\"\n\nexport interface MacConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.\n *\n * For example, `\"category\": \"public.app-category.developer-tools\"` will set the application category to *Developer Tools*.\n *\n * Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).\n */\n readonly category?: string | null\n\n /**\n * The target package type: list of `default`, `dmg`, `mas`, `mas-dev`, `pkg`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `default` (`dmg` and `zip` for Squirrel.Mac). Note: Squirrel.Mac auto update mechanism requires both `dmg` and `zip` to be enabled, even when only `dmg` is used. Disabling `zip` will break auto update in `dmg` packages.\n */\n readonly target?: Array<MacOsTargetName | TargetConfiguration> | MacOsTargetName | TargetConfiguration | null\n\n /**\n * The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](/code-signing) instead of specifying this option.\n * MAS installer identity is specified in the [mas](/configuration/mas).\n */\n readonly identity?: string | null\n\n /**\n * The path to application icon.\n * @default build/icon.icns\n */\n readonly icon?: string | null\n\n /**\n * The path to entitlements file for signing the app. `build/entitlements.mac.plist` will be used if exists (it is a recommended way to set).\n * MAS entitlements is specified in the [mas](/configuration/mas).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n * Be aware that your app may crash if the right entitlements are not set like `com.apple.security.cs.allow-jit` for example on arm64 builds with Electron 20+.\n * See [Signing and Notarizing macOS Builds from the Electron documentation](https://www.electronjs.org/docs/latest/tutorial/code-signing#signing--notarizing-macos-builds) for more information.\n */\n readonly entitlements?: string | null\n\n /**\n * The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mac.inherit.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n *\n * This option only applies when signing with `entitlements` provided.\n */\n readonly entitlementsInherit?: string | null\n\n /**\n * Path to login helper entitlement file.\n * When using App Sandbox, the the `com.apple.security.inherit` key that is normally in the inherited entitlements cannot be inherited since the login helper is a standalone executable.\n * Defaults to the value provided for `entitlements`. This option only applies when signing with `entitlements` provided.\n */\n readonly entitlementsLoginHelper?: string | null\n\n /**\n * The path to the provisioning profile to use when signing, absolute or relative to the app root.\n */\n readonly provisioningProfile?: string | null\n\n /**\n * The `CFBundleVersion`. Do not use it unless [you need to](https://github.com/electron-userland/electron-builder/issues/565#issuecomment-230678643).\n */\n readonly bundleVersion?: string | null\n\n /**\n * The `CFBundleShortVersionString`. Do not use it unless you need to.\n */\n readonly bundleShortVersion?: string | null\n\n /**\n * Whether a dark mode is supported. If your app does have a dark mode, you can make your app follow the system-wide dark mode setting.\n * @default false\n */\n readonly darkModeSupport?: boolean\n\n /**\n * The bundle identifier to use in the application helper's plist.\n * @default ${appBundleIdentifier}.helper\n */\n readonly helperBundleId?: string | null\n\n /**\n * The bundle identifier to use in the Renderer helper's plist.\n * @default ${appBundleIdentifier}.helper.Renderer\n */\n readonly helperRendererBundleId?: string | null\n\n /**\n * The bundle identifier to use in the Plugin helper's plist.\n * @default ${appBundleIdentifier}.helper.Plugin\n */\n readonly helperPluginBundleId?: string | null\n\n /**\n * The bundle identifier to use in the GPU helper's plist.\n * @default ${appBundleIdentifier}.helper.GPU\n */\n readonly helperGPUBundleId?: string | null\n\n /**\n * The bundle identifier to use in the EH helper's plist.\n * @default ${appBundleIdentifier}.helper.EH\n */\n readonly helperEHBundleId?: string | null\n\n /**\n * The bundle identifier to use in the NP helper's plist.\n * @default ${appBundleIdentifier}.helper.NP\n */\n readonly helperNPBundleId?: string | null\n\n /**\n * Whether to sign app for development or for distribution.\n * @default distribution\n */\n readonly type?: \"distribution\" | \"development\" | null\n\n /**\n * The extra entries for `Info.plist`.\n */\n readonly extendInfo?: any\n\n /**\n * Paths of any extra binaries that need to be signed.\n */\n readonly binaries?: Array<string> | null\n\n /**\n * The minimum version of macOS required for the app to run. Corresponds to `LSMinimumSystemVersion`.\n */\n readonly minimumSystemVersion?: string | null\n\n /**\n * Path of [requirements file](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) used in signing. Not applicable for MAS.\n */\n readonly requirements?: string | null\n\n /** @private */\n readonly cscInstallerLink?: string | null\n /** @private */\n readonly cscInstallerKeyPassword?: string | null\n\n /**\n * Extra files to put in archive. Not applicable for `tar.*`.\n */\n readonly extraDistFiles?: Array<string> | string | null\n\n /**\n * Whether your app has to be signed with hardened runtime.\n * @default true\n */\n readonly hardenedRuntime?: boolean\n\n /**\n * Whether to let @electron/osx-sign validate the signing or not.\n * @default false\n */\n readonly gatekeeperAssess?: boolean\n\n /**\n * Whether to let @electron/osx-sign verify the contents or not.\n * @default true\n */\n readonly strictVerify?: boolean\n\n /**\n * Whether to enable entitlements automation from @electron/osx-sign.\n * @default true\n */\n readonly preAutoEntitlements?: boolean\n\n /**\n * Regex or an array of regex's that signal skipping signing a file.\n */\n readonly signIgnore?: Array<string> | string | null\n\n /**\n * The custom function (or path to file or module id) to sign an app bundle.\n */\n readonly sign?: CustomMacSign | string | null\n\n /**\n * Specify the URL of the timestamp authority server\n */\n readonly timestamp?: string | null\n\n /**\n * Whether to merge ASAR files for different architectures or not.\n *\n * This option has no effect unless building for \"universal\" arch.\n * @default true\n */\n readonly mergeASARs?: boolean\n\n /**\n * Minimatch pattern of paths that are allowed to be present in one of the\n * ASAR files, but not in the other.\n *\n * This option has no effect unless building for \"universal\" arch and applies\n * only if `mergeASARs` is `true`.\n */\n readonly singleArchFiles?: string | null\n\n /**\n * Minimatch pattern of paths that are allowed to be x64 binaries in both\n * ASAR files\n *\n * This option has no effect unless building for \"universal\" arch and applies\n * only if `mergeASARs` is `true`.\n */\n readonly x64ArchFiles?: string | null\n\n /**\n * Options to use for @electron/notarize (ref: https://github.com/electron/notarize).\n * Supports both `legacy` and `notarytool` notarization tools. Use `false` to explicitly disable\n *\n * Note: In order to activate the notarization step You MUST specify one of the following via environment variables:\n * 1. `APPLE_API_KEY`, `APPLE_API_KEY_ID` and `APPLE_API_ISSUER`.\n * 2. `APPLE_ID` and `APPLE_APP_SPECIFIC_PASSWORD`\n * 3. `APPLE_KEYCHAIN` and `APPLE_KEYCHAIN_PROFILE`\n *\n * For security reasons it is recommended to use the first option (see https://github.com/electron-userland/electron-builder/issues/7859)\n */\n readonly notarize?: NotarizeLegacyOptions | NotarizeNotaryOptions | boolean | null\n}\n\nexport interface NotarizeLegacyOptions {\n /**\n * The app bundle identifier your Electron app is using. E.g. com.github.electron. Useful if notarization ID differs from app ID (unlikely).\n * Only used by `legacy` notarization tool\n */\n readonly appBundleId?: string | null\n\n /**\n * Your Team Short Name. Only used by `legacy` notarization tool\n */\n readonly ascProvider?: string | null\n}\n\nexport interface NotarizeNotaryOptions {\n /**\n * The team ID you want to notarize under for when using `notarytool`\n */\n readonly teamId: string\n}\n\nexport interface DmgOptions extends TargetSpecificOptions {\n /**\n * The path to background image (default: `build/background.tiff` or `build/background.png` if exists). The resolution of this file determines the resolution of the installer window.\n * If background is not specified, use `window.size`. Default locations expected background size to be 540x380.\n * @see [DMG with Retina background support](http://stackoverflow.com/a/11204769/1910191).\n */\n background?: string | null\n\n /**\n * The background color (accepts css colors). Defaults to `#ffffff` (white) if no background image.\n */\n backgroundColor?: string | null\n\n /**\n * The path to DMG icon (volume icon), which will be shown when mounted, relative to the [build resources](/configuration/configuration#MetadataDirectories-buildResources) or to the project directory.\n * Defaults to the application icon (`build/icon.icns`).\n */\n icon?: string | null\n\n /**\n * The size of all the icons inside the DMG.\n * @default 80\n */\n readonly iconSize?: number | null\n\n /**\n * The size of all the icon texts inside the DMG.\n * @default 12\n */\n readonly iconTextSize?: number | null\n\n /**\n * The title of the produced DMG, which will be shown when mounted (volume name).\n *\n * Macro `${productName}`, `${version}` and `${name}` are supported.\n * @default ${productName} ${version}\n */\n readonly title?: string | null\n\n /**\n * The content — to customize icon locations. The x and y coordinates refer to the position of the **center** of the icon (at 1x scale), and do not take the label into account.\n */\n contents?: Array<DmgContent>\n\n /**\n * The disk image format. `ULFO` (lzfse-compressed image (OS X 10.11+ only)).\n * @default UDZO\n */\n format?: \"UDRW\" | \"UDRO\" | \"UDCO\" | \"UDZO\" | \"UDBZ\" | \"ULFO\"\n\n /**\n * The DMG window position and size. With y co-ordinates running from bottom to top.\n *\n * The Finder makes sure that the window will be on the user’s display, so if you want your window at the top left of the display you could use `\"x\": 0, \"y\": 100000` as the x, y co-ordinates.\n * It is not to be possible to position the window relative to the [top left](https://github.com/electron-userland/electron-builder/issues/3990#issuecomment-512960957) or relative to the center of the user’s screen.\n */\n window?: DmgWindow\n\n /**\n * Whether to create internet-enabled disk image (when it is downloaded using a browser it will automatically decompress the image, put the application on the desktop, unmount and remove the disk image file).\n * @default false\n */\n readonly internetEnabled?: boolean\n\n /**\n * Whether to sign the DMG or not. Signing is not required and will lead to unwanted errors in combination with notarization requirements.\n * @default false\n */\n readonly sign?: boolean\n\n /**\n * @private\n * @default true\n */\n writeUpdateInfo?: boolean\n}\n\nexport interface DmgWindow {\n /**\n * The X position relative to left of the screen.\n * @default 400\n */\n x?: number\n\n /**\n * The Y position relative to bottom of the screen.\n * @default 100\n */\n y?: number\n\n /**\n * The width. Defaults to background image width or 540.\n */\n width?: number\n\n /**\n * The height. Defaults to background image height or 380.\n */\n height?: number\n}\n\nexport interface DmgContent {\n /**\n * The device-independent pixel offset from the left of the window to the **center** of the icon.\n */\n x: number\n /**\n * The device-independent pixel offset from the top of the window to the **center** of the icon.\n */\n y: number\n type?: \"link\" | \"file\" | \"dir\"\n\n /**\n * The name of the file within the DMG. Defaults to basename of `path`.\n */\n name?: string\n\n /**\n * The path of the file within the DMG.\n */\n path?: string\n}\n\nexport interface MasConfiguration extends MacConfiguration {\n /**\n * The path to entitlements file for signing the app. `build/entitlements.mas.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n * Be aware that your app may crash if the right entitlements are not set like `com.apple.security.cs.allow-jit` for example on arm64 builds with Electron 20+.\n * See [Signing and Notarizing macOS Builds from the Electron documentation](https://www.electronjs.org/docs/latest/tutorial/code-signing#signing--notarizing-macos-builds) for more information.\n */\n readonly entitlements?: string | null\n\n /**\n * The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mas.inherit.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n */\n readonly entitlementsInherit?: string | null\n\n /**\n * Paths of any extra binaries that need to be signed.\n */\n readonly binaries?: Array<string> | null\n}\n"]}
1
+ {"version":3,"file":"macOptions.js","sourceRoot":"","sources":["../../src/options/macOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { PlatformSpecificBuildOptions, TargetConfiguration, TargetSpecificOptions } from \"../index\"\nimport { CustomMacSign } from \"../macPackager\"\n\nexport type MacOsTargetName = \"default\" | \"dmg\" | \"mas\" | \"mas-dev\" | \"pkg\" | \"7z\" | \"zip\" | \"tar.xz\" | \"tar.lz\" | \"tar.gz\" | \"tar.bz2\" | \"dir\"\n\nexport interface MacConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.\n *\n * For example, `\"category\": \"public.app-category.developer-tools\"` will set the application category to *Developer Tools*.\n *\n * Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).\n */\n readonly category?: string | null\n\n /**\n * The target package type: list of `default`, `dmg`, `mas`, `mas-dev`, `pkg`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `default` (`dmg` and `zip` for Squirrel.Mac). Note: Squirrel.Mac auto update mechanism requires both `dmg` and `zip` to be enabled, even when only `dmg` is used. Disabling `zip` will break auto update in `dmg` packages.\n */\n readonly target?: Array<MacOsTargetName | TargetConfiguration> | MacOsTargetName | TargetConfiguration | null\n\n /**\n * The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](/code-signing) instead of specifying this option.\n * MAS installer identity is specified in the [mas](/configuration/mas).\n */\n readonly identity?: string | null\n\n /**\n * The path to application icon.\n * @default build/icon.icns\n */\n readonly icon?: string | null\n\n /**\n * The path to entitlements file for signing the app. `build/entitlements.mac.plist` will be used if exists (it is a recommended way to set).\n * MAS entitlements is specified in the [mas](/configuration/mas).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n * Be aware that your app may crash if the right entitlements are not set like `com.apple.security.cs.allow-jit` for example on arm64 builds with Electron 20+.\n * See [Signing and Notarizing macOS Builds from the Electron documentation](https://www.electronjs.org/docs/latest/tutorial/code-signing#signing--notarizing-macos-builds) for more information.\n */\n readonly entitlements?: string | null\n\n /**\n * The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mac.inherit.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n *\n * This option only applies when signing with `entitlements` provided.\n */\n readonly entitlementsInherit?: string | null\n\n /**\n * Path to login helper entitlement file.\n * When using App Sandbox, the the `com.apple.security.inherit` key that is normally in the inherited entitlements cannot be inherited since the login helper is a standalone executable.\n * Defaults to the value provided for `entitlements`. This option only applies when signing with `entitlements` provided.\n */\n readonly entitlementsLoginHelper?: string | null\n\n /**\n * The path to the provisioning profile to use when signing, absolute or relative to the app root.\n */\n readonly provisioningProfile?: string | null\n\n /**\n * The `CFBundleVersion`. Do not use it unless [you need to](https://github.com/electron-userland/electron-builder/issues/565#issuecomment-230678643).\n */\n readonly bundleVersion?: string | null\n\n /**\n * The `CFBundleShortVersionString`. Do not use it unless you need to.\n */\n readonly bundleShortVersion?: string | null\n\n /**\n * Whether a dark mode is supported. If your app does have a dark mode, you can make your app follow the system-wide dark mode setting.\n * @default false\n */\n readonly darkModeSupport?: boolean\n\n /**\n * The bundle identifier to use in the application helper's plist.\n * @default ${appBundleIdentifier}.helper\n */\n readonly helperBundleId?: string | null\n\n /**\n * The bundle identifier to use in the Renderer helper's plist.\n * @default ${appBundleIdentifier}.helper.Renderer\n */\n readonly helperRendererBundleId?: string | null\n\n /**\n * The bundle identifier to use in the Plugin helper's plist.\n * @default ${appBundleIdentifier}.helper.Plugin\n */\n readonly helperPluginBundleId?: string | null\n\n /**\n * The bundle identifier to use in the GPU helper's plist.\n * @default ${appBundleIdentifier}.helper.GPU\n */\n readonly helperGPUBundleId?: string | null\n\n /**\n * The bundle identifier to use in the EH helper's plist.\n * @default ${appBundleIdentifier}.helper.EH\n */\n readonly helperEHBundleId?: string | null\n\n /**\n * The bundle identifier to use in the NP helper's plist.\n * @default ${appBundleIdentifier}.helper.NP\n */\n readonly helperNPBundleId?: string | null\n\n /**\n * Whether to sign app for development or for distribution.\n * @default distribution\n */\n readonly type?: \"distribution\" | \"development\" | null\n\n /**\n * The extra entries for `Info.plist`.\n */\n readonly extendInfo?: any\n\n /**\n * Paths of any extra binaries that need to be signed.\n */\n readonly binaries?: Array<string> | null\n\n /**\n * The minimum version of macOS required for the app to run. Corresponds to `LSMinimumSystemVersion`.\n */\n readonly minimumSystemVersion?: string | null\n\n /**\n * Path of [requirements file](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) used in signing. Not applicable for MAS.\n */\n readonly requirements?: string | null\n\n /** @private */\n readonly cscInstallerLink?: string | null\n /** @private */\n readonly cscInstallerKeyPassword?: string | null\n\n /**\n * Extra files to put in archive. Not applicable for `tar.*`.\n */\n readonly extraDistFiles?: Array<string> | string | null\n\n /**\n * Whether your app has to be signed with hardened runtime.\n * @default true\n */\n readonly hardenedRuntime?: boolean\n\n /**\n * Whether to let `@electron/osx-sign` validate the signing or not.\n * @default false\n */\n readonly gatekeeperAssess?: boolean\n\n /**\n * Whether to let `@electron/osx-sign` verify the contents or not.\n * @default true\n */\n readonly strictVerify?: boolean\n\n /**\n * Whether to enable entitlements automation from `@electron/osx-sign`.\n * @default true\n */\n readonly preAutoEntitlements?: boolean\n\n /**\n * Regex or an array of regex's that signal skipping signing a file.\n */\n readonly signIgnore?: Array<string> | string | null\n\n /**\n * The custom function (or path to file or module id) to sign an app bundle.\n */\n readonly sign?: CustomMacSign | string | null\n\n /**\n * Specify the URL of the timestamp authority server\n */\n readonly timestamp?: string | null\n\n /**\n * Whether to merge ASAR files for different architectures or not.\n *\n * This option has no effect unless building for \"universal\" arch.\n * @default true\n */\n readonly mergeASARs?: boolean\n\n /**\n * Minimatch pattern of paths that are allowed to be present in one of the\n * ASAR files, but not in the other.\n *\n * This option has no effect unless building for \"universal\" arch and applies\n * only if `mergeASARs` is `true`.\n */\n readonly singleArchFiles?: string | null\n\n /**\n * Minimatch pattern of paths that are allowed to be x64 binaries in both\n * ASAR files\n *\n * This option has no effect unless building for \"universal\" arch and applies\n * only if `mergeASARs` is `true`.\n */\n readonly x64ArchFiles?: string | null\n\n /**\n * Options to use for @electron/notarize (ref: https://github.com/electron/notarize).\n * Supports both `legacy` and `notarytool` notarization tools. Use `false` to explicitly disable\n *\n * Note: In order to activate the notarization step You MUST specify one of the following via environment variables:\n * 1. `APPLE_API_KEY`, `APPLE_API_KEY_ID` and `APPLE_API_ISSUER`.\n * 2. `APPLE_ID` and `APPLE_APP_SPECIFIC_PASSWORD`\n * 3. `APPLE_KEYCHAIN` and `APPLE_KEYCHAIN_PROFILE`\n *\n * For security reasons it is recommended to use the first option (see https://github.com/electron-userland/electron-builder/issues/7859)\n */\n readonly notarize?: NotarizeLegacyOptions | NotarizeNotaryOptions | boolean | null\n}\n\nexport interface NotarizeLegacyOptions {\n /**\n * The app bundle identifier your Electron app is using. E.g. com.github.electron. Useful if notarization ID differs from app ID (unlikely).\n * Only used by `legacy` notarization tool\n */\n readonly appBundleId?: string | null\n\n /**\n * Your Team Short Name. Only used by `legacy` notarization tool\n */\n readonly ascProvider?: string | null\n}\n\nexport interface NotarizeNotaryOptions {\n /**\n * The team ID you want to notarize under for when using `notarytool`\n */\n readonly teamId: string\n}\n\nexport interface DmgOptions extends TargetSpecificOptions {\n /**\n * The path to background image (default: `build/background.tiff` or `build/background.png` if exists). The resolution of this file determines the resolution of the installer window.\n * If background is not specified, use `window.size`. Default locations expected background size to be 540x380.\n * @see [DMG with Retina background support](http://stackoverflow.com/a/11204769/1910191).\n */\n background?: string | null\n\n /**\n * The background color (accepts css colors). Defaults to `#ffffff` (white) if no background image.\n */\n backgroundColor?: string | null\n\n /**\n * The path to DMG icon (volume icon), which will be shown when mounted, relative to the [build resources](/configuration/configuration#MetadataDirectories-buildResources) or to the project directory.\n * Defaults to the application icon (`build/icon.icns`).\n */\n icon?: string | null\n\n /**\n * The size of all the icons inside the DMG.\n * @default 80\n */\n readonly iconSize?: number | null\n\n /**\n * The size of all the icon texts inside the DMG.\n * @default 12\n */\n readonly iconTextSize?: number | null\n\n /**\n * The title of the produced DMG, which will be shown when mounted (volume name).\n *\n * Macro `${productName}`, `${version}` and `${name}` are supported.\n * @default ${productName} ${version}\n */\n readonly title?: string | null\n\n /**\n * The content — to customize icon locations. The x and y coordinates refer to the position of the **center** of the icon (at 1x scale), and do not take the label into account.\n */\n contents?: Array<DmgContent>\n\n /**\n * The disk image format. `ULFO` (lzfse-compressed image (OS X 10.11+ only)).\n * @default UDZO\n */\n format?: \"UDRW\" | \"UDRO\" | \"UDCO\" | \"UDZO\" | \"UDBZ\" | \"ULFO\"\n\n /**\n * The DMG window position and size. With y co-ordinates running from bottom to top.\n *\n * The Finder makes sure that the window will be on the user’s display, so if you want your window at the top left of the display you could use `\"x\": 0, \"y\": 100000` as the x, y co-ordinates.\n * It is not to be possible to position the window relative to the [top left](https://github.com/electron-userland/electron-builder/issues/3990#issuecomment-512960957) or relative to the center of the user’s screen.\n */\n window?: DmgWindow\n\n /**\n * Whether to create internet-enabled disk image (when it is downloaded using a browser it will automatically decompress the image, put the application on the desktop, unmount and remove the disk image file).\n * @default false\n */\n readonly internetEnabled?: boolean\n\n /**\n * Whether to sign the DMG or not. Signing is not required and will lead to unwanted errors in combination with notarization requirements.\n * @default false\n */\n readonly sign?: boolean\n\n /**\n * @private\n * @default true\n */\n writeUpdateInfo?: boolean\n}\n\nexport interface DmgWindow {\n /**\n * The X position relative to left of the screen.\n * @default 400\n */\n x?: number\n\n /**\n * The Y position relative to bottom of the screen.\n * @default 100\n */\n y?: number\n\n /**\n * The width. Defaults to background image width or 540.\n */\n width?: number\n\n /**\n * The height. Defaults to background image height or 380.\n */\n height?: number\n}\n\nexport interface DmgContent {\n /**\n * The device-independent pixel offset from the left of the window to the **center** of the icon.\n */\n x: number\n /**\n * The device-independent pixel offset from the top of the window to the **center** of the icon.\n */\n y: number\n type?: \"link\" | \"file\" | \"dir\"\n\n /**\n * The name of the file within the DMG. Defaults to basename of `path`.\n */\n name?: string\n\n /**\n * The path of the file within the DMG.\n */\n path?: string\n}\n\nexport interface MasConfiguration extends MacConfiguration {\n /**\n * The path to entitlements file for signing the app. `build/entitlements.mas.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n * Be aware that your app may crash if the right entitlements are not set like `com.apple.security.cs.allow-jit` for example on arm64 builds with Electron 20+.\n * See [Signing and Notarizing macOS Builds from the Electron documentation](https://www.electronjs.org/docs/latest/tutorial/code-signing#signing--notarizing-macos-builds) for more information.\n */\n readonly entitlements?: string | null\n\n /**\n * The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mas.inherit.plist` will be used if exists (it is a recommended way to set).\n * See [this folder in osx-sign's repository](https://github.com/electron/osx-sign/tree/main/entitlements) for examples.\n */\n readonly entitlementsInherit?: string | null\n\n /**\n * Paths of any extra binaries that need to be signed.\n */\n readonly binaries?: Array<string> | null\n}\n"]}
@@ -234,7 +234,7 @@ class PlatformPackager {
234
234
  await framework.afterPack(packContext);
235
235
  }
236
236
  const isAsar = asarOptions != null;
237
- await this.sanityCheckPackage(appOutDir, isAsar, framework);
237
+ await this.sanityCheckPackage(appOutDir, isAsar, framework, !!this.config.disableSanityCheckAsar);
238
238
  if (sign) {
239
239
  await this.doSignAfterPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets);
240
240
  }
@@ -390,7 +390,10 @@ class PlatformPackager {
390
390
  getMacOsResourcesDir(appOutDir) {
391
391
  return path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents", "Resources");
392
392
  }
393
- async checkFileInPackage(resourcesDir, file, messagePrefix, isAsar) {
393
+ async checkFileInPackage(resourcesDir, file, messagePrefix, isAsar, disableSanityCheckAsar) {
394
+ if (isAsar && disableSanityCheckAsar) {
395
+ return;
396
+ }
394
397
  const relativeFile = path.relative(this.info.appDir, path.resolve(this.info.appDir, file));
395
398
  if (isAsar) {
396
399
  await (0, asarFileChecker_1.checkFileInArchive)(path.join(resourcesDir, "app.asar"), relativeFile, messagePrefix);
@@ -428,7 +431,7 @@ class PlatformPackager {
428
431
  }
429
432
  }
430
433
  }
431
- async sanityCheckPackage(appOutDir, isAsar, framework) {
434
+ async sanityCheckPackage(appOutDir, isAsar, framework, disableSanityCheckAsar) {
432
435
  const outStat = await (0, fs_1.statOrNull)(appOutDir);
433
436
  if (outStat == null) {
434
437
  throw new Error(`Output directory "${appOutDir}" does not exist. Seems like a wrong configuration.`);
@@ -441,8 +444,8 @@ class PlatformPackager {
441
444
  }
442
445
  const resourcesDir = this.getResourcesDir(appOutDir);
443
446
  const mainFile = (framework.getMainFile == null ? null : framework.getMainFile(this.platform)) || this.info.metadata.main || "index.js";
444
- await this.checkFileInPackage(resourcesDir, mainFile, "Application entry file", isAsar);
445
- await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar);
447
+ await this.checkFileInPackage(resourcesDir, mainFile, "Application entry file", isAsar, disableSanityCheckAsar);
448
+ await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar, disableSanityCheckAsar);
446
449
  }
447
450
  // tslint:disable-next-line:no-invalid-template-strings
448
451
  computeSafeArtifactName(suggestedName, ext, arch, skipDefaultArch = true, defaultArch, safePattern = "${name}-${version}-${arch}.${ext}") {