rolldown-pnpm-config 2.4.5 → 2.4.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/cli/version.js +1 -1
- package/index.d.ts +11 -0
- package/package.json +1 -1
- package/plugin/freeze.js +2 -1
- package/plugin/overrides-from-catalogs.js +46 -7
package/cli/version.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -83,6 +83,17 @@ interface AllowedVersionsFromCatalogs {
|
|
|
83
83
|
* authored by hand wins over a derived one on the same selector, and the
|
|
84
84
|
* consumer's own `overrides` still win over the plugin's at install time.
|
|
85
85
|
*
|
|
86
|
+
* Every pinned member's catalog value is frozen to the version its override
|
|
87
|
+
* names, so the catalog and the override always agree. pnpm never matches an
|
|
88
|
+
* override against a `catalog:` specifier, so a catalog left at `~X.Y.Z`
|
|
89
|
+
* would let a dependent writing `catalog:` resolve a newer patch than the
|
|
90
|
+
* override pins everywhere else, and the graph would carry two copies. Only
|
|
91
|
+
* the frozen output changes (the pnpmfile's `base`, `export`, `preview`): the
|
|
92
|
+
* authored range stays what `upgrade` reads and rewrites, and the `:peers`
|
|
93
|
+
* catalog keeps its peer range. When a hand-authored override wins on the
|
|
94
|
+
* selector, the catalog takes its value if that is an exact version and keeps
|
|
95
|
+
* the authored range otherwise.
|
|
96
|
+
*
|
|
86
97
|
* `include` and `exclude` select which members are pinned, so one catalog can
|
|
87
98
|
* hold both a release family that is pinned graph-wide and packages that are
|
|
88
99
|
* not. Each entry is an exact package name or a glob pattern (`@effect/*`),
|
package/package.json
CHANGED
package/plugin/freeze.js
CHANGED
|
@@ -2,7 +2,7 @@ import { normalizeCatalogs } from "../catalogs.js";
|
|
|
2
2
|
import { DESCRIPTORS, deriveSchemas } from "../descriptors/index.js";
|
|
3
3
|
import { FIELD_REGISTRY } from "../registry.js";
|
|
4
4
|
import { resolvePeerDependencyRules } from "./allowed-versions.js";
|
|
5
|
-
import { resolveOverrides } from "./overrides-from-catalogs.js";
|
|
5
|
+
import { pinCatalogs, resolveOverrides } from "./overrides-from-catalogs.js";
|
|
6
6
|
import { Data, Effect, Predicate, Schema } from "effect";
|
|
7
7
|
import { Fmt } from "@effected/cli-kit";
|
|
8
8
|
|
|
@@ -86,6 +86,7 @@ function freeze(config) {
|
|
|
86
86
|
...decl.options ? { options: decl.options } : {}
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
base.catalogs = pinCatalogs(base.catalogs, base.overrides, config.overridesFromCatalogs, config.catalogs);
|
|
89
90
|
return {
|
|
90
91
|
base,
|
|
91
92
|
manifest,
|
|
@@ -33,7 +33,7 @@ function compileFilter(entries, members, label, catalog) {
|
|
|
33
33
|
});
|
|
34
34
|
return (name) => globs.some((glob) => Glob.match(glob, name));
|
|
35
35
|
}
|
|
36
|
-
/** Derive the
|
|
36
|
+
/** Derive the pins for one directive. Pure; throws when the catalog is absent or a filter entry matches nothing. */
|
|
37
37
|
function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" }) {
|
|
38
38
|
const decl = catalogs[catalog];
|
|
39
39
|
if (decl === void 0) throw new Error(`overridesFromCatalogs: catalog "${catalog}" is not declared`);
|
|
@@ -41,7 +41,7 @@ function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" })
|
|
|
41
41
|
const members = Object.keys(decl.packages);
|
|
42
42
|
const isIncluded = include === void 0 ? () => true : compileFilter(include, members, "included", catalog);
|
|
43
43
|
const isExcluded = compileFilter(exclude, members, "excluded", catalog);
|
|
44
|
-
const
|
|
44
|
+
const pins = [];
|
|
45
45
|
for (const [name, spec] of Object.entries(decl.packages)) {
|
|
46
46
|
if (!isIncluded(name) || isExcluded(name)) continue;
|
|
47
47
|
const parsed = Result.getOrNull(VersionSpecifier.parseResult(rangeOf(spec)));
|
|
@@ -49,9 +49,18 @@ function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" })
|
|
|
49
49
|
const { version } = parsed;
|
|
50
50
|
if (version.prerelease.length > 0 || version.build.length > 0) continue;
|
|
51
51
|
const selector = scope === "any" ? name : `${name}@${releaseLine(version.major, version.minor)}`;
|
|
52
|
-
|
|
52
|
+
pins.push({
|
|
53
|
+
catalog,
|
|
54
|
+
name,
|
|
55
|
+
selector,
|
|
56
|
+
version: version.toString()
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
|
-
return
|
|
59
|
+
return pins;
|
|
60
|
+
}
|
|
61
|
+
/** Every directive's pins, in directive order. */
|
|
62
|
+
function derivePins(catalogs, directives) {
|
|
63
|
+
return (Array.isArray(directives) ? directives : [directives]).flatMap((d) => deriveOne(catalogs, d));
|
|
55
64
|
}
|
|
56
65
|
/**
|
|
57
66
|
* Merge the derived overrides for one or more directives (later directives win
|
|
@@ -60,9 +69,39 @@ function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" })
|
|
|
60
69
|
* @internal
|
|
61
70
|
*/
|
|
62
71
|
function deriveOverrides(catalogs, directives) {
|
|
63
|
-
const list = Array.isArray(directives) ? directives : [directives];
|
|
64
72
|
const out = {};
|
|
65
|
-
for (const
|
|
73
|
+
for (const pin of derivePins(catalogs, directives)) out[pin.selector] = pin.version;
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** The exact version an override value names, or `null` for a range, alias or removal. */
|
|
77
|
+
function exactVersion(value) {
|
|
78
|
+
if (typeof value !== "string") return null;
|
|
79
|
+
const parsed = Result.getOrNull(VersionSpecifier.parseResult(value));
|
|
80
|
+
if (parsed === null || parsed.operator !== "" && parsed.operator !== "=") return null;
|
|
81
|
+
return parsed.version.toString();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Freeze each pinned member's catalog value to the exact version its final
|
|
85
|
+
* override names, so a `catalog:` specifier (which pnpm never matches against
|
|
86
|
+
* an override) resolves the same version the override pins. Returns a new
|
|
87
|
+
* catalogs map; `:peers` catalogs and unpinned members pass through verbatim,
|
|
88
|
+
* and a member whose winning override is not an exact version keeps its range.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
function pinCatalogs(resolved, overrides, directives, catalogs) {
|
|
93
|
+
if (directives === void 0 || !Predicate.isObject(overrides)) return resolved;
|
|
94
|
+
const table = overrides;
|
|
95
|
+
const out = { ...resolved };
|
|
96
|
+
for (const { catalog, name, selector } of derivePins(catalogs, directives)) {
|
|
97
|
+
const pinned = exactVersion(table[selector]);
|
|
98
|
+
const current = out[catalog];
|
|
99
|
+
if (pinned === null || current === void 0 || !(name in current)) continue;
|
|
100
|
+
out[catalog] = {
|
|
101
|
+
...current,
|
|
102
|
+
[name]: pinned
|
|
103
|
+
};
|
|
104
|
+
}
|
|
66
105
|
return out;
|
|
67
106
|
}
|
|
68
107
|
/**
|
|
@@ -83,4 +122,4 @@ function resolveOverrides(authored, directives, catalogs) {
|
|
|
83
122
|
};
|
|
84
123
|
}
|
|
85
124
|
|
|
86
|
-
export { deriveOverrides, resolveOverrides };
|
|
125
|
+
export { deriveOverrides, pinCatalogs, resolveOverrides };
|