rolldown-pnpm-config 2.5.1 → 3.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.
package/registry.js CHANGED
@@ -1,7 +1,474 @@
1
- import { DESCRIPTORS, deriveRegistry } from "./descriptors/index.js";
1
+ import { PnpmSettingsCatalog } from "@effected/pnpm/settings";
2
2
 
3
3
  // src/registry.ts
4
- /** Maps each known pnpm field to its strategy + default enforcement. Derived from the descriptor table. @internal */
5
- const FIELD_REGISTRY = deriveRegistry(DESCRIPTORS);
4
+ /**
5
+ * Every pnpm setting the plugin manages, with its policy. The facts about each
6
+ * setting (its schema, where pnpm reads it, its documentation) come from
7
+ * `@effected/pnpm/settings`; this table holds only what the plugin decides.
8
+ *
9
+ * @remarks
10
+ * `satisfies` against the catalog's key set makes a setting the catalog does
11
+ * not know (a phantom, or one pnpm 12 stopped reading) a compile error here,
12
+ * so the plugin cannot offer a setting pnpm would ignore.
13
+ *
14
+ * @internal
15
+ */
16
+ const FIELD_REGISTRY = {
17
+ catalogs: {
18
+ strategy: "catalogs",
19
+ enforcement: "warn"
20
+ },
21
+ packageExtensions: {
22
+ strategy: "mapChildWins",
23
+ enforcement: "absent"
24
+ },
25
+ allowedDeprecatedVersions: {
26
+ strategy: "mapChildWins",
27
+ enforcement: "absent"
28
+ },
29
+ publicHoistPattern: {
30
+ strategy: "arrayUnion",
31
+ enforcement: "absent"
32
+ },
33
+ minimumReleaseAgeExclude: {
34
+ strategy: "arrayUnion",
35
+ enforcement: "absent"
36
+ },
37
+ supportedArchitectures: {
38
+ strategy: "arrayRecordUnion",
39
+ enforcement: "absent"
40
+ },
41
+ audit: {
42
+ strategy: "sectionMerge",
43
+ enforcement: "absent"
44
+ },
45
+ auditConfig: {
46
+ strategy: "arrayRecordUnion",
47
+ enforcement: "absent"
48
+ },
49
+ overrides: {
50
+ strategy: "overrides",
51
+ enforcement: "warn"
52
+ },
53
+ peerDependencyRules: {
54
+ strategy: "peerDependencyRules",
55
+ enforcement: "warn"
56
+ },
57
+ strictDepBuilds: {
58
+ strategy: "securityFlag",
59
+ enforcement: "warn"
60
+ },
61
+ blockExoticSubdeps: {
62
+ strategy: "securityFlag",
63
+ enforcement: "warn"
64
+ },
65
+ minimumReleaseAge: {
66
+ strategy: "securityMin",
67
+ enforcement: "warn"
68
+ },
69
+ allowBuilds: {
70
+ strategy: "allowBuilds",
71
+ enforcement: "warn"
72
+ },
73
+ ignoredOptionalDependencies: {
74
+ strategy: "arrayUnion",
75
+ enforcement: "absent"
76
+ },
77
+ update: {
78
+ strategy: "sectionMerge",
79
+ enforcement: "absent"
80
+ },
81
+ updateConfig: {
82
+ strategy: "mapChildWins",
83
+ enforcement: "absent"
84
+ },
85
+ catalog: {
86
+ strategy: "mapChildWins",
87
+ enforcement: "warn"
88
+ },
89
+ minimumReleaseAgeStrict: {
90
+ strategy: "scalar",
91
+ enforcement: "warn"
92
+ },
93
+ minimumReleaseAgeIgnoreMissingTime: {
94
+ strategy: "scalar",
95
+ enforcement: "warn"
96
+ },
97
+ trustPolicy: {
98
+ strategy: "scalar",
99
+ enforcement: "warn"
100
+ },
101
+ trustPolicyExclude: {
102
+ strategy: "arrayUnion",
103
+ enforcement: "warn"
104
+ },
105
+ trustPolicyIgnoreAfter: {
106
+ strategy: "scalar",
107
+ enforcement: "warn"
108
+ },
109
+ trustLockfile: {
110
+ strategy: "scalar",
111
+ enforcement: "warn"
112
+ },
113
+ hoist: {
114
+ strategy: "scalar",
115
+ enforcement: "absent"
116
+ },
117
+ hoistWorkspacePackages: {
118
+ strategy: "scalar",
119
+ enforcement: "absent"
120
+ },
121
+ hoistPattern: {
122
+ strategy: "arrayUnion",
123
+ enforcement: "absent"
124
+ },
125
+ shamefullyHoist: {
126
+ strategy: "scalar",
127
+ enforcement: "absent"
128
+ },
129
+ hoistingLimits: {
130
+ strategy: "scalar",
131
+ enforcement: "absent"
132
+ },
133
+ modulesDir: {
134
+ strategy: "scalar",
135
+ enforcement: "absent"
136
+ },
137
+ nodeLinker: {
138
+ strategy: "scalar",
139
+ enforcement: "absent"
140
+ },
141
+ symlink: {
142
+ strategy: "scalar",
143
+ enforcement: "absent"
144
+ },
145
+ enableModulesDir: {
146
+ strategy: "scalar",
147
+ enforcement: "absent"
148
+ },
149
+ virtualStoreDir: {
150
+ strategy: "scalar",
151
+ enforcement: "absent"
152
+ },
153
+ virtualStoreDirMaxLength: {
154
+ strategy: "scalar",
155
+ enforcement: "absent"
156
+ },
157
+ virtualStoreOnly: {
158
+ strategy: "scalar",
159
+ enforcement: "absent"
160
+ },
161
+ packageImportMethod: {
162
+ strategy: "scalar",
163
+ enforcement: "absent"
164
+ },
165
+ modulesCacheMaxAge: {
166
+ strategy: "scalar",
167
+ enforcement: "absent"
168
+ },
169
+ dlxCacheMaxAge: {
170
+ strategy: "scalar",
171
+ enforcement: "absent"
172
+ },
173
+ verifyStoreIntegrity: {
174
+ strategy: "scalar",
175
+ enforcement: "warn"
176
+ },
177
+ strictStorePkgContentCheck: {
178
+ strategy: "scalar",
179
+ enforcement: "warn"
180
+ },
181
+ lockfile: {
182
+ strategy: "scalar",
183
+ enforcement: "absent"
184
+ },
185
+ preferFrozenLockfile: {
186
+ strategy: "scalar",
187
+ enforcement: "absent"
188
+ },
189
+ lockfileIncludeTarballUrl: {
190
+ strategy: "scalar",
191
+ enforcement: "absent"
192
+ },
193
+ gitBranchLockfile: {
194
+ strategy: "scalar",
195
+ enforcement: "absent"
196
+ },
197
+ mergeGitBranchLockfilesBranchPattern: {
198
+ strategy: "arrayUnion",
199
+ enforcement: "absent"
200
+ },
201
+ peersSuffixMaxLength: {
202
+ strategy: "scalar",
203
+ enforcement: "absent"
204
+ },
205
+ sharedWorkspaceLockfile: {
206
+ strategy: "scalar",
207
+ enforcement: "absent"
208
+ },
209
+ autoInstallPeers: {
210
+ strategy: "scalar",
211
+ enforcement: "absent"
212
+ },
213
+ dedupePeerDependents: {
214
+ strategy: "scalar",
215
+ enforcement: "absent"
216
+ },
217
+ dedupePeers: {
218
+ strategy: "scalar",
219
+ enforcement: "absent"
220
+ },
221
+ strictPeerDependencies: {
222
+ strategy: "scalar",
223
+ enforcement: "absent"
224
+ },
225
+ resolvePeersFromWorkspaceRoot: {
226
+ strategy: "scalar",
227
+ enforcement: "absent"
228
+ },
229
+ dangerouslyAllowAllBuilds: {
230
+ strategy: "scalar",
231
+ enforcement: "warn"
232
+ },
233
+ ignoreScripts: {
234
+ strategy: "scalar",
235
+ enforcement: "absent"
236
+ },
237
+ childConcurrency: {
238
+ strategy: "scalar",
239
+ enforcement: "absent"
240
+ },
241
+ sideEffectsCache: {
242
+ strategy: "scalar",
243
+ enforcement: "absent"
244
+ },
245
+ sideEffectsCacheReadonly: {
246
+ strategy: "scalar",
247
+ enforcement: "absent"
248
+ },
249
+ nodeOptions: {
250
+ strategy: "scalar",
251
+ enforcement: "absent"
252
+ },
253
+ verifyDepsBeforeRun: {
254
+ strategy: "scalar",
255
+ enforcement: "absent"
256
+ },
257
+ enablePrePostScripts: {
258
+ strategy: "scalar",
259
+ enforcement: "absent"
260
+ },
261
+ scriptShell: {
262
+ strategy: "scalar",
263
+ enforcement: "absent"
264
+ },
265
+ shellEmulator: {
266
+ strategy: "scalar",
267
+ enforcement: "absent"
268
+ },
269
+ requiredScripts: {
270
+ strategy: "arrayUnion",
271
+ enforcement: "absent"
272
+ },
273
+ patchedDependencies: {
274
+ strategy: "mapChildWins",
275
+ enforcement: "warn"
276
+ },
277
+ allowUnusedPatches: {
278
+ strategy: "scalar",
279
+ enforcement: "absent"
280
+ },
281
+ patchesDir: {
282
+ strategy: "scalar",
283
+ enforcement: "absent"
284
+ },
285
+ configDependencies: {
286
+ strategy: "mapChildWins",
287
+ enforcement: "absent"
288
+ },
289
+ injectWorkspacePackages: {
290
+ strategy: "scalar",
291
+ enforcement: "absent"
292
+ },
293
+ syncInjectedDepsAfterScripts: {
294
+ strategy: "arrayUnion",
295
+ enforcement: "absent"
296
+ },
297
+ dedupeInjectedDeps: {
298
+ strategy: "scalar",
299
+ enforcement: "absent"
300
+ },
301
+ pmOnFail: {
302
+ strategy: "scalar",
303
+ enforcement: "absent"
304
+ },
305
+ runtimeOnFail: {
306
+ strategy: "scalar",
307
+ enforcement: "absent"
308
+ },
309
+ nodeVersion: {
310
+ strategy: "scalar",
311
+ enforcement: "absent"
312
+ },
313
+ nodeDownloadMirrors: {
314
+ strategy: "mapChildWins",
315
+ enforcement: "absent"
316
+ },
317
+ catalogMode: {
318
+ strategy: "scalar",
319
+ enforcement: "absent"
320
+ },
321
+ cleanupUnusedCatalogs: {
322
+ strategy: "scalar",
323
+ enforcement: "absent"
324
+ },
325
+ linkWorkspacePackages: {
326
+ strategy: "scalar",
327
+ enforcement: "absent"
328
+ },
329
+ preferWorkspacePackages: {
330
+ strategy: "scalar",
331
+ enforcement: "absent"
332
+ },
333
+ saveWorkspaceProtocol: {
334
+ strategy: "scalar",
335
+ enforcement: "absent"
336
+ },
337
+ includeWorkspaceRoot: {
338
+ strategy: "scalar",
339
+ enforcement: "absent"
340
+ },
341
+ ignoreWorkspaceCycles: {
342
+ strategy: "scalar",
343
+ enforcement: "absent"
344
+ },
345
+ disallowWorkspaceCycles: {
346
+ strategy: "scalar",
347
+ enforcement: "absent"
348
+ },
349
+ workspaceConcurrency: {
350
+ strategy: "scalar",
351
+ enforcement: "absent"
352
+ },
353
+ auditLevel: {
354
+ strategy: "scalar",
355
+ enforcement: "absent"
356
+ },
357
+ resolutionMode: {
358
+ strategy: "scalar",
359
+ enforcement: "absent"
360
+ },
361
+ savePrefix: {
362
+ strategy: "scalar",
363
+ enforcement: "absent"
364
+ },
365
+ saveExact: {
366
+ strategy: "scalar",
367
+ enforcement: "absent"
368
+ },
369
+ tag: {
370
+ strategy: "scalar",
371
+ enforcement: "absent"
372
+ },
373
+ preferOffline: {
374
+ strategy: "scalar",
375
+ enforcement: "absent"
376
+ },
377
+ dedupeDirectDeps: {
378
+ strategy: "scalar",
379
+ enforcement: "absent"
380
+ },
381
+ deployAllFiles: {
382
+ strategy: "scalar",
383
+ enforcement: "absent"
384
+ },
385
+ forceLegacyDeploy: {
386
+ strategy: "scalar",
387
+ enforcement: "absent"
388
+ },
389
+ extendNodePath: {
390
+ strategy: "scalar",
391
+ enforcement: "absent"
392
+ },
393
+ preferSymlinkedExecutables: {
394
+ strategy: "scalar",
395
+ enforcement: "absent"
396
+ },
397
+ ignoreCompatibilityDb: {
398
+ strategy: "scalar",
399
+ enforcement: "absent"
400
+ },
401
+ optimisticRepeatInstall: {
402
+ strategy: "scalar",
403
+ enforcement: "absent"
404
+ },
405
+ recursiveInstall: {
406
+ strategy: "scalar",
407
+ enforcement: "absent"
408
+ },
409
+ engineStrict: {
410
+ strategy: "scalar",
411
+ enforcement: "absent"
412
+ },
413
+ networkConcurrency: {
414
+ strategy: "scalar",
415
+ enforcement: "absent"
416
+ },
417
+ fetchRetries: {
418
+ strategy: "scalar",
419
+ enforcement: "absent"
420
+ },
421
+ fetchRetryFactor: {
422
+ strategy: "scalar",
423
+ enforcement: "absent"
424
+ },
425
+ fetchRetryMintimeout: {
426
+ strategy: "scalar",
427
+ enforcement: "absent"
428
+ },
429
+ fetchRetryMaxtimeout: {
430
+ strategy: "scalar",
431
+ enforcement: "absent"
432
+ },
433
+ fetchTimeout: {
434
+ strategy: "scalar",
435
+ enforcement: "absent"
436
+ },
437
+ gitShallowHosts: {
438
+ strategy: "arrayUnion",
439
+ enforcement: "absent"
440
+ },
441
+ provenance: {
442
+ strategy: "scalar",
443
+ enforcement: "absent"
444
+ },
445
+ gitChecks: {
446
+ strategy: "scalar",
447
+ enforcement: "absent"
448
+ },
449
+ embedReadme: {
450
+ strategy: "scalar",
451
+ enforcement: "absent"
452
+ },
453
+ publishBranch: {
454
+ strategy: "scalar",
455
+ enforcement: "absent"
456
+ }
457
+ };
458
+ /** Every managed field, in table order. @internal */
459
+ const MANAGED_FIELDS = Object.keys(FIELD_REGISTRY);
460
+ /**
461
+ * Each managed field's value schema, from the pnpm settings catalog.
462
+ *
463
+ * @internal
464
+ */
465
+ const FIELD_SCHEMAS = Object.fromEntries(MANAGED_FIELDS.map((field) => [field, PnpmSettingsCatalog.entries[field].schema]));
466
+ /**
467
+ * The managed fields that belong in `pnpm-workspace.yaml`: those pnpm 12 reads
468
+ * from that file, per the catalog's `locations`.
469
+ *
470
+ * @internal
471
+ */
472
+ const WORKSPACE_FIELDS = new Set(MANAGED_FIELDS.filter((field) => PnpmSettingsCatalog.entries[field].locations.includes("workspace")));
6
473
 
