app-builder-lib 26.2.0 → 26.3.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.
Files changed (65) hide show
  1. package/out/asar/asarUtil.js +78 -10
  2. package/out/asar/asarUtil.js.map +1 -1
  3. package/out/codeSign/macCodeSign.js +2 -1
  4. package/out/codeSign/macCodeSign.js.map +1 -1
  5. package/out/electron/search-module.js +1 -1
  6. package/out/electron/search-module.js.map +1 -1
  7. package/out/fileMatcher.js +1 -1
  8. package/out/fileMatcher.js.map +1 -1
  9. package/out/node-module-collector/bunNodeModulesCollector.d.ts +11 -0
  10. package/out/node-module-collector/bunNodeModulesCollector.js +22 -0
  11. package/out/node-module-collector/bunNodeModulesCollector.js.map +1 -0
  12. package/out/node-module-collector/index.d.ts +18 -6
  13. package/out/node-module-collector/index.js +102 -28
  14. package/out/node-module-collector/index.js.map +1 -1
  15. package/out/node-module-collector/moduleCache.d.ts +21 -0
  16. package/out/node-module-collector/moduleCache.js +16 -0
  17. package/out/node-module-collector/moduleCache.js.map +1 -0
  18. package/out/node-module-collector/nodeModulesCollector.d.ts +48 -13
  19. package/out/node-module-collector/nodeModulesCollector.js +184 -59
  20. package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
  21. package/out/node-module-collector/npmNodeModulesCollector.d.ts +10 -3
  22. package/out/node-module-collector/npmNodeModulesCollector.js +95 -13
  23. package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
  24. package/out/node-module-collector/packageManager.d.ts +2 -2
  25. package/out/node-module-collector/packageManager.js +42 -25
  26. package/out/node-module-collector/packageManager.js.map +1 -1
  27. package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +4 -4
  28. package/out/node-module-collector/pnpmNodeModulesCollector.js +43 -23
  29. package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  30. package/out/node-module-collector/types.d.ts +25 -1
  31. package/out/node-module-collector/types.js.map +1 -1
  32. package/out/node-module-collector/yarnBerryNodeModulesCollector.d.ts +15 -0
  33. package/out/node-module-collector/yarnBerryNodeModulesCollector.js +83 -0
  34. package/out/node-module-collector/yarnBerryNodeModulesCollector.js.map +1 -0
  35. package/out/node-module-collector/yarnNodeModulesCollector.d.ts +12 -2
  36. package/out/node-module-collector/yarnNodeModulesCollector.js +234 -5
  37. package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
  38. package/out/options/winOptions.d.ts +2 -1
  39. package/out/options/winOptions.js.map +1 -1
  40. package/out/packager.d.ts +6 -1
  41. package/out/packager.js +27 -2
  42. package/out/packager.js.map +1 -1
  43. package/out/publish/PublishManager.js +2 -2
  44. package/out/publish/PublishManager.js.map +1 -1
  45. package/out/targets/AppxTarget.js +1 -1
  46. package/out/targets/AppxTarget.js.map +1 -1
  47. package/out/targets/MsiTarget.js +1 -1
  48. package/out/targets/MsiTarget.js.map +1 -1
  49. package/out/targets/nsis/NsisTarget.js +2 -2
  50. package/out/targets/nsis/NsisTarget.js.map +1 -1
  51. package/out/targets/nsis/nsisUtil.js +1 -1
  52. package/out/targets/nsis/nsisUtil.js.map +1 -1
  53. package/out/util/appFileCopier.js +17 -10
  54. package/out/util/appFileCopier.js.map +1 -1
  55. package/out/util/yarn.d.ts +3 -2
  56. package/out/util/yarn.js +16 -12
  57. package/out/util/yarn.js.map +1 -1
  58. package/out/version.d.ts +1 -1
  59. package/out/version.js +1 -1
  60. package/out/version.js.map +1 -1
  61. package/out/winPackager.d.ts +1 -1
  62. package/out/winPackager.js +26 -9
  63. package/out/winPackager.js.map +1 -1
  64. package/package.json +9 -9
  65. package/scheme.json +1 -1
@@ -1,14 +1,243 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.YarnNodeModulesCollector = void 0;
4
- const npmNodeModulesCollector_1 = require("./npmNodeModulesCollector");
4
+ const builder_util_1 = require("builder-util");
5
+ const lazy_val_1 = require("lazy-val");
6
+ const path = require("path");
7
+ const nodeModulesCollector_1 = require("./nodeModulesCollector");
5
8
  const packageManager_1 = require("./packageManager");
