rolldown-pnpm-config 2.5.0 → 2.5.2

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 CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "2.5.0";
9
+ const CLI_VERSION = "2.5.2";
10
10
 
11
11
  export { CLI_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -35,18 +35,18 @@
35
35
  "rolldown-pnpm-config": "bin/rolldown-pnpm-config.js"
36
36
  },
37
37
  "dependencies": {
38
- "@effect/platform-node": "4.1.3",
39
- "@effected/changesets": "^0.4.1",
40
- "@effected/cli-kit": "^0.28.1",
41
- "@effected/env": "^0.12.0",
42
- "@effected/files": "^0.3.0",
43
- "@effected/glob": "^0.21.0",
44
- "@effected/npm": "^0.34.0",
45
- "@effected/semver": "^0.24.0",
46
- "@effected/walker": "^0.28.0",
47
- "@effected/workspaces": "^0.46.0",
48
- "@effected/yaml": "^0.30.0",
49
- "effect": "4.1.3",
38
+ "@effect/platform-node": "4.1.4",
39
+ "@effected/changesets": "0.5.1",
40
+ "@effected/cli-kit": "0.29.0",
41
+ "@effected/env": "0.12.0",
42
+ "@effected/files": "0.3.0",
43
+ "@effected/glob": "0.22.0",
44
+ "@effected/npm": "0.34.1",
45
+ "@effected/semver": "0.24.0",
46
+ "@effected/walker": "0.29.0",
47
+ "@effected/workspaces": "0.47.1",
48
+ "@effected/yaml": "0.30.0",
49
+ "effect": "4.1.4",
50
50
  "ink": "^8.0.0",
51
51
  "oxc-parser": "^0.158.0",
52
52
  "react": "^19.3.1"
package/plugin/freeze.js CHANGED
@@ -63,9 +63,11 @@ function freeze(config) {
63
63
  catch: (error) => new ConfigError({ message: Fmt.describe(error) })
64
64
  });
65
65
  base.catalogs = yield* Schema.decodeUnknownEffect(CatalogsSchema)(normalized).pipe(Effect.mapError((error) => new ConfigError({ message: `Invalid catalogs: ${Fmt.describe(error)}` })));
66
+ const exactCatalogs = Object.entries(config.catalogs).flatMap(([name, decl]) => decl?.exact === true && normalized[`${name}:exact`] !== void 0 ? [name] : []);
66
67
  manifest.catalogs = {
67
68
  strategy: "catalogs",
68
- enforcement: "warn"
69
+ enforcement: "warn",
70
+ ...exactCatalogs.length > 0 ? { options: { exactCatalogs } } : {}
69
71
  };
70
72
  if (typeof config.name !== "string" || config.name.trim() === "") return yield* Effect.fail(new ConfigError({ message: "Config `name` is required and must be a non-empty string" }));
71
73
  const directiveError = (error) => new ConfigError({ message: Fmt.describe(error) });
@@ -1,21 +1,60 @@
1
1
  import { mergeMapDetect } from "./overrides.js";
2
+ import { singleVersionOf } from "./single-version.js";
2
3
 
3
4
  // src/runtime/strategies/catalogs.ts
4
5
  /**
5
6
  * Merge each named catalog; child wins per package. Emits override divergences
6
7
  * when a local version differs from the managed one.
7
8
  *
9
+ * `options.exactCatalogs` lists the catalogs whose managed `<name>:exact`
10
+ * variant was derived from their ranges at build time. A local override of
11
+ * `<name>.<pkg>` naming a single version re-derives `<name>:exact.<pkg>` (only
12
+ * where the managed exact catalog carries `<pkg>`, and an explicit local
13
+ * `<name>:exact` entry wins). Without the option nothing is re-derived.
14
+ * `<name>:peers` is authored separately and is never re-derived; the
15
+ * divergence only notes that it keeps its managed value.
16
+ *
8
17
  * @internal
9
18
  */
