app-builder-lib 26.0.4 → 26.0.6
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/node-module-collector/nodeModulesCollector.d.ts +6 -3
- package/out/node-module-collector/nodeModulesCollector.js +22 -1
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/npmNodeModulesCollector.d.ts +2 -0
- package/out/node-module-collector/npmNodeModulesCollector.js +16 -1
- package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +2 -0
- package/out/node-module-collector/pnpmNodeModulesCollector.js +17 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/types.d.ts +18 -1
- package/out/node-module-collector/types.js.map +1 -1
- package/out/node-module-collector/yarnNodeModulesCollector.d.ts +2 -0
- package/out/node-module-collector/yarnNodeModulesCollector.js +16 -1
- package/out/node-module-collector/yarnNodeModulesCollector.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 +7 -7
- package/templates/linux/after-install.tpl +4 -1
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { NodeModuleInfo, DependencyTree
|
|
1
|
+
import { NodeModuleInfo, DependencyTree } from "./types";
|
|
2
2
|
export declare abstract class NodeModulesCollector {
|
|
3
3
|
private readonly rootDir;
|
|
4
4
|
private nodeModules;
|
|
5
5
|
protected dependencyPathMap: Map<string, string>;
|
|
6
|
+
protected allDependencies: Map<string, DependencyTree>;
|
|
6
7
|
constructor(rootDir: string);
|
|
7
8
|
private transToHoisterTree;
|
|
8
|
-
|
|
9
|
-
convertToDependencyGraph
|
|
9
|
+
protected resolvePath(filePath: string): string;
|
|
10
|
+
private convertToDependencyGraph;
|
|
11
|
+
getAllDependencies(tree: DependencyTree): void;
|
|
10
12
|
abstract getCommand(): string;
|
|
11
13
|
abstract getArgs(): string[];
|
|
14
|
+
abstract removeNonProductionDependencie(tree: DependencyTree): void;
|
|
12
15
|
protected getDependenciesTree(): Promise<DependencyTree>;
|
|
13
16
|
private _getNodeModules;
|
|
14
17
|
private getTreeFromWorkspaces;
|
|
@@ -8,6 +8,7 @@ const builder_util_1 = require("builder-util");
|
|
|
8
8
|
class NodeModulesCollector {
|
|
9
9
|
constructor(rootDir) {
|
|
10
10
|
this.rootDir = rootDir;
|
|
11
|
+
this.allDependencies = new Map();
|
|
11
12
|
this.dependencyPathMap = new Map();
|
|
12
13
|
this.nodeModules = [];
|
|
13
14
|
}
|
|
@@ -67,6 +68,15 @@ class NodeModulesCollector {
|
|
|
67
68
|
flatten(tree);
|
|
68
69
|
return result;
|
|
69
70
|
}
|
|
71
|
+
getAllDependencies(tree) {
|
|
72
|
+
const dependencies = tree.dependencies || {};
|
|
73
|
+
for (const [key, value] of Object.entries(dependencies)) {
|
|
74
|
+
if (value.dependencies && Object.keys(value.dependencies).length > 0) {
|
|
75
|
+
this.allDependencies.set(`${key}@${value.version}`, value);
|
|
76
|
+
this.getAllDependencies(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
70
80
|
async getDependenciesTree() {
|
|
71
81
|
const command = this.getCommand();
|
|
72
82
|
const args = this.getArgs();
|
|
@@ -75,7 +85,16 @@ class NodeModulesCollector {
|
|
|
75
85
|
shell: true,
|
|
76
86
|
});
|
|
77
87
|
const dependencyTree = JSON.parse(dependencies);
|
|
78
|
-
|
|
88
|
+
// pnpm returns an array of dependency trees
|
|
89
|
+
if (Array.isArray(dependencyTree)) {
|
|
90
|
+
const tree = dependencyTree[0];
|
|
91
|
+
if (tree.optionalDependencies) {
|
|
92
|
+
tree.dependencies = { ...tree.dependencies, ...tree.optionalDependencies };
|
|
93
|
+
}
|
|
94
|
+
return tree;
|
|
95
|
+
}
|
|
96
|
+
// yarn and npm return a single dependency tree
|
|
97
|
+
return dependencyTree;
|
|
79
98
|
}
|
|
80
99
|
_getNodeModules(dependencies, result) {
|
|
81
100
|
if (dependencies.size === 0) {
|
|
@@ -114,6 +133,8 @@ class NodeModulesCollector {
|
|
|
114
133
|
async getNodeModules() {
|
|
115
134
|
const tree = await this.getDependenciesTree();
|
|
116
135
|
const realTree = this.getTreeFromWorkspaces(tree);
|
|
136
|
+
this.getAllDependencies(realTree);
|
|
137
|
+
this.removeNonProductionDependencie(realTree);
|
|
117
138
|
const dependencyGraph = this.convertToDependencyGraph(realTree);
|
|
118
139
|
const hoisterResult = (0, hoist_1.hoist)(this.transToHoisterTree(dependencyGraph), { check: true });
|
|
119
140
|
this._getNodeModules(hoisterResult.dependencies, this.nodeModules);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AACrE,6BAA4B;AAC5B,yBAAwB;AAExB,+CAAwC;AAExC,MAAsB,oBAAoB;IAIxC,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACvB,CAAC;IAEO,kBAAkB,CAAC,GAAoB,EAAE,MAAc,GAAG,EAAE,QAAkC,IAAI,GAAG,EAAE;QAC7G,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAE,CAAC,CAAC,CAAC,CAAA;QACrC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG;gBACL,IAAI;gBACJ,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE;gBAChD,YAAY,EAAE,IAAI,GAAG,EAAe;gBACpC,SAAS,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I,CAAC,YAAY,EAAE,CAAC;YACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC7D,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;oBAC/C,OAAO,KAAK,CAAA;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACjD,MAAM,eAAe,GAAG,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAA;QAC/D,MAAM,aAAa,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtF,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAClE,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;CACF;AAhID,oDAgIC","sourcesContent":["import { hoist, type HoisterTree, type HoisterResult } from \"./hoist\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { NodeModuleInfo, DependencyTree, DependencyGraph } from \"./types\"\nimport { exec, log } from \"builder-util\"\n\nexport abstract class NodeModulesCollector {\n private nodeModules: NodeModuleInfo[]\n protected dependencyPathMap: Map<string, string>\n\n constructor(private readonly rootDir: string) {\n this.dependencyPathMap = new Map()\n this.nodeModules = []\n }\n\n private transToHoisterTree(obj: DependencyGraph, key: string = `.`, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const name = key.match(/@?[^@]+/)![0]\n if (!node) {\n node = {\n name,\n identName: name,\n reference: key.match(/@?[^@]+@?(.+)?/)![1] || ``,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>([]),\n }\n nodes.set(key, node)\n\n for (const dep of (obj[key] || {}).dependencies || []) {\n node.dependencies.add(this.transToHoisterTree(obj, dep, nodes))\n }\n }\n return node\n }\n\n private resolvePath(filePath: string) {\n try {\n const stats = fs.lstatSync(filePath)\n if (stats.isSymbolicLink()) {\n return fs.realpathSync(filePath)\n } else {\n return filePath\n }\n } catch (error: any) {\n log.debug({ message: error.message || error.stack }, \"error resolving path\")\n return filePath\n }\n }\n\n public convertToDependencyGraph(tree: DependencyTree): DependencyGraph {\n const result: DependencyGraph = { \".\": {} }\n\n const flatten = (node: DependencyTree, parentKey = \".\") => {\n const dependencies = node.dependencies || {}\n\n for (const [key, value] of Object.entries(dependencies)) {\n // Skip empty dependencies(like some optionalDependencies)\n if (Object.keys(value).length === 0) {\n continue\n }\n const version = value.version || \"\"\n const newKey = `${key}@${version}`\n this.dependencyPathMap.set(newKey, path.normalize(this.resolvePath(value.path)))\n if (!result[parentKey]?.dependencies) {\n result[parentKey] = { dependencies: [] }\n }\n result[parentKey].dependencies!.push(newKey)\n flatten(value, newKey)\n }\n }\n\n flatten(tree)\n return result\n }\n\n abstract getCommand(): string\n abstract getArgs(): string[]\n\n protected async getDependenciesTree(): Promise<DependencyTree> {\n const command = this.getCommand()\n const args = this.getArgs()\n const dependencies = await exec(command, args, {\n cwd: this.rootDir,\n shell: true,\n })\n const dependencyTree: DependencyTree | DependencyTree[] = JSON.parse(dependencies)\n return Array.isArray(dependencyTree) ? dependencyTree[0] : dependencyTree\n }\n\n private _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.dependencyPathMap.get(`${d.name}@${reference}`)\n if (p === undefined) {\n log.debug({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: p,\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node[\"dependencies\"] = []\n this._getNodeModules(d.dependencies, node[\"dependencies\"])\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n private getTreeFromWorkspaces(tree: DependencyTree): DependencyTree {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (this.rootDir.endsWith(path.normalize(key))) {\n return value\n }\n }\n }\n return tree\n }\n\n public async getNodeModules(): Promise<NodeModuleInfo[]> {\n const tree = await this.getDependenciesTree()\n const realTree = this.getTreeFromWorkspaces(tree)\n const dependencyGraph = this.convertToDependencyGraph(realTree)\n const hoisterResult = hoist(this.transToHoisterTree(dependencyGraph), { check: true })\n this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n return this.nodeModules\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AACrE,6BAA4B;AAC5B,yBAAwB;AAExB,+CAAwC;AAExC,MAAsB,oBAAoB;IAKxC,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAFlC,oBAAe,GAAgC,IAAI,GAAG,EAAE,CAAA;QAGhE,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACvB,CAAC;IAEO,kBAAkB,CAAC,GAAoB,EAAE,MAAc,GAAG,EAAE,QAAkC,IAAI,GAAG,EAAE;QAC7G,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAE,CAAC,CAAC,CAAC,CAAA;QACrC,IAAI,CAAC,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A;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACjC,IAAI,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAA;QAC7C,MAAM,eAAe,GAAG,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAA;QAC/D,MAAM,aAAa,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtF,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAClE,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;CACF;AAzJD,oDAyJC","sourcesContent":["import { hoist, type HoisterTree, type HoisterResult } from \"./hoist\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { NodeModuleInfo, DependencyTree, DependencyGraph } from \"./types\"\nimport { exec, log } from \"builder-util\"\n\nexport abstract class NodeModulesCollector {\n private nodeModules: NodeModuleInfo[]\n protected dependencyPathMap: Map<string, string>\n protected allDependencies: Map<string, DependencyTree> = new Map()\n\n constructor(private readonly rootDir: string) {\n this.dependencyPathMap = new Map()\n this.nodeModules = []\n }\n\n private transToHoisterTree(obj: DependencyGraph, key: string = `.`, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const name = key.match(/@?[^@]+/)![0]\n if (!node) {\n node = {\n name,\n identName: name,\n reference: key.match(/@?[^@]+@?(.+)?/)![1] || ``,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>([]),\n }\n nodes.set(key, node)\n\n for (const dep of (obj[key] || {}).dependencies || []) {\n node.dependencies.add(this.transToHoisterTree(obj, dep, nodes))\n }\n }\n return node\n }\n\n protected resolvePath(filePath: string) {\n try {\n const stats = fs.lstatSync(filePath)\n if (stats.isSymbolicLink()) {\n return fs.realpathSync(filePath)\n } else {\n return filePath\n }\n } catch (error: any) {\n log.debug({ message: error.message || error.stack }, \"error resolving path\")\n return filePath\n }\n }\n\n private convertToDependencyGraph(tree: DependencyTree): DependencyGraph {\n const result: DependencyGraph = { \".\": {} }\n\n const flatten = (node: DependencyTree, parentKey = \".\") => {\n const dependencies = node.dependencies || {}\n\n for (const [key, value] of Object.entries(dependencies)) {\n // Skip empty dependencies(like some optionalDependencies)\n if (Object.keys(value).length === 0) {\n continue\n }\n const version = value.version || \"\"\n const newKey = `${key}@${version}`\n this.dependencyPathMap.set(newKey, path.normalize(this.resolvePath(value.path)))\n if (!result[parentKey]?.dependencies) {\n result[parentKey] = { dependencies: [] }\n }\n result[parentKey].dependencies!.push(newKey)\n flatten(value, newKey)\n }\n }\n\n flatten(tree)\n return result\n }\n\n getAllDependencies(tree: DependencyTree) {\n const dependencies = tree.dependencies || {}\n for (const [key, value] of Object.entries(dependencies)) {\n if (value.dependencies && Object.keys(value.dependencies).length > 0) {\n this.allDependencies.set(`${key}@${value.version}`, value)\n this.getAllDependencies(value)\n }\n }\n }\n\n abstract getCommand(): string\n abstract getArgs(): string[]\n abstract removeNonProductionDependencie(tree: DependencyTree): void\n\n protected async getDependenciesTree(): Promise<DependencyTree> {\n const command = this.getCommand()\n const args = this.getArgs()\n const dependencies = await exec(command, args, {\n cwd: this.rootDir,\n shell: true,\n })\n const dependencyTree: DependencyTree | DependencyTree[] = JSON.parse(dependencies)\n\n // pnpm returns an array of dependency trees\n if (Array.isArray(dependencyTree)) {\n const tree = dependencyTree[0]\n if (tree.optionalDependencies) {\n tree.dependencies = { ...tree.dependencies, ...tree.optionalDependencies }\n }\n return tree\n }\n\n // yarn and npm return a single dependency tree\n return dependencyTree\n }\n\n private _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.dependencyPathMap.get(`${d.name}@${reference}`)\n if (p === undefined) {\n log.debug({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: p,\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node[\"dependencies\"] = []\n this._getNodeModules(d.dependencies, node[\"dependencies\"])\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n private getTreeFromWorkspaces(tree: DependencyTree): DependencyTree {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (this.rootDir.endsWith(path.normalize(key))) {\n return value\n }\n }\n }\n return tree\n }\n\n public async getNodeModules(): Promise<NodeModuleInfo[]> {\n const tree = await this.getDependenciesTree()\n const realTree = this.getTreeFromWorkspaces(tree)\n this.getAllDependencies(realTree)\n this.removeNonProductionDependencie(realTree)\n const dependencyGraph = this.convertToDependencyGraph(realTree)\n const hoisterResult = hoist(this.transToHoisterTree(dependencyGraph), { check: true })\n this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n return this.nodeModules\n }\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NodeModulesCollector } from "./nodeModulesCollector";
|
|
2
|
+
import { DependencyTree } from "./types";
|
|
2
3
|
export declare class NpmNodeModulesCollector extends NodeModulesCollector {
|
|
3
4
|
constructor(rootDir: string);
|
|
4
5
|
getCommand(): string;
|
|
5
6
|
getArgs(): string[];
|
|
7
|
+
removeNonProductionDependencie(tree: DependencyTree): void;
|
|
6
8
|
}
|
|
@@ -10,7 +10,22 @@ class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollecto
|
|
|
10
10
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
11
11
|
}
|
|
12
12
|
getArgs() {
|
|
13
|
-
return ["list", "--
|
|
13
|
+
return ["list", "-a", "--include", "prod", "--include", "optional", "--omit", "dev", "--json", "--long", "--silent"];
|
|
14
|
+
}
|
|
15
|
+
removeNonProductionDependencie(tree) {
|
|
16
|
+
var _a;
|
|
17
|
+
const dependencies = tree.dependencies || {};
|
|
18
|
+
const _dependencies = tree._dependencies || {};
|
|
19
|
+
if (dependencies && Object.keys(dependencies).length === 0) {
|
|
20
|
+
tree.dependencies = ((_a = this.allDependencies.get(`${tree.name}@${tree.version}`)) === null || _a === void 0 ? void 0 : _a.dependencies) || {};
|
|
21
|
+
}
|
|
22
|
+
for (const [key, value] of Object.entries(dependencies)) {
|
|
23
|
+
if (!_dependencies[key] || Object.keys(value).length === 0) {
|
|
24
|
+
delete dependencies[key];
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
this.removeNonProductionDependencie(value);
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
}
|
|
16
31
|
exports.NpmNodeModulesCollector = NpmNodeModulesCollector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;
|
|
1
|
+
{"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,MAAa,uBAAwB,SAAQ,2CAAoB;IAC/D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;IACzD,CAAC;IAED,OAAO;QACL,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;IACtH,CAAC;IAED,8BAA8B,CAAC,IAAoB;;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAA;QAC5C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,EAAE,CAAA;QAC9C,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,YAAY,GAAG,CAAA,MAAA,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,0CAAE,YAAY,KAAI,EAAE,CAAA;QAClG,CAAC;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3D,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;gBACxB,SAAQ;YACV,CAAC;YACD,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;CACF;AA5BD,0DA4BC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { DependencyTree } from \"./types\"\n\nexport class NpmNodeModulesCollector extends NodeModulesCollector {\n constructor(rootDir: string) {\n super(rootDir)\n }\n\n getCommand(): string {\n return process.platform === \"win32\" ? \"npm.cmd\" : \"npm\"\n }\n\n getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\"]\n }\n\n removeNonProductionDependencie(tree: DependencyTree) {\n const dependencies = tree.dependencies || {}\n const _dependencies = tree._dependencies || {}\n if (dependencies && Object.keys(dependencies).length === 0) {\n tree.dependencies = this.allDependencies.get(`${tree.name}@${tree.version}`)?.dependencies || {}\n }\n\n for (const [key, value] of Object.entries(dependencies)) {\n if (!_dependencies[key] || Object.keys(value).length === 0) {\n delete dependencies[key]\n continue\n }\n this.removeNonProductionDependencie(value)\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NodeModulesCollector } from "./nodeModulesCollector";
|
|
2
|
+
import { DependencyTree } from "./types";
|
|
2
3
|
export declare class PnpmNodeModulesCollector extends NodeModulesCollector {
|
|
3
4
|
constructor(rootDir: string);
|
|
4
5
|
getCommand(): string;
|
|
5
6
|
getArgs(): string[];
|
|
7
|
+
removeNonProductionDependencie(tree: DependencyTree): void;
|
|
6
8
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PnpmNodeModulesCollector = void 0;
|
|
4
4
|
const nodeModulesCollector_1 = require("./nodeModulesCollector");
|
|
5
|
+
const path = require("path");
|
|
5
6
|
class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
|
|
6
7
|
constructor(rootDir) {
|
|
7
8
|
super(rootDir);
|
|
@@ -10,7 +11,22 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
10
11
|
return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
11
12
|
}
|
|
12
13
|
getArgs() {
|
|
13
|
-
return ["list", "--prod", "--json", "--
|
|
14
|
+
return ["list", "--prod", "--json", "--depth", "Infinity"];
|
|
15
|
+
}
|
|
16
|
+
removeNonProductionDependencie(tree) {
|
|
17
|
+
const dependencies = tree.dependencies || {};
|
|
18
|
+
const p = path.normalize(this.resolvePath(tree.path));
|
|
19
|
+
const pJson = require(path.join(p, "package.json"));
|
|
20
|
+
const _dependencies = pJson.dependencies || {};
|
|
21
|
+
const _optionalDependencies = pJson.optionalDependencies || {};
|
|
22
|
+
const prodDependencies = { ..._dependencies, ..._optionalDependencies };
|
|
23
|
+
for (const [key, value] of Object.entries(dependencies)) {
|
|
24
|
+
if (!prodDependencies[key]) {
|
|
25
|
+
delete dependencies[key];
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
this.removeNonProductionDependencie(value);
|
|
29
|
+
}
|
|
14
30
|
}
|
|
15
31
|
}
|
|
16
32
|
exports.PnpmNodeModulesCollector = PnpmNodeModulesCollector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAE7D,MAAa,wBAAyB,SAAQ,2CAAoB;IAChE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAA;IAC3D,CAAC;IAED,OAAO;QACL,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAE7D,6BAA4B;AAE5B,MAAa,wBAAyB,SAAQ,2CAAoB;IAChE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAA;IAC3D,CAAC;IAED,OAAO;QACL,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;IAC5D,CAAC;IAED,8BAA8B,CAAC,IAAoB;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAA;QAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACrD,MAAM,KAAK,GAAe,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;QAC/D,MAAM,aAAa,GAAG,KAAK,CAAC,YAAY,IAAI,EAAE,CAAA;QAC9C,MAAM,qBAAqB,GAAG,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAA;QAC9D,MAAM,gBAAgB,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,qBAAqB,EAAE,CAAA;QACvE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;gBACxB,SAAQ;YACV,CAAC;YACD,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;CACF;AA5BD,4DA4BC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { DependencyTree, Dependency } from \"./types\"\nimport * as path from \"path\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector {\n constructor(rootDir: string) {\n super(rootDir)\n }\n\n getCommand(): string {\n return process.platform === \"win32\" ? \"pnpm.cmd\" : \"pnpm\"\n }\n\n getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\"]\n }\n\n removeNonProductionDependencie(tree: DependencyTree) {\n const dependencies = tree.dependencies || {}\n const p = path.normalize(this.resolvePath(tree.path))\n const pJson: Dependency = require(path.join(p, \"package.json\"))\n const _dependencies = pJson.dependencies || {}\n const _optionalDependencies = pJson.optionalDependencies || {}\n const prodDependencies = { ..._dependencies, ..._optionalDependencies }\n for (const [key, value] of Object.entries(dependencies)) {\n if (!prodDependencies[key]) {\n delete dependencies[key]\n continue\n }\n this.removeNonProductionDependencie(value)\n }\n }\n}\n"]}
|
|
@@ -10,9 +10,26 @@ export interface DependencyTree {
|
|
|
10
10
|
readonly from?: string;
|
|
11
11
|
readonly workspaces?: string[];
|
|
12
12
|
readonly path: string;
|
|
13
|
-
dependencies
|
|
13
|
+
dependencies?: {
|
|
14
14
|
[packageName: string]: DependencyTree;
|
|
15
15
|
};
|
|
16
|
+
_dependencies?: {
|
|
17
|
+
[packageName: string]: string;
|
|
18
|
+
};
|
|
19
|
+
optionalDependencies?: {
|
|
20
|
+
[packageName: string]: DependencyTree;
|
|
21
|
+
};
|
|
22
|
+
peerDependencies?: {
|
|
23
|
+
[packageName: string]: DependencyTree;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface Dependency {
|
|
27
|
+
dependencies?: {
|
|
28
|
+
[packageName: string]: string;
|
|
29
|
+
};
|
|
30
|
+
optionalDependencies?: {
|
|
31
|
+
[packageName: string]: string;
|
|
32
|
+
};
|
|
16
33
|
}
|
|
17
34
|
export interface DependencyGraph {
|
|
18
35
|
[packageNameAndVersion: string]: PackageDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport interface DependencyTree {\n readonly version?: string\n readonly name?: string\n readonly from?: string\n readonly workspaces?: string[]\n readonly path: string\n dependencies: {\n [packageName: string]: DependencyTree\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: PackageDependencies\n}\n\ninterface PackageDependencies {\n dependencies?: string[]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport interface DependencyTree {\n readonly version?: string\n readonly name?: string\n readonly from?: string\n readonly workspaces?: string[]\n readonly path: string\n dependencies?: {\n [packageName: string]: DependencyTree\n }\n // for npm list --json\n _dependencies?: {\n [packageName: string]: string\n }\n optionalDependencies?: {\n [packageName: string]: DependencyTree\n }\n peerDependencies?: {\n [packageName: string]: DependencyTree\n }\n}\n\nexport interface Dependency {\n dependencies?: {\n [packageName: string]: string\n }\n optionalDependencies?: {\n [packageName: string]: string\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: PackageDependencies\n}\n\ninterface PackageDependencies {\n dependencies?: string[]\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NodeModulesCollector } from "./nodeModulesCollector";
|
|
2
|
+
import { DependencyTree } from "./types";
|
|
2
3
|
export declare class YarnNodeModulesCollector extends NodeModulesCollector {
|
|
3
4
|
constructor(rootDir: string);
|
|
4
5
|
getCommand(): string;
|
|
5
6
|
getArgs(): string[];
|
|
7
|
+
removeNonProductionDependencie(tree: DependencyTree): void;
|
|
6
8
|
}
|
|
@@ -10,7 +10,22 @@ class YarnNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
10
10
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
11
11
|
}
|
|
12
12
|
getArgs() {
|
|
13
|
-
return ["list", "--
|
|
13
|
+
return ["list", "-a", "--include", "prod", "--include", "optional", "--omit", "dev", "--json", "--long", "--silent"];
|
|
14
|
+
}
|
|
15
|
+
removeNonProductionDependencie(tree) {
|
|
16
|
+
var _a;
|
|
17
|
+
const dependencies = tree.dependencies || {};
|
|
18
|
+
const _dependencies = tree._dependencies || {};
|
|
19
|
+
if (dependencies && Object.keys(dependencies).length === 0) {
|
|
20
|
+
tree.dependencies = ((_a = this.allDependencies.get(`${tree.name}@${tree.version}`)) === null || _a === void 0 ? void 0 : _a.dependencies) || {};
|
|
21
|
+
}
|
|
22
|
+
for (const [key, value] of Object.entries(dependencies)) {
|
|
23
|
+
if (!_dependencies[key] || Object.keys(value).length === 0) {
|
|
24
|
+
delete dependencies[key];
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
this.removeNonProductionDependencie(value);
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
}
|
|
16
31
|
exports.YarnNodeModulesCollector = YarnNodeModulesCollector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;
|
|
1
|
+
{"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,MAAa,wBAAyB,SAAQ,2CAAoB;IAChE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;IACzD,CAAC;IAED,OAAO;QACL,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;IACtH,CAAC;IAED,8BAA8B,CAAC,IAAoB;;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAA;QAC5C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,EAAE,CAAA;QAC9C,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,YAAY,GAAG,CAAA,MAAA,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,0CAAE,YAAY,KAAI,EAAE,CAAA;QAClG,CAAC;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3D,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;gBACxB,SAAQ;YACV,CAAC;YACD,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;CACF;AA5BD,4DA4BC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { DependencyTree } from \"./types\"\n\nexport class YarnNodeModulesCollector extends NodeModulesCollector {\n constructor(rootDir: string) {\n super(rootDir)\n }\n\n getCommand(): string {\n return process.platform === \"win32\" ? \"npm.cmd\" : \"npm\"\n }\n\n getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\"]\n }\n\n removeNonProductionDependencie(tree: DependencyTree) {\n const dependencies = tree.dependencies || {}\n const _dependencies = tree._dependencies || {}\n if (dependencies && Object.keys(dependencies).length === 0) {\n tree.dependencies = this.allDependencies.get(`${tree.name}@${tree.version}`)?.dependencies || {}\n }\n\n for (const [key, value] of Object.entries(dependencies)) {\n if (!_dependencies[key] || Object.keys(value).length === 0) {\n delete dependencies[key]\n continue\n }\n this.removeNonProductionDependencie(value)\n }\n }\n}\n"]}
|
package/out/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "26.0.
|
|
1
|
+
export declare const PACKAGE_VERSION = "26.0.6";
|
package/out/version.js
CHANGED
package/out/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.0.6\"\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app-builder-lib",
|
|
3
3
|
"description": "electron-builder lib",
|
|
4
|
-
"version": "26.0.
|
|
4
|
+
"version": "26.0.6",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"out",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"temp-file": "^3.4.0",
|
|
77
77
|
"tiny-async-pool": "1.3.0",
|
|
78
78
|
"builder-util": "26.0.4",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
79
|
+
"builder-util-runtime": "9.3.1",
|
|
80
|
+
"electron-publish": "26.0.4"
|
|
81
81
|
},
|
|
82
82
|
"///": "babel in devDependencies for proton tests",
|
|
83
83
|
"devDependencies": {
|
|
@@ -109,12 +109,12 @@
|
|
|
109
109
|
"@types/tar": "^6.1.3",
|
|
110
110
|
"@types/tiny-async-pool": "^1",
|
|
111
111
|
"toml": "^3.0.0",
|
|
112
|
-
"dmg-builder": "26.0.
|
|
113
|
-
"electron-builder-squirrel-windows": "26.0.
|
|
112
|
+
"dmg-builder": "26.0.6",
|
|
113
|
+
"electron-builder-squirrel-windows": "26.0.6"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
|
-
"dmg-builder": "26.0.
|
|
117
|
-
"electron-builder-squirrel-windows": "26.0.
|
|
116
|
+
"dmg-builder": "26.0.6",
|
|
117
|
+
"electron-builder-squirrel-windows": "26.0.6"
|
|
118
118
|
},
|
|
119
119
|
"//": "electron-builder-squirrel-windows and dmg-builder added as dev dep for tests (as otherwise `require` doesn't work using Yarn 2)",
|
|
120
120
|
"typings": "./out/index.d.ts"
|
|
@@ -42,7 +42,10 @@ if test -d "/etc/apparmor.d"; then
|
|
|
42
42
|
if apparmor_parser --skip-kernel-load --debug "$APPARMOR_PROFILE_SOURCE" > /dev/null 2>&1; then
|
|
43
43
|
cp -f "$APPARMOR_PROFILE_SOURCE" "$APPARMOR_PROFILE_TARGET"
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
# Updating the current AppArmor profile is not possible and probably not meaningful in a chroot'ed environment.
|
|
46
|
+
# Use cases are for example environments where images for clients are maintained.
|
|
47
|
+
# There, AppArmor might correctly be installed, but live updating makes no sense.
|
|
48
|
+
if ! { [ -x '/usr/bin/ischroot' ] && /usr/bin/ischroot; } && hash apparmor_parser 2>/dev/null; then
|
|
46
49
|
# Extra flags taken from dh_apparmor:
|
|
47
50
|
# > By using '-W -T' we ensure that any abstraction updates are also pulled in.
|
|
48
51
|
# https://wiki.debian.org/AppArmor/Contribute/FirstTimeProfileImport
|