6
- class YarnNodeModulesCollector extends npmNodeModulesCollector_1.NpmNodeModulesCollector {
9
+ class YarnNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
7
10
  constructor() {
8
11
  super(...arguments);
9
- // note: do not override instance-var `pmCommand`. We explicitly use npm for the json payload
10
- // yarn list cannot get the detailed dependencies path info, But we can use npm to get all dependencies path info
11
- this.installOptions = { manager: packageManager_1.PM.NPM, lockfile: "yarn.lock" };
12
+ this.installOptions = {
13
+ manager: packageManager_1.PM.YARN,
14
+ lockfile: "yarn.lock",
15
+ };
16
+ this.isHoisted = new lazy_val_1.Lazy(async () => {
17
+ return Promise.resolve(true); // Yarn Classic always hoists
18
+ });
19
+ }
20
+ getArgs() {
21
+ return ["list", "--production", "--json", "--depth=Infinity", "--no-progress"];
22
+ }
23
+ async getTreeFromWorkspaces(tree) {
24
+ var _a;
25
+ if (!tree.workspaces || !tree.dependencies) {
26
+ return tree;
27
+ }
28
+ const appName = this.packageVersionString(tree);
29
+ if ((_a = tree.dependencies) === null || _a === void 0 ? void 0 : _a[appName]) {
30
+ const { name, path } = tree.dependencies[appName];
31
+ builder_util_1.log.debug({ name, path }, "pruning root app/self package from workspace tree");
32
+ delete tree.dependencies[appName];
33
+ }
34
+ return Promise.resolve(tree);
35
+ }
36
+ async extractProductionDependencyGraph(tree, dependencyId) {
37
+ if (this.productionGraph[dependencyId]) {
38
+ return;
39
+ }
40
+ const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {
41
+ const dep = {
42
+ ...dependency,
43
+ path: await this.resolvePath(dependency.path),
44
+ };
45
+ const childDependencyId = this.packageVersionString(dep);
46
+ await this.extractProductionDependencyGraph(dep, childDependencyId);
47
+ return childDependencyId;
48
+ });
49
+ this.productionGraph[dependencyId] = { dependencies: await Promise.all(productionDeps) };
50
+ }
51
+ getDependencyType(pkgName, parentPkgJson) {
52
+ var _a, _b, _c;
53
+ if ((_a = parentPkgJson.optionalDependencies) === null || _a === void 0 ? void 0 : _a[pkgName]) {
54
+ return "optional";
55
+ }
56
+ if ((_b = parentPkgJson.devDependencies) === null || _b === void 0 ? void 0 : _b[pkgName]) {
57
+ return "dev";
58
+ }
59
+ if ((_c = parentPkgJson.dependencies) === null || _c === void 0 ? void 0 : _c[pkgName]) {
60
+ return "prod";
61
+ }
62
+ return "prod";
63
+ }
64
+ async parseDependenciesTree(jsonBlob) {
65
+ const lines = jsonBlob
66
+ .split("\n")
67
+ .map(l => l.trim())
68
+ .filter(Boolean)
69
+ .map(l => {
70
+ try {
71
+ return JSON.parse(l);
72
+ }
73
+ catch {
74
+ return undefined;
75
+ }
76
+ })
77
+ .filter(Boolean);
78
+ const parsedTree = lines
79
+ .filter(l => l.type === "tree")
80
+ .map(l => l.data.trees)
81
+ .shift();
82
+ if (!parsedTree) {
83
+ throw new Error('Failed to extract Yarn tree: no "type":"tree" line found in console output');
84
+ }
85
+ const normalizedTree = await this.normalizeTree(parsedTree, new Set(), undefined);
86
+ const dependencies = {};
87
+ for (const [name, dep] of Object.entries(normalizedTree)) {
88
+ dependencies[name] = dep;
89
+ }
90
+ const rootPkgJson = await this.appPkgJson.value;
91
+ return Promise.resolve({
92
+ name: (rootPkgJson === null || rootPkgJson === void 0 ? void 0 : rootPkgJson.name) || ".",
93
+ version: (rootPkgJson === null || rootPkgJson === void 0 ? void 0 : rootPkgJson.version) || "unknown",
94
+ path: this.rootDir,
95
+ dependencies,
96
+ workspaces: rootPkgJson === null || rootPkgJson === void 0 ? void 0 : rootPkgJson.workspaces,
97
+ });
98
+ }
99
+ async normalizeTree(tree, seen = new Set(), appName) {
100
+ const normalized = {};
101
+ for (const node of tree) {
102
+ const match = node.name.match(/^(.*)@([^@]+)$/);
103
+ if (!match) {
104
+ builder_util_1.log.debug({ name: node.name }, "invalid node name format");
105
+ continue;
106
+ }
107
+ const [, pkgName, version] = match;
108
+ const id = `${pkgName}@${version}`;
109
+ const isShadow = node.shadow && node.color === "dim";
110
+ if (isShadow) {
111
+ builder_util_1.log.debug({ pkgName, version }, "skipping shadow node");
112
+ continue;
113
+ }
114
+ if (seen.has(id)) {
115
+ continue;
116
+ }
117
+ seen.add(id);
118
+ // Build the expected path - yarn classic hoists to root node_modules
119
+ const pkgPath = path.join(this.rootDir, "node_modules", pkgName);
120
+ const normalizedDep = {
121
+ name: pkgName,
122
+ version,
123
+ path: pkgPath, // Will be resolved later in collectAllDependencies
124
+ dependencies: {},
125
+ optionalDependencies: {},
126
+ };
127
+ builder_util_1.log.debug({ name: pkgName, version }, "+ normalize");
128
+ if (node.children && node.children.length > 0) {
129
+ for (const child of node.children) {
130
+ const childMatch = child.name.match(/^(.*)@([^@]+)$/);
131
+ if (!childMatch) {
132
+ continue;
133
+ }
134
+ const [, childName, childVersion] = childMatch;
135
+ if (child.shadow && child.color === "dim") {
136
+ continue;
137
+ }
138
+ builder_util_1.log.debug({ parent: pkgName, childName, childVersion }, " + normalize child");
139
+ const childDeps = await this.normalizeTree([child], seen, appName);
140
+ for (const [childDepName, childDep] of Object.entries(childDeps)) {
141
+ normalizedDep.dependencies[childDepName] = childDep;
142
+ }
143
+ }
144
+ }
145
+ normalized[pkgName] = normalizedDep;
146
+ }
147
+ return normalized;
148
+ }
149
+ async collectAllDependencies(tree, packageToExclude) {
150
+ const rootPkgJson = await this.appPkgJson.value;
151
+ const failedPackages = new Set();
152
+ builder_util_1.log.debug({ packageToExclude, hasWorkspaces: !!tree.workspaces }, "collectAllDependencies starting");
153
+ const collect = async (deps = {}, isOptionalDependency, parentIsOptional = false) => {
154
+ var _a, _b, _c, _d;
155
+ for (const [, value] of Object.entries(deps)) {
156
+ // Skip the app package if provided
157
+ if (packageToExclude && value.name === packageToExclude) {
158
+ builder_util_1.log.debug({ name: value.name }, "skipping app package in collectAllDependencies");
159
+ continue;
160
+ }
161
+ const isRootOptional = !!((_a = rootPkgJson.optionalDependencies) === null || _a === void 0 ? void 0 : _a[value.name]);
162
+ const isDirectRootDep = ((_b = rootPkgJson.dependencies) === null || _b === void 0 ? void 0 : _b[value.name]) || ((_c = rootPkgJson.optionalDependencies) === null || _c === void 0 ? void 0 : _c[value.name]) || ((_d = rootPkgJson.devDependencies) === null || _d === void 0 ? void 0 : _d[value.name]);
163
+ const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional;
164
+ let p;
165
+ try {
166
+ p = await this.resolvePath(value.path);
167
+ }
168
+ catch (e) {
169
+ if (treatAsOptional) {
170
+ builder_util_1.log.debug({ pkg: this.cacheKey(value), name: value.name }, "failed to resolve optional dependency, skipping");
171
+ failedPackages.add(value.name);
172
+ continue;
173
+ }
174
+ if (!isDirectRootDep) {
175
+ builder_util_1.log.debug({ pkg: this.cacheKey(value), name: value.name }, "failed to resolve transitive dependency, treating as optional");
176
+ failedPackages.add(value.name);
177
+ continue;
178
+ }
179
+ builder_util_1.log.error({ pkg: this.cacheKey(value) }, "failed to resolve module directory");
180
+ throw e;
181
+ }
182
+ if (!p) {
183
+ builder_util_1.log.debug({ pkg: this.cacheKey(value), name: value.name }, "optional dependency not found, skipping");
184
+ failedPackages.add(value.name);
185
+ continue;
186
+ }
187
+ let resolvedVersion = value.version;
188
+ const versionMatch = p.match(/[/\\]node_modules[/\\][^@]+@([^/\\]+)[/\\]/);
189
+ if (versionMatch) {
190
+ resolvedVersion = versionMatch[1];
191
+ if (resolvedVersion !== value.version) {
192
+ builder_util_1.log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, "resolved actual version from path");
193
+ }
194
+ }
195
+ const m = {
196
+ ...value,
197
+ version: resolvedVersion,
198
+ path: p,
199
+ };
200
+ const moduleKey = this.packageVersionString(m);
201
+ if (this.allDependencies.has(moduleKey)) {
202
+ continue;
203
+ }
204
+ this.allDependencies.set(moduleKey, m);
205
+ const childIsOptional = treatAsOptional;
206
+ await collect(m.dependencies, false, childIsOptional);
207
+ await collect(m.optionalDependencies, true, true);
208
+ }
209
+ };
210
+ await collect(tree.dependencies, false, false);
211
+ await collect(tree.optionalDependencies, true, true);
212
+ // Final cleanup: remove the app package from allDependencies
213
+ if (packageToExclude) {
214
+ for (const [key, dep] of this.allDependencies.entries()) {
215
+ if (dep.name === packageToExclude) {
216
+ builder_util_1.log.debug({ key, name: dep.name }, "removing app package from allDependencies");
217
+ this.allDependencies.delete(key);
218
+ }
219
+ }
220
+ }
221
+ if (failedPackages.size > 0) {
222
+ const cleanDependencies = (deps = {}) => {
223
+ for (const [key, dep] of Object.entries(deps)) {
224
+ if (failedPackages.has(dep.name)) {
225
+ builder_util_1.log.debug({ name: dep.name }, "removing failed package from tree");
226
+ delete deps[key];
227
+ }
228
+ else {
229
+ if (dep.dependencies) {
230
+ cleanDependencies(dep.dependencies);
231
+ }
232
+ if (dep.optionalDependencies) {
233
+ cleanDependencies(dep.optionalDependencies);
234
+ }
235
+ }
236
+ }
237
+ };
238
+ cleanDependencies(tree.dependencies);
239
+ cleanDependencies(tree.optionalDependencies);
240
+ }
12
241
  }