10
- const catalogs = (base, local) => {
19
+ const catalogs = (base, local, _ctx, options) => {
11
20
  const managed = base ?? {};
12
21
  const child = local ?? {};
22
+ const exactNames = new Set(Array.isArray(options?.exactCatalogs) ? options.exactCatalogs : []);
13
23
  const divergences = [];
14
24
  const merged = { ...child };
25
+ const followed = /* @__PURE__ */ new Map();
15
26
  for (const [name, entries] of Object.entries(managed)) {
16
27
  const cat = mergeMapDetect(`catalogs.${name}`, entries, child[name] ?? {});
17
28
  merged[name] = cat.merged;
18
- divergences.push(...cat.divergences);
29
+ const managedExact = exactNames.has(name) ? managed[`${name}:exact`] : void 0;
30
+ const managedPeers = managed[`${name}:peers`];
31
+ const derived = {};
32
+ for (const d of cat.divergences) {
33
+ const pkg = d.setting.slice(`catalogs.${name}.`.length);
34
+ const notes = [];
35
+ if (managedExact?.[pkg] !== void 0 && child[`${name}:exact`]?.[pkg] !== void 0) notes.push(`The local ${name}:exact entry sets it instead.`);
36
+ else if (managedExact?.[pkg] !== void 0) {
37
+ const version = singleVersionOf(d.localValue);
38
+ if (version !== null) {
39
+ derived[pkg] = version;
40
+ notes.push(`${name}:exact followed it to ${version}.`);
41
+ } else notes.push(`${name}:exact was left at its managed value (${managedExact[pkg]}).`);
42
+ }
43
+ if (managedPeers?.[pkg] !== void 0) notes.push(`${name}:peers keeps its managed value.`);
44
+ divergences.push(notes.length > 0 ? {
45
+ ...d,
46
+ detail: `${d.detail} ${notes.join(" ")}`
47
+ } : d);
48
+ }
49
+ followed.set(`${name}:exact`, derived);
50
+ }
51
+ for (const [exactName, derived] of followed) {
52
+ if (Object.keys(derived).length === 0 || managed[exactName] === void 0) continue;
53
+ merged[exactName] = {
54
+ ...merged[exactName],
55
+ ...derived,
56
+ ...child[exactName] ?? {}
57
+ };
19
58
  }
20
59
  return {
21
60
  merged,
@@ -0,0 +1,15 @@
1
+ // src/runtime/strategies/single-version.ts
2
+ /** One comparator (`^`, `~`, `>=`, `=` or none) on one full version, prerelease allowed. */
3
+ const SINGLE_VERSION_RE = /^(?:\^|~|>=|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)$/;
4
+ /**
5
+ * The single version a range names, or `null` when it names none (compound,
6
+ * wildcard, tag, `<`, `>`, partial). A zero-dependency mirror of the build's
7
+ * `singleVersionOf` in `catalogs.ts`; a test pins the two together.
8
+ *
9
+ * @internal
10
+ */
11
+ function singleVersionOf(range) {
12
+ return SINGLE_VERSION_RE.exec(range.trim())?.[1] ?? null;
13
+ }
14
+
15
+ export { singleVersionOf };
package/runtime.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface StrategyResult {
54
54
  *
55
55
  * @internal
56
56
  */
57
- export type Strategy = (base: unknown, local: unknown, ctx: RuntimeCtx) => StrategyResult;
57
+ export type Strategy = (base: unknown, local: unknown, ctx: RuntimeCtx, options?: Record<string, unknown>) => StrategyResult;
58
58
  /**
59
59
  * How a field's divergences are enforced: silent, console warning, or a thrown
60
60
  * error that fails the install. Part of the public authoring API via
package/runtime.js CHANGED
@@ -26,7 +26,7 @@ function createHooks(base, manifest, name) {
26
26
  for (const [field, entry] of Object.entries(manifest)) {
27
27
  const strategy = STRATEGY_TABLE[entry.strategy];
28
28
  if (!strategy) continue;
29
- const result = strategy(base[field], config[field], ctx);
29
+ const result = strategy(base[field], config[field], ctx, entry.options);
30
30
  let merged = result.merged;
31
31
  const byRepo = entry.options?.excludeByRepo;
32
32
  if (byRepo && Array.isArray(merged)) merged = excludeByRepo(merged, ctx, byRepo);