rolldown-pnpm-config 0.1.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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/bin/rolldown-pnpm-config.js +21 -0
  4. package/catalogs.js +27 -0
  5. package/cli/commands/export.js +118 -0
  6. package/cli/commands/preview.js +73 -0
  7. package/cli/commands/upgrade.js +437 -0
  8. package/cli/diff/build.js +122 -0
  9. package/cli/diff/render.js +103 -0
  10. package/cli/discover.js +128 -0
  11. package/cli/drift.js +22 -0
  12. package/cli/edits.js +41 -0
  13. package/cli/effective.js +42 -0
  14. package/cli/evaluate.js +91 -0
  15. package/cli/interop.js +285 -0
  16. package/cli/local-merge.js +75 -0
  17. package/cli/peer-range.js +34 -0
  18. package/cli/plan.js +66 -0
  19. package/cli/preview-views.js +34 -0
  20. package/cli/release-age.js +74 -0
  21. package/cli/resolve.js +109 -0
  22. package/cli/rewrite.js +22 -0
  23. package/cli/select-file.js +64 -0
  24. package/cli/summary.js +137 -0
  25. package/cli/ui/Preview.js +60 -0
  26. package/cli/ui/Walk.js +55 -0
  27. package/cli/ui/ansi.js +20 -0
  28. package/cli/ui/env.js +20 -0
  29. package/cli/ui/run-preview.js +23 -0
  30. package/cli/ui/run-walk.js +29 -0
  31. package/cli/ui/styled.js +27 -0
  32. package/cli/walk-plan.js +35 -0
  33. package/cli/walk-reducer.js +61 -0
  34. package/cli/workspace-file.js +58 -0
  35. package/cli/workspace-overlay.js +21 -0
  36. package/descriptors/build.js +248 -0
  37. package/descriptors/hoisting.js +175 -0
  38. package/descriptors/index.js +38 -0
  39. package/descriptors/lockfile.js +117 -0
  40. package/descriptors/misc.js +144 -0
  41. package/descriptors/network.js +108 -0
  42. package/descriptors/resolution.js +250 -0
  43. package/descriptors/runtime-cfg.js +90 -0
  44. package/descriptors/schemas.js +26 -0
  45. package/descriptors/workspace.js +116 -0
  46. package/index.d.ts +363 -0
  47. package/index.js +3 -0
  48. package/package.json +60 -0
  49. package/plugin/freeze.js +79 -0
  50. package/plugin/index.js +48 -0
  51. package/plugin/serialize.js +26 -0
  52. package/registry.js +8 -0
  53. package/runtime/ctx.js +39 -0
  54. package/runtime/enforcement.js +36 -0
  55. package/runtime/strategies/arrays.js +37 -0
  56. package/runtime/strategies/catalogs.js +36 -0
  57. package/runtime/strategies/maps.js +46 -0
  58. package/runtime/strategies/overrides.js +57 -0
  59. package/runtime/strategies/scalar.js +57 -0
  60. package/runtime/strategies/table.js +27 -0
  61. package/runtime/warnings.js +61 -0
  62. package/runtime.d.ts +111 -0
  63. package/runtime.js +54 -0
  64. package/tsdoc-metadata.json +11 -0
  65. package/virtual.d.ts +18 -0
package/runtime.js ADDED
@@ -0,0 +1,54 @@
1
+ import { excludeByRepo, resolveRootName } from "./runtime/ctx.js";
2
+ import { applyEnforcement } from "./runtime/enforcement.js";
3
+ import { STRATEGY_TABLE } from "./runtime/strategies/table.js";
4
+ import { formatOverrideWarning, formatSecurityWarning } from "./runtime/warnings.js";
5
+
6
+ //#region src/runtime/index.ts
7
+ /**
8
+ * Build the pnpm hooks from frozen base data + a field→strategy manifest.
9
+ * Zero dependencies — bundled verbatim into the shipped pnpmfile.
10
+ *
11
+ * @remarks
12
+ * `updateConfig` deliberately has no catch-and-fall-back-to-local guard: an
13
+ * `error`-enforced divergence throws `EnforcementError`, which is meant to
14
+ * propagate and fail the install. If a swallow-guard is ever added here, it MUST
15
+ * rethrow `EnforcementError` (check `err instanceof EnforcementError` /
16
+ * `err.name === "EnforcementError"`) rather than fall back to the local config.
17
+ *
18
+ * @public
19
+ */
20
+ function createHooks(base, manifest, name) {
21
+ return { updateConfig(config) {
22
+ const ctx = { rootName: resolveRootName(config) };
23
+ const out = { ...config };
24
+ const allOverrides = [];
25
+ const allSecurity = [];
26
+ for (const [field, entry] of Object.entries(manifest)) {
27
+ const strategy = STRATEGY_TABLE[entry.strategy];
28
+ if (!strategy) continue;
29
+ const result = strategy(base[field], config[field], ctx);
30
+ let merged = result.merged;
31
+ const byRepo = entry.options?.excludeByRepo;
32
+ if (byRepo && Array.isArray(merged)) merged = excludeByRepo(merged, ctx, byRepo);
33
+ const named = result.divergences.map((d) => d.setting === "" ? {
34
+ ...d,
35
+ setting: field
36
+ } : d);
37
+ const { value, overrides, security } = applyEnforcement(field, {
38
+ merged,
39
+ divergences: named
40
+ }, entry.enforcement);
41
+ allOverrides.push(...overrides);
42
+ allSecurity.push(...security);
43
+ if (value !== void 0 && !(typeof value === "object" && value !== null && Object.keys(value).length === 0)) out[field] = value;
44
+ }
45
+ const ob = formatOverrideWarning(allOverrides, name);
46
+ if (ob) console.warn(ob);
47
+ const sb = formatSecurityWarning(allSecurity, name);
48
+ if (sb) console.warn(sb);
49
+ return out;
50
+ } };
51
+ }
52
+
53
+ //#endregion
54
+ export { createHooks };
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.58.9"
9
+ }
10
+ ]
11
+ }
package/virtual.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ // Ambient module declarations for the virtual modules served by PnpmConfigPlugin.
2
+ //
3
+ // Consumers opt into these types with a single reference directive in their build
4
+ // entry or a types/*.d.ts file:
5
+ //
6
+ // /// <reference types="rolldown-pnpm-config/virtual" />
7
+ //
8
+ // After that, imports from the virtual module paths type-check with no additional
9
+ // per-module boilerplate.
10
+
11
+ declare module "rolldown-pnpm-config/virtual/pnpmfile" {
12
+ import type { PnpmHooks } from "rolldown-pnpm-config/runtime";
13
+ export const hooks: PnpmHooks;
14
+ }
15
+
16
+ declare module "rolldown-pnpm-config/virtual/catalogs" {
17
+ export const catalogs: Map<string, Map<string, string>>;
18
+ }