13
242
  }
14
243
  exports.YarnNodeModulesCollector = YarnNodeModulesCollector;
@@ -1 +1 @@
1
- {"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAmE;AACnE,qDAAqC;AAErC,MAAa,wBAAyB,SAAQ,iDAAuB;IAArE;;QACE,6FAA6F;QAC7F,iHAAiH;QACjG,mBAAc,GAAG,EAAE,OAAO,EAAE,mBAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;IAC7E,CAAC;CAAA;AAJD,4DAIC","sourcesContent":["import { NpmNodeModulesCollector } from \"./npmNodeModulesCollector\"\nimport { PM } from \"./packageManager\"\n\nexport class YarnNodeModulesCollector extends NpmNodeModulesCollector {\n // note: do not override instance-var `pmCommand`. We explicitly use npm for the json payload\n // yarn list cannot get the detailed dependencies path info, But we can use npm to get all dependencies path info\n public readonly installOptions = { manager: PM.NPM, lockfile: \"yarn.lock\" }\n}\n"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Ae,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,iBAAiB,GAAG,CAAC,OAAuC,EAAE,EAAE,EAAE;gBACtE,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC9C,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjC,kBAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,mCAAmC,CAAC,CAAA;wBAClE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;oBAClB,CAAC;yBAAM,CAAC;wBACN,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;4BACrB,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;wBACrC,CAAC;wBACD,IAAI,GAAG,CAAC,oBAAoB,EAAE,CAAC;4BAC7B,iBAAiB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;wBAC7C,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAA;YAED,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YACpC,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;CACF;AAxRD,4DAwRC","sourcesContent":["import { log } from \"builder-util\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { PackageJson, YarnDependency } from \"./types\"\n\ntype YarnListJsonLine =\n | {\n type: \"tree\"\n data: {\n type: \"list\"\n trees: YarnListTree[]\n }\n }\n | {\n type: \"info\" | \"warning\" | \"error\"\n data: string\n }\n\ninterface YarnListTree {\n name: string // e.g. \"lodash@4.17.21\"\n children: YarnListTree[]\n shadow?: boolean\n color?: string\n hint?: any\n depth?: number\n}\n\nexport class YarnNodeModulesCollector extends NodeModulesCollector<YarnDependency, YarnDependency> {\n public readonly installOptions = {\n manager: PM.YARN,\n lockfile: \"yarn.lock\",\n }\n\n protected isHoisted: Lazy<boolean> = new Lazy<boolean>(async () => {\n return Promise.resolve(true) // Yarn Classic always hoists\n })\n\n protected getArgs(): string[] {\n return [\"list\", \"--production\", \"--json\", \"--depth=Infinity\", \"--no-progress\"]\n }\n\n protected async getTreeFromWorkspaces(tree: YarnDependency): Promise<YarnDependency> {\n if (!tree.workspaces || !tree.dependencies) {\n return tree\n }\n\n const appName = this.packageVersionString(tree)\n\n if (tree.dependencies?.[appName]) {\n const { name, path } = tree.dependencies[appName]\n log.debug({ name, path }, \"pruning root app/self package from workspace tree\")\n delete tree.dependencies[appName]\n }\n return Promise.resolve(tree)\n }\n\n protected async extractProductionDependencyGraph(tree: YarnDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {\n const dep = {\n ...dependency,\n path: await this.resolvePath(dependency.path),\n }\n\n const childDependencyId = this.packageVersionString(dep)\n await this.extractProductionDependencyGraph(dep, childDependencyId)\n return childDependencyId\n })\n\n this.productionGraph[dependencyId] = { dependencies: await Promise.all(productionDeps) }\n }\n\n protected getDependencyType(pkgName: string, parentPkgJson: PackageJson): \"prod\" | \"dev\" | \"optional\" {\n if (parentPkgJson.optionalDependencies?.[pkgName]) {\n return \"optional\"\n }\n\n if (parentPkgJson.devDependencies?.[pkgName]) {\n return \"dev\"\n }\n\n if (parentPkgJson.dependencies?.[pkgName]) {\n return \"prod\"\n }\n\n return \"prod\"\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<YarnDependency> {\n const lines = jsonBlob\n .split(\"\\n\")\n .map(l => l.trim())\n .filter(Boolean)\n .map(l => {\n try {\n return JSON.parse(l)\n } catch {\n return undefined\n }\n })\n .filter(Boolean) as YarnListJsonLine[]\n\n const parsedTree: YarnListTree[] | undefined = lines\n .filter(l => l.type === \"tree\")\n .map(l => (l.data as any).trees)\n .shift()\n\n if (!parsedTree) {\n throw new Error('Failed to extract Yarn tree: no \"type\":\"tree\" line found in console output')\n }\n\n const normalizedTree = await this.normalizeTree(parsedTree, new Set<string>(), undefined)\n\n const dependencies: Record<string, YarnDependency> = {}\n for (const [name, dep] of Object.entries(normalizedTree)) {\n dependencies[name] = dep\n }\n\n const rootPkgJson = await this.appPkgJson.value\n return Promise.resolve({\n name: rootPkgJson?.name || \".\",\n version: rootPkgJson?.version || \"unknown\",\n path: this.rootDir,\n dependencies,\n workspaces: rootPkgJson?.workspaces,\n })\n }\n\n private async normalizeTree(tree: YarnListTree[], seen = new Set<string>(), appName?: string): Promise<Record<string, YarnDependency>> {\n const normalized: Record<string, YarnDependency> = {}\n\n for (const node of tree) {\n const match = node.name.match(/^(.*)@([^@]+)$/)\n if (!match) {\n log.debug({ name: node.name }, \"invalid node name format\")\n continue\n }\n\n const [, pkgName, version] = match\n const id = `${pkgName}@${version}`\n\n const isShadow = node.shadow && node.color === \"dim\"\n if (isShadow) {\n log.debug({ pkgName, version }, \"skipping shadow node\")\n continue\n }\n\n if (seen.has(id)) {\n continue\n }\n\n seen.add(id)\n\n // Build the expected path - yarn classic hoists to root node_modules\n const pkgPath = path.join(this.rootDir, \"node_modules\", pkgName)\n\n const normalizedDep: YarnDependency = {\n name: pkgName,\n version,\n path: pkgPath, // Will be resolved later in collectAllDependencies\n dependencies: {},\n optionalDependencies: {},\n }\n\n log.debug({ name: pkgName, version }, \"+ normalize\")\n\n if (node.children && node.children.length > 0) {\n for (const child of node.children) {\n const childMatch = child.name.match(/^(.*)@([^@]+)$/)\n if (!childMatch) {\n continue\n }\n\n const [, childName, childVersion] = childMatch\n if (child.shadow && child.color === \"dim\") {\n continue\n }\n\n log.debug({ parent: pkgName, childName, childVersion }, \" + normalize child\")\n const childDeps = await this.normalizeTree([child], seen, appName)\n\n for (const [childDepName, childDep] of Object.entries(childDeps)) {\n normalizedDep.dependencies![childDepName] = childDep\n }\n }\n }\n\n normalized[pkgName] = normalizedDep\n }\n\n return normalized\n }\n\n protected async collectAllDependencies(tree: YarnDependency, packageToExclude: string) {\n const rootPkgJson = await this.appPkgJson.value\n const failedPackages = new Set<string>()\n\n log.debug({ packageToExclude, hasWorkspaces: !!tree.workspaces }, \"collectAllDependencies starting\")\n\n const collect = async (\n deps: YarnDependency[\"dependencies\"] | YarnDependency[\"optionalDependencies\"] = {},\n isOptionalDependency: boolean,\n parentIsOptional: boolean = false\n ) => {\n for (const [, value] of Object.entries(deps)) {\n // Skip the app package if provided\n if (packageToExclude && value.name === packageToExclude) {\n log.debug({ name: value.name }, \"skipping app package in collectAllDependencies\")\n continue\n }\n\n const isRootOptional = !!rootPkgJson.optionalDependencies?.[value.name]\n const isDirectRootDep = rootPkgJson.dependencies?.[value.name] || rootPkgJson.optionalDependencies?.[value.name] || rootPkgJson.devDependencies?.[value.name]\n const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional\n\n let p: string | null\n\n try {\n p = await this.resolvePath(value.path)\n } catch (e) {\n if (treatAsOptional) {\n log.debug({ pkg: this.cacheKey(value), name: value.name }, \"failed to resolve optional dependency, skipping\")\n failedPackages.add(value.name)\n continue\n }\n\n if (!isDirectRootDep) {\n log.debug({ pkg: this.cacheKey(value), name: value.name }, \"failed to resolve transitive dependency, treating as optional\")\n failedPackages.add(value.name)\n continue\n }\n\n log.error({ pkg: this.cacheKey(value) }, \"failed to resolve module directory\")\n throw e\n }\n\n if (!p) {\n log.debug({ pkg: this.cacheKey(value), name: value.name }, \"optional dependency not found, skipping\")\n failedPackages.add(value.name)\n continue\n }\n\n let resolvedVersion = value.version\n const versionMatch = p.match(/[/\\\\]node_modules[/\\\\][^@]+@([^/\\\\]+)[/\\\\]/)\n if (versionMatch) {\n resolvedVersion = versionMatch[1]\n if (resolvedVersion !== value.version) {\n log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, \"resolved actual version from path\")\n }\n }\n\n const m: YarnDependency = {\n ...value,\n version: resolvedVersion,\n path: p,\n }\n\n const moduleKey = this.packageVersionString(m)\n if (this.allDependencies.has(moduleKey)) {\n continue\n }\n\n this.allDependencies.set(moduleKey, m)\n\n const childIsOptional = treatAsOptional\n await collect(m.dependencies, false, childIsOptional)\n await collect(m.optionalDependencies, true, true)\n }\n }\n\n await collect(tree.dependencies, false, false)\n await collect(tree.optionalDependencies, true, true)\n\n // Final cleanup: remove the app package from allDependencies\n if (packageToExclude) {\n for (const [key, dep] of this.allDependencies.entries()) {\n if (dep.name === packageToExclude) {\n log.debug({ key, name: dep.name }, \"removing app package from allDependencies\")\n this.allDependencies.delete(key)\n }\n }\n }\n\n if (failedPackages.size > 0) {\n const cleanDependencies = (deps: Record<string, YarnDependency> = {}) => {\n for (const [key, dep] of Object.entries(deps)) {\n if (failedPackages.has(dep.name)) {\n log.debug({ name: dep.name }, \"removing failed package from tree\")\n delete deps[key]\n } else {\n if (dep.dependencies) {\n cleanDependencies(dep.dependencies)\n }\n if (dep.optionalDependencies) {\n cleanDependencies(dep.optionalDependencies)\n }\n }\n }\n }\n\n cleanDependencies(tree.dependencies)\n cleanDependencies(tree.optionalDependencies)\n }\n }\n}\n"]}
@@ -52,7 +52,8 @@ export interface WindowsConfiguration extends PlatformSpecificBuildOptions {
52
52
  */
53
53
  readonly signAndEditExecutable?: boolean;
54
54
  /**
55
- * Explicit file extensions to also sign. Advanced option.
55
+ * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.
56
+ * Supports negative patterns, e.g. example that excludes `.appx` files: `["somefilename", ".dll", "!.appx"]`.
56
57
  * @see https://github.com/electron-userland/electron-builder/issues/7329
57
58
  * @default null
58
59
  */
@@ -1 +1 @@
1
- {"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]./nsis.md#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable.\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * (Advanced option leveraging `rcedit`)\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Explicit file extensions to also sign. Advanced option.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX `sha256` is always used.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason.\n * Please see [Code Signing](./code-signing.md).\n */\n readonly certificateFile?: string | null\n\n /**\n * The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason.\n * Please see [Code Signing](./code-signing.md).\n */\n readonly certificatePassword?: string | null\n\n /**\n * The name of the subject of the signing certificate, which is often labeled with the field name `issued to`. Required only for EV Code Signing and works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * The SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches. Works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
1
+ {"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]./nsis.md#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable.\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * (Advanced option leveraging `rcedit`)\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.\n * Supports negative patterns, e.g. example that excludes `.appx` files: `[\"somefilename\", \".dll\", \"!.appx\"]`.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX `sha256` is always used.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason.\n * Please see [Code Signing](./code-signing.md).\n */\n readonly certificateFile?: string | null\n\n /**\n * The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason.\n * Please see [Code Signing](./code-signing.md).\n */\n readonly certificatePassword?: string | null\n\n /**\n * The name of the subject of the signing certificate, which is often labeled with the field name `issued to`. Required only for EV Code Signing and works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * The SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches. Works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
package/out/packager.d.ts CHANGED
@@ -10,6 +10,7 @@ import { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from "./packag
10
10
  import { PlatformPackager } from "./platformPackager";
11
11
  import { NodeModuleDirInfo, NodeModuleInfo } from "./util/packageDependencies";
12
12
  import { HandlerType } from "./util/asyncEventEmitter";
13
+ import { PM } from "./node-module-collector";
13
14
  type PackagerEvents = {
14
15
  artifactBuildStarted: Hook<ArtifactBuildStarted, void>;
15
16
  beforePack: Hook<BeforePackContext, void>;
@@ -26,6 +27,9 @@ export declare class Packager {
26
27
  readonly projectDir: string;
27
28
  private _appDir;
28
29
  get appDir(): string;
30
+ private _packageManager;
31
+ getPackageManager(): Promise<PM>;
32
+ getWorkspaceRoot(): Promise<string>;
29
33
  private _metadata;
30
34
  get metadata(): Metadata;
31
35
  private _nodeModulesHandledExternally;
@@ -46,6 +50,7 @@ export declare class Packager {
46
50
  readonly debugLogger: DebugLogger;
47
51
  get repositoryInfo(): Promise<SourceRepositoryInfo | null>;
48
52
  private nodeDependencyInfo;
53
+ private runtimeEnvironmentVariables;
49
54
  getNodeDependencyInfo(platform: Platform | null, flatten?: boolean): Lazy<Array<NodeModuleInfo | NodeModuleDirInfo>>;
50
55
  stageDirPathCustomizer: (target: Target, packager: PlatformPackager<any>, arch: Arch) => string;
51
56
  private _buildResourcesDir;
@@ -56,7 +61,7 @@ export declare class Packager {
56
61
  private readonly toDispose;
57
62
  disposeOnBuildFinish(disposer: () => Promise<void>): void;
58
63
  constructor(options: PackagerOptions, cancellationToken?: CancellationToken);
59
- addPackagerEventHandlers(): Promise<void>;
64
+ private addPackagerEventHandlers;
60
65
  onAfterPack(handler: PackagerEvents["afterPack"]): Packager;
61
66
  onArtifactCreated(handler: PackagerEvents["artifactCreated"]): Packager;
62
67
  filterPackagerEventListeners(event: keyof PackagerEvents, type: HandlerType | undefined): {
package/out/packager.js CHANGED
@@ -25,6 +25,7 @@ const yarn_1 = require("./util/yarn");
25
25
  const version_1 = require("./version");
26
26
  const asyncEventEmitter_1 = require("./util/asyncEventEmitter");
27
27
  const tiny_async_pool_1 = require("tiny-async-pool");
28
+ const node_module_collector_1 = require("./node-module-collector");
28
29
  async function createFrameworkInfo(configuration, packager) {
29
30
  let framework = configuration.framework;
30
31
  if (framework != null) {
@@ -53,6 +54,12 @@ class Packager {
53
54
  get appDir() {
54
55
  return this._appDir;
55
56
  }
57
+ async getPackageManager() {
58
+ return (await this._packageManager.value).pm;
59
+ }
60
+ async getWorkspaceRoot() {
61
+ return (await (await this._packageManager.value).workspaceRoot) || this.projectDir;
62
+ }
56
63
  get metadata() {
57
64
  return this._metadata;
58
65
  }
@@ -110,6 +117,23 @@ class Packager {
110
117
  //noinspection JSUnusedGlobalSymbols
111
118
  constructor(options, cancellationToken = new builder_util_runtime_1.CancellationToken()) {
112
119
  this.cancellationToken = cancellationToken;
120
+ this._packageManager = new lazy_val_1.Lazy(async () => {
121
+ const availableDirs = [this.projectDir, this.appDir];
122
+ const pm = await (0, node_module_collector_1.detectPackageManager)(availableDirs);
123
+ const workspaceRoot = await (0, node_module_collector_1.findWorkspaceRoot)(pm.pm, this.projectDir);
124
+ if (workspaceRoot != null) {
125
+ // re-detect package manager from workspace root, this seems particularly necessary for pnpm workspaces
126
+ const actualPm = await (0, node_module_collector_1.detectPackageManager)([workspaceRoot]);
127
+ return {
128
+ pm: actualPm.pm,
129
+ workspaceRoot: Promise.resolve(actualPm.resolvedDirectory),
130
+ };
131
+ }
132
+ return {
133
+ pm: pm.pm,
134
+ workspaceRoot: Promise.resolve(pm.resolvedDirectory),
135
+ };
136
+ });
113
137
  this._metadata = null;
114
138
  this._nodeModulesHandledExternally = false;
115
139
  this._isPrepackedAppAsar = false;
@@ -122,6 +146,7 @@ class Packager {
122
146
  this._repositoryInfo = new lazy_val_1.Lazy(() => (0, repositoryInfo_1.getRepositoryInfo)(this.projectDir, this.metadata, this.devMetadata));
123
147
  this.debugLogger = new builder_util_1.DebugLogger(builder_util_1.log.isDebugEnabled);
124
148
  this.nodeDependencyInfo = new Map();
149
+ this.runtimeEnvironmentVariables = {};
125
150
  this.stageDirPathCustomizer = (target, packager, arch) => {
126
151
  return path.join(target.outDir, `__${target.name}-${(0, builder_util_1.getArtifactArchName)(arch, target.name)}`);
127
152
  };
@@ -457,12 +482,12 @@ class Packager {
457
482
  builder_util_1.log.info({ reason: "platform is different and buildDependenciesFromSource is set to true" }, "skipped dependencies rebuild");
458
483
  }
459
484
  else {
460
- await (0, yarn_1.installOrRebuild)(config, { appDir: this.appDir, projectDir: this.projectDir }, {
485
+ await (0, yarn_1.installOrRebuild)(config, { appDir: this.appDir, projectDir: this.projectDir, workspaceRoot: await this.getWorkspaceRoot() }, {
461
486
  frameworkInfo,
462
487
  platform: platform.nodeName,
463
488
  arch: builder_util_1.Arch[arch],
464
489
  productionDeps: this.getNodeDependencyInfo(null, false),
465
- });
490
+ }, false, this.runtimeEnvironmentVariables);
466
491
  }
467
492
  }
468
493
  }