rolldown-pnpm-config 3.2.1 → 4.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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/catalogs.js +32 -15
  3. package/cli/commands/export.js +8 -3
  4. package/cli/commands/preview.js +10 -7
  5. package/cli/commands/sync.js +140 -70
  6. package/cli/commands/upgrade.js +333 -135
  7. package/cli/discover.js +134 -28
  8. package/cli/drift.js +1 -1
  9. package/cli/edits.js +8 -17
  10. package/cli/effective.js +119 -4
  11. package/cli/interop.js +7 -15
  12. package/cli/local-merge.js +4 -1
  13. package/cli/plan.js +8 -3
  14. package/cli/preview-views.js +3 -1
  15. package/cli/release-age.js +2 -1
  16. package/cli/respell.js +86 -0
  17. package/cli/select-file.js +5 -2
  18. package/cli/summary.js +42 -6
  19. package/cli/sync/commit-message.js +4 -3
  20. package/cli/sync/config.js +60 -24
  21. package/cli/sync/local-gate.js +19 -9
  22. package/cli/sync/membership.js +93 -31
  23. package/cli/sync/ripples.js +4 -4
  24. package/cli/sync/running-list.js +9 -5
  25. package/cli/ui/walk-screen.js +66 -20
  26. package/cli/validate.js +1 -1
  27. package/cli/version.js +1 -1
  28. package/cli/walk-plan.js +17 -10
  29. package/cli/walk-reducer.js +99 -19
  30. package/index.d.ts +176 -127
  31. package/package.json +6 -6
  32. package/plugin/allowed-versions.js +3 -3
  33. package/plugin/families.js +185 -0
  34. package/plugin/freeze.js +122 -32
  35. package/plugin/second-forms.js +155 -0
  36. package/plugin/synced-catalogs.js +32 -0
  37. package/registry.js +13 -1
  38. package/skills/rolldown-pnpm-config/SKILL.md +13 -3
  39. package/skills/rolldown-pnpm-config/references/catalogs.md +109 -12
  40. package/skills/rolldown-pnpm-config/references/options.md +126 -47
  41. package/skills/rolldown-pnpm-config/references/sync.md +32 -21
  42. package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
  43. package/plugin/overrides-from-catalogs.js +0 -151
