app-builder-lib 26.5.0 → 26.6.0
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 +17 -0
- package/out/binDownload.js +153 -0
- package/out/binDownload.js.map +1 -1
- package/out/node-module-collector/nodeModulesCollector.js +1 -1
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/npmNodeModulesCollector.js +1 -3
- package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +0 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js +28 -33
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/options/macOptions.d.ts +0 -1
- package/out/options/macOptions.js.map +1 -1
- package/out/platformPackager.d.ts +1 -1
- package/out/platformPackager.js.map +1 -1
- package/out/targets/FlatpakTarget.js +11 -9
- package/out/targets/FlatpakTarget.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 +12 -9
- package/scheme.json +1 -1
- package/templates/nsis/uninstaller.nsh +2 -0
package/out/binDownload.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic <length>-character URL-safe hash (a–z0–9)
|
|
3
|
+
*/
|
|
4
|
+
export declare function hashUrlSafe(input: string, length?: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Get cache directory for electron-builder
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCacheDirectory(isAvoidSystemOnWindows?: boolean): string;
|
|
9
|
+
/**
|
|
10
|
+
* Downloads an artifact from GitHub releases (convenience wrapper)
|
|
11
|
+
*/
|
|
12
|
+
export declare function downloadArtifact(options: {
|
|
13
|
+
releaseName: string;
|
|
14
|
+
filenameWithExt: string;
|
|
15
|
+
checksums: Record<string, string>;
|
|
16
|
+
githubOrgRepo?: string;
|
|
17
|
+
}): Promise<string>;
|
|
1
18
|
export declare function download(url: string, output: string, checksum?: string | null): Promise<void>;
|
|
2
19
|
export declare function getBinFromCustomLoc(name: string, version: string, binariesLocUrl: string, checksum: string): Promise<string>;
|
|
3
20
|
export declare function getBinFromUrl(releaseName: string, filenameWithExt: string, checksum: string, githubOrgRepo?: string): Promise<string>;
|
package/out/binDownload.js
CHANGED
|
@@ -1,12 +1,165 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashUrlSafe = hashUrlSafe;
|
|
4
|
+
exports.getCacheDirectory = getCacheDirectory;
|
|
5
|
+
exports.downloadArtifact = downloadArtifact;
|
|
3
6
|
exports.download = download;
|
|
4
7
|
exports.getBinFromCustomLoc = getBinFromCustomLoc;
|
|
5
8
|
exports.getBinFromUrl = getBinFromUrl;
|
|
6
9
|
exports.getBin = getBin;
|
|
10
|
+
const get = require("@electron/get");
|
|
11
|
+
const get_1 = require("@electron/get");
|
|
7
12
|
const builder_util_1 = require("builder-util");
|
|
8
13
|
const filename_1 = require("builder-util/out/filename");
|
|
14
|
+
const multiProgress_1 = require("electron-publish/out/multiProgress");
|
|
15
|
+
const fs = require("fs/promises");
|
|
16
|
+
const os = require("os");
|
|
9
17
|
const path = require("path");
|
|
18
|
+
const lockfile = require("proper-lockfile");
|
|
19
|
+
const tar = require("tar");
|
|
20
|
+
/**
|
|
21
|
+
* Deterministic <length>-character URL-safe hash (a–z0–9)
|
|
22
|
+
*/
|
|
23
|
+
function hashUrlSafe(input, length = 6) {
|
|
24
|
+
let hash = 5381;
|
|
25
|
+
for (let i = 0; i < input.length; i++) {
|
|
26
|
+
hash = ((hash << 5) + hash) ^ input.charCodeAt(i); // hash * 33 ^ c
|
|
27
|
+
}
|
|
28
|
+
// Force unsigned 32-bit
|
|
29
|
+
hash >>>= 0;
|
|
30
|
+
// Base-36 (0–9a–z)
|
|
31
|
+
const out = hash.toString(36);
|
|
32
|
+
// Ensure exactly `length` chars
|
|
33
|
+
if (out.length >= length) {
|
|
34
|
+
return out.slice(0, length);
|
|
35
|
+
}
|
|
36
|
+
return out.padStart(length, "0");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get cache directory for electron-builder
|
|
40
|
+
*/
|
|
41
|
+
function getCacheDirectory(isAvoidSystemOnWindows = false) {
|
|
42
|
+
var _a, _b, _c, _d, _e;
|
|
43
|
+
const env = (_a = process.env.ELECTRON_BUILDER_CACHE) === null || _a === void 0 ? void 0 : _a.trim();
|
|
44
|
+
if (env) {
|
|
45
|
+
return env;
|
|
46
|
+
}
|
|
47
|
+
const appName = "electron-builder";
|
|
48
|
+
const platform = os.platform();
|
|
49
|
+
const homeDir = os.homedir();
|
|
50
|
+
if (platform === "darwin") {
|
|
51
|
+
return path.join(homeDir, "Library", "Caches", appName);
|
|
52
|
+
}
|
|
53
|
+
if (platform === "win32") {
|
|
54
|
+
const localAppData = (_b = process.env.LOCALAPPDATA) === null || _b === void 0 ? void 0 : _b.trim();
|
|
55
|
+
const username = (_d = (_c = process.env.USERNAME) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
|
56
|
+
const isSystemUser = isAvoidSystemOnWindows && (((_e = localAppData === null || localAppData === void 0 ? void 0 : localAppData.toLowerCase()) === null || _e === void 0 ? void 0 : _e.includes("\\windows\\system32\\")) || username === "system");
|
|
57
|
+
if (!localAppData || isSystemUser) {
|
|
58
|
+
return path.join(os.tmpdir(), `${appName}-cache`);
|
|
59
|
+
}
|
|
60
|
+
return path.join(localAppData, appName, "Cache");
|
|
61
|
+
}
|
|
62
|
+
// linux
|
|
63
|
+
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
64
|
+
if (xdgCache) {
|
|
65
|
+
return path.join(xdgCache, appName);
|
|
66
|
+
}
|
|
67
|
+
return path.join(homeDir, ".cache", appName);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Downloads an artifact from GitHub releases (convenience wrapper)
|
|
71
|
+
*/
|
|
72
|
+
async function downloadArtifact(options) {
|
|
73
|
+
const { releaseName, filenameWithExt, checksums, githubOrgRepo = "electron-userland/electron-builder-binaries" } = options;
|
|
74
|
+
const file = await _downloadArtifact(`https://github.com/${githubOrgRepo}/releases/download/`, releaseName, filenameWithExt, checksums);
|
|
75
|
+
return file;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Downloads, validates, and extracts a .tar.gz from a release URL
|
|
79
|
+
*/
|
|
80
|
+
async function _downloadArtifact(baseUrl, releaseName, filenameWithExt, checksums) {
|
|
81
|
+
var _a;
|
|
82
|
+
const suffix = hashUrlSafe(`${baseUrl}-${releaseName}-${filenameWithExt}`, 5);
|
|
83
|
+
const folderName = `${filenameWithExt.replace(/\.(tar\.gz|tgz)$/, "")}-${suffix}`;
|
|
84
|
+
const extractDir = path.join(getCacheDirectory(), releaseName, folderName);
|
|
85
|
+
const extractionCompleteMarker = `${extractDir}.complete`;
|
|
86
|
+
// Ensure download directory exists before trying to lock
|
|
87
|
+
await fs.mkdir(extractDir, { recursive: true });
|
|
88
|
+
// Acquire the lock
|
|
89
|
+
let release;
|
|
90
|
+
try {
|
|
91
|
+
release = await lockfile.lock(extractDir, {
|
|
92
|
+
retries: {
|
|
93
|
+
retries: 5,
|
|
94
|
+
minTimeout: 1000,
|
|
95
|
+
maxTimeout: 5000,
|
|
96
|
+
},
|
|
97
|
+
stale: 60000,
|
|
98
|
+
});
|
|
99
|
+
const varName = "ELECTRON_DOWNLOAD_CACHE_MODE";
|
|
100
|
+
const cacheOverride = (_a = process.env[varName]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
101
|
+
let cacheMode = get_1.ElectronDownloadCacheMode.ReadWrite;
|
|
102
|
+
if (cacheOverride && Number(cacheOverride) in get_1.ElectronDownloadCacheMode) {
|
|
103
|
+
cacheMode = Number(cacheOverride);
|
|
104
|
+
builder_util_1.log.debug({ mode: cacheMode }, `cache mode overridden via env var ${varName}`);
|
|
105
|
+
}
|
|
106
|
+
if (await (0, builder_util_1.exists)(extractionCompleteMarker)) {
|
|
107
|
+
builder_util_1.log.debug({ file: filenameWithExt, path: extractDir }, "using cached artifact - skipping download/extract");
|
|
108
|
+
return extractDir;
|
|
109
|
+
}
|
|
110
|
+
// These are just stubs. Actual url construction/file naming are in `mirrorOptions` below.
|
|
111
|
+
const details = {
|
|
112
|
+
// Needs to be higher than 1.3.2 to avoid @electron/get validation shortcut
|
|
113
|
+
// https://github.com/electron/get/blob/05c466d4fc60fa0c83064df28dce245eb83d63c9/src/index.ts#L60
|
|
114
|
+
version: "9.9.9",
|
|
115
|
+
artifactName: filenameWithExt, // also is the output filename
|
|
116
|
+
};
|
|
117
|
+
const progress = process.stdout.isTTY ? new multiProgress_1.MultiProgress() : null;
|
|
118
|
+
const progressBar = progress === null || progress === void 0 ? void 0 : progress.createBar(`${" ".repeat(builder_util_1.PADDING + 2)}[:bar] :percent | ${filenameWithExt}`, { total: 100 });
|
|
119
|
+
const downloadOptions = {
|
|
120
|
+
getProgressCallback: info => {
|
|
121
|
+
progressBar === null || progressBar === void 0 ? void 0 : progressBar.update(info.percent != null ? Math.floor(info.percent * 100) : 0);
|
|
122
|
+
return Promise.resolve();
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const options = {
|
|
126
|
+
cacheRoot: path.resolve(getCacheDirectory(), "downloads"),
|
|
127
|
+
cacheMode,
|
|
128
|
+
downloadOptions,
|
|
129
|
+
checksums,
|
|
130
|
+
mirrorOptions: {
|
|
131
|
+
// `${opts.mirror}${opts.customDir}/${opts.customFilename}`
|
|
132
|
+
mirror: baseUrl,
|
|
133
|
+
customDir: releaseName,
|
|
134
|
+
customFilename: filenameWithExt,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
builder_util_1.log.info({ release: releaseName, file: filenameWithExt }, "downloading");
|
|
138
|
+
progressBar === null || progressBar === void 0 ? void 0 : progressBar.render();
|
|
139
|
+
const downloadedFile = await get.downloadArtifact({
|
|
140
|
+
...details,
|
|
141
|
+
...options,
|
|
142
|
+
isGeneric: true,
|
|
143
|
+
});
|
|
144
|
+
await tar.extract({
|
|
145
|
+
file: downloadedFile,
|
|
146
|
+
cwd: extractDir,
|
|
147
|
+
strip: 1, // Strip the top-level directory from the archive
|
|
148
|
+
});
|
|
149
|
+
// Write the extraction complete marker file to indicate successful extraction and prevent future re-extraction
|
|
150
|
+
await fs.writeFile(extractionCompleteMarker, "");
|
|
151
|
+
builder_util_1.log.debug({ file: filenameWithExt, path: extractDir }, "downloaded");
|
|
152
|
+
progressBar === null || progressBar === void 0 ? void 0 : progressBar.update(100);
|
|
153
|
+
progressBar === null || progressBar === void 0 ? void 0 : progressBar.terminate();
|
|
154
|
+
return extractDir;
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
// Release the lock
|
|
158
|
+
if (release) {
|
|
159
|
+
await release();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
10
163
|
const versionToPromise = new Map();
|
|
11
164
|
function download(url, output, checksum) {
|
|
12
165
|
const args = ["download", "--url", url, "--output", output];
|
package/out/binDownload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;AAOA,4BAMC;AAED,kDAGC;AAED,sCAsBC;AAED,wBAYC;AAxDD,+CAAgD;AAEhD,wDAA4D;AAC5D,6BAA4B;AAE5B,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,C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,CAAA;AACxC,CAAC;AAED,SAAgB,MAAM,CAAC,QAAgB,EAAE,GAAmB,EAAE,QAAwB;;IACpF,6DAA6D;IAC7D,MAAM,SAAS,GAAG,IAAA,2BAAgB,EAAC,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,mCAAI,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAA;IAC5F,IAAI,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA,CAAC,6CAA6C;IAE3F,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO,GAAG,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3C,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACxC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAqB,EAAE,QAA0B;IAC/E,MAAM,IAAI,GAAG,CAAC,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\"\nimport * as path from \"path\"\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 const cacheKey = `${releaseName}-${path.basename(filenameWithExt, path.extname(filenameWithExt))}`\n return getBin(cacheKey, url, checksum)\n}\n\nexport function getBin(cacheKey: 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 ?? \"\"}${cacheKey}`)\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(cacheKey, 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"]}
|
|
1
|
+
{"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;AAeA,kCAcC;AAKD,8CAgCC;AAKD,4CAMC;AAsGD,4BAMC;AAED,kDAGC;AAED,sCAsBC;AAED,wBAYC;AApOD,qCAAoC;AACpC,uCAAwI;AACxI,+CAAsE;AAEtE,wDAA4D;AAC5D,sEAAkE;AAClE,kCAAiC;AACjC,yBAAwB;AACxB,6BAA4B;AAC5B,4CAA2C;AAC3C,2BAA0B;AAE1B;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,MAAM,GAAG,CAAC;IACnD,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,CAAC,gBAAgB;IACpE,CAAC;IACD,wBAAwB;IACxB,IAAI,MAAM,CAAC,CAAA;IACX,mBAAmB;IACnB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC7B,gCAAgC;IAChC,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,sBAAsB,GAAG,KAAK;;IAC9D,MAAM,GAAG,GAAG,MAAA,OAAO,C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AAC,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 * as get from \"@electron/get\"\nimport { ElectronDownloadCacheMode, ElectronDownloadRequest, ElectronDownloadRequestOptions, GotDownloaderOptions } from \"@electron/get\"\nimport { executeAppBuilder, exists, log, PADDING } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { MultiProgress } from \"electron-publish/out/multiProgress\"\nimport * as fs from \"fs/promises\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as lockfile from \"proper-lockfile\"\nimport * as tar from \"tar\"\n\n/**\n * Deterministic <length>-character URL-safe hash (a–z0–9)\n */\nexport function hashUrlSafe(input: string, length = 6): string {\n let hash = 5381\n for (let i = 0; i < input.length; i++) {\n hash = ((hash << 5) + hash) ^ input.charCodeAt(i) // hash * 33 ^ c\n }\n // Force unsigned 32-bit\n hash >>>= 0\n // Base-36 (0–9a–z)\n const out = hash.toString(36)\n // Ensure exactly `length` chars\n if (out.length >= length) {\n return out.slice(0, length)\n }\n return out.padStart(length, \"0\")\n}\n\n/**\n * Get cache directory for electron-builder\n */\nexport function getCacheDirectory(isAvoidSystemOnWindows = false): string {\n const env = process.env.ELECTRON_BUILDER_CACHE?.trim()\n if (env) {\n return env\n }\n\n const appName = \"electron-builder\"\n\n const platform = os.platform()\n const homeDir = os.homedir()\n\n if (platform === \"darwin\") {\n return path.join(homeDir, \"Library\", \"Caches\", appName)\n }\n\n if (platform === \"win32\") {\n const localAppData = process.env.LOCALAPPDATA?.trim()\n const username = process.env.USERNAME?.trim()?.toLowerCase()\n const isSystemUser = isAvoidSystemOnWindows && (localAppData?.toLowerCase()?.includes(\"\\\\windows\\\\system32\\\\\") || username === \"system\")\n if (!localAppData || isSystemUser) {\n return path.join(os.tmpdir(), `${appName}-cache`)\n }\n return path.join(localAppData, appName, \"Cache\")\n }\n\n // linux\n const xdgCache = process.env.XDG_CACHE_HOME\n if (xdgCache) {\n return path.join(xdgCache, appName)\n }\n\n return path.join(homeDir, \".cache\", appName)\n}\n\n/**\n * Downloads an artifact from GitHub releases (convenience wrapper)\n */\nexport async function downloadArtifact(options: { releaseName: string; filenameWithExt: string; checksums: Record<string, string>; githubOrgRepo?: string }): Promise<string> {\n const { releaseName, filenameWithExt, checksums, githubOrgRepo = \"electron-userland/electron-builder-binaries\" } = options\n\n const file = await _downloadArtifact(`https://github.com/${githubOrgRepo}/releases/download/`, releaseName, filenameWithExt, checksums)\n\n return file\n}\n\n/**\n * Downloads, validates, and extracts a .tar.gz from a release URL\n */\nasync function _downloadArtifact(baseUrl: string, releaseName: string, filenameWithExt: string, checksums: Record<string, string>): Promise<string> {\n const suffix = hashUrlSafe(`${baseUrl}-${releaseName}-${filenameWithExt}`, 5)\n const folderName = `${filenameWithExt.replace(/\\.(tar\\.gz|tgz)$/, \"\")}-${suffix}`\n const extractDir = path.join(getCacheDirectory(), releaseName, folderName)\n const extractionCompleteMarker = `${extractDir}.complete`\n\n // Ensure download directory exists before trying to lock\n await fs.mkdir(extractDir, { recursive: true })\n\n // Acquire the lock\n let release: (() => Promise<void>) | undefined\n try {\n release = await lockfile.lock(extractDir, {\n retries: {\n retries: 5,\n minTimeout: 1000,\n maxTimeout: 5000,\n },\n stale: 60000,\n })\n\n const varName = \"ELECTRON_DOWNLOAD_CACHE_MODE\"\n const cacheOverride = process.env[varName]?.trim()\n\n let cacheMode: ElectronDownloadCacheMode = ElectronDownloadCacheMode.ReadWrite\n if (cacheOverride && Number(cacheOverride) in ElectronDownloadCacheMode) {\n cacheMode = Number(cacheOverride)\n log.debug({ mode: cacheMode }, `cache mode overridden via env var ${varName}`)\n }\n\n if (await exists(extractionCompleteMarker)) {\n log.debug({ file: filenameWithExt, path: extractDir }, \"using cached artifact - skipping download/extract\")\n return extractDir\n }\n\n // These are just stubs. Actual url construction/file naming are in `mirrorOptions` below.\n const details: ElectronDownloadRequest = {\n // Needs to be higher than 1.3.2 to avoid @electron/get validation shortcut\n // https://github.com/electron/get/blob/05c466d4fc60fa0c83064df28dce245eb83d63c9/src/index.ts#L60\n version: \"9.9.9\",\n artifactName: filenameWithExt, // also is the output filename\n }\n\n const progress = process.stdout.isTTY ? new MultiProgress() : null\n const progressBar = progress?.createBar(`${\" \".repeat(PADDING + 2)}[:bar] :percent | ${filenameWithExt}`, { total: 100 })\n\n const downloadOptions: GotDownloaderOptions = {\n getProgressCallback: info => {\n progressBar?.update(info.percent != null ? Math.floor(info.percent * 100) : 0)\n return Promise.resolve()\n },\n }\n const options: ElectronDownloadRequestOptions = {\n cacheRoot: path.resolve(getCacheDirectory(), \"downloads\"),\n cacheMode,\n downloadOptions,\n checksums,\n mirrorOptions: {\n // `${opts.mirror}${opts.customDir}/${opts.customFilename}`\n mirror: baseUrl,\n customDir: releaseName,\n customFilename: filenameWithExt,\n },\n }\n\n log.info({ release: releaseName, file: filenameWithExt }, \"downloading\")\n progressBar?.render()\n const downloadedFile = await get.downloadArtifact({\n ...details,\n ...options,\n isGeneric: true,\n })\n\n await tar.extract({\n file: downloadedFile,\n cwd: extractDir,\n strip: 1, // Strip the top-level directory from the archive\n })\n\n // Write the extraction complete marker file to indicate successful extraction and prevent future re-extraction\n await fs.writeFile(extractionCompleteMarker, \"\")\n\n log.debug({ file: filenameWithExt, path: extractDir }, \"downloaded\")\n progressBar?.update(100)\n progressBar?.terminate()\n\n return extractDir\n } finally {\n // Release the lock\n if (release) {\n await release()\n }\n }\n}\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 const cacheKey = `${releaseName}-${path.basename(filenameWithExt, path.extname(filenameWithExt))}`\n return getBin(cacheKey, url, checksum)\n}\n\nexport function getBin(cacheKey: 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 ?? \"\"}${cacheKey}`)\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(cacheKey, 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"]}
|
|
@@ -82,7 +82,7 @@ class NodeModulesCollector {
|
|
|
82
82
|
return (0, builder_util_1.retry)(async () => {
|
|
83
83
|
await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile);
|
|
84
84
|
const shellOutput = await fs.readFile(tempOutputFile, { encoding: "utf8" });
|
|
85
|
-
const result = Promise.resolve(this.parseDependenciesTree(shellOutput));
|
|
85
|
+
const result = await Promise.resolve(this.parseDependenciesTree(shellOutput));
|
|
86
86
|
return result;
|
|
87
87
|
}, {
|
|
88
88
|
retries: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAA+C;AAC/C,qDAA+D;AAG/D,MAAsB,oBAAoB;IAsBxC,YACqB,OAAe,EACjB,cAAsB;QADpB,YAAO,GAAP,OAAO,CAAQ;QACjB,mBAAc,GAAd,cAAc,CAAQ;QAvBxB,gBAAW,GAAqB,EAAE,CAAA;QAChC,oBAAe,GAA6B,IAAI,GAAG,EAAE,CAAA;QACrD,oBAAe,GAAoB,EAAE,CAAA;QACrC,UAAK,GAAkB,IAAI,6BAAa,EAAE,CAAA;QAEnD,cAAS,GAAG,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAA;YACvC,MAAM,OAAO,GAAG,IAAA,yCAAwB,EAAC,OAAO,CAAC,CAAA;YACjD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,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AE,IAAI,CAAC,EAAE;gBACvB,SAAS,CAAC,KAAK,EAAE,CAAA;gBACjB,0CAA0C;gBAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;gBACjF,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,IAAI,YAAY,CAAA;gBAChD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC,CAAA;YAC5H,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAraD,oDAqaC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\nimport * as childProcess from \"child_process\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleManager } from \"./moduleManager\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types\"\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n *\n * @param options - Configuration object\n * @param options.packageName - The name of the package to collect modules for\n * @returns Promise resolving to an array of NodeModuleInfo objects representing all collected modules\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = await this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\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 extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n *\n * @param pm - The package manager to use (npm, yarn, pnpm, etc.)\n * @returns Promise resolving to the parsed dependency tree\n * @throws {Error} If the dependency tree cannot be retrieved after retries\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const result = Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const logFields = { error: error.message, tempOutputFile, cwd: this.rootDir }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(logFields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const fields = { ...logFields, fileContent }\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n /**\n *\n * This method attempts to extract and parse JSON data from shell output that may contain\n * additional non-JSON content (like warnings or informational messages). It first tries\n * to parse the entire output as JSON, and if that fails, it intelligently searches for\n * JSON content within the output by:\n * 1. Finding the first line that starts with `{` or `[`\n * 2. Tracking bracket depth to find the matching closing bracket\n * 3. Extracting only the valid JSON portion\n *\n * @param shellOutput - The raw output from a shell command, potentially containing JSON\n * @returns The parsed dependencies tree object\n * @throws {Error} If no JSON content is found in the output\n * @throws {Error} If no matching closing bracket is found in the output\n * @throws {SyntaxError} If the extracted content is not valid JSON\n */\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n return JSON.parse(consoleOutput)\n } catch {\n // Continue\n }\n\n const lines = consoleOutput.split(\"\\n\")\n\n // Find the first line that starts with { or [\n const jsonStartIdx = lines.findIndex(line => {\n const trimmed = line.trim()\n return trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")\n })\n\n if (jsonStartIdx === -1) {\n throw new Error(\"No JSON content found in output\")\n }\n\n // Find matching closing bracket using bracket counting\n let depth = 0\n let jsonEndIdx = -1\n\n for (let i = jsonStartIdx; i < lines.length; i++) {\n const line = lines[i]\n for (const char of line) {\n if (char === \"{\" || char === \"[\") {\n depth++\n } else if (char === \"}\" || char === \"]\") {\n depth--\n if (depth === 0) {\n jsonEndIdx = i\n break\n }\n }\n }\n if (jsonEndIdx !== -1) {\n break\n }\n }\n\n if (jsonEndIdx === -1) {\n throw new Error(\"No matching closing bracket found in output\")\n }\n\n // Parse the matched JSON section\n const candidate = lines\n .slice(jsonStartIdx, jsonEndIdx + 1)\n .join(\"\\n\")\n .trim()\n\n return JSON.parse(candidate)\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: Pick<ProdDepType, \"name\" | \"version\">): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns Promise resolving to the pruned dependency tree\n */\n protected async getTreeFromWorkspaces(tree: ProdDepType, packageName: string): Promise<ProdDepType> {\n if (!(tree.workspaces && tree.dependencies)) {\n return tree\n }\n\n if (tree.dependencies?.[packageName]) {\n const { name, path, dependencies } = tree.dependencies[packageName]\n log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, \"pruning root app/self reference from workspace tree\")\n for (const [name, pkg] of Object.entries(dependencies ?? {})) {\n tree.dependencies[name] = pkg\n this.allDependencies.set(this.packageVersionString(pkg), pkg)\n }\n delete tree.dependencies[packageName]\n }\n return Promise.resolve(tree)\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _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.warn({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.cache.realPath[p],\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\n */\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", tempBatFile, ...args]\n }\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAA+C;AAC/C,qDAA+D;AAG/D,MAAsB,oBAAoB;IAsBxC,YACqB,OAAe,EACjB,cAAsB;QADpB,YAAO,GAAP,OAAO,CAAQ;QACjB,mBAAc,GAAd,cAAc,CAAQ;QAvBxB,gBAAW,GAAqB,EAAE,CAAA;QAChC,oBAAe,GAA6B,IAAI,GAAG,EAAE,CAAA;QACrD,oBAAe,GAAoB,EAAE,CAAA;QACrC,UAAK,GAAkB,IAAI,6BAAa,EAAE,CAAA;QAEnD,cAAS,GAAG,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAA;YACvC,MAAM,OAAO,GAAG,IAAA,yCAAwB,EAAC,OAAO,CAAC,CAAA;YACjD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACzE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,kBAAG,CAAC,KAAK,CAAC,E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,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;gBACjF,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,IAAI,YAAY,CAAA;gBAChD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC,CAAA;YAC5H,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAraD,oDAqaC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\nimport * as childProcess from \"child_process\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleManager } from \"./moduleManager\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types\"\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n *\n * @param options - Configuration object\n * @param options.packageName - The name of the package to collect modules for\n * @returns Promise resolving to an array of NodeModuleInfo objects representing all collected modules\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = await this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\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 extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n *\n * @param pm - The package manager to use (npm, yarn, pnpm, etc.)\n * @returns Promise resolving to the parsed dependency tree\n * @throws {Error} If the dependency tree cannot be retrieved after retries\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const logFields = { error: error.message, tempOutputFile, cwd: this.rootDir }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(logFields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const fields = { ...logFields, fileContent }\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n /**\n *\n * This method attempts to extract and parse JSON data from shell output that may contain\n * additional non-JSON content (like warnings or informational messages). It first tries\n * to parse the entire output as JSON, and if that fails, it intelligently searches for\n * JSON content within the output by:\n * 1. Finding the first line that starts with `{` or `[`\n * 2. Tracking bracket depth to find the matching closing bracket\n * 3. Extracting only the valid JSON portion\n *\n * @param shellOutput - The raw output from a shell command, potentially containing JSON\n * @returns The parsed dependencies tree object\n * @throws {Error} If no JSON content is found in the output\n * @throws {Error} If no matching closing bracket is found in the output\n * @throws {SyntaxError} If the extracted content is not valid JSON\n */\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n return JSON.parse(consoleOutput)\n } catch {\n // Continue\n }\n\n const lines = consoleOutput.split(\"\\n\")\n\n // Find the first line that starts with { or [\n const jsonStartIdx = lines.findIndex(line => {\n const trimmed = line.trim()\n return trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")\n })\n\n if (jsonStartIdx === -1) {\n throw new Error(\"No JSON content found in output\")\n }\n\n // Find matching closing bracket using bracket counting\n let depth = 0\n let jsonEndIdx = -1\n\n for (let i = jsonStartIdx; i < lines.length; i++) {\n const line = lines[i]\n for (const char of line) {\n if (char === \"{\" || char === \"[\") {\n depth++\n } else if (char === \"}\" || char === \"]\") {\n depth--\n if (depth === 0) {\n jsonEndIdx = i\n break\n }\n }\n }\n if (jsonEndIdx !== -1) {\n break\n }\n }\n\n if (jsonEndIdx === -1) {\n throw new Error(\"No matching closing bracket found in output\")\n }\n\n // Parse the matched JSON section\n const candidate = lines\n .slice(jsonStartIdx, jsonEndIdx + 1)\n .join(\"\\n\")\n .trim()\n\n return JSON.parse(candidate)\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: Pick<ProdDepType, \"name\" | \"version\">): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns Promise resolving to the pruned dependency tree\n */\n protected async getTreeFromWorkspaces(tree: ProdDepType, packageName: string): Promise<ProdDepType> {\n if (!(tree.workspaces && tree.dependencies)) {\n return tree\n }\n\n if (tree.dependencies?.[packageName]) {\n const { name, path, dependencies } = tree.dependencies[packageName]\n log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, \"pruning root app/self reference from workspace tree\")\n for (const [name, pkg] of Object.entries(dependencies ?? {})) {\n tree.dependencies[name] = pkg\n this.allDependencies.set(this.packageVersionString(pkg), pkg)\n }\n delete tree.dependencies[packageName]\n }\n return Promise.resolve(tree)\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _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.warn({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.cache.realPath[p],\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\n */\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", tempBatFile, ...args]\n }\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n}\n"]}
|
|
@@ -45,9 +45,7 @@ class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesColle
|
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
47
|
const dependency = resolvedDeps[packageName];
|
|
48
|
-
|
|
49
|
-
const normalizedName = packageName !== dependency.name ? packageName : dependency.name;
|
|
50
|
-
const childDependencyId = `${normalizedName}@${dependency.version}`;
|
|
48
|
+
const childDependencyId = this.packageVersionString({ name: packageName, version: dependency.version });
|
|
51
49
|
await this.extractProductionDependencyGraph(dependency, childDependencyId);
|
|
52
50
|
collectedDependencies.push(childDependencyId);
|
|
53
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,2DAAwC;AAGxC,MAAa,uBAAwB,SAAQ,8CAA2C;IAAxF;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,sBAAE,CAAC,GAAG;YACf,QAAQ,EAAE,mBAAmB;SAC9B,CAAA;
|
|
1
|
+
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,2DAAwC;AAGxC,MAAa,uBAAwB,SAAQ,8CAA2C;IAAxF;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,sBAAE,CAAC,GAAG;YACf,QAAQ,EAAE,mBAAmB;SAC9B,CAAA;IA2DH,CAAC;IAzDW,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,IAAI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;IAClD,CAAC;CACF;AA/DD,0DA+DC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector.js\"\nimport { PM } from \"./packageManager.js\"\nimport { NpmDependency } from \"./types.js\"\n\nexport class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency, string> {\n public readonly installOptions = {\n manager: PM.NPM,\n lockfile: \"package-lock.json\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\"]\n }\n\n protected async collectAllDependencies(tree: NpmDependency) {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n if (this.isDuplicatedNpmDependency(value)) {\n continue\n }\n // Use the key (alias name) instead of value.name for npm aliased packages\n // e.g., { \"foo\": { name: \"@scope/bar\", ... } } should be stored as \"foo@version\"\n // This ensures aliased packages are copied to the correct location in node_modules\n const normalizedDep: NpmDependency = key !== value.name ? { ...value, name: key } : value\n this.allDependencies.set(this.packageVersionString(normalizedDep), normalizedDep)\n await this.collectAllDependencies(value)\n }\n }\n\n protected async extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const isDuplicateDep = this.isDuplicatedNpmDependency(tree)\n const resolvedDeps = isDuplicateDep ? this.allDependencies.get(dependencyId)?.dependencies : tree.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\n const collectedDependencies: string[] = []\n if (resolvedDeps && Object.keys(resolvedDeps).length > 0) {\n for (const packageName in resolvedDeps) {\n if (!this.isProdDependency(packageName, tree)) {\n continue\n }\n const dependency = resolvedDeps[packageName]\n const childDependencyId = this.packageVersionString({ name: packageName, version: dependency.version })\n await this.extractProductionDependencyGraph(dependency, childDependencyId)\n collectedDependencies.push(childDependencyId)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n // Check: is package already included as a prod dependency due to another package?\n // We need to check this to prevent infinite loops in case of duplicated dependencies\n private isDuplicatedNpmDependency(tree: NpmDependency): boolean {\n const { _dependencies = {}, dependencies = {} } = tree\n const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0\n return isDuplicateDep\n }\n\n // `npm list` provides explicit list of deps in _dependencies\n protected isProdDependency(packageName: string, tree: NpmDependency) {\n return tree._dependencies?.[packageName] != null\n }\n}\n"]}
|
|
@@ -7,7 +7,6 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
|
|
|
7
7
|
lockfile: string;
|
|
8
8
|
};
|
|
9
9
|
protected getArgs(): string[];
|
|
10
|
-
private getProductionDependencies;
|
|
11
10
|
protected extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string): Promise<void>;
|
|
12
11
|
protected collectAllDependencies(tree: PnpmDependency): Promise<void>;
|
|
13
12
|
protected packageVersionString(pkg: PnpmDependency): string;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PnpmNodeModulesCollector = void 0;
|
|
4
4
|
const builder_util_1 = require("builder-util");
|
|
5
|
-
const path = require("path");
|
|
6
5
|
const nodeModulesCollector_1 = require("./nodeModulesCollector");
|
|
7
6
|
const packageManager_1 = require("./packageManager");
|
|
8
7
|
class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
|
|
@@ -16,59 +15,55 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
16
15
|
getArgs() {
|
|
17
16
|
return ["list", "--prod", "--json", "--depth", "Infinity"];
|
|
18
17
|
}
|
|
19
|
-
async getProductionDependencies(depTree) {
|
|
20
|
-
const packageName = depTree.name || depTree.from;
|
|
21
|
-
if ((0, builder_util_1.isEmptyOrSpaces)(packageName)) {
|
|
22
|
-
builder_util_1.log.error(depTree, `Cannot determine production dependencies for package with empty name`);
|
|
23
|
-
throw new Error(`Cannot compute production dependencies for package with empty name: ${packageName}`);
|
|
24
|
-
}
|
|
25
|
-
const result = await this.cache.locatePackageVersion({ parentDir: depTree.path, pkgName: packageName, requiredRange: depTree.version });
|
|
26
|
-
if (result == null) {
|
|
27
|
-
return { path: path.resolve(depTree.path), dependencies: {}, optionalDependencies: {} };
|
|
28
|
-
}
|
|
29
|
-
const { dependencies, optionalDependencies } = result.packageJson;
|
|
30
|
-
return { path: result.packageDir, dependencies: { ...dependencies }, optionalDependencies: { ...optionalDependencies } };
|
|
31
|
-
}
|
|
32
18
|
async extractProductionDependencyGraph(tree, dependencyId) {
|
|
33
|
-
var _a, _b, _c, _d;
|
|
34
19
|
if (this.productionGraph[dependencyId]) {
|
|
35
20
|
return;
|
|
36
21
|
}
|
|
37
22
|
this.productionGraph[dependencyId] = { dependencies: [] };
|
|
38
23
|
const packageName = tree.name || tree.from;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const { packageJson } = (await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: tree.version })) || {};
|
|
25
|
+
const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies };
|
|
26
|
+
const optional = packageJson ? { ...packageJson.optionalDependencies } : {};
|
|
27
|
+
const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) };
|
|
28
|
+
this.productionGraph[dependencyId] = { dependencies: [] };
|
|
29
|
+
const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {
|
|
30
|
+
// First check if it's in production dependencies
|
|
31
|
+
if (!all[packageName]) {
|
|
32
|
+
return undefined;
|
|
46
33
|
}
|
|
47
34
|
// Then check if optional dependency path exists (using actual resolved path)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
if (optional[packageName]) {
|
|
36
|
+
const pkg = await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: dependency.version });
|
|
37
|
+
if (!pkg) {
|
|
38
|
+
builder_util_1.log.debug({ name: packageName, version: dependency.version, path: dependency.path }, `optional dependency doesn't exist, skipping - likely not installed`);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
53
41
|
}
|
|
54
|
-
const dependency = treeDep[packageName];
|
|
55
42
|
const childDependencyId = this.packageVersionString(dependency);
|
|
56
43
|
await this.extractProductionDependencyGraph(dependency, childDependencyId);
|
|
57
|
-
|
|
44
|
+
return childDependencyId;
|
|
45
|
+
});
|
|
46
|
+
const collectedDependencies = [];
|
|
47
|
+
for (const dep of depPromises) {
|
|
48
|
+
const result = await dep;
|
|
49
|
+
if (result !== undefined) {
|
|
50
|
+
collectedDependencies.push(result);
|
|
51
|
+
}
|
|
58
52
|
}
|
|
59
53
|
this.productionGraph[dependencyId] = { dependencies: collectedDependencies };
|
|
60
54
|
}
|
|
61
55
|
async collectAllDependencies(tree) {
|
|
56
|
+
var _a, _b;
|
|
62
57
|
// Collect regular dependencies
|
|
63
58
|
for (const [key, value] of Object.entries(tree.dependencies || {})) {
|
|
64
|
-
const
|
|
65
|
-
this.allDependencies.set(`${key}@${value.version}`, { ...value, path:
|
|
59
|
+
const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version });
|
|
60
|
+
this.allDependencies.set(`${key}@${value.version}`, { ...value, path: (_a = pkg === null || pkg === void 0 ? void 0 : pkg.packageDir) !== null && _a !== void 0 ? _a : value.path });
|
|
66
61
|
await this.collectAllDependencies(value);
|
|
67
62
|
}
|
|
68
63
|
// Collect optional dependencies if they exist
|
|
69
64
|
for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {
|
|
70
|
-
const
|
|
71
|
-
this.allDependencies.set(`${key}@${value.version}`, { ...value, path:
|
|
65
|
+
const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version });
|
|
66
|
+
this.allDependencies.set(`${key}@${value.version}`, { ...value, path: (_b = pkg === null || pkg === void 0 ? void 0 : pkg.packageDir) !== null && _b !== void 0 ? _b : value.path });
|
|
72
67
|
await this.collectAllDependencies(value);
|
|
73
68
|
}
|
|
74
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,iEAA6D;AAC7D,qDAAqC;AAGrC,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,gBAAgB;SAC3B,CAAA;IA2EH,CAAC;IAzEW,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;IAC5D,CAAC;IAES,KAAK,CAAC,gCAAgC,CAAC,IAAoB,EAAE,YAAoB;QACzF,IAAI,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;QAEzD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAC1C,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,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,CAAE,UAAU,mCAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YACtG,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;QAC1C,CAAC;QAED,8CAA8C;QAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC;YAC3E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC1H,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,mCAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YACtG,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,GAAmB;QAChD,yEAAyE;QACzE,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;IAES,qBAAqB,CAAC,QAAgB;QAC9C,4CAA4C;QAC5C,MAAM,cAAc,GAAqB,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACvG,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF;AA/ED,4DA+EC","sourcesContent":["import { log } from \"builder-util\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { PnpmDependency } from \"./types\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {\n public readonly installOptions = {\n manager: PM.PNPM,\n lockfile: \"pnpm-lock.yaml\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\"]\n }\n\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: tree.version })) || {}\n\n const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies }\n const optional = packageJson ? { ...packageJson.optionalDependencies } : {}\n\n const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n this.productionGraph[dependencyId] = { dependencies: [] }\n const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {\n // First check if it's in production dependencies\n if (!all[packageName]) {\n return undefined\n }\n\n // Then check if optional dependency path exists (using actual resolved path)\n if (optional[packageName]) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: dependency.version })\n if (!pkg) {\n log.debug({ name: packageName, version: dependency.version, path: dependency.path }, `optional dependency doesn't exist, skipping - likely not installed`)\n return undefined\n }\n }\n const childDependencyId = this.packageVersionString(dependency)\n await this.extractProductionDependencyGraph(dependency, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(tree: PnpmDependency) {\n // Collect regular dependencies\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n\n // Collect optional dependencies if they exist\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n }\n\n protected packageVersionString(pkg: PnpmDependency): string {\n // we use 'from' field because 'name' may be different in case of aliases\n return `${pkg.from}@${pkg.version}`\n }\n\n protected parseDependenciesTree(jsonBlob: string): PnpmDependency {\n // pnpm returns an array of dependency trees\n const dependencyTree: PnpmDependency[] = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n return dependencyTree[0]\n }\n}\n"]}
|
|
@@ -213,7 +213,6 @@ export interface DmgOptions extends TargetSpecificOptions {
|
|
|
213
213
|
backgroundColor?: string | null;
|
|
214
214
|
/**
|
|
215
215
|
* The path to DMG icon (badge icon), which will be shown when mounted, relative to the [build resources](./contents.md#extraresources) or to the project directory.
|
|
216
|
-
* Defaults to the application icon (`build/icon.icns`).
|
|
217
216
|
*/
|
|
218
217
|
badgeIcon?: string | null;
|
|
219
218
|
/**
|