app-builder-lib 27.0.0-alpha.11 → 27.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codeSign/win/authenticodeSignature.d.ts +71 -0
- package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -0
- package/dist/codeSign/win/authenticodeSignature.js +241 -0
- package/dist/codeSign/win/authenticodeSignature.js.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts +11 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +36 -16
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts +25 -0
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -0
- package/dist/codeSign/win/verifyUpdatePublisher.js +98 -0
- package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -0
- package/dist/configuration.d.ts +11 -10
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/ElectronFramework.d.ts +15 -0
- package/dist/electron/ElectronFramework.d.ts.map +1 -1
- package/dist/electron/ElectronFramework.js +33 -2
- package/dist/electron/ElectronFramework.js.map +1 -1
- package/dist/electron/mac/asarIntegrityDigest.d.ts +10 -0
- package/dist/electron/mac/asarIntegrityDigest.d.ts.map +1 -0
- package/dist/electron/mac/asarIntegrityDigest.js +122 -0
- package/dist/electron/mac/asarIntegrityDigest.js.map +1 -0
- package/dist/electron/mac/electronMac.js +1 -28
- package/dist/electron/mac/electronMac.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +8 -0
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
- package/dist/electron/mac/electronMacUtils.js +36 -0
- package/dist/electron/mac/electronMacUtils.js.map +1 -1
- package/dist/fileMatcher.d.ts +34 -11
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +121 -34
- package/dist/fileMatcher.js.map +1 -1
- package/dist/forge-maker.d.ts +64 -0
- package/dist/forge-maker.d.ts.map +1 -1
- package/dist/forge-maker.js +104 -2
- package/dist/forge-maker.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +2 -1
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +2 -1
- package/dist/indexInternal.js.map +1 -1
- package/dist/macPackager.d.ts +6 -0
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +48 -2
- package/dist/macPackager.js.map +1 -1
- package/dist/options/FuseOptionsV1.d.ts +4 -0
- package/dist/options/FuseOptionsV1.d.ts.map +1 -1
- package/dist/options/FuseOptionsV1.js.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.d.ts +81 -12
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +15 -1
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +7 -4
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +2 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +4 -0
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts +4 -2
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +12 -2
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +1 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +59 -15
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/targets/archive.d.ts +6 -0
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +12 -2
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.js +4 -0
- package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +2 -10
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/snap/core24.d.ts.map +1 -1
- package/dist/targets/linux/snap/core24.js +2 -9
- package/dist/targets/linux/snap/core24.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +6 -0
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +47 -3
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +1 -0
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +7 -1
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/toolsets/winCodeSign.d.ts +14 -1
- package/dist/toolsets/winCodeSign.d.ts.map +1 -1
- package/dist/toolsets/winCodeSign.js +14 -1
- package/dist/toolsets/winCodeSign.js.map +1 -1
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +6 -8
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/config/config.d.ts.map +1 -1
- package/dist/util/config/config.js +9 -1
- package/dist/util/config/config.js.map +1 -1
- package/dist/util/config/fileOptions.d.ts +22 -0
- package/dist/util/config/fileOptions.d.ts.map +1 -1
- package/dist/util/config/fileOptions.js +90 -0
- package/dist/util/config/fileOptions.js.map +1 -1
- package/dist/util/config/legacyOptions.d.ts.map +1 -1
- package/dist/util/config/legacyOptions.js +12 -0
- package/dist/util/config/legacyOptions.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +11 -9
- package/scheme.json +166 -28
- package/templates/nsis/installSection.nsh +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asarIntegrityDigest.js","sourceRoot":"","sources":["../../../src/electron/mac/asarIntegrityDigest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAc,IAAI,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,kCAAkC,CAAA;AAEhF,oFAAoF;AACpF,MAAM,CAAC,MAAM,+CAA+C,GAAG,EAAE,CAAA;AAEjE,MAAM,cAAc,GAAG,CAAC,CAAA;AACxB,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,0BAA0B;AAC1B,MAAM,WAAW,GAAG,CAAC,GAAG,aAAa,CAAA;AACrC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvC;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,SAAwB;IACjE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACjC,8IAA8I;IAC9I,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;QACtD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAA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,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;QAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;QAChG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;QAC3C,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACnG,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { exec, InvalidConfigurationError, log, sanitizeDirPath } from \"builder-util\"\nimport { createHash } from \"crypto\"\nimport { FileHandle, open } from \"fs/promises\"\nimport * as path from \"path\"\nimport { AsarIntegrity } from \"../../asar/integrity.js\"\nimport { parsePlistFile } from \"../../util/mac/plist.js\"\n\n/**\n * Marks the slot Electron (>= 41) reserves in the `Electron Framework` binary for the digest of the\n * `ElectronAsarIntegrity` Info.plist dictionary. The sentinel is followed by `used` (1 byte), `version` (1 byte) and\n * the SHA-256 digest (32 bytes); Electron skips the check (fails open) while `used` is 0.\n * @see https://github.com/electron/electron/blob/main/shell/common/asar/integrity_digest.mm\n */\nexport const ASAR_INTEGRITY_DIGEST_SENTINEL = \"AGbevlPCksUGKNL8TSn7wGmJEuJsXb2A\"\n\n/** electron/electron#48587, first released in 41.0.0-alpha.1 and not backported. */\nexport const FIRST_ELECTRON_MAJOR_WITH_ASAR_INTEGRITY_DIGEST = 41\n\nconst DIGEST_VERSION = 1\nconst DIGEST_LENGTH = 32\n// used + version + digest\nconst SLOT_LENGTH = 2 + DIGEST_LENGTH\nconst SCAN_CHUNK_SIZE = 4 * 1024 * 1024\n\n/**\n * Computes the version 1 digest Electron validates the `ElectronAsarIntegrity` dictionary against: SHA-256 over the\n * UTF-8 key, algorithm and hash of every entry, in key order.\n * @internal\n */\nexport function computeAsarIntegrityDigest(integrity: AsarIntegrity): Buffer {\n const hash = createHash(\"sha256\")\n // Electron sorts the keys with NSLiteralSearch (UTF-16 code unit order), which is what the default sort() does; localeCompare would not match\n for (const key of Object.keys(integrity).sort()) {\n const { algorithm, hash: headerHash } = integrity[key]\n hash.update(key).update(algorithm).update(headerHash)\n }\n return hash.digest()\n}\n\n/**\n * Writes `digest` into every digest slot of an `Electron Framework` binary (one per architecture slice) and returns how\n * many slots were written, 0 if the binary has none (Electron < 41). The slots are counted and bounds-checked before the\n * first write, so a failure never leaves one slice of a universal binary enforcing a digest the other lacks.\n * @internal\n */\nexport async function writeAsarIntegrityDigest(binaryPath: string, digest: Buffer): Promise<number> {\n if (digest.length !== DIGEST_LENGTH) {\n throw new Error(`ASAR integrity digest must be ${DIGEST_LENGTH} bytes, got ${digest.length}`)\n }\n\n const sentinel = Buffer.from(ASAR_INTEGRITY_DIGEST_SENTINEL)\n const handle = await open(binaryPath, \"r+\")\n try {\n const { size } = await handle.stat()\n const slotOffsets = (await findSentinels(handle, size, sentinel)).map(it => it + sentinel.length)\n if (slotOffsets.length > 2) {\n throw new Error(`Found ${slotOffsets.length} ASAR integrity digest slots in ${binaryPath}, at most 2 are expected (one per slice of a universal binary)`)\n }\n for (const offset of slotOffsets) {\n if (offset + SLOT_LENGTH > size) {\n throw new Error(`ASAR integrity digest slot at offset ${offset} of ${binaryPath} is truncated, the binary is corrupted or not an Electron Framework`)\n }\n }\n\n const payload = Buffer.alloc(SLOT_LENGTH)\n payload[0] = 1 // used\n payload[1] = DIGEST_VERSION\n digest.copy(payload, 2)\n for (const offset of slotOffsets) {\n await handle.write(payload, 0, payload.length, offset)\n }\n return slotOffsets.length\n } finally {\n await handle.close()\n }\n}\n\n/**\n * Embeds the digest of the app's `ElectronAsarIntegrity` Info.plist entries into its Electron Framework, then signs the\n * framework again, ad hoc: the write invalidates its signature (Electron's arm64 builds ship linker-signed), and Apple\n * Silicon refuses to load a binary whose signature is invalid. Code signing the app afterwards replaces the ad-hoc\n * signature. macOS only (codesign). Returns whether the digest was embedded.\n * @internal\n */\nexport async function embedAsarIntegrityDigest(appPath: string, frameworkName: string): Promise<boolean> {\n const safeAppPath = sanitizeDirPath(appPath)\n const infoPlistPath = path.join(safeAppPath, \"Contents\", \"Info.plist\")\n const integrity = await readAsarIntegrity(infoPlistPath)\n if (integrity == null || Object.keys(integrity).length === 0) {\n log.warn({ file: log.filePath(infoPlistPath), reason: \"Info.plist has no ElectronAsarIntegrity entries\" }, \"skipped ASAR integrity digest\")\n return false\n }\n\n // frameworkName is a file name, not a path: resolving it on its own would root it at the cwd. Containment keeps both paths inside the app\n const frameworksDir = path.join(safeAppPath, \"Contents\", \"Frameworks\")\n const frameworkPath = sanitizeDirPath(path.join(frameworksDir, `${frameworkName}.framework`), frameworksDir)\n const binaryPath = sanitizeDirPath(path.join(frameworkPath, frameworkName), frameworkPath)\n if ((await writeAsarIntegrityDigest(binaryPath, computeAsarIntegrityDigest(integrity))) === 0) {\n log.warn({ file: log.filePath(binaryPath), reason: \"the binary has no ASAR integrity digest slot\" }, \"skipped ASAR integrity digest\")\n return false\n }\n\n // --deep: Electron's x64 builds ship the framework's nested code unsigned, and codesign refuses to seal a bundle around unsigned code\n // Copied/verified from electron/packager:\n // https://github.com/electron/packager/blob/8c5cc941018b1d890c7152734972c44b9b98f268/src/mac.ts#L704-L733\n await exec(\"/usr/bin/codesign\", [\"--sign\", \"-\", \"--force\", \"--deep\", \"--preserve-metadata=entitlements,requirements,flags,runtime\", frameworkPath])\n log.info({ file: log.filePath(frameworkPath) }, \"embedded ASAR integrity digest\")\n return true\n}\n\n// parsePlistFile reads the XML format electron-builder writes; an afterPack hook that edits Info.plist with `defaults write` leaves it binary\nasync function readAsarIntegrity(infoPlistPath: string): Promise<AsarIntegrity | undefined> {\n try {\n return (await parsePlistFile<{ ElectronAsarIntegrity?: AsarIntegrity }>(infoPlistPath)).ElectronAsarIntegrity\n } catch (e: any) {\n throw new InvalidConfigurationError(\n `Cannot read ${infoPlistPath} to embed the ASAR integrity digest: ${e.message}. Keep Info.plist in the XML format electron-builder writes (\\`defaults write\\` converts it to binary, PlistBuddy and \\`plutil -replace\\` keep it XML), or set mac.asarIntegrityDigest to false`\n )\n }\n}\n\nasync function findSentinels(handle: FileHandle, size: number, sentinel: Buffer): Promise<Array<number>> {\n // each read overlaps the next chunk by sentinel.length - 1 bytes, so a sentinel straddling a chunk boundary is found (once)\n const buffer = Buffer.allocUnsafe(SCAN_CHUNK_SIZE + sentinel.length - 1)\n const offsets: Array<number> = []\n for (let start = 0; start < size; start += SCAN_CHUNK_SIZE) {\n const { bytesRead } = await handle.read(buffer, 0, Math.min(buffer.length, size - start), start)\n const chunk = buffer.subarray(0, bytesRead)\n for (let index = chunk.indexOf(sentinel); index !== -1; index = chunk.indexOf(sentinel, index + 1)) {\n offsets.push(start + index)\n }\n }\n return offsets\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { normalizeExt } from "../../platformPackager.js";
|
|
|
7
7
|
import { savePlistFile, parsePlistFile } from "../../util/mac/plist.js";
|
|
8
8
|
import { createBrandingOpts } from "../ElectronFramework.js";
|
|
9
9
|
import { MacTargetHelper } from "../../targets/mac/MacTargetHelper.js";
|
|
10
|
-
import { assertSafeHelperName, getAvailableHelperSuffixes } from "./electronMacUtils.js";
|
|
10
|
+
import { assertSafeHelperName, configureLocalhostAts, getAvailableHelperSuffixes } from "./electronMacUtils.js";
|
|
11
11
|
function doRename(basePath, oldName, newName) {
|
|
12
12
|
return rename(path.join(basePath, oldName), path.join(basePath, newName));
|
|
13
13
|
}
|
|
@@ -213,31 +213,4 @@ export async function createMacApp(packager, appOutDir, asarIntegrity, targetPla
|
|
|
213
213
|
const now = Date.now() / 1000;
|
|
214
214
|
await utimes(appPath, now, now);
|
|
215
215
|
}
|
|
216
|
-
function configureLocalhostAts(appPlist) {
|
|
217
|
-
// https://bencoding.com/2015/07/20/app-transport-security-and-localhost/
|
|
218
|
-
let ats = appPlist.NSAppTransportSecurity;
|
|
219
|
-
if (ats == null) {
|
|
220
|
-
ats = {};
|
|
221
|
-
appPlist.NSAppTransportSecurity = ats;
|
|
222
|
-
}
|
|
223
|
-
ats.NSAllowsLocalNetworking = true;
|
|
224
|
-
// https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814
|
|
225
|
-
ats.NSAllowsArbitraryLoads = true;
|
|
226
|
-
let exceptionDomains = ats.NSExceptionDomains;
|
|
227
|
-
if (exceptionDomains == null) {
|
|
228
|
-
exceptionDomains = {};
|
|
229
|
-
ats.NSExceptionDomains = exceptionDomains;
|
|
230
|
-
}
|
|
231
|
-
if (exceptionDomains.localhost == null) {
|
|
232
|
-
const allowHttp = {
|
|
233
|
-
NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,
|
|
234
|
-
NSIncludesSubdomains: false,
|
|
235
|
-
NSTemporaryExceptionAllowsInsecureHTTPLoads: true,
|
|
236
|
-
NSTemporaryExceptionMinimumTLSVersion: "1.0",
|
|
237
|
-
NSTemporaryExceptionRequiresForwardSecrecy: false,
|
|
238
|
-
};
|
|
239
|
-
exceptionDomains.localhost = allowHttp;
|
|
240
|
-
exceptionDomains["127.0.0.1"] = allowHttp;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
216
|
//# sourceMappingURL=electronMac.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electronMac.js","sourceRoot":"","sources":["../../../src/electron/mac/electronMac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA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IACzC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,GAAG,EAAE,CAAA;QACR,QAAQ,CAAC,sBAAsB,GAAG,GAAG,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,uBAAuB,GAAG,IAAI,CAAA;IAClC,2FAA2F;IAC3F,GAAG,CAAC,sBAAsB,GAAG,IAAI,CAAA;IAEjC,IAAI,gBAAgB,GAAG,GAAG,CAAC,kBAAkB,CAAA;IAC7C,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;QAC7B,gBAAgB,GAAG,EAAE,CAAA;QACrB,GAAG,CAAC,kBAAkB,GAAG,gBAAgB,CAAA;IAC3C,CAAC;IAED,IAAI,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG;YAChB,4CAA4C,EAAE,KAAK;YACnD,oBAAoB,EAAE,KAAK;YAC3B,2CAA2C,EAAE,IAAI;YACjD,qCAAqC,EAAE,KAAK;YAC5C,0CAA0C,EAAE,KAAK;SAClD,CAAA;QACD,gBAAgB,CAAC,SAAS,GAAG,SAAS,CAAA;QACtC,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import { asArray, copyOrLinkFile, getPlatformIconFileName, InvalidConfigurationError } from \"builder-util\"\nimport { rename, utimes } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { filterCFBundleIdentifier } from \"../../appInfo.js\"\nimport { AsarIntegrity } from \"../../asar/integrity.js\"\nimport { MacPackager } from \"../../macPackager.js\"\nimport { normalizeExt } from \"../../platformPackager.js\"\nimport { savePlistFile, parsePlistFile, PlistObject, PlistValue } from \"../../util/mac/plist.js\"\nimport { createBrandingOpts } from \"../ElectronFramework.js\"\nimport { MacTargetHelper, PlatformType } from \"../../targets/mac/MacTargetHelper.js\"\nimport { assertSafeHelperName, getAvailableHelperSuffixes } from \"./electronMacUtils.js\"\n\nfunction doRename(basePath: string, oldName: string, newName: string) {\n return rename(path.join(basePath, oldName), path.join(basePath, newName))\n}\n\nfunction moveHelpers(helperSuffixes: Array<string>, frameworksPath: string, appName: string, prefix: string): Promise<any> {\n return Promise.all(\n helperSuffixes.map(suffix => {\n const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix).then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))\n })\n )\n}\n\n/** @internal */\nexport async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, targetPlatform: PlatformType) {\n const appInfo = packager.appInfo\n // Electon uses the application name (CFBundleName) to resolve helper apps\n // https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm\n // https://github.com/electron-userland/electron-builder/issues/6962\n const appFilename = appInfo.sanitizedProductName\n const electronBranding = createBrandingOpts(packager.config)\n // The branding name is the on-disk prefix of every helper bundle we read from the Electron dist,\n // so reject values that could escape the Frameworks directory.\n assertSafeHelperName(electronBranding.productName, \"electronBranding.productName\")\n\n const contentsPath = path.join(appOutDir, packager.framework.distMacOsAppName, \"Contents\")\n const frameworksPath = path.join(contentsPath, \"Frameworks\")\n const loginItemPath = path.join(contentsPath, \"Library\", \"LoginItems\")\n\n const appPlistFilename = path.join(contentsPath, \"Info.plist\")\n const helperPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper.app`, \"Contents\", \"Info.plist\")\n const helperEHPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper EH.app`, \"Contents\", \"Info.plist\")\n const helperNPPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper NP.app`, \"Contents\", \"Info.plist\")\n const helperRendererPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Renderer).app`, \"Contents\", \"Info.plist\")\n const helperPluginPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Plugin).app`, \"Contents\", \"Info.plist\")\n const helperGPUPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (GPU).app`, \"Contents\", \"Info.plist\")\n const helperLoginPlistFilename = path.join(loginItemPath, `${electronBranding.productName} Login Helper.app`, \"Contents\", \"Info.plist\")\n\n const safeParsePlistFile = async (filePath: string): Promise<PlistObject | null> => {\n if (!fs.existsSync(filePath)) {\n return null\n }\n return await parsePlistFile(filePath)\n }\n\n const appPlist = (await safeParsePlistFile(appPlistFilename))!\n if (appPlist == null) {\n throw new Error(\"corrupted Electron dist\")\n }\n\n // Parse each helper plist; variants absent from the current Electron dist resolve to null.\n const helperPlist = await safeParsePlistFile(helperPlistFilename)\n const helperEHPlist = await safeParsePlistFile(helperEHPlistFilename)\n const helperNPPlist = await safeParsePlistFile(helperNPPlistFilename)\n const helperRendererPlist = await safeParsePlistFile(helperRendererPlistFilename)\n const helperPluginPlist = await safeParsePlistFile(helperPluginPlistFilename)\n const helperGPUPlist = await safeParsePlistFile(helperGPUPlistFilename)\n const helperLoginPlist = await safeParsePlistFile(helperLoginPlistFilename)\n\n const buildMetadata = packager.config\n\n /**\n * Configure bundleIdentifier for the generic Electron Helper process\n *\n * This was the only Helper in Electron 5 and before. Allow users to configure\n * the bundleIdentifier for continuity.\n */\n\n // `targetPlatform` is the authoritative 3-way flavor, so the cascaded config (incl. masDev overrides) is correct for mas-dev too.\n const cascadedOptions = packager.getPlatformConfig(targetPlatform).config\n const cfBundleIdentifier = filterCFBundleIdentifier(cascadedOptions?.appId || appInfo.macBundleIdentifier)\n const helperBundleIdentifier = filterCFBundleIdentifier(cascadedOptions?.helperBundleId || `${cfBundleIdentifier}.helper`)\n\n appPlist.CFBundleIdentifier = cfBundleIdentifier\n\n await packager.applyCommonInfo(appPlist, contentsPath, cascadedOptions)\n\n // required for electron-updater proxy. Both mas and mas-dev are sandboxed App Store flavors, so skip ATS for either.\n const isMasFlavor = MacTargetHelper.isMasTarget(targetPlatform)\n if (!isMasFlavor) {\n configureLocalhostAts(appPlist)\n }\n\n if (helperPlist != null) {\n helperPlist.CFBundleExecutable = `${appFilename} Helper`\n helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`\n helperPlist.CFBundleIdentifier = helperBundleIdentifier\n helperPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n /**\n * Configure bundleIdentifier for Electron 5+ Helper processes\n *\n * In Electron 6, parts of the generic Electron Helper process were split into\n * individual helper processes. Allow users to configure the bundleIdentifiers\n * for continuity, specifically because macOS keychain access relies on\n * bundleIdentifiers not changing (i.e. across versions of Electron).\n */\n\n function configureHelper(helper: any, postfix: string, userProvidedBundleIdentifier?: string | null) {\n helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`\n helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`\n helper.CFBundleIdentifier = userProvidedBundleIdentifier\n ? filterCFBundleIdentifier(userProvidedBundleIdentifier)\n : filterCFBundleIdentifier(`${helperBundleIdentifier}.${postfix}`)\n helper.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n if (helperRendererPlist != null) {\n configureHelper(helperRendererPlist, \"(Renderer)\", packager.platformOptions.helperRendererBundleId)\n }\n if (helperPluginPlist != null) {\n configureHelper(helperPluginPlist, \"(Plugin)\", packager.platformOptions.helperPluginBundleId)\n }\n if (helperGPUPlist != null) {\n configureHelper(helperGPUPlist, \"(GPU)\", packager.platformOptions.helperGPUBundleId)\n }\n if (helperEHPlist != null) {\n configureHelper(helperEHPlist, \"EH\", packager.platformOptions.helperEHBundleId)\n }\n if (helperNPPlist != null) {\n configureHelper(helperNPPlist, \"NP\", packager.platformOptions.helperNPBundleId)\n }\n if (helperLoginPlist != null) {\n helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`\n helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`\n // noinspection SpellCheckingInspection\n helperLoginPlist.CFBundleIdentifier = `${cfBundleIdentifier}.loginhelper`\n helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformOptions.protocols))\n if (protocols.length > 0) {\n appPlist.CFBundleURLTypes = protocols.map(protocol => {\n const schemes = asArray(protocol.schemes)\n if (schemes.length === 0) {\n throw new InvalidConfigurationError(`Protocol \"${protocol.name}\": must be at least one scheme specified`)\n }\n return {\n CFBundleURLName: protocol.name,\n CFBundleTypeRole: protocol.role || \"Editor\",\n CFBundleURLSchemes: schemes.slice(),\n }\n })\n }\n\n const fileAssociations = packager.fileAssociations\n if (fileAssociations.length > 0) {\n const documentTypes = await Promise.all(\n fileAssociations.map(async fileAssociation => {\n const extensions = asArray(fileAssociation.ext).map(normalizeExt)\n const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)\n let iconFile = appPlist.CFBundleIconFile\n if (customIcon != null) {\n iconFile = path.basename(customIcon)\n await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, \"Resources\"), iconFile))\n }\n\n const result = {\n CFBundleTypeExtensions: extensions,\n CFBundleTypeName: fileAssociation.name || extensions[0],\n CFBundleTypeRole: fileAssociation.role || \"Editor\",\n LSHandlerRank: fileAssociation.rank || \"Default\",\n CFBundleTypeIconFile: iconFile,\n } as any\n\n if (fileAssociation.isPackage) {\n result.LSTypeIsPackage = true\n }\n return result\n })\n )\n\n // `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case\n appPlist.CFBundleDocumentTypes = [...((appPlist.CFBundleDocumentTypes as PlistValue[]) || []), ...documentTypes]\n }\n\n const toPlistObject = (asarIntegrity: AsarIntegrity): PlistObject => {\n const result: PlistObject = {}\n for (const [filePath, headerHash] of Object.entries(asarIntegrity)) {\n result[filePath] = {\n algorithm: headerHash.algorithm,\n hash: headerHash.hash,\n }\n }\n return result\n }\n\n if (asarIntegrity != null) {\n appPlist.ElectronAsarIntegrity = toPlistObject(asarIntegrity)\n }\n\n if (helperEHPlist != null) {\n await savePlistFile(helperEHPlistFilename, helperEHPlist)\n }\n\n if (helperNPPlist != null) {\n await savePlistFile(helperNPPlistFilename, helperNPPlist)\n }\n\n if (helperRendererPlist != null) {\n await savePlistFile(helperRendererPlistFilename, helperRendererPlist)\n }\n\n if (helperPluginPlist != null) {\n await savePlistFile(helperPluginPlistFilename, helperPluginPlist)\n }\n\n if (helperGPUPlist != null) {\n await savePlistFile(helperGPUPlistFilename, helperGPUPlist)\n }\n\n if (helperLoginPlist != null) {\n await savePlistFile(helperLoginPlistFilename, helperLoginPlist)\n }\n\n await savePlistFile(appPlistFilename, appPlist)\n if (helperPlist != null) {\n await savePlistFile(helperPlistFilename, helperPlist)\n }\n\n await doRename(path.join(contentsPath, \"MacOS\"), electronBranding.productName, appPlist.CFBundleExecutable as string)\n\n await moveHelpers(\n getAvailableHelperSuffixes({\n EH: helperEHPlist != null,\n NP: helperNPPlist != null,\n Renderer: helperRendererPlist != null,\n Plugin: helperPluginPlist != null,\n GPU: helperGPUPlist != null,\n }),\n frameworksPath,\n appFilename,\n electronBranding.productName\n )\n\n if (helperLoginPlist != null) {\n const prefix = electronBranding.productName\n const suffix = \" Login Helper\"\n const executableBasePath = path.join(loginItemPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`))\n }\n\n const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`)\n await rename(path.dirname(contentsPath), appPath)\n // https://github.com/electron-userland/electron-builder/issues/840\n const now = Date.now() / 1000\n await utimes(appPath, now, now)\n}\n\nfunction configureLocalhostAts(appPlist: any) {\n // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/\n let ats = appPlist.NSAppTransportSecurity\n if (ats == null) {\n ats = {}\n appPlist.NSAppTransportSecurity = ats\n }\n\n ats.NSAllowsLocalNetworking = true\n // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814\n ats.NSAllowsArbitraryLoads = true\n\n let exceptionDomains = ats.NSExceptionDomains\n if (exceptionDomains == null) {\n exceptionDomains = {}\n ats.NSExceptionDomains = exceptionDomains\n }\n\n if (exceptionDomains.localhost == null) {\n const allowHttp = {\n NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,\n NSIncludesSubdomains: false,\n NSTemporaryExceptionAllowsInsecureHTTPLoads: true,\n NSTemporaryExceptionMinimumTLSVersion: \"1.0\",\n NSTemporaryExceptionRequiresForwardSecrecy: false,\n }\n exceptionDomains.localhost = allowHttp\n exceptionDomains[\"127.0.0.1\"] = allowHttp\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"electronMac.js","sourceRoot":"","sources":["../../../src/electron/mac/electronMac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC1G,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,cAAc,EAA2B,MAAM,yBAAyB,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAgB,MAAM,sCAAsC,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAE/G,SAAS,QAAQ,CAAC,QAAgB,EAAE,OAAe,EAAE,OAAe;IAClE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC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AC,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,GAAG,WAAW,GAAG,MAAM,MAAM,CAAC,CAAC,CAAA;IAC7K,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,eAAe,MAAM,CAAC,CAAA;IACtE,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;IACjD,mEAAmE;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;IAC7B,MAAM,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import { asArray, copyOrLinkFile, getPlatformIconFileName, InvalidConfigurationError } from \"builder-util\"\nimport { rename, utimes } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { filterCFBundleIdentifier } from \"../../appInfo.js\"\nimport { AsarIntegrity } from \"../../asar/integrity.js\"\nimport { MacPackager } from \"../../macPackager.js\"\nimport { normalizeExt } from \"../../platformPackager.js\"\nimport { savePlistFile, parsePlistFile, PlistObject, PlistValue } from \"../../util/mac/plist.js\"\nimport { createBrandingOpts } from \"../ElectronFramework.js\"\nimport { MacTargetHelper, PlatformType } from \"../../targets/mac/MacTargetHelper.js\"\nimport { assertSafeHelperName, configureLocalhostAts, getAvailableHelperSuffixes } from \"./electronMacUtils.js\"\n\nfunction doRename(basePath: string, oldName: string, newName: string) {\n return rename(path.join(basePath, oldName), path.join(basePath, newName))\n}\n\nfunction moveHelpers(helperSuffixes: Array<string>, frameworksPath: string, appName: string, prefix: string): Promise<any> {\n return Promise.all(\n helperSuffixes.map(suffix => {\n const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix).then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))\n })\n )\n}\n\n/** @internal */\nexport async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, targetPlatform: PlatformType) {\n const appInfo = packager.appInfo\n // Electon uses the application name (CFBundleName) to resolve helper apps\n // https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm\n // https://github.com/electron-userland/electron-builder/issues/6962\n const appFilename = appInfo.sanitizedProductName\n const electronBranding = createBrandingOpts(packager.config)\n // The branding name is the on-disk prefix of every helper bundle we read from the Electron dist,\n // so reject values that could escape the Frameworks directory.\n assertSafeHelperName(electronBranding.productName, \"electronBranding.productName\")\n\n const contentsPath = path.join(appOutDir, packager.framework.distMacOsAppName, \"Contents\")\n const frameworksPath = path.join(contentsPath, \"Frameworks\")\n const loginItemPath = path.join(contentsPath, \"Library\", \"LoginItems\")\n\n const appPlistFilename = path.join(contentsPath, \"Info.plist\")\n const helperPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper.app`, \"Contents\", \"Info.plist\")\n const helperEHPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper EH.app`, \"Contents\", \"Info.plist\")\n const helperNPPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper NP.app`, \"Contents\", \"Info.plist\")\n const helperRendererPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Renderer).app`, \"Contents\", \"Info.plist\")\n const helperPluginPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Plugin).app`, \"Contents\", \"Info.plist\")\n const helperGPUPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (GPU).app`, \"Contents\", \"Info.plist\")\n const helperLoginPlistFilename = path.join(loginItemPath, `${electronBranding.productName} Login Helper.app`, \"Contents\", \"Info.plist\")\n\n const safeParsePlistFile = async (filePath: string): Promise<PlistObject | null> => {\n if (!fs.existsSync(filePath)) {\n return null\n }\n return await parsePlistFile(filePath)\n }\n\n const appPlist = (await safeParsePlistFile(appPlistFilename))!\n if (appPlist == null) {\n throw new Error(\"corrupted Electron dist\")\n }\n\n // Parse each helper plist; variants absent from the current Electron dist resolve to null.\n const helperPlist = await safeParsePlistFile(helperPlistFilename)\n const helperEHPlist = await safeParsePlistFile(helperEHPlistFilename)\n const helperNPPlist = await safeParsePlistFile(helperNPPlistFilename)\n const helperRendererPlist = await safeParsePlistFile(helperRendererPlistFilename)\n const helperPluginPlist = await safeParsePlistFile(helperPluginPlistFilename)\n const helperGPUPlist = await safeParsePlistFile(helperGPUPlistFilename)\n const helperLoginPlist = await safeParsePlistFile(helperLoginPlistFilename)\n\n const buildMetadata = packager.config\n\n /**\n * Configure bundleIdentifier for the generic Electron Helper process\n *\n * This was the only Helper in Electron 5 and before. Allow users to configure\n * the bundleIdentifier for continuity.\n */\n\n // `targetPlatform` is the authoritative 3-way flavor, so the cascaded config (incl. masDev overrides) is correct for mas-dev too.\n const cascadedOptions = packager.getPlatformConfig(targetPlatform).config\n const cfBundleIdentifier = filterCFBundleIdentifier(cascadedOptions?.appId || appInfo.macBundleIdentifier)\n const helperBundleIdentifier = filterCFBundleIdentifier(cascadedOptions?.helperBundleId || `${cfBundleIdentifier}.helper`)\n\n appPlist.CFBundleIdentifier = cfBundleIdentifier\n\n await packager.applyCommonInfo(appPlist, contentsPath, cascadedOptions)\n\n // required for electron-updater proxy. Both mas and mas-dev are sandboxed App Store flavors, so skip ATS for either.\n const isMasFlavor = MacTargetHelper.isMasTarget(targetPlatform)\n if (!isMasFlavor) {\n configureLocalhostAts(appPlist)\n }\n\n if (helperPlist != null) {\n helperPlist.CFBundleExecutable = `${appFilename} Helper`\n helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`\n helperPlist.CFBundleIdentifier = helperBundleIdentifier\n helperPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n /**\n * Configure bundleIdentifier for Electron 5+ Helper processes\n *\n * In Electron 6, parts of the generic Electron Helper process were split into\n * individual helper processes. Allow users to configure the bundleIdentifiers\n * for continuity, specifically because macOS keychain access relies on\n * bundleIdentifiers not changing (i.e. across versions of Electron).\n */\n\n function configureHelper(helper: any, postfix: string, userProvidedBundleIdentifier?: string | null) {\n helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`\n helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`\n helper.CFBundleIdentifier = userProvidedBundleIdentifier\n ? filterCFBundleIdentifier(userProvidedBundleIdentifier)\n : filterCFBundleIdentifier(`${helperBundleIdentifier}.${postfix}`)\n helper.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n if (helperRendererPlist != null) {\n configureHelper(helperRendererPlist, \"(Renderer)\", packager.platformOptions.helperRendererBundleId)\n }\n if (helperPluginPlist != null) {\n configureHelper(helperPluginPlist, \"(Plugin)\", packager.platformOptions.helperPluginBundleId)\n }\n if (helperGPUPlist != null) {\n configureHelper(helperGPUPlist, \"(GPU)\", packager.platformOptions.helperGPUBundleId)\n }\n if (helperEHPlist != null) {\n configureHelper(helperEHPlist, \"EH\", packager.platformOptions.helperEHBundleId)\n }\n if (helperNPPlist != null) {\n configureHelper(helperNPPlist, \"NP\", packager.platformOptions.helperNPBundleId)\n }\n if (helperLoginPlist != null) {\n helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`\n helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`\n // noinspection SpellCheckingInspection\n helperLoginPlist.CFBundleIdentifier = `${cfBundleIdentifier}.loginhelper`\n helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformOptions.protocols))\n if (protocols.length > 0) {\n appPlist.CFBundleURLTypes = protocols.map(protocol => {\n const schemes = asArray(protocol.schemes)\n if (schemes.length === 0) {\n throw new InvalidConfigurationError(`Protocol \"${protocol.name}\": must be at least one scheme specified`)\n }\n return {\n CFBundleURLName: protocol.name,\n CFBundleTypeRole: protocol.role || \"Editor\",\n CFBundleURLSchemes: schemes.slice(),\n }\n })\n }\n\n const fileAssociations = packager.fileAssociations\n if (fileAssociations.length > 0) {\n const documentTypes = await Promise.all(\n fileAssociations.map(async fileAssociation => {\n const extensions = asArray(fileAssociation.ext).map(normalizeExt)\n const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)\n let iconFile = appPlist.CFBundleIconFile\n if (customIcon != null) {\n iconFile = path.basename(customIcon)\n await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, \"Resources\"), iconFile))\n }\n\n const result = {\n CFBundleTypeExtensions: extensions,\n CFBundleTypeName: fileAssociation.name || extensions[0],\n CFBundleTypeRole: fileAssociation.role || \"Editor\",\n LSHandlerRank: fileAssociation.rank || \"Default\",\n CFBundleTypeIconFile: iconFile,\n } as any\n\n if (fileAssociation.isPackage) {\n result.LSTypeIsPackage = true\n }\n return result\n })\n )\n\n // `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case\n appPlist.CFBundleDocumentTypes = [...((appPlist.CFBundleDocumentTypes as PlistValue[]) || []), ...documentTypes]\n }\n\n const toPlistObject = (asarIntegrity: AsarIntegrity): PlistObject => {\n const result: PlistObject = {}\n for (const [filePath, headerHash] of Object.entries(asarIntegrity)) {\n result[filePath] = {\n algorithm: headerHash.algorithm,\n hash: headerHash.hash,\n }\n }\n return result\n }\n\n if (asarIntegrity != null) {\n appPlist.ElectronAsarIntegrity = toPlistObject(asarIntegrity)\n }\n\n if (helperEHPlist != null) {\n await savePlistFile(helperEHPlistFilename, helperEHPlist)\n }\n\n if (helperNPPlist != null) {\n await savePlistFile(helperNPPlistFilename, helperNPPlist)\n }\n\n if (helperRendererPlist != null) {\n await savePlistFile(helperRendererPlistFilename, helperRendererPlist)\n }\n\n if (helperPluginPlist != null) {\n await savePlistFile(helperPluginPlistFilename, helperPluginPlist)\n }\n\n if (helperGPUPlist != null) {\n await savePlistFile(helperGPUPlistFilename, helperGPUPlist)\n }\n\n if (helperLoginPlist != null) {\n await savePlistFile(helperLoginPlistFilename, helperLoginPlist)\n }\n\n await savePlistFile(appPlistFilename, appPlist)\n if (helperPlist != null) {\n await savePlistFile(helperPlistFilename, helperPlist)\n }\n\n await doRename(path.join(contentsPath, \"MacOS\"), electronBranding.productName, appPlist.CFBundleExecutable as string)\n\n await moveHelpers(\n getAvailableHelperSuffixes({\n EH: helperEHPlist != null,\n NP: helperNPPlist != null,\n Renderer: helperRendererPlist != null,\n Plugin: helperPluginPlist != null,\n GPU: helperGPUPlist != null,\n }),\n frameworksPath,\n appFilename,\n electronBranding.productName\n )\n\n if (helperLoginPlist != null) {\n const prefix = electronBranding.productName\n const suffix = \" Login Helper\"\n const executableBasePath = path.join(loginItemPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`))\n }\n\n const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`)\n await rename(path.dirname(contentsPath), appPath)\n // https://github.com/electron-userland/electron-builder/issues/840\n const now = Date.now() / 1000\n await utimes(appPath, now, now)\n}\n"]}
|
|
@@ -21,4 +21,12 @@ export interface AvailableHelpers {
|
|
|
21
21
|
* `" Helper"` bundle is always present; the remaining variants vary by Electron version.
|
|
22
22
|
*/
|
|
23
23
|
export declare function getAvailableHelperSuffixes(present: AvailableHelpers): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and
|
|
26
|
+
* plain-HTTP exceptions for `localhost` and `127.0.0.1`.
|
|
27
|
+
*
|
|
28
|
+
* `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through
|
|
29
|
+
* `mac.extendInfo`, so an explicit `false` is kept.
|
|
30
|
+
*/
|
|
31
|
+
export declare function configureLocalhostAts(appPlist: any): void;
|
|
24
32
|
//# sourceMappingURL=electronMacUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electronMacUtils.d.ts","sourceRoot":"","sources":["../../../src/electron/mac/electronMacUtils.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOtE;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAkB9E"}
|
|
1
|
+
{"version":3,"file":"electronMacUtils.d.ts","sourceRoot":"","sources":["../../../src/electron/mac/electronMacUtils.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOtE;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAkB9E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CA+BzD"}
|
|
@@ -39,4 +39,40 @@ export function getAvailableHelperSuffixes(present) {
|
|
|
39
39
|
}
|
|
40
40
|
return result;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and
|
|
44
|
+
* plain-HTTP exceptions for `localhost` and `127.0.0.1`.
|
|
45
|
+
*
|
|
46
|
+
* `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through
|
|
47
|
+
* `mac.extendInfo`, so an explicit `false` is kept.
|
|
48
|
+
*/
|
|
49
|
+
export function configureLocalhostAts(appPlist) {
|
|
50
|
+
// https://bencoding.com/2015/07/20/app-transport-security-and-localhost/
|
|
51
|
+
let ats = appPlist.NSAppTransportSecurity;
|
|
52
|
+
if (ats == null) {
|
|
53
|
+
ats = {};
|
|
54
|
+
appPlist.NSAppTransportSecurity = ats;
|
|
55
|
+
}
|
|
56
|
+
ats.NSAllowsLocalNetworking = true;
|
|
57
|
+
// https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814
|
|
58
|
+
if (ats.NSAllowsArbitraryLoads == null) {
|
|
59
|
+
ats.NSAllowsArbitraryLoads = true;
|
|
60
|
+
}
|
|
61
|
+
let exceptionDomains = ats.NSExceptionDomains;
|
|
62
|
+
if (exceptionDomains == null) {
|
|
63
|
+
exceptionDomains = {};
|
|
64
|
+
ats.NSExceptionDomains = exceptionDomains;
|
|
65
|
+
}
|
|
66
|
+
if (exceptionDomains.localhost == null) {
|
|
67
|
+
const allowHttp = {
|
|
68
|
+
NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,
|
|
69
|
+
NSIncludesSubdomains: false,
|
|
70
|
+
NSTemporaryExceptionAllowsInsecureHTTPLoads: true,
|
|
71
|
+
NSTemporaryExceptionMinimumTLSVersion: "1.0",
|
|
72
|
+
NSTemporaryExceptionRequiresForwardSecrecy: false,
|
|
73
|
+
};
|
|
74
|
+
exceptionDomains.localhost = allowHttp;
|
|
75
|
+
exceptionDomains["127.0.0.1"] = allowHttp;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
42
78
|
//# sourceMappingURL=electronMacUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electronMacUtils.js","sourceRoot":"","sources":["../../../src/electron/mac/electronMacUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAa;IAC9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACxC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,yBAAyB,CACjC,GAAG,KAAK,KAAK,IAAI,qEAAqE,SAAS,aAAa,KAAK,0CAA0C,CAC5J,CAAA;IACH,CAAC;AACH,CAAC;AAUD;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAyB;IAClE,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,CAAA;IAC1B,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC3B,CAAC;IACD,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC3B,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IACnC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACjC,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC9B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/internal\"\n\n/**\n * At runtime Electron locates its helper apps relative to the main application name, resolving each\n * one as `${CFBundleName} Helper.app` (see `electron_main_delegate_mac.mm`). electron-builder uses\n * the product name verbatim for both `CFBundleName` and the on-disk helper/app bundle names, so the\n * name must be usable as a filename without modification.\n *\n * If the name would be altered by filename sanitization, the on-disk bundle (sanitized) and\n * `CFBundleName` (verbatim) would diverge and break helper discovery. Reject such names up front with\n * a clear error so the user can choose a valid name, rather than silently changing it for them.\n */\nexport function assertSafeHelperName(name: string, field: string): void {\n const sanitized = sanitizeFileName(name)\n if (sanitized !== name) {\n throw new InvalidConfigurationError(\n `${field} \"${name}\" is not a valid macOS app bundle name (it would be sanitized to \"${sanitized}\"). Set a ${field} that requires no filename sanitization.`\n )\n }\n}\n\nexport interface AvailableHelpers {\n EH?: boolean\n NP?: boolean\n Renderer?: boolean\n Plugin?: boolean\n GPU?: boolean\n}\n\n/**\n * Returns the helper bundle suffixes present in the current Electron distribution. The generic\n * `\" Helper\"` bundle is always present; the remaining variants vary by Electron version.\n */\nexport function getAvailableHelperSuffixes(present: AvailableHelpers): string[] {\n const result = [\" Helper\"]\n if (present.EH) {\n result.push(\" Helper EH\")\n }\n if (present.NP) {\n result.push(\" Helper NP\")\n }\n if (present.Renderer) {\n result.push(\" Helper (Renderer)\")\n }\n if (present.Plugin) {\n result.push(\" Helper (Plugin)\")\n }\n if (present.GPU) {\n result.push(\" Helper (GPU)\")\n }\n return result\n}\n"]}
|
|
1
|
+
{"version":3,"file":"electronMacUtils.js","sourceRoot":"","sources":["../../../src/electron/mac/electronMacUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAa;IAC9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACxC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,yBAAyB,CACjC,GAA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B,IAAI,IAAI,EAAE,CAAC;QAC7B,gBAAgB,GAAG,EAAE,CAAA;QACrB,GAAG,CAAC,kBAAkB,GAAG,gBAAgB,CAAA;IAC3C,CAAC;IAED,IAAI,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG;YAChB,4CAA4C,EAAE,KAAK;YACnD,oBAAoB,EAAE,KAAK;YAC3B,2CAA2C,EAAE,IAAI;YACjD,qCAAqC,EAAE,KAAK;YAC5C,0CAA0C,EAAE,KAAK;SAClD,CAAA;QACD,gBAAgB,CAAC,SAAS,GAAG,SAAS,CAAA;QACtC,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/internal\"\n\n/**\n * At runtime Electron locates its helper apps relative to the main application name, resolving each\n * one as `${CFBundleName} Helper.app` (see `electron_main_delegate_mac.mm`). electron-builder uses\n * the product name verbatim for both `CFBundleName` and the on-disk helper/app bundle names, so the\n * name must be usable as a filename without modification.\n *\n * If the name would be altered by filename sanitization, the on-disk bundle (sanitized) and\n * `CFBundleName` (verbatim) would diverge and break helper discovery. Reject such names up front with\n * a clear error so the user can choose a valid name, rather than silently changing it for them.\n */\nexport function assertSafeHelperName(name: string, field: string): void {\n const sanitized = sanitizeFileName(name)\n if (sanitized !== name) {\n throw new InvalidConfigurationError(\n `${field} \"${name}\" is not a valid macOS app bundle name (it would be sanitized to \"${sanitized}\"). Set a ${field} that requires no filename sanitization.`\n )\n }\n}\n\nexport interface AvailableHelpers {\n EH?: boolean\n NP?: boolean\n Renderer?: boolean\n Plugin?: boolean\n GPU?: boolean\n}\n\n/**\n * Returns the helper bundle suffixes present in the current Electron distribution. The generic\n * `\" Helper\"` bundle is always present; the remaining variants vary by Electron version.\n */\nexport function getAvailableHelperSuffixes(present: AvailableHelpers): string[] {\n const result = [\" Helper\"]\n if (present.EH) {\n result.push(\" Helper EH\")\n }\n if (present.NP) {\n result.push(\" Helper NP\")\n }\n if (present.Renderer) {\n result.push(\" Helper (Renderer)\")\n }\n if (present.Plugin) {\n result.push(\" Helper (Plugin)\")\n }\n if (present.GPU) {\n result.push(\" Helper (GPU)\")\n }\n return result\n}\n\n/**\n * Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and\n * plain-HTTP exceptions for `localhost` and `127.0.0.1`.\n *\n * `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through\n * `mac.extendInfo`, so an explicit `false` is kept.\n */\nexport function configureLocalhostAts(appPlist: any): void {\n // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/\n let ats = appPlist.NSAppTransportSecurity\n if (ats == null) {\n ats = {}\n appPlist.NSAppTransportSecurity = ats\n }\n\n ats.NSAllowsLocalNetworking = true\n // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814\n if (ats.NSAllowsArbitraryLoads == null) {\n ats.NSAllowsArbitraryLoads = true\n }\n\n let exceptionDomains = ats.NSExceptionDomains\n if (exceptionDomains == null) {\n exceptionDomains = {}\n ats.NSExceptionDomains = exceptionDomains\n }\n\n if (exceptionDomains.localhost == null) {\n const allowHttp = {\n NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,\n NSIncludesSubdomains: false,\n NSTemporaryExceptionAllowsInsecureHTTPLoads: true,\n NSTemporaryExceptionMinimumTLSVersion: \"1.0\",\n NSTemporaryExceptionRequiresForwardSecrecy: false,\n }\n exceptionDomains.localhost = allowHttp\n exceptionDomains[\"127.0.0.1\"] = allowHttp\n }\n}\n"]}
|
package/dist/fileMatcher.d.ts
CHANGED
|
@@ -6,36 +6,59 @@ import { PlatformSpecificBuildOptions } from "./options/PlatformSpecificBuildOpt
|
|
|
6
6
|
export declare const DEFAULT_EXCLUDED_NAMES: ReadonlyArray<string>;
|
|
7
7
|
export declare const DEFAULT_EXCLUDED_EXTENSIONS: ReadonlyArray<string>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* The file extensions (without leading dot) excluded from the app files and the copied `node_modules`, from the
|
|
10
|
+
* `fileOptions.excludedExts` build option: the platform-level value (`mac.fileOptions.excludedExts`, ...) when it is set,
|
|
11
|
+
* otherwise the root one, otherwise `["default"]`. See `FilesBuildOptions.excludedExts`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveExcludedExtensions(config: Pick<Configuration, "fileOptions">, platformOptions: PlatformSpecificBuildOptions | Nullish): Array<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Determines which excluded extensions (`excludedExtensions`, see {@link resolveExcludedExtensions}) and default-excluded
|
|
16
|
+
* names a user has explicitly opted back in to via their `files` patterns: the extensions for the warning (the files a pattern
|
|
17
|
+
* names are let through by {@link FileMatcher.extensionReincludes}), the names to leave out of the name exclusion glob.
|
|
11
18
|
*
|
|
12
|
-
*
|
|
19
|
+
* An exclusion is treated as opted back in only when a non-negated pattern references it concretely:
|
|
13
20
|
* an extension when a pattern's basename ends with `.<ext>` (e.g. `**\/*.obj`, `assets/*.{obj,gltf}`,
|
|
14
|
-
* `**\/*.d.ts`)
|
|
21
|
+
* `**\/*.d.ts`), only the longest such extension counting (`*.d.ts` names `d.ts`, not also a listed `ts`);
|
|
22
|
+
* a name when any path segment equals it (e.g. `**\/.github/**`, `**\/yarn.lock`).
|
|
15
23
|
* Broad patterns such as `**\/*` reference nothing concrete and therefore opt nothing in.
|
|
16
24
|
*/
|
|
17
|
-
export declare function collectExplicitReincludes(patterns: ReadonlyArray<string>): {
|
|
25
|
+
export declare function collectExplicitReincludes(patterns: ReadonlyArray<string>, excludedExtensions?: ReadonlyArray<string>): {
|
|
18
26
|
extensions: Set<string>;
|
|
19
27
|
names: Set<string>;
|
|
20
28
|
};
|
|
21
29
|
/**
|
|
22
|
-
* Builds the trailing list of default ignore globs appended to the main app file matcher
|
|
23
|
-
*
|
|
24
|
-
*
|
|
30
|
+
* Builds the trailing list of default ignore globs appended to the main app file matcher: a glob that excludes every one of
|
|
31
|
+
* `excludedExtensions` (see {@link resolveExcludedExtensions}), then the default-excluded names except those a `files` entry
|
|
32
|
+
* re-includes (see {@link collectExplicitReincludes}) and the fixed ignores. The files a `files` entry names despite their
|
|
33
|
+
* excluded extension are let through by {@link FileMatcher.extensionReincludes}, not by these patterns.
|
|
25
34
|
*/
|
|
26
|
-
export declare function getDefaultIgnoredPatterns(userPatterns: ReadonlyArray<string>,
|
|
35
|
+
export declare function getDefaultIgnoredPatterns(userPatterns: ReadonlyArray<string>, excludedExtensions?: ReadonlyArray<string>): Array<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Lets through the files a `files` pattern names despite their excluded extension (see getMainFileMatchers): the extension glob
|
|
38
|
+
* excludes every file with an excluded extension, and such a file is included only when a pattern that names its extension matches
|
|
39
|
+
* it and the matcher's other patterns (`node_modules` and the build resources and output directories, `files` negations) include it.
|
|
40
|
+
*/
|
|
41
|
+
export interface ExtensionReincludes {
|
|
42
|
+
/** The pattern of the matcher that excludes the extensions. */
|
|
43
|
+
readonly glob: string;
|
|
44
|
+
readonly extensions: ReadonlyArray<string>;
|
|
45
|
+
/** Per excluded extension, the `files` patterns that name it (see {@link collectExtensionReincludes}). */
|
|
46
|
+
readonly namedBy: ReadonlyMap<string, ReadonlyArray<string>>;
|
|
47
|
+
}
|
|
27
48
|
/**
|
|
28
49
|
* Returns the default-excluded names/extensions that the given `files` patterns opt back in, formatted
|
|
29
50
|
* for display (extensions as `*.<ext>`, names verbatim). Empty when nothing default-excluded is
|
|
30
51
|
* re-included. Used to warn that files normally kept out of the package will now be included.
|
|
31
52
|
*/
|
|
32
|
-
export declare function getReincludedDefaultExclusions(patterns: ReadonlyArray<string>): Array<string>;
|
|
53
|
+
export declare function getReincludedDefaultExclusions(patterns: ReadonlyArray<string>, excludedExtensions?: ReadonlyArray<string>): Array<string>;
|
|
33
54
|
export declare class FileMatcher {
|
|
34
55
|
readonly macroExpander: (pattern: string) => string;
|
|
35
56
|
readonly from: string;
|
|
36
57
|
readonly to: string;
|
|
37
58
|
readonly patterns: Array<string>;
|
|
38
59
|
excludePatterns: Array<Minimatch> | null;
|
|
60
|
+
/** The files a `files` pattern names despite their excluded extension, which the filter lets through the extension glob. */
|
|
61
|
+
extensionReincludes: ExtensionReincludes | null;
|
|
39
62
|
readonly isSpecifiedAsEmptyArray: boolean;
|
|
40
63
|
constructor(from: string, to: string, macroExpander: (pattern: string) => string, patterns?: Array<string> | string | null);
|
|
41
64
|
normalizePattern(pattern: string): string;
|
|
@@ -43,7 +66,7 @@ export declare class FileMatcher {
|
|
|
43
66
|
prependPattern(pattern: string): void;
|
|
44
67
|
isEmpty(): boolean;
|
|
45
68
|
containsOnlyIgnore(): boolean;
|
|
46
|
-
computeParsedPatterns(result: Array<Minimatch>, fromDir?: string): void;
|
|
69
|
+
computeParsedPatterns(result: Array<Minimatch>, fromDir?: string, patterns?: ReadonlyArray<string>): void;
|
|
47
70
|
createFilter(): Filter;
|
|
48
71
|
toString(): string;
|
|
49
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileMatcher.d.ts","sourceRoot":"","sources":["../src/fileMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAElB,MAAM,EAOP,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"fileMatcher.d.ts","sourceRoot":"","sources":["../src/fileMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAElB,MAAM,EAOP,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAW,4BAA4B,EAAE,MAAM,2CAA2C,CAAA;AAWjG,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,MAAM,CAoCxD,CA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eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,OAAO,GAAG,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,EAClE,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,sBAAsB,GAC9B,KAAK,CAAC,WAAW,CAAC,GAAG,IAAI,CAgD3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,kIAAkI;IAClI,QAAQ,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IAC3D,8HAA8H;IAC9H,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACnD"}
|
package/dist/fileMatcher.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { asArray, copyDir, copyOrLinkFile, InvalidConfigurationError, isPathWithin, log, statOrNull, USE_HARD_LINKS, WriteContainment, } from "builder-util";
|
|
2
|
+
import { DEFAULT_KEYWORD, resolveDefaultKeywordList } from "builder-util/internal";
|
|
2
3
|
import { Minimatch } from "minimatch";
|
|
3
4
|
import * as path from "path";
|
|
5
|
+
import { normalizeExcludedExtensions } from "./util/config/fileOptions.js";
|
|
4
6
|
import { createFilter, hasMagic } from "./util/filter.js";
|
|
5
7
|
// https://github.com/electron-userland/electron-builder/issues/733
|
|
6
8
|
const minimatchOptions = { dot: true };
|
|
@@ -44,7 +46,7 @@ export const DEFAULT_EXCLUDED_NAMES = [
|
|
|
44
46
|
".github",
|
|
45
47
|
"electron-builder.env",
|
|
46
48
|
];
|
|
47
|
-
// File extensions (without leading dot) excluded by default from the packaged app.
|
|
49
|
+
// File extensions (without leading dot) excluded by default from the packaged app, the `"default"` entry of `fileOptions.excludedExts`.
|
|
48
50
|
export const DEFAULT_EXCLUDED_EXTENSIONS = [
|
|
49
51
|
"iml",
|
|
50
52
|
"hprof",
|
|
@@ -66,7 +68,18 @@ export const DEFAULT_EXCLUDED_EXTENSIONS = [
|
|
|
66
68
|
"o",
|
|
67
69
|
"obj",
|
|
68
70
|
"forge-meta",
|
|
71
|
+
"pdb",
|
|
69
72
|
];
|
|
73
|
+
/**
|
|
74
|
+
* The file extensions (without leading dot) excluded from the app files and the copied `node_modules`, from the
|
|
75
|
+
* `fileOptions.excludedExts` build option: the platform-level value (`mac.fileOptions.excludedExts`, ...) when it is set,
|
|
76
|
+
* otherwise the root one, otherwise `["default"]`. See `FilesBuildOptions.excludedExts`.
|
|
77
|
+
*/
|
|
78
|
+
export function resolveExcludedExtensions(config, platformOptions) {
|
|
79
|
+
const entries = platformOptions?.fileOptions?.excludedExts ?? config.fileOptions?.excludedExts ?? [DEFAULT_KEYWORD];
|
|
80
|
+
// a "!ext" that removes nothing is reported by validateConfiguration, naming the section
|
|
81
|
+
return resolveDefaultKeywordList(normalizeExcludedExtensions(entries), DEFAULT_EXCLUDED_EXTENSIONS).result;
|
|
82
|
+
}
|
|
70
83
|
// Hard cap on the number of strings a single pattern may expand to. Real opt-in patterns expand to a
|
|
71
84
|
// handful (`{obj,gltf,glb}`); this bound makes the expansion provably finite so a pathological pattern
|
|
72
85
|
// (e.g. nested or many large `{...}` groups whose product is huge) degrades to "treated literally"
|
|
@@ -130,17 +143,19 @@ function splitTopLevel(value) {
|
|
|
130
143
|
return parts;
|
|
131
144
|
}
|
|
132
145
|
/**
|
|
133
|
-
* Determines which
|
|
134
|
-
* their `files` patterns
|
|
146
|
+
* Determines which excluded extensions (`excludedExtensions`, see {@link resolveExcludedExtensions}) and default-excluded
|
|
147
|
+
* names a user has explicitly opted back in to via their `files` patterns: the extensions for the warning (the files a pattern
|
|
148
|
+
* names are let through by {@link FileMatcher.extensionReincludes}), the names to leave out of the name exclusion glob.
|
|
135
149
|
*
|
|
136
|
-
*
|
|
150
|
+
* An exclusion is treated as opted back in only when a non-negated pattern references it concretely:
|
|
137
151
|
* an extension when a pattern's basename ends with `.<ext>` (e.g. `**\/*.obj`, `assets/*.{obj,gltf}`,
|
|
138
|
-
* `**\/*.d.ts`)
|
|
152
|
+
* `**\/*.d.ts`), only the longest such extension counting (`*.d.ts` names `d.ts`, not also a listed `ts`);
|
|
153
|
+
* a name when any path segment equals it (e.g. `**\/.github/**`, `**\/yarn.lock`).
|
|
139
154
|
* Broad patterns such as `**\/*` reference nothing concrete and therefore opt nothing in.
|
|
140
155
|
*/
|
|
141
|
-
export function collectExplicitReincludes(patterns) {
|
|
156
|
+
export function collectExplicitReincludes(patterns, excludedExtensions = DEFAULT_EXCLUDED_EXTENSIONS) {
|
|
142
157
|
const segments = new Set();
|
|
143
|
-
const
|
|
158
|
+
const namedExtensions = new Set();
|
|
144
159
|
for (const pattern of patterns) {
|
|
145
160
|
if (pattern.startsWith("!")) {
|
|
146
161
|
continue;
|
|
@@ -150,36 +165,34 @@ export function collectExplicitReincludes(patterns) {
|
|
|
150
165
|
for (const part of parts) {
|
|
151
166
|
segments.add(part);
|
|
152
167
|
}
|
|
153
|
-
|
|
168
|
+
const named = longestExcludedExtension(parts[parts.length - 1], excludedExtensions);
|
|
169
|
+
if (named != null) {
|
|
170
|
+
namedExtensions.add(named);
|
|
171
|
+
}
|
|
154
172
|
}
|
|
155
173
|
}
|
|
156
|
-
const extensions = new Set(
|
|
174
|
+
const extensions = new Set(excludedExtensions.filter(ext => namedExtensions.has(ext)));
|
|
157
175
|
const names = new Set(DEFAULT_EXCLUDED_NAMES.filter(name => segments.has(name)));
|
|
158
176
|
return { extensions, names };
|
|
159
177
|
}
|
|
160
178
|
/**
|
|
161
|
-
* Builds the trailing list of default ignore globs appended to the main app file matcher
|
|
162
|
-
*
|
|
163
|
-
*
|
|
179
|
+
* Builds the trailing list of default ignore globs appended to the main app file matcher: a glob that excludes every one of
|
|
180
|
+
* `excludedExtensions` (see {@link resolveExcludedExtensions}), then the default-excluded names except those a `files` entry
|
|
181
|
+
* re-includes (see {@link collectExplicitReincludes}) and the fixed ignores. The files a `files` entry names despite their
|
|
182
|
+
* excluded extension are let through by {@link FileMatcher.extensionReincludes}, not by these patterns.
|
|
164
183
|
*/
|
|
165
|
-
export function getDefaultIgnoredPatterns(userPatterns,
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
if (!includePdb) {
|
|
169
|
-
extensions.push("pdb");
|
|
170
|
-
}
|
|
171
|
-
const names = DEFAULT_EXCLUDED_NAMES.filter(name => !reincluded.names.has(name));
|
|
184
|
+
export function getDefaultIgnoredPatterns(userPatterns, excludedExtensions = DEFAULT_EXCLUDED_EXTENSIONS) {
|
|
185
|
+
const reincludedNames = collectExplicitReincludes(userPatterns, excludedExtensions).names;
|
|
186
|
+
const names = DEFAULT_EXCLUDED_NAMES.filter(name => !reincludedNames.has(name));
|
|
172
187
|
const patterns = [];
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
patterns.push(`!**/*.${extensions[0]}`);
|
|
177
|
-
}
|
|
178
|
-
else if (extensions.length > 1) {
|
|
179
|
-
patterns.push(`!**/*.{${extensions.join(",")}}`);
|
|
188
|
+
const extensionGlob = excludedExtensionsGlob(excludedExtensions);
|
|
189
|
+
if (extensionGlob != null) {
|
|
190
|
+
patterns.push(extensionGlob);
|
|
180
191
|
}
|
|
181
192
|
patterns.push("!**/._*");
|
|
182
193
|
patterns.push("!**/electron-builder.{yaml,yml,json,json5,toml,ts}");
|
|
194
|
+
// minimatch does not expand a single-member brace (`{x}` is matched literally), so emit a bare
|
|
195
|
+
// glob when only one name is excluded.
|
|
183
196
|
if (names.length === 1) {
|
|
184
197
|
patterns.push(`!**/${names[0]}`);
|
|
185
198
|
}
|
|
@@ -193,13 +206,52 @@ export function getDefaultIgnoredPatterns(userPatterns, includePdb) {
|
|
|
193
206
|
patterns.push("!.yarnrc.yml");
|
|
194
207
|
return patterns;
|
|
195
208
|
}
|
|
209
|
+
/** The glob that excludes `excludedExtensions` (a bare one for a single extension, since minimatch matches `{x}` literally), or null for none. */
|
|
210
|
+
function excludedExtensionsGlob(excludedExtensions) {
|
|
211
|
+
if (excludedExtensions.length === 0) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
return excludedExtensions.length === 1 ? `!**/*.${excludedExtensions[0]}` : `!**/*.{${excludedExtensions.join(",")}}`;
|
|
215
|
+
}
|
|
216
|
+
/** The longest of `excludedExtensions` that `name` ends with (`index.d.ts` → `d.ts`, not also a listed `ts`), or null. */
|
|
217
|
+
function longestExcludedExtension(name, excludedExtensions) {
|
|
218
|
+
let result = null;
|
|
219
|
+
for (const ext of excludedExtensions) {
|
|
220
|
+
if (name.endsWith(`.${ext}`) && (result == null || ext.length > result.length)) {
|
|
221
|
+
result = ext;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Per excluded extension, the `files` patterns that name it: each brace-expanded alternative of a non-negated pattern whose basename
|
|
228
|
+
* ends with that extension (the longest one, see {@link longestExcludedExtension}). An alternative of `native/{**\/*,addon.pdb}`
|
|
229
|
+
* without such an extension names nothing. An alternative that still holds braces (a pattern too large to expand, or a literal brace)
|
|
230
|
+
* is recorded whole: an extension cannot hold a brace, so the extension it ends with follows its last brace and every alternative minimatch
|
|
231
|
+
* expands it to ends with it.
|
|
232
|
+
*/
|
|
233
|
+
function collectExtensionReincludes(patterns, excludedExtensions) {
|
|
234
|
+
const result = new Map();
|
|
235
|
+
for (const pattern of patterns) {
|
|
236
|
+
if (pattern.startsWith("!")) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
for (const expanded of expandBraces(pattern)) {
|
|
240
|
+
const extension = longestExcludedExtension(expanded.substring(expanded.lastIndexOf("/") + 1), excludedExtensions);
|
|
241
|
+
if (extension != null) {
|
|
242
|
+
result.set(extension, [...(result.get(extension) ?? []), expanded]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
196
248
|
/**
|
|
197
249
|
* Returns the default-excluded names/extensions that the given `files` patterns opt back in, formatted
|
|
198
250
|
* for display (extensions as `*.<ext>`, names verbatim). Empty when nothing default-excluded is
|
|
199
251
|
* re-included. Used to warn that files normally kept out of the package will now be included.
|
|
200
252
|
*/
|
|
201
|
-
export function getReincludedDefaultExclusions(patterns) {
|
|
202
|
-
const reincluded = collectExplicitReincludes(patterns);
|
|
253
|
+
export function getReincludedDefaultExclusions(patterns, excludedExtensions = DEFAULT_EXCLUDED_EXTENSIONS) {
|
|
254
|
+
const reincluded = collectExplicitReincludes(patterns, excludedExtensions);
|
|
203
255
|
return [...[...reincluded.extensions].map(ext => `*.${ext}`), ...reincluded.names];
|
|
204
256
|
}
|
|
205
257
|
function ensureNoEndSlash(file) {
|
|
@@ -220,6 +272,8 @@ export class FileMatcher {
|
|
|
220
272
|
constructor(from, to, macroExpander, patterns) {
|
|
221
273
|
this.macroExpander = macroExpander;
|
|
222
274
|
this.excludePatterns = null;
|
|
275
|
+
/** The files a `files` pattern names despite their excluded extension, which the filter lets through the extension glob. */
|
|
276
|
+
this.extensionReincludes = null;
|
|
223
277
|
this.from = ensureNoEndSlash(macroExpander(from));
|
|
224
278
|
this.to = ensureNoEndSlash(macroExpander(to));
|
|
225
279
|
this.patterns = asArray(patterns).map(it => this.normalizePattern(it));
|
|
@@ -243,14 +297,14 @@ export class FileMatcher {
|
|
|
243
297
|
containsOnlyIgnore() {
|
|
244
298
|
return !this.isEmpty() && this.patterns.find(it => !it.startsWith("!")) == null;
|
|
245
299
|
}
|
|
246
|
-
computeParsedPatterns(result, fromDir) {
|
|
300
|
+
computeParsedPatterns(result, fromDir, patterns = this.patterns) {
|
|
247
301
|
const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from);
|
|
248
|
-
if (
|
|
302
|
+
if (patterns.length === 0 && relativeFrom != null) {
|
|
249
303
|
// file mappings, from here is a file
|
|
250
304
|
result.push(new Minimatch(relativeFrom, minimatchOptions));
|
|
251
305
|
return;
|
|
252
306
|
}
|
|
253
|
-
for (let pattern of
|
|
307
|
+
for (let pattern of patterns) {
|
|
254
308
|
if (relativeFrom != null) {
|
|
255
309
|
pattern = path.join(relativeFrom, pattern);
|
|
256
310
|
}
|
|
@@ -267,7 +321,34 @@ export class FileMatcher {
|
|
|
267
321
|
createFilter() {
|
|
268
322
|
const parsedPatterns = [];
|
|
269
323
|
this.computeParsedPatterns(parsedPatterns);
|
|
270
|
-
|
|
324
|
+
const filter = createFilter(this.from, parsedPatterns, this.excludePatterns);
|
|
325
|
+
const reincludes = this.extensionReincludes;
|
|
326
|
+
if (reincludes == null) {
|
|
327
|
+
return filter;
|
|
328
|
+
}
|
|
329
|
+
// only the glob getMainFileMatchers appended (the last one): a `files` negation with the same text still applies
|
|
330
|
+
const globIndex = this.patterns.lastIndexOf(reincludes.glob);
|
|
331
|
+
const withoutGlob = this.patterns.filter((_, index) => index !== globIndex);
|
|
332
|
+
const otherPatterns = [];
|
|
333
|
+
this.computeParsedPatterns(otherPatterns, undefined, withoutGlob);
|
|
334
|
+
const withoutExtensionGlob = createFilter(this.from, otherPatterns, this.excludePatterns);
|
|
335
|
+
const namedBy = new Map([...reincludes.namedBy].map(([extension, patterns]) => [extension, patterns.map(it => new Minimatch(it, minimatchOptions))]));
|
|
336
|
+
return (file, stat) => {
|
|
337
|
+
if (filter(file, stat)) {
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
// a directory named with an excluded extension stays excluded
|
|
341
|
+
if (stat.isDirectory()) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
const extension = longestExcludedExtension(path.basename(file), reincludes.extensions);
|
|
345
|
+
const named = extension == null ? undefined : namedBy.get(extension);
|
|
346
|
+
if (named == null) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
const relative = path.relative(this.from, file).split(path.sep).join("/");
|
|
350
|
+
return named.some(it => it.match(relative)) && withoutExtensionGlob(file, stat);
|
|
351
|
+
};
|
|
271
352
|
}
|
|
272
353
|
toString() {
|
|
273
354
|
return `from: ${this.from}, to: ${this.to}, patterns: ${this.patterns.join(", ")}`;
|
|
@@ -336,12 +417,18 @@ export function getMainFileMatchers(appDir, destination, macroExpander, platform
|
|
|
336
417
|
}
|
|
337
418
|
}
|
|
338
419
|
patterns.splice(insertIndex, 0, ...customFirstPatterns);
|
|
339
|
-
const
|
|
420
|
+
const excludedExtensions = resolveExcludedExtensions(platformPackager.config, platformSpecificBuildOptions);
|
|
421
|
+
const reincludedDefaults = getReincludedDefaultExclusions(userSpecifiedPatterns, excludedExtensions);
|
|
340
422
|
if (reincludedDefaults.length > 0) {
|
|
341
423
|
// These files are kept out of the package by default; a user `files` pattern is opting them back in.
|
|
342
424
|
log.warn({ files: reincludedDefaults.join(", ") }, "`files` configuration re-includes files that are excluded by default — verify this is intentional");
|
|
343
425
|
}
|
|
344
|
-
patterns.push(...getDefaultIgnoredPatterns(userSpecifiedPatterns,
|
|
426
|
+
patterns.push(...getDefaultIgnoredPatterns(userSpecifiedPatterns, excludedExtensions));
|
|
427
|
+
const extensionGlob = excludedExtensionsGlob(excludedExtensions);
|
|
428
|
+
const namedBy = collectExtensionReincludes(userSpecifiedPatterns, excludedExtensions);
|
|
429
|
+
if (extensionGlob != null && namedBy.size > 0) {
|
|
430
|
+
matcher.extensionReincludes = { glob: extensionGlob, extensions: excludedExtensions, namedBy };
|
|
431
|
+
}
|
|
345
432
|
const debugLogger = platformPackager.debugLogger;
|
|
346
433
|
if (debugLogger.isEnabled) {
|
|
347
434
|
//tslint:disable-next-line:no-invalid-template-strings
|