@stll/oxlint-config 1.3.1 → 1.4.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/README.md +254 -17
- package/dist/cloud-setup-cli.cjs +18 -38
- package/dist/cloud-setup-cli.cjs.map +1 -1
- package/dist/cloud-setup-cli.mjs +21 -41
- package/dist/cloud-setup-cli.mjs.map +1 -1
- package/dist/consumer-compat-cli.cjs +50 -249
- package/dist/consumer-compat-cli.cjs.map +1 -1
- package/dist/consumer-compat-cli.mjs +6 -205
- package/dist/consumer-compat-cli.mjs.map +1 -1
- package/dist/consumer-node-support.cjs +497 -0
- package/dist/consumer-node-support.cjs.map +1 -0
- package/dist/consumer-node-support.mjs +381 -0
- package/dist/consumer-node-support.mjs.map +1 -0
- package/dist/dependabot-cli.cjs +67 -0
- package/dist/dependabot-cli.cjs.map +1 -0
- package/dist/dependabot-cli.d.cts +1 -0
- package/dist/dependabot-cli.d.mts +1 -0
- package/dist/dependabot-cli.mjs +67 -0
- package/dist/dependabot-cli.mjs.map +1 -0
- package/dist/dependabot.cjs +5 -0
- package/dist/dependabot.d.cts +108 -0
- package/dist/dependabot.d.mts +108 -0
- package/dist/dependabot.mjs +3 -0
- package/dist/generated-file.cjs +61 -0
- package/dist/generated-file.cjs.map +1 -0
- package/dist/generated-file.mjs +44 -0
- package/dist/generated-file.mjs.map +1 -0
- package/dist/publish-artifact-syntax.cjs +1309 -0
- package/dist/publish-artifact-syntax.cjs.map +1 -0
- package/dist/publish-artifact-syntax.mjs +1265 -0
- package/dist/publish-artifact-syntax.mjs.map +1 -0
- package/dist/publish-contract-cli.cjs +53 -12
- package/dist/publish-contract-cli.cjs.map +1 -1
- package/dist/publish-contract-cli.mjs +49 -8
- package/dist/publish-contract-cli.mjs.map +1 -1
- package/dist/toolchain-changed.cjs +5 -1
- package/dist/toolchain-changed.cjs.map +1 -1
- package/dist/toolchain-changed.mjs +6 -2
- package/dist/toolchain-changed.mjs.map +1 -1
- package/dist/toolchain-dependabot.cjs +455 -0
- package/dist/toolchain-dependabot.cjs.map +1 -0
- package/dist/toolchain-dependabot.mjs +423 -0
- package/dist/toolchain-dependabot.mjs.map +1 -0
- package/dist/toolchain-guard.cjs +1096 -424
- package/dist/toolchain-guard.cjs.map +1 -1
- package/dist/toolchain-guard.mjs +1085 -413
- package/dist/toolchain-guard.mjs.map +1 -1
- package/dist/toolchain-inputs.cjs +113 -21
- package/dist/toolchain-inputs.cjs.map +1 -1
- package/dist/toolchain-inputs.mjs +108 -22
- package/dist/toolchain-inputs.mjs.map +1 -1
- package/dist/toolchain-schema.cjs +0 -493
- package/dist/toolchain-schema.cjs.map +1 -1
- package/dist/toolchain-schema.mjs +3 -379
- package/dist/toolchain-schema.mjs.map +1 -1
- package/dist/typecheck-parity.cjs +1 -1
- package/dist/typecheck-probe-cli.cjs +1 -1
- package/dist/typecheck-probe-cli.cjs.map +1 -1
- package/dist/typecheck-probe-cli.mjs +1 -1
- package/dist/typecheck-probe-cli.mjs.map +1 -1
- package/package.json +13 -1
- package/dist/publish-contract.cjs +0 -431
- package/dist/publish-contract.cjs.map +0 -1
- package/dist/publish-contract.mjs +0 -396
- package/dist/publish-contract.mjs.map +0 -1
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_rolldown_runtime = require("./rolldown-runtime.cjs");
|
|
4
|
+
const require_consumer_node_support = require("./consumer-node-support.cjs");
|
|
4
5
|
const require_toolchain_schema = require("./toolchain-schema.cjs");
|
|
5
|
-
const
|
|
6
|
+
const require_publish_artifact_syntax = require("./publish-artifact-syntax.cjs");
|
|
6
7
|
let node_child_process = require("node:child_process");
|
|
7
8
|
let node_path = require("node:path");
|
|
8
9
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
9
10
|
let node_crypto = require("node:crypto");
|
|
10
11
|
let semver = require("semver");
|
|
11
|
-
let node_util = require("node:util");
|
|
12
12
|
let yaml = require("yaml");
|
|
13
13
|
let node_os = require("node:os");
|
|
14
14
|
let node_fs_promises = require("node:fs/promises");
|
|
15
|
-
let node_module = require("node:module");
|
|
16
|
-
let acorn = require("acorn");
|
|
17
15
|
//#region src/consumer-build-approvals.ts
|
|
18
16
|
const consumerBuildApprovals = async ({ manifest, lock, manager, directory }) => {
|
|
19
|
-
if (!
|
|
17
|
+
if (!require_consumer_node_support.consumerRecord(lock)) throw new Error("invalid consumer dependency lock");
|
|
20
18
|
const approvals = {};
|
|
21
19
|
const rebuildTargets = /* @__PURE__ */ new Set();
|
|
22
20
|
for (const field of [
|
|
@@ -26,16 +24,16 @@ const consumerBuildApprovals = async ({ manifest, lock, manager, directory }) =>
|
|
|
26
24
|
]) {
|
|
27
25
|
const entries = manifest[field];
|
|
28
26
|
if (entries === void 0) continue;
|
|
29
|
-
if (!
|
|
27
|
+
if (!require_consumer_node_support.consumerRecord(entries)) throw new Error(`invalid fixture ${field}`);
|
|
30
28
|
for (const key of Object.keys(entries)) {
|
|
31
29
|
const packages = lock["packages"];
|
|
32
30
|
const importers = lock["importers"];
|
|
33
|
-
const importer =
|
|
34
|
-
const dependencies =
|
|
31
|
+
const importer = require_consumer_node_support.consumerRecord(importers) ? importers["."] : void 0;
|
|
32
|
+
const dependencies = require_consumer_node_support.consumerRecord(importer) ? importer[field] : void 0;
|
|
35
33
|
const dependencyTable = manager === "npm" ? packages : dependencies;
|
|
36
34
|
const installedKey = manager === "npm" ? `node_modules/${key}` : key;
|
|
37
|
-
const dependency =
|
|
38
|
-
if (!
|
|
35
|
+
const dependency = require_consumer_node_support.consumerRecord(dependencyTable) ? dependencyTable[installedKey] : void 0;
|
|
36
|
+
if (!require_consumer_node_support.consumerRecord(dependency)) {
|
|
39
37
|
if (field === "optionalDependencies") continue;
|
|
40
38
|
throw new Error(`missing resolved fixture dependency identity: ${key}`);
|
|
41
39
|
}
|
|
@@ -47,7 +45,7 @@ const consumerBuildApprovals = async ({ manifest, lock, manager, directory }) =>
|
|
|
47
45
|
throw error;
|
|
48
46
|
}
|
|
49
47
|
const installed = JSON.parse(await (0, node_fs_promises.readFile)(node_path.default.join(installedDirectory, "package.json"), "utf8"));
|
|
50
|
-
if (!
|
|
48
|
+
if (!require_consumer_node_support.consumerRecord(installed) || typeof installed["name"] !== "string" || installed["name"] === "" || typeof installed["version"] !== "string" || (0, semver.valid)(installed["version"]) === null) throw new Error(`invalid installed fixture dependency identity: ${key}`);
|
|
51
49
|
const identity = `${installed["name"]}@${installed["version"]}`;
|
|
52
50
|
rebuildTargets.add(await (0, node_fs_promises.realpath)(installedDirectory));
|
|
53
51
|
const resolved = dependency["resolved"];
|
|
@@ -113,7 +111,7 @@ const assertConsumerInstalledToolBins = async (directory) => {
|
|
|
113
111
|
};
|
|
114
112
|
//#endregion
|
|
115
113
|
//#region src/consumer-react.ts
|
|
116
|
-
const record
|
|
114
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
117
115
|
const publishedVersions = ({ versions, range }) => {
|
|
118
116
|
if (!(0, semver.validRange)(range)) throw new Error(`invalid consumer peer range: ${range}`);
|
|
119
117
|
const candidates = Object.keys(versions).filter((version) => (0, semver.valid)(version) !== null && (0, semver.satisfies)(version, range)).sort(semver.compare);
|
|
@@ -139,7 +137,7 @@ const selectConsumerReactVersions = ({ reactRange, reactVersions, dom }) => {
|
|
|
139
137
|
for (const react of reactCandidates) {
|
|
140
138
|
const renderer = domCandidates.find((version) => {
|
|
141
139
|
const metadata = dom.versions[version];
|
|
142
|
-
if (!record
|
|
140
|
+
if (!record(metadata) || !record(metadata["peerDependencies"])) return false;
|
|
143
141
|
const range = metadata["peerDependencies"]["react"];
|
|
144
142
|
return typeof range === "string" && (0, semver.validRange)(range) !== null && (0, semver.satisfies)(react, range);
|
|
145
143
|
});
|
|
@@ -151,203 +149,6 @@ const selectConsumerReactVersions = ({ reactRange, reactVersions, dom }) => {
|
|
|
151
149
|
throw new Error(`no published React/ReactDOM pair satisfies React ${reactRange} and ReactDOM ${domRange}`);
|
|
152
150
|
};
|
|
153
151
|
//#endregion
|
|
154
|
-
//#region src/publish-artifact-syntax.ts
|
|
155
|
-
const command = (0, node_util.promisify)(node_child_process.execFile);
|
|
156
|
-
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157
|
-
const javascript = /\.(?:js|mjs|cjs)$/i;
|
|
158
|
-
const syntaxYears = new Map(Object.entries({
|
|
159
|
-
es5: 5,
|
|
160
|
-
es2015: 2015,
|
|
161
|
-
es2016: 2016,
|
|
162
|
-
es2017: 2017,
|
|
163
|
-
es2018: 2018,
|
|
164
|
-
es2019: 2019,
|
|
165
|
-
es2020: 2020,
|
|
166
|
-
es2021: 2021,
|
|
167
|
-
es2022: 2022,
|
|
168
|
-
es2023: 2023,
|
|
169
|
-
es2024: 2024,
|
|
170
|
-
es2025: 2025
|
|
171
|
-
}));
|
|
172
|
-
/** Explicit ECMAScript targets bound syntax; unbounded targets use native Node. */
|
|
173
|
-
const artifactEcmaVersion = ({ target, node }) => {
|
|
174
|
-
if (target.type === "types-only") return "latest";
|
|
175
|
-
if (target.targets.length === 0) throw new Error("Packed JavaScript requires a declared target");
|
|
176
|
-
let version = "latest";
|
|
177
|
-
for (const identifier of target.targets) {
|
|
178
|
-
if (identifier === "esnext") continue;
|
|
179
|
-
const year = syntaxYears.get(identifier);
|
|
180
|
-
if (year !== void 0) {
|
|
181
|
-
if (version === "latest" || year < version) version = year;
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (require_publish_contract.publishedNodeTargetSupportsConsumer({
|
|
185
|
-
target: identifier,
|
|
186
|
-
node
|
|
187
|
-
})) continue;
|
|
188
|
-
throw new Error(`Unsupported packed JavaScript syntax target ${identifier}; use an explicit ECMAScript year or a supported Node target`);
|
|
189
|
-
}
|
|
190
|
-
return version;
|
|
191
|
-
};
|
|
192
|
-
const packedBinFiles = (files) => {
|
|
193
|
-
const result = /* @__PURE__ */ new Set();
|
|
194
|
-
for (const [file, source] of files) {
|
|
195
|
-
if (node_path.default.posix.basename(file) !== "package.json") continue;
|
|
196
|
-
const manifest = JSON.parse(source);
|
|
197
|
-
if (!record(manifest)) throw new Error(`Invalid packed manifest: ${file}`);
|
|
198
|
-
const bin = manifest["bin"];
|
|
199
|
-
if (bin === void 0) continue;
|
|
200
|
-
let entries;
|
|
201
|
-
if (typeof bin === "string") entries = [bin];
|
|
202
|
-
else if (record(bin)) entries = Object.values(bin);
|
|
203
|
-
if (entries === void 0) throw new Error(`Unsupported packed bin declaration: ${file}`);
|
|
204
|
-
for (const entry of entries) {
|
|
205
|
-
if (typeof entry !== "string" || entry === "" || node_path.default.posix.isAbsolute(entry) || entry.includes("\\") || entry.split("/").includes("..")) throw new Error(`Unsafe packed bin declaration: ${file}`);
|
|
206
|
-
result.add(node_path.default.posix.join(node_path.default.posix.dirname(file), entry));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return result;
|
|
210
|
-
};
|
|
211
|
-
const syntaxFiles = (files) => {
|
|
212
|
-
const bins = packedBinFiles(files);
|
|
213
|
-
for (const file of bins) {
|
|
214
|
-
const source = files.get(file);
|
|
215
|
-
if (source === void 0) throw new Error(`Missing packed executable: ${file}`);
|
|
216
|
-
if (!javascript.test(file) && !/^#!(?:[^\n]*\/node|\/usr\/bin\/env(?: -S)? node)(?:[ \r\n]|$)/.test(source)) throw new Error(`Unsupported packed executable language: ${file}`);
|
|
217
|
-
}
|
|
218
|
-
return [...new Set([...files.keys()].filter((file) => javascript.test(file)).concat([...bins]))];
|
|
219
|
-
};
|
|
220
|
-
const packageMode = (files, file) => {
|
|
221
|
-
let directory = node_path.default.posix.dirname(file);
|
|
222
|
-
while (directory !== ".") {
|
|
223
|
-
const source = files.get(`${directory}/package.json`);
|
|
224
|
-
if (source !== void 0) {
|
|
225
|
-
const manifest = JSON.parse(source);
|
|
226
|
-
if (!record(manifest)) throw new Error(`Invalid packed manifest: ${directory}`);
|
|
227
|
-
if (manifest["type"] === "module") return "module";
|
|
228
|
-
if (manifest["type"] === "commonjs") return "script";
|
|
229
|
-
if (manifest["type"] !== void 0) throw new Error(`Invalid packed package type: ${directory}`);
|
|
230
|
-
return "detect";
|
|
231
|
-
}
|
|
232
|
-
directory = node_path.default.posix.dirname(directory);
|
|
233
|
-
}
|
|
234
|
-
return "detect";
|
|
235
|
-
};
|
|
236
|
-
const parseArtifactSource = (source, options) => {
|
|
237
|
-
const script = options.sourceType === "script";
|
|
238
|
-
const content = script ? source.replace(/^\uFEFF/, "").replace(/^#![^\r\n]*/, "") : source;
|
|
239
|
-
try {
|
|
240
|
-
return (0, acorn.parse)(script ? (0, node_module.wrap)(content) : content, options);
|
|
241
|
-
} catch (error) {
|
|
242
|
-
if (!script || !(error instanceof SyntaxError) || !record(error) || typeof error["pos"] !== "number") throw error;
|
|
243
|
-
const prefixLength = (0, node_module.wrap)("\0").indexOf("\0");
|
|
244
|
-
const position = Math.max(0, Math.min(source.length, error["pos"] - prefixLength + source.length - content.length));
|
|
245
|
-
const lines = source.slice(0, position).split(/\r\n|[\n\r\u2028\u2029]/);
|
|
246
|
-
const location = `(${lines.length}:${lines.at(-1)?.length ?? 0})`;
|
|
247
|
-
throw new SyntaxError(error.message.replace(/\(\d+:\d+\)$/, location));
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
/** Enumerate all chunks and bins, including JavaScript outside declared exports. */
|
|
251
|
-
const assertPackedArtifactSyntax = ({ files, target, node }) => {
|
|
252
|
-
const ecmaVersion = artifactEcmaVersion({
|
|
253
|
-
target,
|
|
254
|
-
node
|
|
255
|
-
});
|
|
256
|
-
const selected = syntaxFiles(files);
|
|
257
|
-
if (target.type === "types-only" && selected.length > 0) throw new Error(`Types-only artifact contains JavaScript: ${selected[0]}`);
|
|
258
|
-
for (const file of selected) {
|
|
259
|
-
const source = files.get(file);
|
|
260
|
-
if (source === void 0) throw new Error(`Missing packed JavaScript: ${file}`);
|
|
261
|
-
let mode = packageMode(files, file);
|
|
262
|
-
if (/\.mjs$/i.test(file)) mode = "module";
|
|
263
|
-
if (/\.cjs$/i.test(file)) mode = "script";
|
|
264
|
-
const parseMode = (sourceType) => {
|
|
265
|
-
const tree = parseArtifactSource(source, {
|
|
266
|
-
ecmaVersion,
|
|
267
|
-
sourceType,
|
|
268
|
-
allowHashBang: true,
|
|
269
|
-
allowReturnOutsideFunction: sourceType === "script"
|
|
270
|
-
});
|
|
271
|
-
if (ecmaVersion === 5 && tree.body.some((item) => /^(?:Import|Export)/.test(item.type))) throw new Error("Module declarations exceed ES5");
|
|
272
|
-
};
|
|
273
|
-
try {
|
|
274
|
-
if (mode === "detect") try {
|
|
275
|
-
parseMode("script");
|
|
276
|
-
} catch {
|
|
277
|
-
parseMode("module");
|
|
278
|
-
}
|
|
279
|
-
else parseMode(mode);
|
|
280
|
-
} catch (error) {
|
|
281
|
-
throw new Error(`Packed JavaScript ${file} exceeds its declared syntax target: ${String(error)}`);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
const archiveMembers = (members) => {
|
|
286
|
-
const seen = /* @__PURE__ */ new Set();
|
|
287
|
-
for (const file of members) {
|
|
288
|
-
const parts = file.split("/");
|
|
289
|
-
if (!file.startsWith("package/") || file.includes("\\") || file.split("").some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127) || parts.some((part) => part === ".." || part === ".") || parts.slice(0, -1).some((part) => part === "") || seen.has(file)) throw new Error(`Unsupported packed artifact member: ${file}`);
|
|
290
|
-
seen.add(file);
|
|
291
|
-
}
|
|
292
|
-
return members;
|
|
293
|
-
};
|
|
294
|
-
const checkPackedJavaScriptWithNode = async ({ files, target, node, executable }) => {
|
|
295
|
-
assertPackedArtifactSyntax({
|
|
296
|
-
files,
|
|
297
|
-
target,
|
|
298
|
-
node
|
|
299
|
-
});
|
|
300
|
-
archiveMembers([...files.keys()]);
|
|
301
|
-
const scratch = await (0, node_fs_promises.mkdtemp)(node_path.default.join((0, node_os.tmpdir)(), "stll-artifact-syntax-"));
|
|
302
|
-
try {
|
|
303
|
-
for (const [file, source] of files) {
|
|
304
|
-
const destination = node_path.default.join(scratch, file);
|
|
305
|
-
await (0, node_fs_promises.mkdir)(node_path.default.dirname(destination), { recursive: true });
|
|
306
|
-
await (0, node_fs_promises.writeFile)(destination, source);
|
|
307
|
-
}
|
|
308
|
-
for (const file of syntaxFiles(files)) try {
|
|
309
|
-
await command(executable, ["--check", node_path.default.join(scratch, file)], {
|
|
310
|
-
cwd: scratch,
|
|
311
|
-
env: {
|
|
312
|
-
PATH: "/usr/bin:/bin",
|
|
313
|
-
HOME: scratch
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
} catch (error) {
|
|
317
|
-
throw new Error(`Packed JavaScript ${file} is incompatible with consumer Node ${node}: ${String(error)}`);
|
|
318
|
-
}
|
|
319
|
-
} finally {
|
|
320
|
-
await (0, node_fs_promises.rm)(scratch, {
|
|
321
|
-
recursive: true,
|
|
322
|
-
force: true
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
/** Read bytes without extracting archive-controlled paths or links. */
|
|
327
|
-
const readPackedSyntaxFiles = async (archive) => {
|
|
328
|
-
const { stdout: listing } = await command("tar", ["-tzf", archive], { maxBuffer: 16777216 });
|
|
329
|
-
const files = /* @__PURE__ */ new Map();
|
|
330
|
-
const members = archiveMembers(listing.split("\n").filter((entry) => entry !== ""));
|
|
331
|
-
const read = async (file) => {
|
|
332
|
-
if (!members.includes(file)) throw new Error(`Missing packed syntax input: ${file}`);
|
|
333
|
-
const { stdout: metadata } = await command("tar", [
|
|
334
|
-
"-tvzf",
|
|
335
|
-
archive,
|
|
336
|
-
file
|
|
337
|
-
]);
|
|
338
|
-
if (!metadata.startsWith("-") || metadata.trimEnd().split("\n").length !== 1) throw new Error(`Packed syntax input must be a regular file: ${file}`);
|
|
339
|
-
const { stdout } = await command("tar", [
|
|
340
|
-
"-xOf",
|
|
341
|
-
archive,
|
|
342
|
-
file
|
|
343
|
-
], { maxBuffer: 16777216 });
|
|
344
|
-
files.set(file, stdout);
|
|
345
|
-
};
|
|
346
|
-
for (const file of members) if (javascript.test(file) || node_path.default.posix.basename(file) === "package.json") await read(file);
|
|
347
|
-
for (const file of packedBinFiles(files)) if (!files.has(file)) await read(file);
|
|
348
|
-
return files;
|
|
349
|
-
};
|
|
350
|
-
//#endregion
|
|
351
152
|
//#region src/consumer-compat.ts
|
|
352
153
|
const execute = (executable, args, { cwd, env = process.env }) => new Promise((resolve, reject) => {
|
|
353
154
|
const child = (0, node_child_process.spawn)(executable, args, {
|
|
@@ -370,7 +171,7 @@ const execute = (executable, args, { cwd, env = process.env }) => new Promise((r
|
|
|
370
171
|
});
|
|
371
172
|
const jsonFile = async (file) => {
|
|
372
173
|
const value = JSON.parse(await (0, node_fs_promises.readFile)(file, "utf8"));
|
|
373
|
-
if (!
|
|
174
|
+
if (!require_consumer_node_support.consumerRecord(value)) throw new Error(`expected JSON object: ${file}`);
|
|
374
175
|
return value;
|
|
375
176
|
};
|
|
376
177
|
const containedDirectory = async (root, relative) => {
|
|
@@ -395,7 +196,7 @@ const verifyConsumerNodeArchive = ({ filename, checksums, archive }) => {
|
|
|
395
196
|
};
|
|
396
197
|
const resolveInstalledManagerBin = async ({ directory, name }) => {
|
|
397
198
|
const bin = (await jsonFile(node_path.default.join(directory, "package.json")))["bin"];
|
|
398
|
-
const selector =
|
|
199
|
+
const selector = require_consumer_node_support.consumerRecord(bin) ? bin[name] : bin;
|
|
399
200
|
if (typeof selector !== "string" || selector.length === 0) throw new Error(`Installed ${name} package must declare its ${name} bin`);
|
|
400
201
|
const root = await (0, node_fs_promises.realpath)(directory);
|
|
401
202
|
const resolved = node_path.default.resolve(root, selector);
|
|
@@ -545,7 +346,7 @@ const copyWithoutDependencies = async (source, destination) => {
|
|
|
545
346
|
};
|
|
546
347
|
const stageConsumerWorkspace = async ({ files, root, staging, packages }) => {
|
|
547
348
|
const directories = /* @__PURE__ */ new Map();
|
|
548
|
-
const paths =
|
|
349
|
+
const paths = require_consumer_node_support.consumerStagingPaths(packages);
|
|
549
350
|
const ordered = [...packages.values()].sort((left, right) => left.directory.length - right.directory.length);
|
|
550
351
|
for (const pkg of ordered) {
|
|
551
352
|
const relative = paths.get(pkg.name);
|
|
@@ -554,25 +355,25 @@ const stageConsumerWorkspace = async ({ files, root, staging, packages }) => {
|
|
|
554
355
|
if (pkg.directory !== "." || pkg.manifest["private"] !== true) await copyWithoutDependencies(await containedDirectory(root, pkg.directory), destination);
|
|
555
356
|
directories.set(pkg.name, destination);
|
|
556
357
|
}
|
|
557
|
-
const rootManifest =
|
|
358
|
+
const rootManifest = require_consumer_node_support.consumerPackRootManifest(packages, files);
|
|
558
359
|
await (0, node_fs_promises.writeFile)(node_path.default.join(staging, "package.json"), JSON.stringify(rootManifest));
|
|
559
360
|
const rootSource = files["pnpm-workspace.yaml"];
|
|
560
|
-
const rootCatalogs = rootSource === void 0 ?
|
|
361
|
+
const rootCatalogs = rootSource === void 0 ? require_consumer_node_support.bunCatalogState(rootManifest) : require_consumer_node_support.catalogState(require_consumer_node_support.pnpmWorkspaceState(rootSource, "pnpm-workspace.yaml"), "pnpm-workspace.yaml");
|
|
561
362
|
await (0, node_fs_promises.writeFile)(node_path.default.join(staging, "pnpm-workspace.yaml"), (0, yaml.stringify)({
|
|
562
363
|
packages: [...directories.values()].map((directory) => node_path.default.relative(staging, directory).split(node_path.default.sep).join("/") || "."),
|
|
563
364
|
...rootCatalogs
|
|
564
365
|
}));
|
|
565
|
-
for (const [directory, manifest] of
|
|
366
|
+
for (const [directory, manifest] of require_consumer_node_support.discoverConsumerManifests(files)) {
|
|
566
367
|
if (directory === ".") continue;
|
|
567
368
|
const file = `${directory}/pnpm-workspace.yaml`;
|
|
568
369
|
const source = files[file];
|
|
569
370
|
let workspace;
|
|
570
|
-
if (source !== void 0) workspace =
|
|
371
|
+
if (source !== void 0) workspace = require_consumer_node_support.pnpmWorkspaceState(source, file);
|
|
571
372
|
else {
|
|
572
|
-
const catalogs =
|
|
373
|
+
const catalogs = require_consumer_node_support.bunCatalogState(manifest);
|
|
573
374
|
if (Object.keys(catalogs).length === 0) continue;
|
|
574
375
|
const declaration = manifest["workspaces"];
|
|
575
|
-
const patterns =
|
|
376
|
+
const patterns = require_consumer_node_support.consumerRecord(declaration) ? declaration["packages"] : declaration;
|
|
576
377
|
if (!Array.isArray(patterns) || !patterns.every((entry) => typeof entry === "string")) throw new Error(`catalog owner requires declared workspace packages: ${directory}`);
|
|
577
378
|
workspace = {
|
|
578
379
|
packages: patterns,
|
|
@@ -589,12 +390,12 @@ const stageConsumerWorkspace = async ({ files, root, staging, packages }) => {
|
|
|
589
390
|
const assertConsumerFixtureFiles = async (directory) => {
|
|
590
391
|
const visit = async (location) => {
|
|
591
392
|
for (const entry of await (0, node_fs_promises.readdir)(location, { withFileTypes: true })) {
|
|
592
|
-
if (
|
|
393
|
+
if (require_consumer_node_support.consumerDependencyConfigFiles.some((name) => name === entry.name)) throw new Error(`consumer fixture must not supply dependency-manager configuration: ${entry.name}`);
|
|
593
394
|
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== ".git") await visit(node_path.default.join(location, entry.name));
|
|
594
395
|
}
|
|
595
396
|
};
|
|
596
397
|
await visit(directory);
|
|
597
|
-
|
|
398
|
+
require_consumer_node_support.assertConsumerFixtureManifest(await jsonFile(node_path.default.join(directory, "package.json")));
|
|
598
399
|
};
|
|
599
400
|
const provisionConsumerReleasePacker = async ({ tools, scratch, release }) => {
|
|
600
401
|
const prefix = node_path.default.join(scratch, "release-packer");
|
|
@@ -632,7 +433,7 @@ const provisionConsumerReleasePacker = async ({ tools, scratch, release }) => {
|
|
|
632
433
|
return cli;
|
|
633
434
|
};
|
|
634
435
|
const packConsumerArtifacts = async ({ files, root, scratch, tools, packages, workspacePackages }) => {
|
|
635
|
-
const release =
|
|
436
|
+
const release = require_publish_artifact_syntax.resolveConsumerReleasePack(files);
|
|
636
437
|
const releaseCli = await provisionConsumerReleasePacker({
|
|
637
438
|
tools,
|
|
638
439
|
scratch,
|
|
@@ -655,7 +456,7 @@ const packConsumerArtifacts = async ({ files, root, scratch, tools, packages, wo
|
|
|
655
456
|
await (0, node_fs_promises.mkdir)(packed);
|
|
656
457
|
const directory = stagedDirectories.get(pkg.name);
|
|
657
458
|
if (!directory) throw new Error(`missing pack workspace member: ${pkg.name}`);
|
|
658
|
-
await execute(tools.node, [releaseCli, ...
|
|
459
|
+
await execute(tools.node, [releaseCli, ...require_publish_artifact_syntax.consumerReleasePackArguments({
|
|
659
460
|
packer: release,
|
|
660
461
|
directory: packed
|
|
661
462
|
})], {
|
|
@@ -673,7 +474,7 @@ const packConsumerArtifacts = async ({ files, root, scratch, tools, packages, wo
|
|
|
673
474
|
};
|
|
674
475
|
const registryMetadata = async (name) => {
|
|
675
476
|
const value = JSON.parse((await fetchBytes(`https://registry.npmjs.org/${encodeURIComponent(name)}`)).toString("utf8"));
|
|
676
|
-
if (!
|
|
477
|
+
if (!require_consumer_node_support.consumerRecord(value) || !require_consumer_node_support.consumerRecord(value["versions"])) throw new Error(`invalid registry response: ${name}`);
|
|
677
478
|
return value["versions"];
|
|
678
479
|
};
|
|
679
480
|
const consumerCommandEnvironment = ({ tools, directory, home, environment = process.env }) => {
|
|
@@ -768,7 +569,7 @@ const installConsumerFixtureDependencies = async (options) => {
|
|
|
768
569
|
if (index !== 0) continue;
|
|
769
570
|
const manifestFile = node_path.default.join(options.directory, "package.json");
|
|
770
571
|
const manifest = JSON.parse(await (0, node_fs_promises.readFile)(manifestFile, "utf8"));
|
|
771
|
-
if (!
|
|
572
|
+
if (!require_consumer_node_support.consumerRecord(manifest)) throw new Error("invalid consumer fixture manifest");
|
|
772
573
|
const lockSource = await (0, node_fs_promises.readFile)(node_path.default.join(options.directory, options.manager === "npm" ? "package-lock.json" : "pnpm-lock.yaml"), "utf8");
|
|
773
574
|
const lock = options.manager === "npm" ? JSON.parse(lockSource) : (0, yaml.parse)(lockSource);
|
|
774
575
|
const { approvals, rebuildTargets } = await consumerBuildApprovals({
|
|
@@ -789,7 +590,7 @@ const installConsumerFixtureDependencies = async (options) => {
|
|
|
789
590
|
} else {
|
|
790
591
|
const workspaceFile = node_path.default.join(options.directory, "pnpm-workspace.yaml");
|
|
791
592
|
const workspace = (0, yaml.parse)(await (0, node_fs_promises.readFile)(workspaceFile, "utf8"));
|
|
792
|
-
if (!
|
|
593
|
+
if (!require_consumer_node_support.consumerRecord(workspace)) throw new Error("invalid generated consumer workspace");
|
|
793
594
|
await (0, node_fs_promises.writeFile)(workspaceFile, (0, yaml.stringify)({
|
|
794
595
|
...workspace,
|
|
795
596
|
allowBuilds: approvals
|
|
@@ -805,8 +606,8 @@ const runFixture = async ({ fixtureRoot, fixture, pkg, closure, artifacts, scrat
|
|
|
805
606
|
selectedArtifact,
|
|
806
607
|
"package/package.json"
|
|
807
608
|
], { cwd: scratch }));
|
|
808
|
-
if (!
|
|
809
|
-
|
|
609
|
+
if (!require_consumer_node_support.consumerRecord(published)) throw new Error(`invalid packed package manifest: ${pkg.name}`);
|
|
610
|
+
require_consumer_node_support.assertConsumerFixtureKind({
|
|
810
611
|
fixture,
|
|
811
612
|
pkg: {
|
|
812
613
|
directory: pkg.directory,
|
|
@@ -825,12 +626,12 @@ const runFixture = async ({ fixtureRoot, fixture, pkg, closure, artifacts, scrat
|
|
|
825
626
|
"optionalDependencies"
|
|
826
627
|
].some((field) => {
|
|
827
628
|
const entries = manifest[field];
|
|
828
|
-
return
|
|
629
|
+
return require_consumer_node_support.consumerRecord(entries) && typeof entries["react-dom"] === "string";
|
|
829
630
|
});
|
|
830
631
|
const reactBindings = {};
|
|
831
632
|
if (fixture.kind === "react") {
|
|
832
633
|
const peers = published["peerDependencies"];
|
|
833
|
-
if (!
|
|
634
|
+
if (!require_consumer_node_support.consumerRecord(peers) || typeof peers["react"] !== "string") throw new Error(`React fixture requires a React peer: ${pkg.name}`);
|
|
834
635
|
const needsDom = typeof peers["react-dom"] === "string" || needsReactDom;
|
|
835
636
|
const bindings = selectConsumerReactVersions({
|
|
836
637
|
reactRange: peers["react"],
|
|
@@ -849,7 +650,7 @@ const runFixture = async ({ fixtureRoot, fixture, pkg, closure, artifacts, scrat
|
|
|
849
650
|
if (!artifact) throw new Error(`missing consumer artifact: ${name}`);
|
|
850
651
|
closureArtifacts.set(name, artifact);
|
|
851
652
|
}
|
|
852
|
-
const boundManifest =
|
|
653
|
+
const boundManifest = require_consumer_node_support.bindConsumerManifest({
|
|
853
654
|
manifest,
|
|
854
655
|
artifacts: closureArtifacts,
|
|
855
656
|
typescript: policy.consumerTypescript,
|
|
@@ -897,8 +698,8 @@ const assertConsumerPackedNodeSupport = async ({ artifacts, node, directory }) =
|
|
|
897
698
|
artifact,
|
|
898
699
|
"package/package.json"
|
|
899
700
|
], { cwd: directory }));
|
|
900
|
-
if (!
|
|
901
|
-
|
|
701
|
+
if (!require_consumer_node_support.consumerRecord(manifest)) throw new Error(`invalid packed package manifest: ${name}`);
|
|
702
|
+
require_consumer_node_support.assertConsumerNodeSupport({
|
|
902
703
|
manifest,
|
|
903
704
|
node,
|
|
904
705
|
label: `packed ${name}`
|
|
@@ -906,18 +707,18 @@ const assertConsumerPackedNodeSupport = async ({ artifacts, node, directory }) =
|
|
|
906
707
|
}
|
|
907
708
|
};
|
|
908
709
|
const assertConsumerPackedSyntax = async ({ artifacts, packages, files, node, typescript, executable }) => {
|
|
909
|
-
const packer =
|
|
710
|
+
const packer = require_publish_artifact_syntax.resolveConsumerReleasePack(files).manager;
|
|
910
711
|
for (const [name, archive] of artifacts) {
|
|
911
712
|
const pkg = packages.get(name);
|
|
912
713
|
if (pkg === void 0) throw new Error(`Missing packed package: ${name}`);
|
|
913
714
|
const declaration = node_path.default.posix.join(pkg.directory, "publish-contract.json");
|
|
914
715
|
const source = files[declaration];
|
|
915
716
|
if (source === void 0) throw new Error(`Missing tracked publish contract: ${declaration}`);
|
|
916
|
-
const contract =
|
|
917
|
-
const packed = await readPackedSyntaxFiles(archive);
|
|
717
|
+
const contract = require_publish_artifact_syntax.parsePublishContract(JSON.parse(source));
|
|
718
|
+
const packed = await require_publish_artifact_syntax.readPackedSyntaxFiles(archive);
|
|
918
719
|
const manifest = packed.get("package/package.json");
|
|
919
720
|
if (manifest === void 0) throw new Error(`Missing packed manifest: ${name}`);
|
|
920
|
-
const diagnostics =
|
|
721
|
+
const diagnostics = require_publish_artifact_syntax.checkPublishContract({
|
|
921
722
|
manifest: JSON.parse(manifest),
|
|
922
723
|
target: contract.target,
|
|
923
724
|
contract,
|
|
@@ -928,7 +729,7 @@ const assertConsumerPackedSyntax = async ({ artifacts, packages, files, node, ty
|
|
|
928
729
|
}
|
|
929
730
|
});
|
|
930
731
|
if (diagnostics.length > 0) throw new Error(`Packed publish contract differs for ${name}: ${diagnostics.map((entry) => entry.message).join("; ")}`);
|
|
931
|
-
await checkPackedJavaScriptWithNode({
|
|
732
|
+
await require_publish_artifact_syntax.checkPackedJavaScriptWithNode({
|
|
932
733
|
files: packed,
|
|
933
734
|
target: contract.target,
|
|
934
735
|
node,
|
|
@@ -941,26 +742,26 @@ const runConsumerCompat = async ({ root: inputRoot, packages: selected, consumer
|
|
|
941
742
|
if (consumerNode !== policy.consumerNode) throw new Error("consumer Node must match the published toolchain policy");
|
|
942
743
|
if (selected.length === 0) throw new Error("consumer compatibility requires at least one package");
|
|
943
744
|
const root = await (0, node_fs_promises.realpath)(inputRoot);
|
|
944
|
-
const fixtureRoot = await containedDirectory(root,
|
|
945
|
-
const fixtures =
|
|
946
|
-
|
|
745
|
+
const fixtureRoot = await containedDirectory(root, require_consumer_node_support.consumerRelativePath(fixturePath, "fixture-path"));
|
|
746
|
+
const fixtures = require_consumer_node_support.parseConsumerFixtures(await jsonFile(node_path.default.join(fixtureRoot, "consumer-compat.json")));
|
|
747
|
+
require_consumer_node_support.assertConsumerFixtureSelection({
|
|
947
748
|
selected,
|
|
948
749
|
fixtures
|
|
949
750
|
});
|
|
950
751
|
const files = await trackedManifests(root);
|
|
951
|
-
const packages =
|
|
752
|
+
const packages = require_consumer_node_support.discoverConsumerPackages(files);
|
|
952
753
|
const selections = [];
|
|
953
754
|
const all = /* @__PURE__ */ new Map();
|
|
954
755
|
const seen = /* @__PURE__ */ new Set();
|
|
955
756
|
for (const input of selected) {
|
|
956
|
-
const directory =
|
|
757
|
+
const directory = require_consumer_node_support.consumerRelativePath(input, "selected package");
|
|
957
758
|
if (seen.has(directory)) throw new Error(`duplicate selected package: ${directory}`);
|
|
958
759
|
seen.add(directory);
|
|
959
760
|
const pkg = [...packages.values()].find((candidate) => candidate.directory === directory);
|
|
960
761
|
if (!pkg || pkg.manifest["private"] === true) throw new Error(`selected package is not a public root or declared workspace package: ${directory}`);
|
|
961
762
|
const fixture = fixtures.find((candidate) => candidate.package === directory);
|
|
962
763
|
if (!fixture) throw new Error(`missing declared consumer fixture: ${directory}`);
|
|
963
|
-
|
|
764
|
+
require_consumer_node_support.assertConsumerFixtureKind({
|
|
964
765
|
fixture,
|
|
965
766
|
pkg
|
|
966
767
|
});
|
|
@@ -977,13 +778,13 @@ const runConsumerCompat = async ({ root: inputRoot, packages: selected, consumer
|
|
|
977
778
|
pnpm: "pnpm",
|
|
978
779
|
bin: ""
|
|
979
780
|
});
|
|
980
|
-
const closure =
|
|
781
|
+
const closure = require_consumer_node_support.consumerPackageClosure({
|
|
981
782
|
selected: pkg,
|
|
982
783
|
packages,
|
|
983
784
|
files
|
|
984
785
|
});
|
|
985
786
|
for (const [name, member] of closure) {
|
|
986
|
-
|
|
787
|
+
require_consumer_node_support.assertConsumerNodeSupport({
|
|
987
788
|
manifest: member.manifest,
|
|
988
789
|
node: policy.consumerNode,
|
|
989
790
|
label: node_path.default.posix.join(member.directory, "package.json")
|
|
@@ -996,7 +797,7 @@ const runConsumerCompat = async ({ root: inputRoot, packages: selected, consumer
|
|
|
996
797
|
closure
|
|
997
798
|
});
|
|
998
799
|
}
|
|
999
|
-
|
|
800
|
+
require_publish_artifact_syntax.resolveConsumerReleasePack(files);
|
|
1000
801
|
const scratch = await (0, node_fs_promises.mkdtemp)(node_path.default.join((0, node_os.tmpdir)(), "stll-consumer-compat-"));
|
|
1001
802
|
try {
|
|
1002
803
|
const tools = await provisionConsumerTools(scratch, policy);
|
|
@@ -1061,9 +862,9 @@ const parseConsumerCompatArguments = (args) => {
|
|
|
1061
862
|
if (!Array.isArray(packages) || packages.length === 0) throw new Error("--packages must be a nonempty JSON array");
|
|
1062
863
|
return {
|
|
1063
864
|
mode: "run",
|
|
1064
|
-
packages: packages.map((entry) =>
|
|
865
|
+
packages: packages.map((entry) => require_consumer_node_support.consumerRelativePath(entry, "--packages")),
|
|
1065
866
|
consumerNode,
|
|
1066
|
-
fixturePath:
|
|
867
|
+
fixturePath: require_consumer_node_support.consumerRelativePath(fixturePath, "--fixture-path")
|
|
1067
868
|
};
|
|
1068
869
|
};
|
|
1069
870
|
//#endregion
|