@stll/oxlint-config 0.12.2 → 0.15.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 (88) hide show
  1. package/README.md +261 -1
  2. package/dist/cloud-setup-cli.cjs +6 -4
  3. package/dist/cloud-setup-cli.cjs.map +1 -1
  4. package/dist/cloud-setup-cli.mjs +3 -1
  5. package/dist/cloud-setup-cli.mjs.map +1 -1
  6. package/dist/compiler-packages.cjs +28 -0
  7. package/dist/compiler-packages.cjs.map +1 -0
  8. package/dist/compiler-packages.mjs +17 -0
  9. package/dist/compiler-packages.mjs.map +1 -0
  10. package/dist/consumer-compat-cli.cjs +1091 -0
  11. package/dist/consumer-compat-cli.cjs.map +1 -0
  12. package/dist/consumer-compat-cli.d.cts +1 -0
  13. package/dist/consumer-compat-cli.d.mts +1 -0
  14. package/dist/consumer-compat-cli.mjs +1089 -0
  15. package/dist/consumer-compat-cli.mjs.map +1 -0
  16. package/dist/index.cjs +50 -40
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +46 -41
  19. package/dist/index.d.mts +46 -41
  20. package/dist/index.mjs +50 -41
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/publish-build-target-nuxt-helper.cjs +71 -0
  23. package/dist/publish-build-target-nuxt-helper.cjs.map +1 -0
  24. package/dist/publish-build-target-nuxt-helper.d.cts +10 -0
  25. package/dist/publish-build-target-nuxt-helper.d.mts +10 -0
  26. package/dist/publish-build-target-nuxt-helper.mjs +68 -0
  27. package/dist/publish-build-target-nuxt-helper.mjs.map +1 -0
  28. package/dist/publish-build-target-vite-dts-helper.cjs +3 -0
  29. package/dist/publish-build-target-vite-dts-helper.d.cts +24 -0
  30. package/dist/publish-build-target-vite-dts-helper.d.mts +24 -0
  31. package/dist/publish-build-target-vite-dts-helper.mjs +2 -0
  32. package/dist/publish-build-target-vite-dts-helper2.cjs +372 -0
  33. package/dist/publish-build-target-vite-dts-helper2.cjs.map +1 -0
  34. package/dist/publish-build-target-vite-dts-helper2.mjs +359 -0
  35. package/dist/publish-build-target-vite-dts-helper2.mjs.map +1 -0
  36. package/dist/publish-contract-cli.cjs +983 -0
  37. package/dist/publish-contract-cli.cjs.map +1 -0
  38. package/dist/publish-contract-cli.d.cts +1 -0
  39. package/dist/publish-contract-cli.d.mts +1 -0
  40. package/dist/publish-contract-cli.mjs +981 -0
  41. package/dist/publish-contract-cli.mjs.map +1 -0
  42. package/dist/publish-contract.cjs +431 -0
  43. package/dist/publish-contract.cjs.map +1 -0
  44. package/dist/publish-contract.mjs +396 -0
  45. package/dist/publish-contract.mjs.map +1 -0
  46. package/dist/rolldown-runtime.cjs +28 -0
  47. package/dist/toolchain-changed-cli.cjs +34 -0
  48. package/dist/toolchain-changed-cli.cjs.map +1 -0
  49. package/dist/toolchain-changed-cli.d.cts +1 -0
  50. package/dist/toolchain-changed-cli.d.mts +1 -0
  51. package/dist/toolchain-changed-cli.mjs +34 -0
  52. package/dist/toolchain-changed-cli.mjs.map +1 -0
  53. package/dist/toolchain-changed.cjs +1470 -0
  54. package/dist/toolchain-changed.cjs.map +1 -0
  55. package/dist/toolchain-changed.mjs +1463 -0
  56. package/dist/toolchain-changed.mjs.map +1 -0
  57. package/dist/toolchain-check-cli.cjs +2 -1
  58. package/dist/toolchain-check-cli.cjs.map +1 -1
  59. package/dist/toolchain-check-cli.mjs +2 -1
  60. package/dist/toolchain-check-cli.mjs.map +1 -1
  61. package/dist/toolchain-guard.cjs +360 -1161
  62. package/dist/toolchain-guard.cjs.map +1 -1
  63. package/dist/toolchain-guard.mjs +338 -1100
  64. package/dist/toolchain-guard.mjs.map +1 -1
  65. package/dist/toolchain-inputs.cjs +926 -0
  66. package/dist/toolchain-inputs.cjs.map +1 -0
  67. package/dist/toolchain-inputs.mjs +816 -0
  68. package/dist/toolchain-inputs.mjs.map +1 -0
  69. package/dist/toolchain-schema.cjs +702 -0
  70. package/dist/toolchain-schema.cjs.map +1 -0
  71. package/dist/toolchain-schema.mjs +580 -0
  72. package/dist/toolchain-schema.mjs.map +1 -0
  73. package/dist/typecheck-parity-cli.cjs +38 -898
  74. package/dist/typecheck-parity-cli.cjs.map +1 -1
  75. package/dist/typecheck-parity-cli.mjs +39 -899
  76. package/dist/typecheck-parity-cli.mjs.map +1 -1
  77. package/dist/typecheck-parity.cjs +905 -0
  78. package/dist/typecheck-parity.cjs.map +1 -0
  79. package/dist/typecheck-parity.mjs +894 -0
  80. package/dist/typecheck-parity.mjs.map +1 -0
  81. package/dist/typecheck-probe-cli.cjs +176 -0
  82. package/dist/typecheck-probe-cli.cjs.map +1 -0
  83. package/dist/typecheck-probe-cli.d.cts +1 -0
  84. package/dist/typecheck-probe-cli.d.mts +1 -0
  85. package/dist/typecheck-probe-cli.mjs +174 -0
  86. package/dist/typecheck-probe-cli.mjs.map +1 -0
  87. package/package.json +43 -5
  88. package/toolchain.json +9 -1
