rolldown-pnpm-config 0.5.5 → 0.5.7

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.
@@ -12,7 +12,7 @@ const root = Command.make("rolldown-pnpm-config").pipe(Command.withSubcommands([
12
12
  exportCommand,
13
13
  previewCommand
14
14
  ]));
15
- Command.run(root, { version: "0.5.5" }).pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
15
+ Command.run(root, { version: "0.5.7" }).pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
16
16
 
17
17
  //#endregion
18
18
  export { };
@@ -43,13 +43,15 @@ const WORKSPACE_FIELDS = new Set(Object.entries(DESCRIPTORS).filter(([, d]) => d
43
43
  */
44
44
  function runExport(opts) {
45
45
  return Effect.gen(function* () {
46
- const { config, errors } = evaluatePluginConfig(yield* Effect.try({
46
+ const configSource = yield* Effect.try({
47
47
  try: () => readFileSync(opts.configFile, "utf8"),
48
48
  catch: () => new ExportError({ message: `Cannot read ${opts.configFile}` })
49
- }), opts.configFile);
49
+ });
50
+ const { config, errors } = evaluatePluginConfig(configSource, opts.configFile);
50
51
  if (config === null) return yield* Effect.fail(new ExportError({ message: `No PnpmConfigPlugin call found in ${opts.configFile}` }));
51
52
  if (errors.length > 0) return yield* Effect.fail(new ExportError({ message: `Non-literal config values: ${errors.join("; ")}` }));
52
- const { base, manifest } = yield* freeze(withResolvedBuildPatches(config, dirname(opts.configFile))).pipe(Effect.mapError((e) => new ExportError({ message: e.message })));
53
+ const resolvedConfig = withResolvedBuildPatches(config, dirname(opts.configFile));
54
+ const { base, manifest } = yield* freeze(resolvedConfig).pipe(Effect.mapError((e) => new ExportError({ message: e.message })));
53
55
  const managed = {};
54
56
  for (const [k, v] of Object.entries(base)) if (WORKSPACE_FIELDS.has(k)) managed[k] = v;
55
57
  const path = opts.workspacePath ?? findWorkspaceFile(process.cwd()) ?? join(process.cwd(), "pnpm-workspace.yaml");
@@ -58,7 +60,8 @@ function runExport(opts) {
58
60
  catch: (e) => new ExportError({ message: `Cannot read or parse ${path}: ${String(e)}` })
59
61
  }) : {};
60
62
  const rootName = resolveRootName({ dir: dirname(path) });
61
- const effective = effectiveManaged(managed, config.local && typeof config.local === "object" ? config.local : void 0, parsed, manifest, rootName);
63
+ const localCfg = config.local && typeof config.local === "object" ? config.local : void 0;
64
+ const effective = effectiveManaged(managed, localCfg, parsed, manifest, rootName);
62
65
  const rawPatched = config.patchedDependencies;
63
66
  const explicitPatchMap = rawPatched !== void 0 && !isRewriteDirective(rawPatched);
64
67
  const contributed = {};
@@ -87,10 +90,11 @@ function runExport(opts) {
87
90
  const merged = overlayWorkspace(effective, parsed);
88
91
  const rendered = renderWorkspace(merged);
89
92
  const localKeys = new Set(config.local && typeof config.local === "object" ? Object.keys(config.local) : []);
90
- const diff = renderExportDiff(buildDiff(canonicalize(parsed), canonicalize(merged), {
93
+ const tree = buildDiff(canonicalize(parsed), canonicalize(merged), {
91
94
  localKeys,
92
95
  managedKeys: WORKSPACE_FIELDS
93
- }), { full: opts.full ?? false });
96
+ });
97
+ const diff = renderExportDiff(tree, { full: opts.full ?? false });
94
98
  if (opts.preview) return {
95
99
  path,
96
100
  rendered,
@@ -127,7 +131,8 @@ const exportCommand = Command.make("export", {
127
131
  dryRun: dryRunFlag,
128
132
  full: fullFlag
129
133
  }, ({ path, dryRun, full }) => Effect.gen(function* () {
130
- const picked = pickConfigCandidate(yield* findConfigFiles(process.cwd()));
134
+ const matches = yield* findConfigFiles(process.cwd());
135
+ const picked = pickConfigCandidate(matches);
131
136
  if (!picked.ok) return yield* Effect.fail(new ExportError({ message: picked.message }));
132
137
  const workspacePath = Option.getOrUndefined(path);
133
138
  const result = yield* runExport({
@@ -25,10 +25,11 @@ var PreviewError = class extends Data.TaggedError("PreviewError") {};
25
25
  */
26
26
  function runPreviewViews(opts) {
27
27
  return Effect.gen(function* () {
28
- const { config, errors } = evaluatePluginConfig(yield* Effect.try({
28
+ const configSource = yield* Effect.try({
29
29
  try: () => readFileSync(opts.configFile, "utf8"),
30
30
  catch: () => new PreviewError({ message: `Cannot read ${opts.configFile}` })
31
- }), opts.configFile);
31
+ });
32
+ const { config, errors } = evaluatePluginConfig(configSource, opts.configFile);
32
33
  if (config === null) return yield* Effect.fail(new PreviewError({ message: `No PnpmConfigPlugin call found in ${opts.configFile}` }));
33
34
  if (errors.length > 0) return yield* Effect.fail(new PreviewError({ message: `Non-literal config values: ${errors.join("; ")}` }));
34
35
  const { base, manifest } = yield* freeze(config).pipe(Effect.mapError((e) => new PreviewError({ message: e.message })));
@@ -58,7 +59,8 @@ const pathArg = Argument.file("path").pipe(Argument.optional);
58
59
  * @internal
59
60
  */
60
61
  const previewCommand = Command.make("preview", { path: pathArg }, ({ path }) => Effect.gen(function* () {
61
- const picked = pickConfigCandidate(yield* findConfigFiles(process.cwd()));
62
+ const matches = yield* findConfigFiles(process.cwd());
63
+ const picked = pickConfigCandidate(matches);
62
64
  if (!picked.ok) return yield* Effect.fail(new PreviewError({ message: picked.message }));
63
65
  const workspacePath = Option.getOrUndefined(path);
64
66
  const views = yield* runPreviewViews({
@@ -324,7 +324,8 @@ function runUpgradePreview(opts) {
324
324
  });
325
325
  const gate = yield* computeGate(source, opts.file, opts.resolver);
326
326
  const versions = yield* resolveGatedVersions(discovered.entries, opts.resolver, gate, Date.now());
327
- const text = renderSummary(projectDecisions(yield* buildWalkItems(discovered.entries, versions.gated).pipe(Effect.catch((e) => Effect.fail(new UpgradeError({ message: e.message })))), opts.full), void 0, { color: opts.color ?? false });
327
+ const items = yield* buildWalkItems(discovered.entries, versions.gated).pipe(Effect.catch((e) => Effect.fail(new UpgradeError({ message: e.message }))));
328
+ const text = renderSummary(projectDecisions(items, opts.full), void 0, { color: opts.color ?? false });
328
329
  return versions.unresolved.length > 0 ? `${text}\n⚠ ${unresolvedMessage(versions.unresolved)}` : text;
329
330
  });
330
331
  }
@@ -337,7 +338,8 @@ function resolveTargetFile(fileOpt) {
337
338
  return Effect.gen(function* () {
338
339
  const explicit = Option.getOrUndefined(fileOpt);
339
340
  if (explicit !== void 0) return explicit;
340
- const picked = pickConfigCandidate(yield* findConfigFiles(process.cwd()));
341
+ const matches = yield* findConfigFiles(process.cwd());
342
+ const picked = pickConfigCandidate(matches);
341
343
  if (!picked.ok) return yield* Effect.fail(new UpgradeError({ message: picked.message }));
342
344
  return picked.file;
343
345
  });
@@ -476,7 +478,8 @@ const upgradeCommand = Command.make("upgrade", {
476
478
  if (rangeChanged || peerChanged) interopChanged++;
477
479
  }
478
480
  }
479
- const { accepted, rejected } = yield* validateEdits(buildEdits(nonInteropDecisions), versions.raw);
481
+ const planned = buildEdits(nonInteropDecisions);
482
+ const { accepted, rejected } = yield* validateEdits(planned, versions.raw);
480
483
  const acceptedPkgs = new Set(accepted.map((e) => e.pkg));
481
484
  yield* Effect.sync(() => process.stdout.write(`${renderSummary(decisions, {
482
485
  adjustments: [],
@@ -20,9 +20,11 @@ function buildPreviewViews(input) {
20
20
  localKeys: new Set(input.local ? Object.keys(input.local) : []),
21
21
  managedKeys: WORKSPACE_FIELDS
22
22
  };
23
- const merged = overlayWorkspace(effectiveManaged(input.managed, input.local, input.parsed, input.manifest, input.rootName), input.parsed);
23
+ const effective = effectiveManaged(input.managed, input.local, input.parsed, input.manifest, input.rootName);
24
+ const merged = overlayWorkspace(effective, input.parsed);
24
25
  const vanilla = vanillaManaged(input.managed, input.manifest, input.rootName);
25
- const changesTree = buildDiff(canonicalize(input.parsed), canonicalize(merged), meta);
26
+ const before = canonicalize(input.parsed);
27
+ const changesTree = buildDiff(before, canonicalize(merged), meta);
26
28
  return {
27
29
  changes: renderExportDiff(changesTree, { full: false }),
28
30
  full: renderExportDiff(changesTree, { full: true }),
@@ -24,7 +24,8 @@ function findConfigFiles(dir) {
24
24
  if (!name.endsWith(".ts") || name.endsWith(".d.ts")) continue;
25
25
  const path = join(dir, name);
26
26
  try {
27
- const { entries } = discoverCatalogEntries(readFileSync(path, "utf8"), path);
27
+ const source = readFileSync(path, "utf8");
28
+ const { entries } = discoverCatalogEntries(source, path);
28
29
  if (entries.length > 0) matches.push(path);
29
30
  } catch {}
30
31
  }
package/cli/ui/Preview.js CHANGED
@@ -23,9 +23,10 @@ function renderLines(lines) {
23
23
  const indent = " ".repeat(l.indent);
24
24
  const tag = l.tag === "local" ? " (local)" : "";
25
25
  const body = l.segments.map((s, j) => {
26
+ const props = INK_PROPS[s.style] ?? {};
26
27
  return createElement(Text, {
27
28
  key: j,
28
- ...INK_PROPS[s.style] ?? {}
29
+ ...props
29
30
  }, s.text);
30
31
  });
31
32
  return createElement(Text, { key: i }, `${l.gutter} ${indent}`, ...body, tag);
@@ -46,7 +47,7 @@ function Preview({ views, onExit }) {
46
47
  app.exit();
47
48
  }
48
49
  });
49
- return createElement(Box, { flexDirection: "column" }, createElement(TabsC, { onChange: (name) => setActive(name) }, createElement(TabC, {
50
+ const tabs = createElement(TabsC, { onChange: (name) => setActive(name) }, createElement(TabC, {
50
51
  name: "changes",
51
52
  key: "changes"
52
53
  }, "Changes"), createElement(TabC, {
@@ -55,7 +56,9 @@ function Preview({ views, onExit }) {
55
56
  }, "Full"), createElement(TabC, {
56
57
  name: "simulated",
57
58
  key: "simulated"
58
- }, "Simulated")), renderLines(active === "simulated" ? simulatedLegendLines() : legendLines()), renderLines(views[active]));
59
+ }, "Simulated"));
60
+ const legend = renderLines(active === "simulated" ? simulatedLegendLines() : legendLines());
61
+ return createElement(Box, { flexDirection: "column" }, tabs, legend, renderLines(views[active]));
59
62
  }
60
63
 
61
64
  //#endregion
package/cli/walk-plan.js CHANGED
@@ -16,7 +16,8 @@ function buildWalkItems(entries, versionsByPkg) {
16
16
  return Effect.gen(function* () {
17
17
  const items = [];
18
18
  for (const entry of entries) {
19
- const candidates = yield* planEntry(entry, [...versionsByPkg.get(entry.pkg) ?? []]);
19
+ const versions = versionsByPkg.get(entry.pkg) ?? [];
20
+ const candidates = yield* planEntry(entry, [...versions]);
20
21
  const driftPeer = yield* detectPeerDrift(entry);
21
22
  let peerWarning = null;
22
23
  let materializePeer = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -36,13 +36,13 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@effect/platform-node": "4.0.0-beta.101",
39
- "@effected/npm": "^0.6.0",
40
- "@effected/semver": "^0.2.1",
41
- "@effected/yaml": "^0.6.0",
39
+ "@effected/npm": "^0.8.1",
40
+ "@effected/semver": "^0.3.1",
41
+ "@effected/yaml": "^0.6.1",
42
42
  "effect": "4.0.0-beta.101",
43
43
  "ink": "^7.1.1",
44
44
  "ink-tab": "^5.2.0",
45
- "oxc-parser": "^0.142.0",
45
+ "oxc-parser": "^0.143.0",
46
46
  "react": "^19.2.8",
47
47
  "std-env": "^4.2.0",
48
48
  "std-osc8": "^0.2.0"
package/patches/paths.js CHANGED
@@ -21,7 +21,8 @@ function distributedPatchPath(name, rel) {
21
21
  * @internal
22
22
  */
23
23
  function distributedRel(baseDir, distRoot, fileName) {
24
- const rel = relative(join(baseDir, "public"), distRoot);
24
+ const publicDir = join(baseDir, "public");
25
+ const rel = relative(publicDir, distRoot);
25
26
  return `${(rel === "" || rel.startsWith("..") ? basename(distRoot) : rel).split(/[\\/]/).filter(Boolean).join("/")}/${fileName}`;
26
27
  }
27
28
 
@@ -12,7 +12,7 @@ function pad(line) {
12
12
  */
13
13
  function formatOverrideWarning(divergences, name) {
14
14
  if (divergences.length === 0) return "";
15
- const border = "─".repeat(WARNING_BOX_WIDTH - 2);
15
+ const border = "─".repeat(73);
16
16
  const lines = [];
17
17
  lines.push(`┌${border}┐`);
18
18
  lines.push(pad(` [${name}]`));
@@ -39,7 +39,7 @@ function formatOverrideWarning(divergences, name) {
39
39
  */
40
40
  function formatSecurityWarning(divergences, name) {
41
41
  if (divergences.length === 0) return "";
42
- const border = "─".repeat(WARNING_BOX_WIDTH - 2);
42
+ const border = "─".repeat(73);
43
43
  const lines = [];
44
44
  lines.push(`┌${border}┐`);
45
45
  lines.push(pad(` [${name}]`));
package/virtual.d.ts CHANGED
@@ -14,8 +14,9 @@ declare module "rolldown-pnpm-config/virtual/pnpmfile" {
14
14
  // against this package's own *source* `exports` map during the build's declaration
15
15
  // pass and pulls a raw .ts file into API Extractor's analysis (ae-wrong-input-file-type).
16
16
  // Keep this shape in sync with `PnpmConfig`/`PnpmHooks` in `src/runtime/types.ts`.
17
- interface PnpmConfig {
18
- catalogs?: Record<string, Record<string, string>>;
17
+ export type Catalogs = Map<string, Map<string, string>>;
18
+ export interface PnpmConfig {
19
+ catalogs?: Catalogs;
19
20
  [key: string]: unknown;
20
21
  }
21
22
  export const hooks: {
@@ -24,5 +25,6 @@ declare module "rolldown-pnpm-config/virtual/pnpmfile" {
24
25
  }
25
26
 
26
27
  declare module "rolldown-pnpm-config/virtual/catalogs" {
27
- export const catalogs: Map<string, Map<string, string>>;
28
+ export type Catalogs = Map<string, Map<string, string>>;
29
+ export const catalogs: Catalogs;
28
30
  }