@pnpm/lockfile.filtering 1100.0.7 → 1100.1.1
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/lib/filterImporter.d.ts +2 -0
- package/lib/filterImporter.js +19 -5
- package/lib/filterLockfile.d.ts +1 -0
- package/lib/filterLockfileByImporters.d.ts +1 -0
- package/lib/filterLockfileByImporters.js +5 -5
- package/lib/filterLockfileByImportersAndEngine.d.ts +1 -0
- package/lib/filterLockfileByImportersAndEngine.js +6 -2
- package/package.json +10 -10
package/lib/filterImporter.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ import type { ProjectSnapshot } from '@pnpm/lockfile.types';
|
|
|
2
2
|
import type { DependenciesField } from '@pnpm/types';
|
|
3
3
|
export declare function filterImporter(importer: ProjectSnapshot, include: {
|
|
4
4
|
[dependenciesField in DependenciesField]: boolean;
|
|
5
|
+
}, opts?: {
|
|
6
|
+
skipRuntimes?: boolean;
|
|
5
7
|
}): ProjectSnapshot;
|
package/lib/filterImporter.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
export function filterImporter(importer, include) {
|
|
1
|
+
export function filterImporter(importer, include, opts) {
|
|
2
|
+
const skipRuntimes = opts?.skipRuntimes === true;
|
|
2
3
|
return {
|
|
3
|
-
dependencies: !include.dependencies ? {} : importer.dependencies
|
|
4
|
-
devDependencies: !include.devDependencies ? {} : importer.devDependencies
|
|
5
|
-
optionalDependencies: !include.optionalDependencies ? {} : importer.optionalDependencies
|
|
6
|
-
specifiers: importer.specifiers,
|
|
4
|
+
dependencies: !include.dependencies ? {} : pickNonRuntime(importer.dependencies, skipRuntimes),
|
|
5
|
+
devDependencies: !include.devDependencies ? {} : pickNonRuntime(importer.devDependencies, skipRuntimes),
|
|
6
|
+
optionalDependencies: !include.optionalDependencies ? {} : pickNonRuntime(importer.optionalDependencies, skipRuntimes),
|
|
7
|
+
specifiers: pickNonRuntime(importer.specifiers, skipRuntimes),
|
|
7
8
|
};
|
|
8
9
|
}
|
|
10
|
+
function pickNonRuntime(deps, skipRuntimes) {
|
|
11
|
+
if (!deps)
|
|
12
|
+
return {};
|
|
13
|
+
if (!skipRuntimes)
|
|
14
|
+
return deps;
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const [name, ref] of Object.entries(deps)) {
|
|
17
|
+
if (!ref.startsWith('runtime:')) {
|
|
18
|
+
result[name] = ref;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
9
23
|
//# sourceMappingURL=filterImporter.js.map
|
package/lib/filterLockfile.d.ts
CHANGED
|
@@ -5,16 +5,16 @@ import { logger } from '@pnpm/logger';
|
|
|
5
5
|
import { filterImporter } from './filterImporter.js';
|
|
6
6
|
const lockfileLogger = logger('lockfile');
|
|
7
7
|
export function filterLockfileByImporters(lockfile, importerIds, opts) {
|
|
8
|
+
const importers = { ...lockfile.importers };
|
|
9
|
+
for (const importerId of importerIds) {
|
|
10
|
+
importers[importerId] = filterImporter(lockfile.importers[importerId], opts.include, { skipRuntimes: opts.skipRuntimes });
|
|
11
|
+
}
|
|
8
12
|
const packages = {};
|
|
9
13
|
if (lockfile.packages != null) {
|
|
10
|
-
pkgAllDeps(lockfileWalker(lockfile, importerIds, { include: opts.include, skipped: opts.skipped }).step, packages, {
|
|
14
|
+
pkgAllDeps(lockfileWalker({ ...lockfile, importers }, importerIds, { include: opts.include, skipped: opts.skipped }).step, packages, {
|
|
11
15
|
failOnMissingDependencies: opts.failOnMissingDependencies,
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
|
-
const importers = { ...lockfile.importers };
|
|
15
|
-
for (const importerId of importerIds) {
|
|
16
|
-
importers[importerId] = filterImporter(lockfile.importers[importerId], opts.include);
|
|
17
|
-
}
|
|
18
18
|
return {
|
|
19
19
|
...lockfile,
|
|
20
20
|
importers,
|
|
@@ -18,6 +18,7 @@ export interface FilterLockfileOptions {
|
|
|
18
18
|
failOnMissingDependencies: boolean;
|
|
19
19
|
lockfileDir: string;
|
|
20
20
|
skipped: Set<string>;
|
|
21
|
+
skipRuntimes?: boolean;
|
|
21
22
|
supportedArchitectures?: SupportedArchitectures;
|
|
22
23
|
}
|
|
23
24
|
export declare function filterLockfileByImportersAndEngine(lockfile: LockfileObject, importerIds: ProjectId[], opts: FilterLockfileOptions): FilterLockfileResult;
|
|
@@ -16,6 +16,7 @@ export function filterLockfileByImportersAndEngine(lockfile, importerIds, opts)
|
|
|
16
16
|
const directDepPaths = toImporterDepPaths(lockfile, importerIds, {
|
|
17
17
|
include: opts.include,
|
|
18
18
|
importerIdSet,
|
|
19
|
+
skipRuntimes: opts.skipRuntimes,
|
|
19
20
|
});
|
|
20
21
|
const packages = lockfile.packages != null
|
|
21
22
|
? pickPkgsWithAllDeps(lockfile, directDepPaths, importerIdSet, {
|
|
@@ -26,11 +27,12 @@ export function filterLockfileByImportersAndEngine(lockfile, importerIds, opts)
|
|
|
26
27
|
includeIncompatiblePackages: opts.includeIncompatiblePackages === true,
|
|
27
28
|
lockfileDir: opts.lockfileDir,
|
|
28
29
|
skipped: opts.skipped,
|
|
30
|
+
skipRuntimes: opts.skipRuntimes,
|
|
29
31
|
supportedArchitectures: opts.supportedArchitectures,
|
|
30
32
|
})
|
|
31
33
|
: {};
|
|
32
34
|
const importers = mapValues((importer) => {
|
|
33
|
-
const newImporter = filterImporter(importer, opts.include);
|
|
35
|
+
const newImporter = filterImporter(importer, opts.include, { skipRuntimes: opts.skipRuntimes });
|
|
34
36
|
if (newImporter.optionalDependencies != null) {
|
|
35
37
|
newImporter.optionalDependencies = pickBy((ref, depName) => {
|
|
36
38
|
const depPath = dp.refToRelative(ref, depName);
|
|
@@ -110,6 +112,7 @@ function pkgAllDeps(ctx, depPaths, parentIsInstallable, opts) {
|
|
|
110
112
|
nextRelDepPaths.push(...toImporterDepPaths(ctx.lockfile, additionalImporterIds, {
|
|
111
113
|
include: opts.include,
|
|
112
114
|
importerIdSet: ctx.importerIdSet,
|
|
115
|
+
skipRuntimes: opts.skipRuntimes,
|
|
113
116
|
}));
|
|
114
117
|
pkgAllDeps(ctx, nextRelDepPaths, installable, opts);
|
|
115
118
|
}
|
|
@@ -124,7 +127,8 @@ function toImporterDepPaths(lockfile, importerIds, opts) {
|
|
|
124
127
|
? importer.optionalDependencies
|
|
125
128
|
: {}),
|
|
126
129
|
}))
|
|
127
|
-
.map(Object.entries)
|
|
130
|
+
.map(Object.entries)
|
|
131
|
+
.map(entries => opts.skipRuntimes ? entries.filter(([, ref]) => !ref.startsWith('runtime:')) : entries);
|
|
128
132
|
let { depPaths, importerIds: nextImporterIds } = parseDepRefs(unnest(importerDeps), lockfile);
|
|
129
133
|
if (!nextImporterIds.length) {
|
|
130
134
|
return depPaths;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.filtering",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.1.1",
|
|
4
4
|
"description": "Filters a lockfile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -27,26 +27,26 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
30
|
+
"@pnpm/config.package-is-installable": "1100.0.5",
|
|
30
31
|
"@pnpm/constants": "1100.0.0",
|
|
31
|
-
"@pnpm/config.package-is-installable": "1100.0.3",
|
|
32
|
-
"@pnpm/lockfile.utils": "1100.0.6",
|
|
33
|
-
"@pnpm/deps.path": "1100.0.2",
|
|
34
|
-
"@pnpm/lockfile.walker": "1100.0.4",
|
|
35
|
-
"@pnpm/lockfile.types": "1100.0.4",
|
|
36
32
|
"@pnpm/error": "1100.0.0",
|
|
37
|
-
"@pnpm/types": "
|
|
33
|
+
"@pnpm/lockfile.types": "1100.0.6",
|
|
34
|
+
"@pnpm/types": "1101.1.0",
|
|
35
|
+
"@pnpm/lockfile.walker": "1100.0.6",
|
|
36
|
+
"@pnpm/lockfile.utils": "1100.0.8",
|
|
37
|
+
"@pnpm/deps.path": "1100.0.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@pnpm/logger": "
|
|
40
|
+
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "30.3.0",
|
|
44
44
|
"@types/ramda": "0.31.1",
|
|
45
|
-
"detect-libc": "^2.
|
|
45
|
+
"detect-libc": "^2.0.3",
|
|
46
46
|
"tempy": "3.0.0",
|
|
47
47
|
"write-yaml-file": "^6.0.0",
|
|
48
48
|
"yaml-tag": "1.1.0",
|
|
49
|
-
"@pnpm/lockfile.filtering": "1100.
|
|
49
|
+
"@pnpm/lockfile.filtering": "1100.1.1",
|
|
50
50
|
"@pnpm/logger": "1100.0.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|