@pnpm/lockfile.filtering 1100.0.7 → 1100.1.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.
@@ -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;
@@ -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
@@ -5,4 +5,5 @@ export declare function filterLockfile(lockfile: LockfileObject, opts: {
5
5
  [dependenciesField in DependenciesField]: boolean;
6
6
  };
7
7
  skipped: Set<DepPath>;
8
+ skipRuntimes?: boolean;
8
9
  }): LockfileObject;
@@ -5,5 +5,6 @@ export declare function filterLockfileByImporters(lockfile: LockfileObject, impo
5
5
  [dependenciesField in DependenciesField]: boolean;
6
6
  };
7
7
  skipped: Set<DepPath>;
8
+ skipRuntimes?: boolean;
8
9
  failOnMissingDependencies: boolean;
9
10
  }): LockfileObject;
@@ -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.0.7",
3
+ "version": "1100.1.0",
4
4
  "description": "Filters a lockfile",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,25 +28,25 @@
28
28
  "dependencies": {
29
29
  "ramda": "npm:@pnpm/ramda@0.28.1",
30
30
  "@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",
31
+ "@pnpm/deps.path": "1100.0.3",
32
+ "@pnpm/config.package-is-installable": "1100.0.4",
33
+ "@pnpm/lockfile.utils": "1100.0.7",
34
+ "@pnpm/lockfile.walker": "1100.0.5",
36
35
  "@pnpm/error": "1100.0.0",
37
- "@pnpm/types": "1101.0.0"
36
+ "@pnpm/types": "1101.1.0",
37
+ "@pnpm/lockfile.types": "1100.0.5"
38
38
  },
39
39
  "peerDependencies": {
40
- "@pnpm/logger": "^1001.0.1"
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.1.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.0.7",
49
+ "@pnpm/lockfile.filtering": "1100.1.0",
50
50
  "@pnpm/logger": "1100.0.0"
51
51
  },
52
52
  "engines": {