@pnpm/lockfile.preferred-versions 1100.0.34 → 1100.0.35
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/CHANGELOG.md +12 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +18 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pnpm/lockfile.preferred-versions
|
|
2
2
|
|
|
3
|
+
## 1100.0.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `pnpm dedupe` now moves transitive dependencies to the version a `catalog:` dependency pins, as it already did for versions written directly in `package.json`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- @pnpm/lockfile.utils@1102.1.4
|
|
11
|
+
- @pnpm/pkg-manifest.utils@1100.4.6
|
|
12
|
+
- @pnpm/resolving.resolver-base@1101.3.1
|
|
13
|
+
- @pnpm/types@1102.1.1
|
|
14
|
+
|
|
3
15
|
## 1100.0.34
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { Catalogs } from '@pnpm/catalogs.types';
|
|
1
2
|
import { type PackageSnapshots } from '@pnpm/lockfile.utils';
|
|
2
3
|
import { type PreferredVersions } from '@pnpm/resolving.resolver-base';
|
|
3
4
|
import type { DependencyManifest, ProjectManifest } from '@pnpm/types';
|
|
4
5
|
export declare function getPreferredVersionsFromLockfileAndManifests(snapshots: PackageSnapshots | undefined, manifests: Array<DependencyManifest | ProjectManifest>, opts?: {
|
|
6
|
+
catalogs?: Catalogs;
|
|
5
7
|
dedupe?: boolean;
|
|
6
8
|
}): PreferredVersions;
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveFromCatalog } from '@pnpm/catalogs.resolver';
|
|
1
2
|
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils';
|
|
2
3
|
import { getAllDependenciesFromManifest } from '@pnpm/pkg-manifest.utils';
|
|
3
4
|
import { DIRECT_DEP_SELECTOR_WEIGHT, EXISTING_VERSION_SELECTOR_WEIGHT, } from '@pnpm/resolving.resolver-base';
|
|
@@ -10,7 +11,10 @@ export function getPreferredVersionsFromLockfileAndManifests(snapshots, manifest
|
|
|
10
11
|
const preferredVersions = Object.create(null);
|
|
11
12
|
for (const manifest of manifests) {
|
|
12
13
|
const specs = getAllDependenciesFromManifest(manifest);
|
|
13
|
-
for (const [name,
|
|
14
|
+
for (const [name, bareSpecifier] of Object.entries(specs)) {
|
|
15
|
+
const spec = resolveCatalogSpec(opts.catalogs ?? {}, name, bareSpecifier);
|
|
16
|
+
if (spec == null)
|
|
17
|
+
continue;
|
|
14
18
|
const selector = getVersionSelectorType(spec);
|
|
15
19
|
if (!selector)
|
|
16
20
|
continue;
|
|
@@ -27,6 +31,19 @@ export function getPreferredVersionsFromLockfileAndManifests(snapshots, manifest
|
|
|
27
31
|
addPreferredVersionsFromLockfile(snapshots, preferredVersions, opts.dedupe ? 1 : EXISTING_VERSION_SELECTOR_WEIGHT);
|
|
28
32
|
return preferredVersions;
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The specifier the resolver installs for a direct dependency: the catalog
|
|
36
|
+
* entry a `catalog:` specifier names, otherwise the specifier itself.
|
|
37
|
+
* `undefined` for a `catalog:` specifier without a usable entry.
|
|
38
|
+
*/
|
|
39
|
+
function resolveCatalogSpec(catalogs, alias, bareSpecifier) {
|
|
40
|
+
const result = resolveFromCatalog(catalogs, { alias, bareSpecifier });
|
|
41
|
+
switch (result.type) {
|
|
42
|
+
case 'found': return result.resolution.specifier;
|
|
43
|
+
case 'misconfiguration': return undefined;
|
|
44
|
+
case 'unused': return bareSpecifier;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
30
47
|
function addPreferredVersionsFromLockfile(snapshots, preferredVersions, weight) {
|
|
31
48
|
// The snapshots object can contain multiple entries with the same package
|
|
32
49
|
// name and version. This is because a dependency can appear multiple times
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.preferred-versions",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.35",
|
|
4
4
|
"description": "Get preferred version from lockfile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,15 +29,17 @@
|
|
|
29
29
|
"!*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pnpm/
|
|
33
|
-
"@pnpm/
|
|
34
|
-
"@pnpm/
|
|
35
|
-
"@pnpm/
|
|
32
|
+
"@pnpm/catalogs.resolver": "1100.1.0",
|
|
33
|
+
"@pnpm/catalogs.types": "1100.0.1",
|
|
34
|
+
"@pnpm/lockfile.utils": "1102.1.4",
|
|
35
|
+
"@pnpm/pkg-manifest.utils": "1100.4.6",
|
|
36
|
+
"@pnpm/resolving.resolver-base": "1101.3.1",
|
|
37
|
+
"@pnpm/types": "1102.1.1",
|
|
36
38
|
"version-selector-type": "^3.0.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@jest/globals": "30.4.1",
|
|
40
|
-
"@pnpm/lockfile.preferred-versions": "1100.0.
|
|
42
|
+
"@pnpm/lockfile.preferred-versions": "1100.0.35",
|
|
41
43
|
"cross-env": "^10.1.0"
|
|
42
44
|
},
|
|
43
45
|
"engines": {
|