@@ -1,151 +0,0 @@
1
- import { OverrideKey } from "@effected/pnpm";
2
- import { VersionSpecifier } from "@effected/semver";
3
- import { Glob, Option, Predicate, Result } from "effect";
4
- import { rangeOf } from "../catalogs.js";
5
-
6
- // src/plugin/overrides-from-catalogs.ts
7
- /** The simple operators that can pin: an optional `^`, `~`, `>=` or `=` on one version. */
8
- const PINNABLE_OPERATORS = /* @__PURE__ */ new Set([
9
- "^",
10
- "~",
11
- ">=",
12
- "=",
13
- ""
14
- ]);
15
- /**
16
- * The release line a plain version belongs to: `^X.0.0`, or `^0.Y.0` when the
17
- * major is 0. A `0.0.Z` version has no caret line (`^0.0.0` admits only
18
- * `0.0.0` itself), so it takes the tilde line `~0.0.0`, which covers every
19
- * `0.0.Z` request.
20
- */
21
- function releaseLine(major, minor) {
22
- if (major !== 0) return `^${major}.0.0`;
23
- return minor === 0 ? "~0.0.0" : `^0.${minor}.0`;
24
- }
25
- /**
26
- * Compile a filter list into a member predicate, throwing when an entry
27
- * matches no member (an exact name or a pattern alike).
28
- */
29
- function compileFilter(entries, members, label, catalog) {
30
- const globs = entries.map((entry) => {
31
- const glob = Glob.make(entry);
32
- if (!members.some((name) => Glob.match(glob, name))) throw new Error(`overridesFromCatalogs: ${label} member "${entry}" is not in catalog "${catalog}"`);
33
- return glob;
34
- });
35
- return (name) => globs.some((glob) => Glob.match(glob, name));
36
- }
37
- /** The override selector for `name`, qualified by `range` when given, in pnpm's grammar. */
38
- function selectorOf(name, range) {
39
- return OverrideKey.make({ path: [{
40
- name,
41
- range: range === void 0 ? Option.none() : Option.some(range)
42
- }] }).format();
43
- }
44
- /**
45
- * The canonical spelling of an `overrides` key, so `" effect@^4.0.0"` and
46
- * `"effect@^4.0.0"` are recognised as one selector; a key pnpm cannot parse is
47
- * kept as written (the settings schema refuses it later).
48
- */
49
- function canonicalSelector(key) {
50
- const parsed = OverrideKey.parseResult(key);
51
- return Result.isSuccess(parsed) ? parsed.success.format() : key;
52
- }
53
- /** Derive the pins for one directive. Pure; throws when the catalog is absent or a filter entry matches nothing. */
54
- function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" }) {
55
- const decl = catalogs[catalog];
56
- if (decl === void 0) throw new Error(`overridesFromCatalogs: catalog "${catalog}" is not declared`);
57
- if (include?.length === 0) throw new Error(`overridesFromCatalogs: include for catalog "${catalog}" is empty, which would pin nothing`);
58
- const members = Object.keys(decl.packages);
59
- const isIncluded = include === void 0 ? () => true : compileFilter(include, members, "included", catalog);
60
- const isExcluded = compileFilter(exclude, members, "excluded", catalog);
61
- const pins = [];
62
- for (const [name, spec] of Object.entries(decl.packages)) {
63
- if (!isIncluded(name) || isExcluded(name)) continue;
64
- const parsed = Result.getOrNull(VersionSpecifier.parseResult(rangeOf(spec)));
65
- if (parsed === null || !PINNABLE_OPERATORS.has(parsed.operator)) continue;
66
- const { version } = parsed;
67
- if (version.prerelease.length > 0 || version.build.length > 0) continue;
68
- const selector = scope === "any" ? selectorOf(name) : selectorOf(name, releaseLine(version.major, version.minor));
69
- pins.push({
70
- catalog,
71
- name,
72
- selector,
73
- version: version.toString()
74
- });
75
- }
76
- return pins;
77
- }
78
- /** Every directive's pins, in directive order. */
79
- function derivePins(catalogs, directives) {
80
- return (Array.isArray(directives) ? directives : [directives]).flatMap((d) => deriveOne(catalogs, d));
81
- }
82
- /**
83
- * Merge the derived overrides for one or more directives (later directives win
84
- * on a selector clash).
85
- *
86
- * @internal
87
- */
88
- function deriveOverrides(catalogs, directives) {
89
- const out = {};
90
- for (const pin of derivePins(catalogs, directives)) out[pin.selector] = pin.version;
91
- return out;
92
- }
93
- /** The exact version an override value names, or `null` for a range, alias or removal. */
94
- function exactVersion(value) {
95
- if (typeof value !== "string") return null;
96
- const parsed = Result.getOrNull(VersionSpecifier.parseResult(value));
97
- if (parsed === null || parsed.operator !== "" && parsed.operator !== "=") return null;
98
- return parsed.version.toString();
99
- }
100
- /**
101
- * Freeze each pinned member's catalog value to the exact version its final
102
- * override names, so a `catalog:` specifier (which pnpm never matches against
103
- * an override) resolves the same version the override pins. Returns a new
104
- * catalogs map, and the `:exact` variant names the same version (a winner that
105
- * is not an exact version throws for a member that variant holds); `:peers`
106
- * catalogs and unpinned members pass through verbatim,
107
- * and a member whose winning override is not an exact version keeps its range.
108
- *
109
- * @internal
110
- */
111
- function pinCatalogs(resolved, overrides, directives, catalogs) {
112
- if (directives === void 0 || !Predicate.isObject(overrides)) return resolved;
113
- const table = new Map(Object.entries(overrides).map(([key, value]) => [canonicalSelector(key), value]));
114
- const out = { ...resolved };
115
- for (const { catalog, name, selector } of derivePins(catalogs, directives)) {
116
- const pinned = exactVersion(table.get(selector));
117
- const current = out[catalog];
118
- const exact = out[`${catalog}:exact`];
119
- if (pinned === null && exact !== void 0 && name in exact) throw new Error(`overridesFromCatalogs: override "${selector}" wins with ${JSON.stringify(table.get(selector))}, which is not an exact version, so catalog "${catalog}:exact" cannot name the version it pins; override with an exact version, or set exact: false on "${name}"`);
120
- if (pinned === null || current === void 0 || !(name in current)) continue;
121
- out[catalog] = {
122
- ...current,
123
- [name]: pinned
124
- };
125
- if (exact !== void 0 && name in exact) out[`${catalog}:exact`] = {
126
- ...exact,
127
- [name]: pinned
128
- };
129
- }
130
- return out;
131
- }
132
- /**
133
- * Resolve the `overrides` value a plugin ships: the derived table from the
134
- * directive, with the authored entries merged over it so a hand-written
135
- * selector wins. Without a directive the authored value passes through
136
- * untouched (by reference, so an absent field stays absent).
137
- *
138
- * @internal
139
- */
140
- function resolveOverrides(authored, directives, catalogs) {
141
- if (directives === void 0) return authored;
142
- const derived = deriveOverrides(catalogs, directives);
143
- const manual = Predicate.isObject(authored) ? authored : {};
144
- const authoredSelectors = new Set(Object.keys(manual).map(canonicalSelector));
145
- return {
146
- ...Object.fromEntries(Object.entries(derived).filter(([key]) => !authoredSelectors.has(key))),
147
- ...manual
148
- };
149
- }
150
-
151
- export { deriveOverrides, pinCatalogs, resolveOverrides };