app-builder-lib 26.0.16 → 26.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/binDownload.d.ts +1 -1
- package/out/binDownload.js +10 -10
- package/out/binDownload.js.map +1 -1
- package/out/electron/ElectronFramework.js +51 -43
- package/out/electron/ElectronFramework.js.map +1 -1
- package/out/node-module-collector/index.js +1 -1
- package/out/node-module-collector/index.js.map +1 -1
- package/out/node-module-collector/nodeModulesCollector.d.ts +4 -6
- package/out/node-module-collector/nodeModulesCollector.js +2 -1
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/npmNodeModulesCollector.d.ts +4 -6
- package/out/node-module-collector/npmNodeModulesCollector.js +2 -3
- package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/packageManager.d.ts +1 -0
- package/out/node-module-collector/packageManager.js +52 -65
- package/out/node-module-collector/packageManager.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +4 -7
- package/out/node-module-collector/pnpmNodeModulesCollector.js +4 -19
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/yarnNodeModulesCollector.d.ts +4 -4
- package/out/node-module-collector/yarnNodeModulesCollector.js +3 -5
- package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
- package/out/options/winOptions.d.ts +4 -1
- package/out/options/winOptions.js.map +1 -1
- package/out/targets/MsiTarget.js +1 -1
- package/out/targets/MsiTarget.js.map +1 -1
- package/out/targets/nsis/Defines.d.ts +4 -0
- package/out/targets/nsis/Defines.js.map +1 -1
- package/out/targets/nsis/NsisTarget.js +5 -0
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisOptions.d.ts +16 -0
- package/out/targets/nsis/nsisOptions.js.map +1 -1
- package/out/targets/nsis/nsisUtil.js +2 -3
- package/out/targets/nsis/nsisUtil.js.map +1 -1
- package/out/targets/tools.js +7 -4
- package/out/targets/tools.js.map +1 -1
- package/out/util/yarn.d.ts +1 -0
- package/out/util/yarn.js +3 -1
- package/out/util/yarn.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +10 -8
- package/scheme.json +33 -1
- package/templates/nsis/include/installer.nsh +20 -0
package/out/binDownload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function download(url: string, output: string, checksum?: string | null): Promise<void>;
|
|
2
2
|
export declare function getBinFromCustomLoc(name: string, version: string, binariesLocUrl: string, checksum: string): Promise<string>;
|
|
3
|
-
export declare function getBinFromUrl(
|
|
3
|
+
export declare function getBinFromUrl(releaseName: string, filenameWithExt: string, checksum: string, githubOrgRepo?: string): Promise<string>;
|
|
4
4
|
export declare function getBin(name: string, url?: string | null, checksum?: string | null): Promise<string>;
|
package/out/binDownload.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getBinFromCustomLoc = getBinFromCustomLoc;
|
|
|
5
5
|
exports.getBinFromUrl = getBinFromUrl;
|
|
6
6
|
exports.getBin = getBin;
|
|
7
7
|
const builder_util_1 = require("builder-util");
|
|
8
|
+
const filename_1 = require("builder-util/out/filename");
|
|
8
9
|
const versionToPromise = new Map();
|
|
9
10
|
function download(url, output, checksum) {
|
|
10
11
|
const args = ["download", "--url", url, "--output", output];
|
|
@@ -17,36 +18,35 @@ function getBinFromCustomLoc(name, version, binariesLocUrl, checksum) {
|
|
|
17
18
|
const dirName = `${name}-${version}`;
|
|
18
19
|
return getBin(dirName, binariesLocUrl, checksum);
|
|
19
20
|
}
|
|
20
|
-
function getBinFromUrl(
|
|
21
|
-
const dirName = `${name}-${version}`;
|
|
21
|
+
function getBinFromUrl(releaseName, filenameWithExt, checksum, githubOrgRepo = "electron-userland/electron-builder-binaries") {
|
|
22
22
|
let url;
|
|
23
23
|
if (process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL) {
|
|
24
|
-
url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + "/" +
|
|
24
|
+
url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + "/" + filenameWithExt;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
const baseUrl = process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||
|
|
28
28
|
process.env.npm_config_electron_builder_binaries_mirror ||
|
|
29
29
|
process.env.npm_package_config_electron_builder_binaries_mirror ||
|
|
30
30
|
process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||
|
|
31
|
-
|
|
31
|
+
`https://github.com/${githubOrgRepo}/releases/download/`;
|
|
32
32
|
const middleUrl = process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||
|
|
33
33
|
process.env.npm_config_electron_builder_binaries_custom_dir ||
|
|
34
34
|
process.env.npm_package_config_electron_builder_binaries_custom_dir ||
|
|
35
35
|
process.env.ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
url = `${baseUrl}${middleUrl}/${urlSuffix}`;
|
|
36
|
+
releaseName;
|
|
37
|
+
url = `${baseUrl}${middleUrl}/${filenameWithExt}`;
|
|
39
38
|
}
|
|
40
|
-
return getBin(
|
|
39
|
+
return getBin(releaseName, url, checksum);
|
|
41
40
|
}
|
|
42
41
|
function getBin(name, url, checksum) {
|
|
42
|
+
var _a;
|
|
43
43
|
// Old cache is ignored if cache environment variable changes
|
|
44
|
-
const cacheName = `${process.env.ELECTRON_BUILDER_CACHE}${name}
|
|
44
|
+
const cacheName = (0, filename_1.sanitizeFileName)(`${(_a = process.env.ELECTRON_BUILDER_CACHE) !== null && _a !== void 0 ? _a : ""}${name}`);
|
|
45
45
|
let promise = versionToPromise.get(cacheName); // if rejected, we will try to download again
|
|
46
46
|
if (promise != null) {
|
|
47
47
|
return promise;
|
|
48
48
|
}
|
|
49
|
-
promise = doGetBin(
|
|
49
|
+
promise = doGetBin(cacheName, url, checksum);
|
|
50
50
|
versionToPromise.set(cacheName, promise);
|
|
51
51
|
return promise;
|
|
52
52
|
}
|
package/out/binDownload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;AAMA,4BAMC;AAED,kDAGC;AAED,sCAqBC;AAED,wBAYC;AAtDD,+CAAgD;AAEhD,wDAA4D;AAE5D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAA;AAE3D,SAAgB,QAAQ,CAAC,GAAW,EAAE,MAAc,EAAE,QAAwB;IAC5E,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;IAC3D,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAiB,CAAA;AAChD,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,OAAe,EAAE,cAAsB,EAAE,QAAgB;IACzG,MAAM,OAAO,GAAG,GAAG,IAAI,IAAI,OAAO,EAAE,CAAA;IACpC,OAAO,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAA;AAClD,CAAC;AAED,SAAgB,aAAa,CAAC,WAAmB,EAAE,eAAuB,EAAE,QAAgB,EAAE,aAAa,GAAG,6CAA6C;IACzJ,IAAI,GAAW,CAAA;IACf,IAAI,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,CAAC;QAChE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,+CAA+C,GAAG,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C,mBAAmB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IAClD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import { executeAppBuilder } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\n\nconst versionToPromise = new Map<string, Promise<string>>()\n\nexport function download(url: string, output: string, checksum?: string | null): Promise<void> {\n const args = [\"download\", \"--url\", url, \"--output\", output]\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args) as Promise<any>\n}\n\nexport function getBinFromCustomLoc(name: string, version: string, binariesLocUrl: string, checksum: string): Promise<string> {\n const dirName = `${name}-${version}`\n return getBin(dirName, binariesLocUrl, checksum)\n}\n\nexport function getBinFromUrl(releaseName: string, filenameWithExt: string, checksum: string, githubOrgRepo = \"electron-userland/electron-builder-binaries\"): Promise<string> {\n let url: string\n if (process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL) {\n url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + \"/\" + filenameWithExt\n } else {\n const baseUrl =\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||\n process.env.npm_config_electron_builder_binaries_mirror ||\n process.env.npm_package_config_electron_builder_binaries_mirror ||\n process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||\n `https://github.com/${githubOrgRepo}/releases/download/`\n const middleUrl =\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n process.env.npm_config_electron_builder_binaries_custom_dir ||\n process.env.npm_package_config_electron_builder_binaries_custom_dir ||\n process.env.ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n releaseName\n url = `${baseUrl}${middleUrl}/${filenameWithExt}`\n }\n\n return getBin(releaseName, url, checksum)\n}\n\nexport function getBin(name: string, url?: string | null, checksum?: string | null): Promise<string> {\n // Old cache is ignored if cache environment variable changes\n const cacheName = sanitizeFileName(`${process.env.ELECTRON_BUILDER_CACHE ?? \"\"}${name}`)\n let promise = versionToPromise.get(cacheName) // if rejected, we will try to download again\n\n if (promise != null) {\n return promise\n }\n\n promise = doGetBin(cacheName, url, checksum)\n versionToPromise.set(cacheName, promise)\n return promise\n}\n\nfunction doGetBin(name: string, url: string | Nullish, checksum: string | Nullish): Promise<string> {\n const args = [\"download-artifact\", \"--name\", name]\n if (url != null) {\n args.push(\"--url\", url)\n }\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args)\n}\n"]}
|
|
@@ -137,16 +137,64 @@ async function unpack(prepareOptions, downloadOptions, distMacOsAppName) {
|
|
|
137
137
|
const downloadUsingAdjustedConfig = (options) => {
|
|
138
138
|
return (0, builder_util_1.executeAppBuilder)(["unpack-electron", "--configuration", JSON.stringify([options]), "--output", appOutDir, "--distMacOsAppName", distMacOsAppName]);
|
|
139
139
|
};
|
|
140
|
+
const copyUnpackedElectronDistribution = async (folderPath) => {
|
|
141
|
+
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(folderPath) }, "using custom unpacked Electron distribution");
|
|
142
|
+
const source = packager.getElectronSrcDir(folderPath);
|
|
143
|
+
const destination = packager.getElectronDestinationDir(appOutDir);
|
|
144
|
+
builder_util_1.log.info({ source, destination }, "copying unpacked Electron");
|
|
145
|
+
await (0, fs_extra_1.emptyDir)(appOutDir);
|
|
146
|
+
await (0, builder_util_1.copyDir)(source, destination, {
|
|
147
|
+
isUseHardLink: builder_util_1.DO_NOT_USE_HARD_LINKS,
|
|
148
|
+
});
|
|
149
|
+
return false;
|
|
150
|
+
};
|
|
151
|
+
const selectElectron = async (filepath) => {
|
|
152
|
+
const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath);
|
|
153
|
+
const electronDistStats = await (0, builder_util_1.statOrNull)(resolvedDist);
|
|
154
|
+
if (!electronDistStats) {
|
|
155
|
+
throw new Error(`The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`);
|
|
156
|
+
}
|
|
157
|
+
if (resolvedDist.endsWith(".zip")) {
|
|
158
|
+
builder_util_1.log.info({ zipFile: resolvedDist }, "using custom electronDist zip file");
|
|
159
|
+
await downloadUsingAdjustedConfig({
|
|
160
|
+
...downloadOptions,
|
|
161
|
+
cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory
|
|
162
|
+
customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name
|
|
163
|
+
});
|
|
164
|
+
return false; // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required
|
|
165
|
+
}
|
|
166
|
+
if (electronDistStats.isDirectory()) {
|
|
167
|
+
// backward compatibility: if electronDist is a directory, check for the default zip file inside it
|
|
168
|
+
const files = await (0, fs_extra_1.readdir)(resolvedDist);
|
|
169
|
+
if (files.includes(defaultZipName)) {
|
|
170
|
+
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(resolvedDist) }, "using custom electronDist directory");
|
|
171
|
+
await downloadUsingAdjustedConfig({
|
|
172
|
+
...downloadOptions,
|
|
173
|
+
cache: resolvedDist,
|
|
174
|
+
customFilename: defaultZipName,
|
|
175
|
+
});
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
// if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file
|
|
179
|
+
// e.g. we treat it as a custom already-unpacked Electron distribution
|
|
180
|
+
return await copyUnpackedElectronDistribution(resolvedDist);
|
|
181
|
+
}
|
|
182
|
+
throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`);
|
|
183
|
+
};
|
|
140
184
|
const { packager, appOutDir, platformName } = prepareOptions;
|
|
141
185
|
const { version, arch } = downloadOptions;
|
|
142
186
|
const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`;
|
|
187
|
+
const electronDist = packager.config.electronDist;
|
|
188
|
+
if (typeof electronDist === "string" && !(0, builder_util_1.isEmptyOrSpaces)(electronDist)) {
|
|
189
|
+
return selectElectron(electronDist);
|
|
190
|
+
}
|
|
143
191
|
let resolvedDist = null;
|
|
144
192
|
try {
|
|
145
|
-
const electronDistHook = await (0, resolve_1.resolveFunction)(packager.appInfo.type,
|
|
193
|
+
const electronDistHook = await (0, resolve_1.resolveFunction)(packager.appInfo.type, electronDist, "electronDist");
|
|
146
194
|
resolvedDist = typeof electronDistHook === "function" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook;
|
|
147
195
|
}
|
|
148
196
|
catch (error) {
|
|
149
|
-
|
|
197
|
+
builder_util_1.log.warn({ error }, "Failed to resolve electronDist, using default unpack logic");
|
|
150
198
|
}
|
|
151
199
|
if (resolvedDist == null) {
|
|
152
200
|
// if no custom electronDist is provided, use the default unpack logic
|
|
@@ -154,47 +202,7 @@ async function unpack(prepareOptions, downloadOptions, distMacOsAppName) {
|
|
|
154
202
|
await downloadUsingAdjustedConfig(downloadOptions);
|
|
155
203
|
return true; // indicates that we should clean up after unpacking
|
|
156
204
|
}
|
|
157
|
-
|
|
158
|
-
// if it's a relative path, resolve it against the project directory
|
|
159
|
-
resolvedDist = path.resolve(packager.projectDir, resolvedDist);
|
|
160
|
-
}
|
|
161
|
-
const electronDistStats = await (0, builder_util_1.statOrNull)(resolvedDist);
|
|
162
|
-
if (!electronDistStats) {
|
|
163
|
-
throw new Error(`The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`);
|
|
164
|
-
}
|
|
165
|
-
if (resolvedDist.endsWith(".zip")) {
|
|
166
|
-
builder_util_1.log.info({ zipFile: resolvedDist }, "using custom electronDist zip file");
|
|
167
|
-
await downloadUsingAdjustedConfig({
|
|
168
|
-
...downloadOptions,
|
|
169
|
-
cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory
|
|
170
|
-
customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name
|
|
171
|
-
});
|
|
172
|
-
return false; // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required
|
|
173
|
-
}
|
|
174
|
-
if (electronDistStats.isDirectory()) {
|
|
175
|
-
// backward compatibility: if electronDist is a directory, check for the default zip file inside it
|
|
176
|
-
const files = await (0, fs_extra_1.readdir)(resolvedDist);
|
|
177
|
-
if (files.includes(defaultZipName)) {
|
|
178
|
-
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(resolvedDist) }, "using custom electronDist directory");
|
|
179
|
-
await downloadUsingAdjustedConfig({
|
|
180
|
-
...downloadOptions,
|
|
181
|
-
cache: resolvedDist,
|
|
182
|
-
customFilename: defaultZipName,
|
|
183
|
-
});
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file
|
|
188
|
-
// e.g. we treat it as a custom already-unpacked Electron distribution
|
|
189
|
-
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(resolvedDist) }, "using custom unpacked Electron distribution");
|
|
190
|
-
const source = packager.getElectronSrcDir(resolvedDist);
|
|
191
|
-
const destination = packager.getElectronDestinationDir(appOutDir);
|
|
192
|
-
builder_util_1.log.info({ source, destination }, "copying unpacked Electron");
|
|
193
|
-
await (0, fs_extra_1.emptyDir)(appOutDir);
|
|
194
|
-
await (0, builder_util_1.copyDir)(source, destination, {
|
|
195
|
-
isUseHardLink: builder_util_1.DO_NOT_USE_HARD_LINKS,
|
|
196
|
-
});
|
|
197
|
-
return false;
|
|
205
|
+
return selectElectron(resolvedDist);
|
|
198
206
|
}
|
|
199
207
|
function cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup) {
|
|
200
208
|
const out = prepareOptions.appOutDir;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;AA2BA,gDAKC;AAmID,wEAiBC;AApLD,+CAA6I;AAC7I,uCAAwD;AACxD,6BAA4B;AAC5B,qDAAuC;AAGvC,oCAA6C;AAG7C,qDAAqD;AACrD,6CAAiD;AACjD,+CAA4C;AAC5C,uDAA2F;AAC3F,+CAAmD;AACnD,iDAAyC;AAazC,SAAgB,kBAAkB,CAAC,IAAmB;;IACpD,OAAO;QACL,WAAW,EAAE,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,KAAI,UAAU;QAC7D,WAAW,EAAE,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,KAAI,UAAU;KAC9D,CAAA;AACH,CAAC;AA6BD,SAAS,kBAAkB,CAAC,IAAmB,EAAE,QAA8B,EAAE,IAAY,EAAE,eAAuB;IACpH,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO,EAAE,eAAe;QACxB,GAAG,IAAI,CAAC,gBAAgB;KACzB,CAAA;AACH,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,OAAoC;IACtE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IACvC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5D,IAAI,QAAQ,CAAC,QAAQ,KAAK,gBAAQ,CAAC,KAAK,EAAE,CAAC;QACzC,MAAM,aAAa,GAAG,QAAyB,CAAA;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;QACrE,MAAM,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAg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CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,cAAuD,EAAE,gBAAwB,EAAE,aAAsB;IACnI,MAAM,GAAG,GAAG,cAAc,CAAC,SAAS,CAAA;IACpC,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,KAAK,gBAAQ,CAAC,GAAG,CAAA;IAC/D,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAErH,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAChG,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7E,KAAK;YACH,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;YACnB,CAAC,CAAC,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnF,YAAY;YACd,CAAC,CAAC;KACP,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, executeAppBuilder, log, MAX_FILE_REQUESTS, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport injectFFMPEG from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nasync function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const {\n packager: { config, platformSpecificBuildOptions },\n } = options\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n if (!wantedLanguages.length) {\n return\n }\n\n const { dirs, langFileExt } = getLocalesConfig(options)\n // noinspection SpellCheckingInspection\n const deletedFiles = async (dir: string) => {\n await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {\n if (path.extname(file) !== langFileExt) {\n return\n }\n\n const language = path.basename(file, langFileExt)\n if (!wantedLanguages.includes(language)) {\n return rm(path.join(dir, file), { recursive: true, force: true })\n }\n return\n })\n }\n await Promise.all(dirs.map(deletedFiles))\n\n function getLocalesConfig(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n if (packager.platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly distMacOsAppName: string\n ) {}\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n await injectFFMPEG(options, this.version)\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, distMacOsAppName: string) {\n const downloadUsingAdjustedConfig = (options: ElectronDownloadOptions) => {\n return executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, packager.config.electronDist, \"electronDist\")\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n throw new Error(\"Failed to resolve electronDist: \" + error.message)\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n await downloadUsingAdjustedConfig(downloadOptions)\n return true // indicates that we should clean up after unpacking\n }\n\n if (!path.isAbsolute(resolvedDist)) {\n // if it's a relative path, resolve it against the project directory\n resolvedDist = path.resolve(packager.projectDir, resolvedDist)\n }\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(`The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory\n customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name\n })\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: resolvedDist,\n customFilename: defaultZipName,\n })\n return false\n }\n }\n\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(resolvedDist)\n const destination = packager.getElectronDestinationDir(appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n\n return false\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac\n ? Promise.resolve()\n : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {\n /* ignore */\n }),\n ])\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;AA2BA,gDAKC;AAmID,wEAiBC;AApLD,+CAA8J;AAC9J,uCAAwD;AACxD,6BAA4B;AAC5B,qDAAuC;AAGvC,oCAA6C;AAG7C,qDAAqD;AACrD,6CAAiD;AACjD,+CAA4C;AAC5C,uDAA2F;AAC3F,+CAAmD;AACnD,iDAAyC;AAazC,SAAgB,kBAAkB,CAAC,IAAmB;;IACpD,OAAO;QACL,WAAW,EAAE,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,KAAI,UAAU;QAC7D,WAAW,EAAE,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,KAAI,UAAU;KAC9D,CAAA;AACH,CAAC;AA6BD,SAAS,kBAAkB,CAAC,IAAmB,EAAE,QAA8B,EAAE,IAAY,EAAE,eAAuB;IACpH,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO,EAAE,eAAe;QACxB,GAAG,IAAI,CAAC,gBAAgB;KACzB,CAAA;AACH,CAAC;AAED,KAAK,UAAU,oBAAo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AAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAErH,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAChG,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7E,KAAK;YACH,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;YACnB,CAAC,CAAC,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnF,YAAY;YACd,CAAC,CAAC;KACP,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, executeAppBuilder, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport injectFFMPEG from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nasync function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const {\n packager: { config, platformSpecificBuildOptions },\n } = options\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n if (!wantedLanguages.length) {\n return\n }\n\n const { dirs, langFileExt } = getLocalesConfig(options)\n // noinspection SpellCheckingInspection\n const deletedFiles = async (dir: string) => {\n await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {\n if (path.extname(file) !== langFileExt) {\n return\n }\n\n const language = path.basename(file, langFileExt)\n if (!wantedLanguages.includes(language)) {\n return rm(path.join(dir, file), { recursive: true, force: true })\n }\n return\n })\n }\n await Promise.all(dirs.map(deletedFiles))\n\n function getLocalesConfig(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n if (packager.platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly distMacOsAppName: string\n ) {}\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n await injectFFMPEG(options, this.version)\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, distMacOsAppName: string): Promise<boolean> {\n const downloadUsingAdjustedConfig = (options: ElectronDownloadOptions) => {\n return executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n }\n\n const copyUnpackedElectronDistribution = async (folderPath: string) => {\n log.info({ electronDist: log.filePath(folderPath) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(folderPath)\n const destination = packager.getElectronDestinationDir(appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n return false\n }\n\n const selectElectron = async (filepath: string) => {\n const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(\n `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n )\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory\n customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name\n })\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: resolvedDist,\n customFilename: defaultZipName,\n })\n return false\n }\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n return await copyUnpackedElectronDistribution(resolvedDist)\n }\n throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n const electronDist = packager.config.electronDist\n if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n return selectElectron(electronDist)\n }\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\")\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n await downloadUsingAdjustedConfig(downloadOptions)\n return true // indicates that we should clean up after unpacking\n }\n return selectElectron(resolvedDist)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac\n ? Promise.resolve()\n : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {\n /* ignore */\n }),\n ])\n}\n"]}
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "PM", { enumerable: true, get: function () { retu
|
|
|
12
12
|
Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return packageManager_1.getPackageManagerCommand; } });
|
|
13
13
|
const builder_util_1 = require("builder-util");
|
|
14
14
|
async function isPnpmProjectHoisted(rootDir) {
|
|
15
|
-
const command =
|
|
15
|
+
const command = (0, packageManager_1.getPackageManagerCommand)(packageManager_1.PM.PNPM);
|
|
16
16
|
const config = await (0, builder_util_1.exec)(command, ["config", "list"], { cwd: rootDir, shell: true });
|
|
17
17
|
const lines = Object.fromEntries(config.split("\n").map(line => line.split("=").map(s => s.trim())));
|
|
18
18
|
return lines["node-linker"] === "hoisted";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node-module-collector/index.ts"],"names":[],"mappings":";;;AAcA,oEAeC;AAED,wCAGC;AAlCD,uEAAmE;AACnE,yEAAqE;AACrE,yEAAqE;AACrE,qDAAqF;AAiC5E,qGAjCA,qCAAoB,OAiCA;AAAE,mFAjCA,mBAAE,OAiCA;AAAE,yGAjCA,yCAAwB,OAiCA;AA/B3D,+CAAmC;AAEnC,KA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AAwB,CAAC,OAAO,CAAC,CAAA;QAC9C,KAAK,mBAAE,CAAC,GAAG;YACT,OAAO,IAAI,iDAAuB,CAAC,OAAO,CAAC,CAAA;QAC7C,KAAK,mBAAE,CAAC,IAAI;YACV,OAAO,IAAI,mDAAwB,CAAC,OAAO,CAAC,CAAA;QAC9C;YACE,OAAO,IAAI,iDAAuB,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,SAAS,GAAG,MAAM,4BAA4B,CAAC,OAAO,CAAC,CAAA;IAC7D,OAAO,SAAS,CAAC,cAAc,EAAE,CAAA;AACnC,CAAC","sourcesContent":["import { NpmNodeModulesCollector } from \"./npmNodeModulesCollector\"\nimport { PnpmNodeModulesCollector } from \"./pnpmNodeModulesCollector\"\nimport { YarnNodeModulesCollector } from \"./yarnNodeModulesCollector\"\nimport { detectPackageManager, PM, getPackageManagerCommand } from \"./packageManager\"\nimport { NodeModuleInfo } from \"./types\"\nimport { exec } from \"builder-util\"\n\nasync function isPnpmProjectHoisted(rootDir: string) {\n const command = getPackageManagerCommand(PM.PNPM)\n const config = await exec(command, [\"config\", \"list\"], { cwd: rootDir, shell: true })\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n return lines[\"node-linker\"] === \"hoisted\"\n}\n\nexport async function getCollectorByPackageManager(rootDir: string) {\n const manager: PM = detectPackageManager(rootDir)\n switch (manager) {\n case PM.PNPM:\n if (await isPnpmProjectHoisted(rootDir)) {\n return new NpmNodeModulesCollector(rootDir)\n }\n return new PnpmNodeModulesCollector(rootDir)\n case PM.NPM:\n return new NpmNodeModulesCollector(rootDir)\n case PM.YARN:\n return new YarnNodeModulesCollector(rootDir)\n default:\n return new NpmNodeModulesCollector(rootDir)\n }\n}\n\nexport async function getNodeModules(rootDir: string): Promise<NodeModuleInfo[]> {\n const collector = await getCollectorByPackageManager(rootDir)\n return collector.getNodeModules()\n}\n\nexport { detectPackageManager, PM, getPackageManagerCommand }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeModuleInfo, DependencyGraph, Dependency } from "./types";
|
|
2
|
-
import {
|
|
2
|
+
import { PM } from "./packageManager";
|
|
3
3
|
export declare abstract class NodeModulesCollector<T extends Dependency<T, OptionalsType>, OptionalsType> {
|
|
4
4
|
private readonly rootDir;
|
|
5
5
|
private nodeModules;
|
|
@@ -7,12 +7,10 @@ export declare abstract class NodeModulesCollector<T extends Dependency<T, Optio
|
|
|
7
7
|
protected productionGraph: DependencyGraph;
|
|
8
8
|
constructor(rootDir: string);
|
|
9
9
|
getNodeModules(): Promise<NodeModuleInfo[]>;
|
|
10
|
-
abstract readonly installOptions:
|
|
11
|
-
|
|
12
|
-
args: string[];
|
|
10
|
+
abstract readonly installOptions: {
|
|
11
|
+
manager: PM;
|
|
13
12
|
lockfile: string;
|
|
14
|
-
}
|
|
15
|
-
protected abstract readonly pmCommand: Lazy<string>;
|
|
13
|
+
};
|
|
16
14
|
protected abstract getArgs(): string[];
|
|
17
15
|
protected abstract parseDependenciesTree(jsonBlob: string): T;
|
|
18
16
|
protected abstract extractProductionDependencyGraph(tree: Dependency<T, OptionalsType>, dependencyId: string): void;
|
|
@@ -5,6 +5,7 @@ const hoist_1 = require("./hoist");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const builder_util_1 = require("builder-util");
|
|
8
|
+
const packageManager_1 = require("./packageManager");
|
|
8
9
|
class NodeModulesCollector {
|
|
9
10
|
constructor(rootDir) {
|
|
10
11
|
this.rootDir = rootDir;
|
|
@@ -22,7 +23,7 @@ class NodeModulesCollector {
|
|
|
22
23
|
return this.nodeModules;
|
|
23
24
|
}
|
|
24
25
|
async getDependenciesTree() {
|
|
25
|
-
const command =
|
|
26
|
+
const command = (0, packageManager_1.getPackageManagerCommand)(this.installOptions.manager);
|
|
26
27
|
const args = this.getArgs();
|
|
27
28
|
const dependencies = await (0, builder_util_1.exec)(command, args, {
|
|
28
29
|
cwd: this.rootDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AACrE,6BAA4B;AAC5B,yBAAwB;AAExB,+CAAwC;
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AACrE,6BAA4B;AAC5B,yBAAwB;AAExB,+CAAwC;AACxC,qDAA+D;AAE/D,MAAsB,oBAAoB;IAKxC,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAJpC,gBAAW,GAAqB,EAAE,CAAA;QAChC,oBAAe,GAAmB,IAAI,GAAG,EAAE,CAAA;QAC3C,oBAAe,GAAoB,EAAE,CAAA;IAEA,CAAC;IAEzC,KAAK,CAAC,cAAc;QACzB,MAAM,IAAI,GAAM,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAChD,MAAM,QAAQ,GAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACpD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,gCAAgC,CAAC,QAAQ,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAA;QAE1E,MAAM,aAAa,GAAkB,IAAA,aAAK,EAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1G,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAElE,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAYS,KAAK,CAAC,mBAAmB;QACjC,MAAM,OAAO,GAA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AM,CAAC,GAAG,MAAA,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,0CAAE,IAAI,CAAA;YAClE,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBACpB,kBAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,iCAAiC,CAAC,CAAA;gBACzE,SAAQ;YACV,CAAC;YACD,MAAM,IAAI,GAAmB;gBAC3B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,SAAS;gBAClB,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;aACzB,CAAA;YACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjB,IAAI,CAAC,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC5B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;gBACtB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;YACzD,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAhHD,oDAgHC","sourcesContent":["import { hoist, type HoisterTree, type HoisterResult } from \"./hoist\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport type { NodeModuleInfo, DependencyGraph, Dependency } from \"./types\"\nimport { exec, log } from \"builder-util\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\n\nexport abstract class NodeModulesCollector<T extends Dependency<T, OptionalsType>, OptionalsType> {\n private nodeModules: NodeModuleInfo[] = []\n protected allDependencies: Map<string, T> = new Map()\n protected productionGraph: DependencyGraph = {}\n\n constructor(private readonly rootDir: string) {}\n\n public async getNodeModules(): Promise<NodeModuleInfo[]> {\n const tree: T = await this.getDependenciesTree()\n const realTree: T = this.getTreeFromWorkspaces(tree)\n this.collectAllDependencies(realTree)\n this.extractProductionDependencyGraph(realTree, \".\" /*root project name*/)\n\n const hoisterResult: HoisterResult = hoist(this.transToHoisterTree(this.productionGraph), { check: true })\n this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n\n return this.nodeModules\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract parseDependenciesTree(jsonBlob: string): T\n protected abstract extractProductionDependencyGraph(tree: Dependency<T, OptionalsType>, dependencyId: string): void\n protected abstract collectAllDependencies(tree: Dependency<T, OptionalsType>): void\n\n protected async getDependenciesTree(): Promise<T> {\n const command = getPackageManagerCommand(this.installOptions.manager)\n const args = this.getArgs()\n const dependencies = await exec(command, args, {\n cwd: this.rootDir,\n shell: true,\n })\n return this.parseDependenciesTree(dependencies)\n }\n\n protected resolvePath(filePath: string): string {\n try {\n const stats = fs.lstatSync(filePath)\n if (stats.isSymbolicLink()) {\n return fs.realpathSync(filePath)\n } else {\n return filePath\n }\n } catch (error: any) {\n log.debug({ message: error.message || error.stack }, \"error resolving path\")\n return filePath\n }\n }\n\n private getTreeFromWorkspaces(tree: T): T {\n if (tree.workspaces && tree.dependencies) {\n const packageJson: Dependency<string, string> = require(path.join(this.rootDir, \"package.json\"))\n const dependencyName = packageJson.name\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === dependencyName) {\n return value\n }\n }\n }\n\n return tree\n }\n\n private transToHoisterTree(obj: DependencyGraph, key: string = `.`, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const name = key.match(/@?[^@]+/)![0]\n if (!node) {\n node = {\n name,\n identName: name,\n reference: key.match(/@?[^@]+@?(.+)?/)![1] || ``,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>([]),\n }\n nodes.set(key, node)\n\n for (const dep of (obj[key] || {}).dependencies || []) {\n node.dependencies.add(this.transToHoisterTree(obj, dep, nodes))\n }\n }\n return node\n }\n\n private _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.allDependencies.get(`${d.name}@${reference}`)?.path\n if (p === undefined) {\n log.debug({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: this.resolvePath(p),\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n}\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Lazy } from "lazy-val";
|
|
2
1
|
import { NodeModulesCollector } from "./nodeModulesCollector";
|
|
2
|
+
import { PM } from "./packageManager";
|
|
3
3
|
import { NpmDependency } from "./types";
|
|
4
4
|
export declare class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency, string> {
|
|
5
5
|
constructor(rootDir: string);
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
cmd: string;
|
|
9
|
-
args: string[];
|
|
6
|
+
readonly installOptions: {
|
|
7
|
+
manager: PM;
|
|
10
8
|
lockfile: string;
|
|
11
|
-
}
|
|
9
|
+
};
|
|
12
10
|
protected getArgs(): string[];
|
|
13
11
|
protected collectAllDependencies(tree: NpmDependency): void;
|
|
14
12
|
protected extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): void;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NpmNodeModulesCollector = void 0;
|
|
4
|
-
const lazy_val_1 = require("lazy-val");
|
|
5
4
|
const nodeModulesCollector_1 = require("./nodeModulesCollector");
|
|
5
|
+
const packageManager_1 = require("./packageManager");
|
|
6
6
|
class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
|
|
7
7
|
constructor(rootDir) {
|
|
8
8
|
super(rootDir);
|
|
9
|
-
this.
|
|
10
|
-
this.installOptions = this.pmCommand.value.then(cmd => ({ cmd, args: ["ci"], lockfile: "package-lock.json" }));
|
|
9
|
+
this.installOptions = { manager: packageManager_1.PM.NPM, lockfile: "package-lock.json" };
|
|
11
10
|
}
|
|
12
11
|
getArgs() {
|
|
13
12
|
return ["list", "-a", "--include", "prod", "--include", "optional", "--omit", "dev", "--json", "--long", "--silent"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAC7D,qDAAqC;AAGrC,MAAa,uBAAwB,SAAQ,2CAA2C;IACtF,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QAGA,mBAAc,GAAG,EAAE,OAAO,EAAE,mBAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAFnF,CAAC;IAIS,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;IACtH,CAAC;IAES,sBAAsB,CAAC,IAAmB;QAClD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,CAAC;YACnE,MAAM,EAAE,aAAa,GAAG,EAAE,E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AE,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;aACxD,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,EAAE;YACjC,MAAM,iBAAiB,GAAG,GAAG,WAAW,IAAI,UAAU,CAAC,OAAO,EAAE,CAAA;YAChE,IAAI,CAAC,gCAAgC,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAA;YACpE,OAAO,iBAAiB,CAAA;QAC1B,CAAC,CAAC,CAAA;QACJ,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,EAAE,cAAc,EAAE,CAAA;IACvE,CAAC;IAES,qBAAqB,CAAC,QAAgB;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;CACF;AAhDD,0DAgDC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { NpmDependency } from \"./types\"\n\nexport class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency, string> {\n constructor(rootDir: string) {\n super(rootDir)\n }\n\n public readonly installOptions = { manager: PM.NPM, lockfile: \"package-lock.json\" }\n\n protected getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\"]\n }\n\n protected collectAllDependencies(tree: NpmDependency) {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n const { _dependencies = {}, dependencies = {} } = value\n const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0\n if (isDuplicateDep) {\n continue\n }\n this.allDependencies.set(`${key}@${value.version}`, value)\n this.collectAllDependencies(value)\n }\n }\n\n protected extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): void {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const { _dependencies: prodDependencies = {}, dependencies = {} } = tree\n const isDuplicateDep = Object.keys(prodDependencies).length > 0 && Object.keys(dependencies).length === 0\n const resolvedDeps = isDuplicateDep ? (this.allDependencies.get(dependencyId)?.dependencies ?? {}) : dependencies\n // Initialize with empty dependencies array first to mark this dependency as \"in progress\"\n // After initialization, if there are libraries with the same name+version later, they will not be searched recursively again\n // This will prevents infinite loops when circular dependencies are encountered.\n this.productionGraph[dependencyId] = { dependencies: [] }\n const productionDeps = Object.entries(resolvedDeps)\n .filter(([packageName]) => prodDependencies[packageName])\n .map(([packageName, dependency]) => {\n const childDependencyId = `${packageName}@${dependency.version}`\n this.extractProductionDependencyGraph(dependency, childDependencyId)\n return childDependencyId\n })\n this.productionGraph[dependencyId] = { dependencies: productionDeps }\n }\n\n protected parseDependenciesTree(jsonBlob: string): NpmDependency {\n return JSON.parse(jsonBlob)\n }\n}\n"]}
|