@@ -0,0 +1,702 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime.cjs");
2
+ const require_toolchain_inputs = require("./toolchain-inputs.cjs");
3
+ let node_path = require("node:path");
4
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
5
+ let semver = require("semver");
6
+ let yaml = require("yaml");
7
+ let picomatch = require("picomatch");
8
+ picomatch = require_rolldown_runtime.__toESM(picomatch, 1);
9
+ let node_util = require("node:util");
10
+ //#region src/consumer-catalogs.ts
11
+ const record$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12
+ const catalogMapping = (value, field) => {
13
+ if (!record$1(value)) throw new Error(`${field} must be a mapping`);
14
+ const entries = /* @__PURE__ */ new Map();
15
+ for (const [name, specifier] of Object.entries(value)) {
16
+ if (name === "" || typeof specifier !== "string" || specifier.trim() === "") throw new Error(`${field} must contain nonempty package specifiers`);
17
+ entries.set(name, specifier);
18
+ }
19
+ return Object.fromEntries(entries);
20
+ };
21
+ const catalogState = (source, file) => {
22
+ const result = {};
23
+ if (Object.hasOwn(source, "catalog")) result.catalog = catalogMapping(source["catalog"], `${file}: catalog`);
24
+ if (Object.hasOwn(source, "catalogs")) {
25
+ if (!record$1(source["catalogs"])) throw new Error(`${file}: catalogs must be a mapping`);
26
+ const named = /* @__PURE__ */ new Map();
27
+ for (const [name, entries] of Object.entries(source["catalogs"])) {
28
+ if (name === "") throw new Error(`${file}: catalog names must be nonempty`);
29
+ named.set(name, catalogMapping(entries, `${file}: catalogs.${name}`));
30
+ }
31
+ result.catalogs = Object.fromEntries(named);
32
+ }
33
+ return result;
34
+ };
35
+ const bunCatalogState = (manifest) => {
36
+ const sources = [manifest];
37
+ if (record$1(manifest["workspaces"])) sources.push(manifest["workspaces"]);
38
+ const merged = {};
39
+ for (const source of sources) {
40
+ const state = catalogState(source, "package.json");
41
+ for (const [field, value] of Object.entries(state)) {
42
+ if (Object.hasOwn(merged, field) && !(0, node_util.isDeepStrictEqual)(merged[field], value)) throw new Error(`conflicting Bun ${field} definitions in package.json`);
43
+ merged[field] = value;
44
+ }
45
+ }
46
+ return catalogState(merged, "package.json");
47
+ };
48
+ const pnpmWorkspaceState = (source, file) => {
49
+ const document = (0, yaml.parseDocument)(source, { uniqueKeys: true });
50
+ if (document.errors.length !== 0) throw new Error(`invalid pnpm workspace: ${file}`);
51
+ const workspace = document.toJS({ maxAliasCount: 100 });
52
+ if (!record$1(workspace)) throw new Error(`invalid pnpm workspace: ${file}`);
53
+ const packages = workspace["packages"];
54
+ if (packages !== void 0 && (!Array.isArray(packages) || !packages.every((entry) => typeof entry === "string"))) throw new Error(`invalid pnpm workspace packages: ${file}`);
55
+ return {
56
+ packages: packages ?? [],
57
+ ...catalogState(workspace, file)
58
+ };
59
+ };
60
+ const resolveConsumerCatalog = ({ directory: inputDirectory, name, specifier, files }) => {
61
+ let directory = inputDirectory;
62
+ while (true) {
63
+ const yamlFile = node_path.default.posix.join(directory, "pnpm-workspace.yaml");
64
+ const yaml$1 = files[yamlFile];
65
+ const manifestFile = node_path.default.posix.join(directory, "package.json");
66
+ const json = files[manifestFile];
67
+ let state;
68
+ let patterns = [];
69
+ if (yaml$1 !== void 0) {
70
+ const workspace = pnpmWorkspaceState(yaml$1, yamlFile);
71
+ state = catalogState(workspace, yamlFile);
72
+ patterns = workspace.packages;
73
+ } else if (json !== void 0) {
74
+ const manifest = JSON.parse(json);
75
+ if (!record$1(manifest)) throw new Error(`invalid catalog owner: ${manifestFile}`);
76
+ const declaration = manifest["workspaces"];
77
+ if (directory === "." || declaration !== void 0) {
78
+ state = bunCatalogState(manifest);
79
+ const packages = record$1(declaration) ? declaration["packages"] : declaration;
80
+ if (packages !== void 0 && (!Array.isArray(packages) || !packages.every((entry) => typeof entry === "string"))) throw new Error(`invalid catalog owner packages: ${manifestFile}`);
81
+ patterns = packages ?? [];
82
+ }
83
+ }
84
+ if (state !== void 0) {
85
+ if (!require_toolchain_inputs.workspaceContains({
86
+ directory,
87
+ file: node_path.default.posix.join(inputDirectory, "package.json"),
88
+ patterns,
89
+ rootMembership: "implicit"
90
+ })) throw new Error(`catalog dependency ${name} is outside nearest workspace owner ${directory}`);
91
+ const catalogName = specifier.slice(8) || "default";
92
+ const named = state.catalogs;
93
+ const namedEntries = named !== void 0 && Object.hasOwn(named, catalogName) ? named[catalogName] : void 0;
94
+ const entries = catalogName === "default" ? state.catalog ?? namedEntries : namedEntries;
95
+ const resolved = entries !== void 0 && Object.hasOwn(entries, name) ? entries[name] : void 0;
96
+ if (resolved === void 0) throw new Error(`unresolved catalog dependency ${name} in workspace ${directory}`);
97
+ return resolved;
98
+ }
99
+ if (directory === ".") break;
100
+ directory = node_path.default.posix.dirname(directory);
101
+ }
102
+ throw new Error(`unresolved catalog dependency ${name}: no tracked workspace owner`);
103
+ };
104
+ //#endregion
105
+ //#region src/consumer-compat-config.ts
106
+ const consumerRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
107
+ const consumerRelativePath = (value, field) => {
108
+ if (typeof value !== "string" || value === "" || value.includes("\\") || value.includes("\0") || node_path.default.posix.isAbsolute(value) || value.split("/").some((part) => part === ".." || part === "")) throw new Error(`${field} must be a repository-relative path`);
109
+ return node_path.default.posix.normalize(value);
110
+ };
111
+ const command = (value, field) => {
112
+ if (!Array.isArray(value) || value.length === 0 || !value.every((part) => typeof part === "string" && part !== "" && !part.includes("\0"))) throw new Error(`${field} must be a nonempty command argument array`);
113
+ return value.map((part) => part);
114
+ };
115
+ const parseConsumerFixtures = (input) => {
116
+ if (!consumerRecord(input) || Object.keys(input).some((key) => key !== "packages") || !Array.isArray(input["packages"])) throw new Error("consumer fixtures must contain only a packages array");
117
+ const seen = /* @__PURE__ */ new Set();
118
+ return input["packages"].map((entry) => {
119
+ if (!consumerRecord(entry) || Object.keys(entry).some((key) => ![
120
+ "package",
121
+ "fixture",
122
+ "kind",
123
+ "build",
124
+ "smoke"
125
+ ].includes(key))) throw new Error("invalid consumer fixture declaration");
126
+ const packagePath = consumerRelativePath(entry["package"], "package");
127
+ const fixture = consumerRelativePath(entry["fixture"], "fixture");
128
+ const kind = entry["kind"];
129
+ if (kind !== "node" && kind !== "react") throw new Error("fixture kind must be node or react");
130
+ if (seen.has(packagePath)) throw new Error(`duplicate consumer fixture: ${packagePath}`);
131
+ seen.add(packagePath);
132
+ return {
133
+ package: packagePath,
134
+ fixture,
135
+ kind,
136
+ build: command(entry["build"], "build"),
137
+ smoke: command(entry["smoke"], "smoke")
138
+ };
139
+ });
140
+ };
141
+ const assertConsumerFixtureSelection = ({ selected, fixtures }) => {
142
+ const directories = selected.map((entry) => consumerRelativePath(entry, "selected package"));
143
+ const declared = new Set(fixtures.map((entry) => entry.package));
144
+ if (new Set(directories).size !== directories.length) throw new Error("duplicate selected consumer package");
145
+ if (directories.length !== declared.size || directories.some((entry) => !declared.has(entry))) throw new Error("selected consumer packages must exactly match declared fixtures");
146
+ };
147
+ const consumerBundledDependencyFields = ["bundleDependencies", "bundledDependencies"];
148
+ const consumerPackageNameValid = (value) => {
149
+ if (typeof value !== "string" || value.length === 0 || value.length > 214) return false;
150
+ const components = value.startsWith("@") ? value.slice(1).split("/") : [value];
151
+ if (value.startsWith("@") && components.length !== 2) return false;
152
+ if (!value.startsWith("@") && !/^[a-z0-9]/.test(value)) return false;
153
+ if (components.some((component) => !/^[a-z0-9._-]+$/.test(component) || component === "." || component === "..")) return false;
154
+ const packageName = components.at(-1);
155
+ return packageName !== "node_modules" && packageName !== "favicon.ico";
156
+ };
157
+ const assertConsumerPublishableManifest = ({ manifest, directory }) => {
158
+ const version = manifest["version"];
159
+ if (manifest["private"] !== true && (typeof version !== "string" || (0, semver.valid)(version) === null)) throw new Error(`public consumer package requires a semver-valid version: ${directory}`);
160
+ if (manifest["private"] !== true && !consumerPackageNameValid(manifest["name"])) throw new Error(`public consumer package requires a valid npm name: ${directory}`);
161
+ for (const field of consumerBundledDependencyFields) if (Object.hasOwn(manifest, field)) throw new Error(`consumer packaging does not support ${field}: ${directory}`);
162
+ };
163
+ const assertConsumerFixtureKind = ({ fixture, pkg }) => {
164
+ const peers = pkg.manifest["peerDependencies"];
165
+ if (peers !== void 0 && !consumerRecord(peers)) throw new Error(`invalid published peerDependencies: ${pkg.name}`);
166
+ const react = consumerRecord(peers) ? peers["react"] : void 0;
167
+ if (react !== void 0 && (typeof react !== "string" || react.trim() === "" || (0, semver.validRange)(react) === null)) throw new Error(`invalid published React peer: ${pkg.name}`);
168
+ const kind = react === void 0 ? "node" : "react";
169
+ if (fixture.kind !== kind) throw new Error(`${pkg.name} requires fixture kind ${kind} from its published peers`);
170
+ };
171
+ const consumerStagingPaths = (packages) => {
172
+ const paths = /* @__PURE__ */ new Map();
173
+ for (const [name, pkg] of packages) paths.set(name, consumerRelativePath(pkg.directory, "workspace package directory"));
174
+ return paths;
175
+ };
176
+ const consumerPackRootManifest = (packages, files) => {
177
+ const source = files["package.json"];
178
+ if (source !== void 0) {
179
+ const manifest = JSON.parse(source);
180
+ if (!consumerRecord(manifest)) throw new Error("root package manifest must be an object");
181
+ return manifest;
182
+ }
183
+ return [...packages.values()].find((pkg) => pkg.directory === ".")?.manifest ?? { private: true };
184
+ };
185
+ const consumerDependencyConfigFiles = [
186
+ ".npmrc",
187
+ ".pnpmfile.cjs",
188
+ "pnpm-workspace.yaml",
189
+ ".yarnrc",
190
+ ".yarnrc.yml"
191
+ ];
192
+ const assertConsumerFixtureManifest = (manifest) => {
193
+ for (const field of [
194
+ "pnpm",
195
+ "overrides",
196
+ "resolutions",
197
+ "workspaces",
198
+ "packageManager",
199
+ "allowScripts"
200
+ ]) if (manifest[field] !== void 0) throw new Error(`consumer fixture must not supply dependency-manager setting: ${field}`);
201
+ };
202
+ const bindConsumerManifest = ({ manifest, artifacts, typescript, react, manager }) => {
203
+ assertConsumerFixtureManifest(manifest);
204
+ const artifactBindings = Object.fromEntries([...artifacts].map(([name, file]) => [name, `file:${file}`]));
205
+ const owned = {
206
+ ...artifactBindings,
207
+ typescript,
208
+ ...react
209
+ };
210
+ const result = { ...manifest };
211
+ for (const field of [
212
+ "dependencies",
213
+ "devDependencies",
214
+ "optionalDependencies",
215
+ "peerDependencies"
216
+ ]) {
217
+ const entries = manifest[field];
218
+ if (entries === void 0) continue;
219
+ if (!consumerRecord(entries)) throw new Error(`fixture ${field} must be an object`);
220
+ for (const specifier of Object.values(entries)) if (typeof specifier !== "string" || /^(?:workspace:|file:|link:|\.\.?\/|\/)/.test(specifier)) throw new Error("fixture dependencies must resolve from registry or generated artifact bindings");
221
+ result[field] = Object.fromEntries(Object.entries(entries).filter(([name]) => !Object.hasOwn(owned, name)));
222
+ }
223
+ result["dependencies"] = {
224
+ ...consumerRecord(result["dependencies"]) ? result["dependencies"] : {},
225
+ ...artifactBindings,
226
+ ...react
227
+ };
228
+ result["devDependencies"] = {
229
+ ...consumerRecord(result["devDependencies"]) ? result["devDependencies"] : {},
230
+ typescript
231
+ };
232
+ if (manager === "npm") {
233
+ result["overrides"] = owned;
234
+ return {
235
+ manager,
236
+ manifest: result
237
+ };
238
+ }
239
+ return {
240
+ manager,
241
+ manifest: result,
242
+ workspace: {
243
+ packages: ["."],
244
+ overrides: owned
245
+ }
246
+ };
247
+ };
248
+ const workspacePatterns = (manifest) => {
249
+ const workspace = manifest["workspaces"];
250
+ const patterns = consumerRecord(workspace) ? workspace["packages"] : workspace;
251
+ if (patterns === void 0) return [];
252
+ if (!Array.isArray(patterns) || !patterns.every((entry) => typeof entry === "string")) throw new Error("package workspaces must be string patterns");
253
+ return patterns.map((entry) => entry);
254
+ };
255
+ const discoverConsumerManifests = (files) => {
256
+ const manifests = /* @__PURE__ */ new Map();
257
+ const manifestSources = /* @__PURE__ */ new Map();
258
+ const pnpmSources = /* @__PURE__ */ new Map();
259
+ const pnpmWorkspaces = /* @__PURE__ */ new Map();
260
+ for (const [file, content] of Object.entries(files)) if (node_path.default.posix.basename(file) === "pnpm-workspace.yaml") pnpmSources.set(node_path.default.posix.dirname(file), content);
261
+ else if (node_path.default.posix.basename(file) === "package.json") manifestSources.set(node_path.default.posix.dirname(file), content);
262
+ const assertWorkspaceOwner = (directory) => {
263
+ if (pnpmSources.has(directory) && !manifestSources.has(directory)) throw new Error(`consumer pnpm workspace requires an adjacent tracked package.json: ${node_path.default.posix.join(directory, "pnpm-workspace.yaml")}`);
264
+ };
265
+ const candidates = /* @__PURE__ */ new Set([...manifestSources.keys(), ...pnpmSources.keys()]);
266
+ const manifestAt = (directory) => {
267
+ const cached = manifests.get(directory);
268
+ if (cached) return cached;
269
+ const source = manifestSources.get(directory);
270
+ if (source === void 0) return void 0;
271
+ const json = JSON.parse(source);
272
+ if (!consumerRecord(json)) throw new Error(`invalid package manifest: ${directory}/package.json`);
273
+ manifests.set(directory, json);
274
+ return json;
275
+ };
276
+ const patternsAt = (directory, manifest) => {
277
+ const source = pnpmSources.get(directory);
278
+ if (source !== void 0 && !pnpmWorkspaces.has(directory)) {
279
+ const file = `${directory}/pnpm-workspace.yaml`;
280
+ const document = (0, yaml.parseDocument)(source, { uniqueKeys: true });
281
+ if (document.errors.length) throw new Error(`invalid pnpm workspace: ${file}`);
282
+ const json = document.toJS({ maxAliasCount: 100 });
283
+ if (!consumerRecord(json)) throw new Error(`invalid pnpm workspace: ${file}`);
284
+ const patterns = json["packages"] ?? [];
285
+ if (!Array.isArray(patterns) || !patterns.every((entry) => typeof entry === "string")) throw new Error(`invalid pnpm workspace packages: ${file}`);
286
+ pnpmWorkspaces.set(directory, patterns.map((entry) => entry));
287
+ }
288
+ return pnpmWorkspaces.get(directory) ?? workspacePatterns(manifest ?? {});
289
+ };
290
+ const roots = /* @__PURE__ */ new Set(["."]);
291
+ for (;;) {
292
+ const before = roots.size;
293
+ for (const directory of roots) {
294
+ assertWorkspaceOwner(directory);
295
+ const patterns = patternsAt(directory, manifestAt(directory));
296
+ for (const candidate of candidates) {
297
+ const relative = node_path.default.posix.relative(directory, candidate);
298
+ if (relative === "" || relative.startsWith("../")) continue;
299
+ const positives = patterns.filter((pattern) => !pattern.startsWith("!"));
300
+ const negatives = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
301
+ if (positives.some((pattern) => picomatch.default.isMatch(relative, pattern)) && !negatives.some((pattern) => picomatch.default.isMatch(relative, pattern))) roots.add(candidate);
302
+ }
303
+ }
304
+ if (before === roots.size) break;
305
+ }
306
+ const discovered = /* @__PURE__ */ new Map();
307
+ for (const directory of roots) {
308
+ for (let owner = directory;; owner = node_path.default.posix.dirname(owner)) {
309
+ assertWorkspaceOwner(owner);
310
+ if (owner === ".") break;
311
+ }
312
+ const manifest = manifestAt(directory);
313
+ if (manifest) discovered.set(directory, manifest);
314
+ }
315
+ return discovered;
316
+ };
317
+ const discoverConsumerPackages = (files) => {
318
+ const packages = /* @__PURE__ */ new Map();
319
+ for (const [directory, manifest] of discoverConsumerManifests(files)) {
320
+ const name = manifest["name"];
321
+ if (typeof name !== "string" || name === "") continue;
322
+ if (packages.has(name)) throw new Error(`duplicate workspace package: ${name}`);
323
+ packages.set(name, {
324
+ directory,
325
+ name,
326
+ manifest
327
+ });
328
+ }
329
+ return packages;
330
+ };
331
+ const consumerPublishedDependencyFields = [
332
+ "dependencies",
333
+ "optionalDependencies",
334
+ "peerDependencies"
335
+ ];
336
+ const consumerPackageClosure = ({ selected, packages, files }) => {
337
+ const closure = /* @__PURE__ */ new Map();
338
+ const visit = (pkg) => {
339
+ if (closure.has(pkg.name)) return;
340
+ assertConsumerPublishableManifest(pkg);
341
+ closure.set(pkg.name, pkg);
342
+ for (const field of consumerPublishedDependencyFields) {
343
+ const dependencies = pkg.manifest[field];
344
+ if (!consumerRecord(dependencies)) continue;
345
+ for (const [name, specifier] of Object.entries(dependencies)) {
346
+ const local = packages.get(name);
347
+ if (typeof specifier !== "string") throw new Error(`invalid package dependency: ${pkg.name} -> ${name}`);
348
+ if (specifier.startsWith("catalog:") && local !== void 0) {
349
+ const resolved = resolveConsumerCatalog({
350
+ directory: pkg.directory,
351
+ name,
352
+ specifier,
353
+ files
354
+ });
355
+ const version = local.manifest["version"];
356
+ if (resolved.startsWith("workspace:") || typeof version === "string" && (0, semver.validRange)(resolved) !== null && (0, semver.satisfies)(version, resolved)) throw new Error(`catalog dependency ${name} resolves to workspace package ${local.name}; use workspace:`);
357
+ }
358
+ if (/^workspace:(?:@[^/@]+\/)?[^/@]+@/.test(specifier)) throw new Error(`workspace alias specifiers are not supported by consumer-compat: ${name} -> ${specifier}; use the package name as the dependency key`);
359
+ if (/^(?:file:|link:)/.test(specifier)) throw new Error(`published local dependencies must use workspace protocol: ${pkg.name} -> ${name}`);
360
+ if (local && (specifier.startsWith("workspace:") || typeof local.manifest["version"] === "string" && (0, semver.validRange)(specifier) && (0, semver.satisfies)(local.manifest["version"], specifier))) {
361
+ if (local.manifest["private"] === true) throw new Error(`published package depends on private workspace package: ${pkg.name} -> ${name}`);
362
+ visit(local);
363
+ } else if (typeof specifier === "string" && specifier.startsWith("workspace:")) throw new Error(`unresolved workspace dependency: ${pkg.name} -> ${name}`);
364
+ }
365
+ }
366
+ };
367
+ visit(selected);
368
+ return closure;
369
+ };
370
+ //#endregion
371
+ //#region src/consumer-node-support.ts
372
+ const consumerNodeSupportMatches = ({ range, node }) => range === void 0 || typeof range === "string" && range.trim() !== "" && (0, semver.validRange)(range) !== null && (0, semver.satisfies)(node, range);
373
+ const assertConsumerNodeSupport = ({ manifest, node, label }) => {
374
+ const engines = manifest["engines"];
375
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
376
+ if (engines !== void 0 && !record(engines) || !consumerNodeSupportMatches({
377
+ range: record(engines) ? engines["node"] : void 0,
378
+ node
379
+ })) throw new Error(`${label} engines.node must support consumer Node ${node}`);
380
+ };
381
+ //#endregion
382
+ //#region src/toolchain-schema.ts
383
+ const packagePinKeys = [
384
+ "oxlint",
385
+ "oxlint-tsgolint",
386
+ "@oxlint/plugins",
387
+ "@stll/oxlint-plugin",
388
+ "oxfmt",
389
+ "lefthook"
390
+ ];
391
+ const valkeyArchitectures = ["amd64", "arm64"];
392
+ const valkeyArtifactPackages = {
393
+ server: "valkey-server",
394
+ tools: "valkey-tools"
395
+ };
396
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
397
+ const artifactRecord = (value, keys) => {
398
+ if (!record(value) || Object.keys(value).some((key) => !keys.includes(key)) || keys.some((key) => !Object.hasOwn(value, key))) throw new Error("valkeyArtifacts requires complete, closed artifact objects");
399
+ return value;
400
+ };
401
+ const parseValkeyArtifacts = (input, version) => {
402
+ const architectures = artifactRecord(input, valkeyArchitectures);
403
+ const line = version.split(".").slice(0, 2).join(".");
404
+ const parseArchitecture = (architecture) => {
405
+ const packages = artifactRecord(architectures[architecture], Object.keys(valkeyArtifactPackages));
406
+ const parseArtifact = (kind) => {
407
+ const artifact = artifactRecord(packages[kind], ["url", "sha256"]);
408
+ const url = artifact["url"];
409
+ const sha256 = artifact["sha256"];
410
+ const expected = `https://download.valkey.io/packaging/valkey-${line}/deb/ubuntu2404/${architecture}/${valkeyArtifactPackages[kind]}_${version}-1.noble_${architecture}.deb`;
411
+ if (typeof url !== "string" || url !== expected) throw new Error("valkeyArtifacts URL must select the exact official versioned Ubuntu artifact");
412
+ if (typeof sha256 !== "string" || !/^[a-f0-9]{64}$/.test(sha256)) throw new Error("valkeyArtifacts requires a lowercase SHA256 pin");
413
+ return {
414
+ url,
415
+ sha256
416
+ };
417
+ };
418
+ return {
419
+ server: parseArtifact("server"),
420
+ tools: parseArtifact("tools")
421
+ };
422
+ };
423
+ return {
424
+ amd64: parseArchitecture("amd64"),
425
+ arm64: parseArchitecture("arm64")
426
+ };
427
+ };
428
+ /** Reject unsupported or incomplete installed policies before inspecting a consumer. */
429
+ const parseToolchainPolicy = (input) => {
430
+ if (!record(input) || input["schemaVersion"] !== 1) throw new Error("toolchain.json must use schemaVersion 1");
431
+ const string = (object, key) => {
432
+ const value = object[key];
433
+ if (typeof value !== "string" || value.trim() === "") throw new Error(`toolchain.json requires a nonempty ${key}`);
434
+ return value;
435
+ };
436
+ const packages = {};
437
+ for (const key of packagePinKeys) packages[key] = string(input, key);
438
+ const bun = string(input, "bun");
439
+ const typescript = string(input, "typescript");
440
+ const node = string(input, "node");
441
+ const consumerNode = string(input, "consumerNode");
442
+ const consumerNpm = string(input, "consumerNpm");
443
+ const consumerPnpm = string(input, "consumerPnpm");
444
+ const consumerTypescript = string(input, "consumerTypescript");
445
+ const python = string(input, "python");
446
+ const postgres = string(input, "postgres");
447
+ const valkey = string(input, "valkey");
448
+ const rust = string(input, "rust");
449
+ const rustCompilerDevelopment = string(input, "rustCompilerDevelopment");
450
+ for (const [name, value] of Object.entries({
451
+ ...packages,
452
+ bun,
453
+ typescript,
454
+ consumerNpm,
455
+ consumerPnpm,
456
+ consumerTypescript
457
+ })) if ((0, semver.valid)(value) !== value) throw new Error(`toolchain.json ${name} must be an exact release`);
458
+ if (!/^[1-9]\d*$/.test(postgres) || !Number.isSafeInteger(Number(postgres))) throw new Error("PostgreSQL must be a canonical positive major");
459
+ if ((0, semver.valid)(valkey) !== valkey || !/^\d+\.\d+\.\d+$/.test(valkey)) throw new Error("Valkey must be an exact stable release");
460
+ const valkeyArtifacts = parseValkeyArtifacts(input["valkeyArtifacts"], valkey);
461
+ if (!require_toolchain_inputs.nodePolicyValid(node)) throw new Error("Node must be a canonical major N.x series");
462
+ if ((0, semver.valid)(consumerNode) !== consumerNode || !consumerNode.startsWith("22.") || consumerNode.includes("-") || consumerNode.includes("+")) throw new Error("consumerNode must be an exact stable Node 22 release");
463
+ if (!/^\d+\.\d+(?:\.\d+)?$/.test(python)) throw new Error("Python must be an exact minor or patch release");
464
+ if (!/^\d+\.\d+\.\d+$/.test(rust)) throw new Error("Rust must be an exact stable release");
465
+ if (!/^nightly-\d{4}-\d{2}-\d{2}$/.test(rustCompilerDevelopment)) throw new Error("Rust compiler development must be a dated nightly");
466
+ if (!consumerTypescript.startsWith("6.") || consumerTypescript.includes("-") || consumerTypescript.includes("+")) throw new Error("consumerTypescript must be an exact stable TypeScript 6 release");
467
+ const compatibility = input["typescript6Compatibility"];
468
+ if (!record(compatibility)) throw new Error("missing TypeScript compatibility policy");
469
+ const version = string(compatibility, "version");
470
+ const packageAlias = string(compatibility, "packageAlias");
471
+ if ((0, semver.valid)(version) !== version) throw new Error("TypeScript compatibility must be an exact release");
472
+ const layouts = input["typescriptInstallLayouts"];
473
+ if (!Array.isArray(layouts) || layouts.length === 0) throw new Error("missing TypeScript install layouts");
474
+ const typescriptInstallLayouts = layouts.map((layout) => {
475
+ if (!record(layout)) throw new Error("invalid TypeScript install layout");
476
+ const compilerPackage = string(layout, "compilerPackage");
477
+ const compilerSpecifier = string(layout, "compilerSpecifier");
478
+ const typecheckCommand = string(layout, "typecheckCommand");
479
+ switch (layout["type"]) {
480
+ case "direct":
481
+ if (compilerSpecifier !== typescript || compilerPackage !== "typescript") throw new Error("direct TypeScript layout differs from shared version");
482
+ return {
483
+ type: "direct",
484
+ compilerPackage,
485
+ compilerSpecifier,
486
+ typecheckCommand
487
+ };
488
+ case "split-compatibility": {
489
+ const compatibilityPackage = string(layout, "compatibilityPackage");
490
+ const compatibilitySpecifier = string(layout, "compatibilitySpecifier");
491
+ if (compilerSpecifier !== `npm:typescript@${typescript}` || compatibilitySpecifier !== version) throw new Error("split TypeScript layout differs from shared versions");
492
+ return {
493
+ type: "split-compatibility",
494
+ compilerPackage,
495
+ compilerSpecifier,
496
+ compatibilityPackage,
497
+ compatibilitySpecifier,
498
+ typecheckCommand
499
+ };
500
+ }
501
+ default: throw new Error("unsupported TypeScript install layout");
502
+ }
503
+ });
504
+ const actionsInput = input["actions"];
505
+ if (!record(actionsInput) || Object.keys(actionsInput).length === 0) throw new Error("missing approved actions");
506
+ const actions = {};
507
+ for (const [name, action] of Object.entries(actionsInput)) {
508
+ if (!record(action)) throw new Error(`invalid action policy: ${name}`);
509
+ const sha = string(action, "sha");
510
+ const actionVersion = string(action, "version");
511
+ if (!/^[a-f0-9]{40}$/.test(sha) || !/^v\d+(?:\.\d+)*$/.test(actionVersion)) throw new Error(`invalid action SHA/version: ${name}`);
512
+ actions[name] = {
513
+ sha,
514
+ version: actionVersion
515
+ };
516
+ }
517
+ const dependabotInput = input["dependabot"];
518
+ if (!record(dependabotInput) || !record(dependabotInput["schedule"]) || !record(dependabotInput["cooldown"]) || !record(dependabotInput["groups"])) throw new Error("missing Dependabot policy");
519
+ const scheduleInput = dependabotInput["schedule"];
520
+ const schedule = {
521
+ interval: string(scheduleInput, "interval"),
522
+ day: string(scheduleInput, "day"),
523
+ time: string(scheduleInput, "time"),
524
+ timezone: string(scheduleInput, "timezone")
525
+ };
526
+ const defaultDays = dependabotInput["cooldown"]["defaultDays"];
527
+ if (typeof defaultDays !== "number" || !Number.isInteger(defaultDays) || defaultDays < 5) throw new Error("Dependabot cooldown must be at least five days");
528
+ const strings = (value) => {
529
+ if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) throw new Error("Dependabot group values must be string arrays");
530
+ return value;
531
+ };
532
+ const groups = {};
533
+ for (const [name, group] of Object.entries(dependabotInput["groups"])) {
534
+ if (!record(group)) throw new Error(`invalid Dependabot group: ${name}`);
535
+ groups[name] = {
536
+ patterns: strings(group["patterns"]),
537
+ updateTypes: strings(group["updateTypes"])
538
+ };
539
+ }
540
+ return {
541
+ bun,
542
+ typescript,
543
+ node,
544
+ postgres,
545
+ valkey,
546
+ valkeyArtifacts,
547
+ consumerNode,
548
+ consumerNpm,
549
+ consumerPnpm,
550
+ consumerTypescript,
551
+ python,
552
+ rust,
553
+ rustCompilerDevelopment,
554
+ packages,
555
+ actions,
556
+ typescriptInstallLayouts,
557
+ typescript6Compatibility: {
558
+ version,
559
+ packageAlias
560
+ },
561
+ dependabot: {
562
+ schedule,
563
+ cooldown: { defaultDays },
564
+ groups,
565
+ ignoredPackages: [.../* @__PURE__ */ new Set([
566
+ ...Object.keys(packages),
567
+ ...typescriptInstallLayouts.flatMap((layout) => layout.type === "direct" ? [layout.compilerPackage] : [layout.compilerPackage, layout.compatibilityPackage]),
568
+ packageAlias,
569
+ "bun-types"
570
+ ])],
571
+ ignoredActions: Object.keys(actions),
572
+ ignoredImages: [
573
+ "node",
574
+ "python",
575
+ "oven/bun"
576
+ ]
577
+ }
578
+ };
579
+ };
580
+ //#endregion
581
+ Object.defineProperty(exports, "assertConsumerFixtureKind", {
582
+ enumerable: true,
583
+ get: function() {
584
+ return assertConsumerFixtureKind;
585
+ }
586
+ });
587
+ Object.defineProperty(exports, "assertConsumerFixtureManifest", {
588
+ enumerable: true,
589
+ get: function() {
590
+ return assertConsumerFixtureManifest;
591
+ }
592
+ });
593
+ Object.defineProperty(exports, "assertConsumerFixtureSelection", {
594
+ enumerable: true,
595
+ get: function() {
596
+ return assertConsumerFixtureSelection;
597
+ }
598
+ });
599
+ Object.defineProperty(exports, "assertConsumerNodeSupport", {
600
+ enumerable: true,
601
+ get: function() {
602
+ return assertConsumerNodeSupport;
603
+ }
604
+ });
605
+ Object.defineProperty(exports, "assertConsumerPublishableManifest", {
606
+ enumerable: true,
607
+ get: function() {
608
+ return assertConsumerPublishableManifest;
609
+ }
610
+ });
611
+ Object.defineProperty(exports, "bindConsumerManifest", {
612
+ enumerable: true,
613
+ get: function() {
614
+ return bindConsumerManifest;
615
+ }
616
+ });
617
+ Object.defineProperty(exports, "bunCatalogState", {
618
+ enumerable: true,
619
+ get: function() {
620
+ return bunCatalogState;
621
+ }
622
+ });
623
+ Object.defineProperty(exports, "catalogState", {
624
+ enumerable: true,
625
+ get: function() {
626
+ return catalogState;
627
+ }
628
+ });
629
+ Object.defineProperty(exports, "consumerDependencyConfigFiles", {
630
+ enumerable: true,
631
+ get: function() {
632
+ return consumerDependencyConfigFiles;
633
+ }
634
+ });
635
+ Object.defineProperty(exports, "consumerNodeSupportMatches", {
636
+ enumerable: true,
637
+ get: function() {
638
+ return consumerNodeSupportMatches;
639
+ }
640
+ });
641
+ Object.defineProperty(exports, "consumerPackRootManifest", {
642
+ enumerable: true,
643
+ get: function() {
644
+ return consumerPackRootManifest;
645
+ }
646
+ });
647
+ Object.defineProperty(exports, "consumerPackageClosure", {
648
+ enumerable: true,
649
+ get: function() {
650
+ return consumerPackageClosure;
651
+ }
652
+ });
653
+ Object.defineProperty(exports, "consumerRecord", {
654
+ enumerable: true,
655
+ get: function() {
656
+ return consumerRecord;
657
+ }
658
+ });
659
+ Object.defineProperty(exports, "consumerRelativePath", {
660
+ enumerable: true,
661
+ get: function() {
662
+ return consumerRelativePath;
663
+ }
664
+ });
665
+ Object.defineProperty(exports, "consumerStagingPaths", {
666
+ enumerable: true,
667
+ get: function() {
668
+ return consumerStagingPaths;
669
+ }
670
+ });
671
+ Object.defineProperty(exports, "discoverConsumerManifests", {
672
+ enumerable: true,
673
+ get: function() {
674
+ return discoverConsumerManifests;
675
+ }
676
+ });
677
+ Object.defineProperty(exports, "discoverConsumerPackages", {
678
+ enumerable: true,
679
+ get: function() {
680
+ return discoverConsumerPackages;
681
+ }
682
+ });
683
+ Object.defineProperty(exports, "parseConsumerFixtures", {
684
+ enumerable: true,
685
+ get: function() {
686
+ return parseConsumerFixtures;
687
+ }
688
+ });
689
+ Object.defineProperty(exports, "parseToolchainPolicy", {
690
+ enumerable: true,
691
+ get: function() {
692
+ return parseToolchainPolicy;
693
+ }
694
+ });
695
+ Object.defineProperty(exports, "pnpmWorkspaceState", {
696
+ enumerable: true,
697
+ get: function() {
698
+ return pnpmWorkspaceState;
699
+ }
700
+ });
701
+
702
+ //# sourceMappingURL=toolchain-schema.cjs.map