7
- export { FIELD_REGISTRY };
474
+ export { FIELD_REGISTRY, FIELD_SCHEMAS, MANAGED_FIELDS, WORKSPACE_FIELDS };
@@ -35,5 +35,31 @@ const arrayRecordUnion = (base, local) => {
35
35
  divergences: []
36
36
  };
37
37
  };
38
+ /**
39
+ * A settings section with list and scalar keys (`audit`, `update`): a key whose
40
+ * managed or local value is a string list is unioned like `arrayUnion`, so a
41
+ * consumer's `audit.ignore` adds to the managed advisories instead of replacing
42
+ * them; any other key is `child ?? managed`. Quiet.
43
+ *
44
+ * @internal
45
+ */
46
+ const sectionMerge = (base, local) => {
47
+ const managed = base ?? {};
48
+ const child = local ?? {};
49
+ const result = {};
50
+ for (const key of [.../* @__PURE__ */ new Set([...Object.keys(managed), ...Object.keys(child)])].sort(byCodeUnit)) {
51
+ const m = managed[key];
52
+ const c = child[key];
53
+ if (Array.isArray(m) || Array.isArray(c)) result[key] = unionSort(Array.isArray(m) ? m : [], Array.isArray(c) ? c : void 0);
54
+ else {
55
+ const value = c ?? m;
56
+ if (value !== void 0) result[key] = value;
57
+ }
58
+ }
59
+ return {
60
+ merged: result,
61
+ divergences: []
62
+ };
63
+ };
38
64
 
39
- export { arrayRecordUnion, arrayUnion, unionSort };
65
+ export { arrayRecordUnion, arrayUnion, sectionMerge, unionSort };
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { arrayRecordUnion, arrayUnion } from "./arrays.js";
1
+ import { arrayRecordUnion, arrayUnion, sectionMerge } from "./arrays.js";
2
2
  import { catalogs } from "./catalogs.js";
3
3
  import { allowBuilds, mapChildWins } from "./maps.js";
4
4
  import { overrides, peerDependencyRules } from "./overrides.js";
@@ -16,6 +16,7 @@ const STRATEGY_TABLE = {
16
16
  mapChildWins,
17
17
  arrayUnion,
18
18
  arrayRecordUnion,
19
+ sectionMerge,
19
20
  overrides,
20
21
  peerDependencyRules,
21
22
  securityFlag,
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);