@pnpm/lockfile.filtering 1.0.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/LICENSE +22 -0
- package/README.md +13 -0
- package/lib/filterImporter.d.ts +5 -0
- package/lib/filterImporter.js +13 -0
- package/lib/filterImporter.js.map +1 -0
- package/lib/filterLockfile.d.ts +8 -0
- package/lib/filterLockfile.js +12 -0
- package/lib/filterLockfile.js.map +1 -0
- package/lib/filterLockfileByImporters.d.ts +9 -0
- package/lib/filterLockfileByImporters.js +40 -0
- package/lib/filterLockfileByImporters.js.map +1 -0
- package/lib/filterLockfileByImportersAndEngine.d.ts +23 -0
- package/lib/filterLockfileByImportersAndEngine.js +190 -0
- package/lib/filterLockfileByImportersAndEngine.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2024 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterImporter = void 0;
|
|
4
|
+
function filterImporter(importer, include) {
|
|
5
|
+
return {
|
|
6
|
+
dependencies: !include.dependencies ? {} : importer.dependencies ?? {},
|
|
7
|
+
devDependencies: !include.devDependencies ? {} : importer.devDependencies ?? {},
|
|
8
|
+
optionalDependencies: !include.optionalDependencies ? {} : importer.optionalDependencies ?? {},
|
|
9
|
+
specifiers: importer.specifiers,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.filterImporter = filterImporter;
|
|
13
|
+
//# sourceMappingURL=filterImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterImporter.js","sourceRoot":"","sources":["../src/filterImporter.ts"],"names":[],"mappings":";;;AAGA,SAAgB,cAAc,CAC5B,QAAyB,EACzB,OAA8D;IAE9D,OAAO;QACL,YAAY,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE;QACtE,eAAe,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE;QAC/E,oBAAoB,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,IAAI,EAAE;QAC9F,UAAU,EAAE,QAAQ,CAAC,UAAU;KAChC,CAAA;AACH,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Lockfile } from '@pnpm/lockfile.types';
|
|
2
|
+
import { type DependenciesField, type DepPath } from '@pnpm/types';
|
|
3
|
+
export declare function filterLockfile(lockfile: Lockfile, opts: {
|
|
4
|
+
include: {
|
|
5
|
+
[dependenciesField in DependenciesField]: boolean;
|
|
6
|
+
};
|
|
7
|
+
skipped: Set<DepPath>;
|
|
8
|
+
}): Lockfile;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterLockfile = void 0;
|
|
4
|
+
const filterLockfileByImporters_1 = require("./filterLockfileByImporters");
|
|
5
|
+
function filterLockfile(lockfile, opts) {
|
|
6
|
+
return (0, filterLockfileByImporters_1.filterLockfileByImporters)(lockfile, Object.keys(lockfile.importers), {
|
|
7
|
+
...opts,
|
|
8
|
+
failOnMissingDependencies: false,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.filterLockfile = filterLockfile;
|
|
12
|
+
//# sourceMappingURL=filterLockfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterLockfile.js","sourceRoot":"","sources":["../src/filterLockfile.ts"],"names":[],"mappings":";;;AAEA,2EAAuE;AAEvE,SAAgB,cAAc,CAC5B,QAAkB,EAClB,IAGC;IAED,OAAO,IAAA,qDAAyB,EAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAgB,EAAE;QACzF,GAAG,IAAI;QACP,yBAAyB,EAAE,KAAK;KACjC,CAAC,CAAA;AACJ,CAAC;AAXD,wCAWC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Lockfile } from '@pnpm/lockfile.types';
|
|
2
|
+
import { type DependenciesField, type DepPath, type ProjectId } from '@pnpm/types';
|
|
3
|
+
export declare function filterLockfileByImporters(lockfile: Lockfile, importerIds: ProjectId[], opts: {
|
|
4
|
+
include: {
|
|
5
|
+
[dependenciesField in DependenciesField]: boolean;
|
|
6
|
+
};
|
|
7
|
+
skipped: Set<DepPath>;
|
|
8
|
+
failOnMissingDependencies: boolean;
|
|
9
|
+
}): Lockfile;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterLockfileByImporters = void 0;
|
|
4
|
+
const constants_1 = require("@pnpm/constants");
|
|
5
|
+
const error_1 = require("@pnpm/error");
|
|
6
|
+
const lockfile_walker_1 = require("@pnpm/lockfile.walker");
|
|
7
|
+
const logger_1 = require("@pnpm/logger");
|
|
8
|
+
const filterImporter_1 = require("./filterImporter");
|
|
9
|
+
const lockfileLogger = (0, logger_1.logger)('lockfile');
|
|
10
|
+
function filterLockfileByImporters(lockfile, importerIds, opts) {
|
|
11
|
+
const packages = {};
|
|
12
|
+
if (lockfile.packages != null) {
|
|
13
|
+
pkgAllDeps((0, lockfile_walker_1.lockfileWalker)(lockfile, importerIds, { include: opts.include, skipped: opts.skipped }).step, packages, {
|
|
14
|
+
failOnMissingDependencies: opts.failOnMissingDependencies,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const importers = importerIds.reduce((acc, importerId) => {
|
|
18
|
+
acc[importerId] = (0, filterImporter_1.filterImporter)(lockfile.importers[importerId], opts.include);
|
|
19
|
+
return acc;
|
|
20
|
+
}, { ...lockfile.importers });
|
|
21
|
+
return {
|
|
22
|
+
...lockfile,
|
|
23
|
+
importers,
|
|
24
|
+
packages,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.filterLockfileByImporters = filterLockfileByImporters;
|
|
28
|
+
function pkgAllDeps(step, pickedPackages, opts) {
|
|
29
|
+
for (const { pkgSnapshot, depPath, next } of step.dependencies) {
|
|
30
|
+
pickedPackages[depPath] = pkgSnapshot;
|
|
31
|
+
pkgAllDeps(next(), pickedPackages, opts);
|
|
32
|
+
}
|
|
33
|
+
for (const depPath of step.missing) {
|
|
34
|
+
if (opts.failOnMissingDependencies) {
|
|
35
|
+
throw new error_1.LockfileMissingDependencyError(depPath);
|
|
36
|
+
}
|
|
37
|
+
lockfileLogger.debug(`No entry for "${depPath}" in ${constants_1.WANTED_LOCKFILE}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=filterLockfileByImporters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterLockfileByImporters.js","sourceRoot":"","sources":["../src/filterLockfileByImporters.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AACjD,uCAA4D;AAK5D,2DAA+E;AAC/E,yCAAqC;AAErC,qDAAiD;AAEjD,MAAM,cAAc,GAAG,IAAA,eAAM,EAAC,UAAU,CAAC,CAAA;AAEzC,SAAgB,yBAAyB,CACvC,QAAkB,EAClB,WAAwB,EACxB,IAIC;IAED,MAAM,QAAQ,GAAG,EAAsB,CAAA;IACvC,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC9B,UAAU,CACR,IAAA,gCAAc,EACZ,QAAQ,EACR,WAAW,EACX,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CACjD,CAAC,IAAI,EACN,QAAQ,EACR;YACE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;SAC1D,CACF,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;QACvD,GAAG,CAAC,UAAU,CAAC,GAAG,IAAA,+BAAc,EAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9E,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAA;IAE7B,OAAO;QACL,GAAG,QAAQ;QACX,SAAS;QACT,QAAQ;KACT,CAAA;AACH,CAAC;AAlCD,8DAkCC;AAED,SAAS,UAAU,CACjB,IAAwB,EACxB,cAAgC,EAChC,IAEC;IAED,KAAK,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/D,cAAc,CAAC,OAAO,CAAC,GAAG,WAAW,CAAA;QACrC,UAAU,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACnC,MAAM,IAAI,sCAA8B,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QACD,cAAc,CAAC,KAAK,CAAC,iBAAiB,OAAO,QAAQ,2BAAe,EAAE,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Lockfile } from '@pnpm/lockfile.types';
|
|
2
|
+
import { type SupportedArchitectures, type DependenciesField, type ProjectId } from '@pnpm/types';
|
|
3
|
+
export interface FilterLockfileResult {
|
|
4
|
+
lockfile: Lockfile;
|
|
5
|
+
selectedImporterIds: ProjectId[];
|
|
6
|
+
}
|
|
7
|
+
export declare function filterLockfileByEngine(lockfile: Lockfile, opts: FilterLockfileOptions): FilterLockfileResult;
|
|
8
|
+
export interface FilterLockfileOptions {
|
|
9
|
+
currentEngine: {
|
|
10
|
+
nodeVersion?: string;
|
|
11
|
+
pnpmVersion: string;
|
|
12
|
+
};
|
|
13
|
+
engineStrict: boolean;
|
|
14
|
+
include: {
|
|
15
|
+
[dependenciesField in DependenciesField]: boolean;
|
|
16
|
+
};
|
|
17
|
+
includeIncompatiblePackages?: boolean;
|
|
18
|
+
failOnMissingDependencies: boolean;
|
|
19
|
+
lockfileDir: string;
|
|
20
|
+
skipped: Set<string>;
|
|
21
|
+
supportedArchitectures?: SupportedArchitectures;
|
|
22
|
+
}
|
|
23
|
+
export declare function filterLockfileByImportersAndEngine(lockfile: Lockfile, importerIds: ProjectId[], opts: FilterLockfileOptions): FilterLockfileResult;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.filterLockfileByImportersAndEngine = exports.filterLockfileByEngine = void 0;
|
|
30
|
+
const constants_1 = require("@pnpm/constants");
|
|
31
|
+
const error_1 = require("@pnpm/error");
|
|
32
|
+
const lockfile_utils_1 = require("@pnpm/lockfile.utils");
|
|
33
|
+
const logger_1 = require("@pnpm/logger");
|
|
34
|
+
const package_is_installable_1 = require("@pnpm/package-is-installable");
|
|
35
|
+
const dp = __importStar(require("@pnpm/dependency-path"));
|
|
36
|
+
const map_1 = __importDefault(require("ramda/src/map"));
|
|
37
|
+
const pickBy_1 = __importDefault(require("ramda/src/pickBy"));
|
|
38
|
+
const unnest_1 = __importDefault(require("ramda/src/unnest"));
|
|
39
|
+
const filterImporter_1 = require("./filterImporter");
|
|
40
|
+
const lockfileLogger = (0, logger_1.logger)('lockfile');
|
|
41
|
+
function filterLockfileByEngine(lockfile, opts) {
|
|
42
|
+
const importerIds = Object.keys(lockfile.importers);
|
|
43
|
+
return filterLockfileByImportersAndEngine(lockfile, importerIds, opts);
|
|
44
|
+
}
|
|
45
|
+
exports.filterLockfileByEngine = filterLockfileByEngine;
|
|
46
|
+
function filterLockfileByImportersAndEngine(lockfile, importerIds, opts) {
|
|
47
|
+
const importerIdSet = new Set(importerIds);
|
|
48
|
+
const directDepPaths = toImporterDepPaths(lockfile, importerIds, {
|
|
49
|
+
include: opts.include,
|
|
50
|
+
importerIdSet,
|
|
51
|
+
});
|
|
52
|
+
const packages = lockfile.packages != null
|
|
53
|
+
? pickPkgsWithAllDeps(lockfile, directDepPaths, importerIdSet, {
|
|
54
|
+
currentEngine: opts.currentEngine,
|
|
55
|
+
engineStrict: opts.engineStrict,
|
|
56
|
+
failOnMissingDependencies: opts.failOnMissingDependencies,
|
|
57
|
+
include: opts.include,
|
|
58
|
+
includeIncompatiblePackages: opts.includeIncompatiblePackages === true,
|
|
59
|
+
lockfileDir: opts.lockfileDir,
|
|
60
|
+
skipped: opts.skipped,
|
|
61
|
+
supportedArchitectures: opts.supportedArchitectures,
|
|
62
|
+
})
|
|
63
|
+
: {};
|
|
64
|
+
const importers = (0, map_1.default)((importer) => {
|
|
65
|
+
const newImporter = (0, filterImporter_1.filterImporter)(importer, opts.include);
|
|
66
|
+
if (newImporter.optionalDependencies != null) {
|
|
67
|
+
newImporter.optionalDependencies = (0, pickBy_1.default)((ref, depName) => {
|
|
68
|
+
const depPath = dp.refToRelative(ref, depName);
|
|
69
|
+
return !depPath || packages[depPath] != null;
|
|
70
|
+
}, newImporter.optionalDependencies);
|
|
71
|
+
}
|
|
72
|
+
return newImporter;
|
|
73
|
+
}, lockfile.importers);
|
|
74
|
+
return {
|
|
75
|
+
lockfile: {
|
|
76
|
+
...lockfile,
|
|
77
|
+
importers,
|
|
78
|
+
packages,
|
|
79
|
+
},
|
|
80
|
+
selectedImporterIds: Array.from(importerIdSet),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.filterLockfileByImportersAndEngine = filterLockfileByImportersAndEngine;
|
|
84
|
+
function pickPkgsWithAllDeps(lockfile, depPaths, importerIdSet, opts) {
|
|
85
|
+
const pickedPackages = {};
|
|
86
|
+
pkgAllDeps({ lockfile, pickedPackages, importerIdSet }, depPaths, true, opts);
|
|
87
|
+
return pickedPackages;
|
|
88
|
+
}
|
|
89
|
+
function pkgAllDeps(ctx, depPaths, parentIsInstallable, opts) {
|
|
90
|
+
for (const depPath of depPaths) {
|
|
91
|
+
if (ctx.pickedPackages[depPath])
|
|
92
|
+
continue;
|
|
93
|
+
const pkgSnapshot = ctx.lockfile.packages[depPath];
|
|
94
|
+
if (!pkgSnapshot && !depPath.startsWith('link:')) {
|
|
95
|
+
if (opts.failOnMissingDependencies) {
|
|
96
|
+
throw new error_1.LockfileMissingDependencyError(depPath);
|
|
97
|
+
}
|
|
98
|
+
lockfileLogger.debug(`No entry for "${depPath}" in ${constants_1.WANTED_LOCKFILE}`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let installable;
|
|
102
|
+
if (!parentIsInstallable) {
|
|
103
|
+
installable = false;
|
|
104
|
+
if (!ctx.pickedPackages[depPath] && pkgSnapshot.optional === true) {
|
|
105
|
+
opts.skipped.add(depPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const pkg = {
|
|
110
|
+
...(0, lockfile_utils_1.nameVerFromPkgSnapshot)(depPath, pkgSnapshot),
|
|
111
|
+
cpu: pkgSnapshot.cpu,
|
|
112
|
+
engines: pkgSnapshot.engines,
|
|
113
|
+
os: pkgSnapshot.os,
|
|
114
|
+
libc: pkgSnapshot.libc,
|
|
115
|
+
};
|
|
116
|
+
// TODO: depPath is not the package ID. Should be fixed
|
|
117
|
+
installable =
|
|
118
|
+
opts.includeIncompatiblePackages ||
|
|
119
|
+
(0, package_is_installable_1.packageIsInstallable)(pkgSnapshot.id ?? depPath, pkg, {
|
|
120
|
+
engineStrict: opts.engineStrict,
|
|
121
|
+
lockfileDir: opts.lockfileDir,
|
|
122
|
+
nodeVersion: opts.currentEngine.nodeVersion,
|
|
123
|
+
optional: pkgSnapshot.optional === true,
|
|
124
|
+
supportedArchitectures: opts.supportedArchitectures,
|
|
125
|
+
}) !== false;
|
|
126
|
+
if (!installable) {
|
|
127
|
+
if (!ctx.pickedPackages[depPath] && pkgSnapshot.optional === true) {
|
|
128
|
+
opts.skipped.add(depPath);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
opts.skipped.delete(depPath);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
ctx.pickedPackages[depPath] = pkgSnapshot;
|
|
136
|
+
const { depPaths: nextRelDepPaths, importerIds: additionalImporterIds } = parseDepRefs(Object.entries({
|
|
137
|
+
...pkgSnapshot.dependencies,
|
|
138
|
+
...(opts.include.optionalDependencies
|
|
139
|
+
? pkgSnapshot.optionalDependencies
|
|
140
|
+
: {}),
|
|
141
|
+
}), ctx.lockfile);
|
|
142
|
+
additionalImporterIds.forEach((importerId) => ctx.importerIdSet.add(importerId));
|
|
143
|
+
nextRelDepPaths.push(...toImporterDepPaths(ctx.lockfile, additionalImporterIds, {
|
|
144
|
+
include: opts.include,
|
|
145
|
+
importerIdSet: ctx.importerIdSet,
|
|
146
|
+
}));
|
|
147
|
+
pkgAllDeps(ctx, nextRelDepPaths, installable, opts);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function toImporterDepPaths(lockfile, importerIds, opts) {
|
|
151
|
+
const importerDeps = importerIds
|
|
152
|
+
.map(importerId => lockfile.importers[importerId])
|
|
153
|
+
.map(importer => ({
|
|
154
|
+
...(opts.include.dependencies ? importer.dependencies : {}),
|
|
155
|
+
...(opts.include.devDependencies ? importer.devDependencies : {}),
|
|
156
|
+
...(opts.include.optionalDependencies
|
|
157
|
+
? importer.optionalDependencies
|
|
158
|
+
: {}),
|
|
159
|
+
}))
|
|
160
|
+
.map(Object.entries);
|
|
161
|
+
const { depPaths, importerIds: nextImporterIds } = parseDepRefs((0, unnest_1.default)(importerDeps), lockfile);
|
|
162
|
+
if (!nextImporterIds.length) {
|
|
163
|
+
return depPaths;
|
|
164
|
+
}
|
|
165
|
+
nextImporterIds.forEach((importerId) => {
|
|
166
|
+
opts.importerIdSet.add(importerId);
|
|
167
|
+
});
|
|
168
|
+
return [
|
|
169
|
+
...depPaths,
|
|
170
|
+
...toImporterDepPaths(lockfile, nextImporterIds, opts),
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
function parseDepRefs(refsByPkgNames, lockfile) {
|
|
174
|
+
return refsByPkgNames
|
|
175
|
+
.reduce((acc, [pkgName, ref]) => {
|
|
176
|
+
if (ref.startsWith('link:')) {
|
|
177
|
+
const importerId = ref.substring(5);
|
|
178
|
+
if (lockfile.importers[importerId]) {
|
|
179
|
+
acc.importerIds.push(importerId);
|
|
180
|
+
}
|
|
181
|
+
return acc;
|
|
182
|
+
}
|
|
183
|
+
const depPath = dp.refToRelative(ref, pkgName);
|
|
184
|
+
if (depPath == null)
|
|
185
|
+
return acc;
|
|
186
|
+
acc.depPaths.push(depPath);
|
|
187
|
+
return acc;
|
|
188
|
+
}, { depPaths: [], importerIds: [] });
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=filterLockfileByImportersAndEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterLockfileByImportersAndEngine.js","sourceRoot":"","sources":["../src/filterLockfileByImportersAndEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AACjD,uCAA4D;AAK5D,yDAA6D;AAC7D,yCAAqC;AACrC,yEAAmE;AAEnE,0DAA2C;AAC3C,wDAAqC;AACrC,8DAAqC;AACrC,8DAAqC;AACrC,qDAAiD;AAEjD,MAAM,cAAc,GAAG,IAAA,eAAM,EAAC,UAAU,CAAC,CAAA;AAOzC,SAAgB,sBAAsB,CACpC,QAAkB,EAClB,IAA2B;IAE3B,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAgB,CAAA;IAClE,OAAO,kCAAkC,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;AACxE,CAAC;AAND,wDAMC;AAgBD,SAAgB,kCAAkC,CAChD,QAAkB,EAClB,WAAwB,EACxB,IAA2B;IAE3B,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAA;IAE1C,MAAM,cAAc,GAAG,kBAAkB,CAAC,QAAQ,EAAE,WAAW,EAAE;QAC/D,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,aAAa;KACd,CAAC,CAAA;IAEF,MAAM,QAAQ,GACZ,QAAQ,CAAC,QAAQ,IAAI,IAAI;QACvB,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE;YAC7D,aAAa,EAAE,IAAI,CAA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L,GAAG,QAAQ;QACX,GAAG,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC;KACvD,CAAA;AACH,CAAC;AAOD,SAAS,YAAY,CAAE,cAAuC,EAAE,QAAkB;IAChF,OAAO,cAAc;SAClB,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE;QAC9B,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAc,CAAA;YAChD,IAAI,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAClC,CAAC;YACD,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC9C,IAAI,OAAO,IAAI,IAAI;YAAE,OAAO,GAAG,CAAA;QAC/B,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAmB,CAAC,CAAA;AAC1D,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterLockfileByEngine = exports.filterLockfileByImportersAndEngine = exports.filterLockfileByImporters = exports.filterLockfile = void 0;
|
|
4
|
+
var filterLockfile_1 = require("./filterLockfile");
|
|
5
|
+
Object.defineProperty(exports, "filterLockfile", { enumerable: true, get: function () { return filterLockfile_1.filterLockfile; } });
|
|
6
|
+
var filterLockfileByImporters_1 = require("./filterLockfileByImporters");
|
|
7
|
+
Object.defineProperty(exports, "filterLockfileByImporters", { enumerable: true, get: function () { return filterLockfileByImporters_1.filterLockfileByImporters; } });
|
|
8
|
+
var filterLockfileByImportersAndEngine_1 = require("./filterLockfileByImportersAndEngine");
|
|
9
|
+
Object.defineProperty(exports, "filterLockfileByImportersAndEngine", { enumerable: true, get: function () { return filterLockfileByImportersAndEngine_1.filterLockfileByImportersAndEngine; } });
|
|
10
|
+
Object.defineProperty(exports, "filterLockfileByEngine", { enumerable: true, get: function () { return filterLockfileByImportersAndEngine_1.filterLockfileByEngine; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,yEAAuE;AAA9D,sIAAA,yBAAyB,OAAA;AAClC,2FAAiH;AAAxG,wJAAA,kCAAkC,OAAA;AAAE,4IAAA,sBAAsB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/lockfile.filtering",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Filters a lockfile",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.12"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"!*.map"
|
|
13
|
+
],
|
|
14
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/lockfile/filtering",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pnpm9",
|
|
17
|
+
"pnpm",
|
|
18
|
+
"shrinkwrap",
|
|
19
|
+
"lockfile"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/lockfile/filtering#readme",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@pnpm/logger": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/ramda": "0.29.12",
|
|
31
|
+
"detect-libc": "^2.0.3",
|
|
32
|
+
"tempy": "^1.0.1",
|
|
33
|
+
"write-yaml-file": "^5.0.0",
|
|
34
|
+
"yaml-tag": "1.1.0",
|
|
35
|
+
"@pnpm/lockfile.filtering": "1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
39
|
+
"@pnpm/constants": "8.0.0",
|
|
40
|
+
"@pnpm/error": "6.0.1",
|
|
41
|
+
"@pnpm/dependency-path": "5.1.3",
|
|
42
|
+
"@pnpm/lockfile.types": "1.0.0",
|
|
43
|
+
"@pnpm/lockfile.utils": "1.0.0",
|
|
44
|
+
"@pnpm/lockfile.walker": "1.0.0",
|
|
45
|
+
"@pnpm/package-is-installable": "9.0.5",
|
|
46
|
+
"@pnpm/types": "11.1.0"
|
|
47
|
+
},
|
|
48
|
+
"funding": "https://opencollective.com/pnpm",
|
|
49
|
+
"exports": {
|
|
50
|
+
".": "./lib/index.js"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
54
|
+
"_test": "jest",
|
|
55
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
56
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
57
|
+
}
|
|
58
|
+
}
|