@stll/oxlint-config 1.0.2 → 1.2.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 (49) hide show
  1. package/README.md +97 -4
  2. package/dist/cloud-setup-cli.cjs +62 -21
  3. package/dist/cloud-setup-cli.cjs.map +1 -1
  4. package/dist/cloud-setup-cli.mjs +63 -22
  5. package/dist/cloud-setup-cli.mjs.map +1 -1
  6. package/dist/consumer-compat-cli.cjs +7 -6
  7. package/dist/consumer-compat-cli.cjs.map +1 -1
  8. package/dist/consumer-compat-cli.mjs +7 -6
  9. package/dist/consumer-compat-cli.mjs.map +1 -1
  10. package/dist/git-tracked-output.cjs.map +1 -1
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/publish-build-target-vite-dts-helper.mjs +1 -2
  13. package/dist/publish-build-target-vite-dts-helper2.cjs +5 -5
  14. package/dist/publish-build-target-vite-dts-helper2.cjs.map +1 -1
  15. package/dist/publish-contract-cli.cjs +17 -16
  16. package/dist/publish-contract-cli.cjs.map +1 -1
  17. package/dist/publish-contract-cli.mjs +6 -5
  18. package/dist/publish-contract-cli.mjs.map +1 -1
  19. package/dist/publish-contract.cjs +1 -1
  20. package/dist/publish-contract.cjs.map +1 -1
  21. package/dist/publish-contract.mjs +1 -1
  22. package/dist/rolldown-runtime.cjs +1 -1
  23. package/dist/toolchain-changed.cjs +25 -15
  24. package/dist/toolchain-changed.cjs.map +1 -1
  25. package/dist/toolchain-changed.mjs +27 -17
  26. package/dist/toolchain-changed.mjs.map +1 -1
  27. package/dist/toolchain-check-cli.cjs.map +1 -1
  28. package/dist/toolchain-check-cli.mjs.map +1 -1
  29. package/dist/toolchain-guard.cjs +72 -48
  30. package/dist/toolchain-guard.cjs.map +1 -1
  31. package/dist/toolchain-guard.mjs +79 -55
  32. package/dist/toolchain-guard.mjs.map +1 -1
  33. package/dist/toolchain-inputs.cjs +803 -40
  34. package/dist/toolchain-inputs.cjs.map +1 -1
  35. package/dist/toolchain-inputs.mjs +768 -41
  36. package/dist/toolchain-inputs.mjs.map +1 -1
  37. package/dist/toolchain-schema.cjs +1 -1
  38. package/dist/toolchain-schema.cjs.map +1 -1
  39. package/dist/toolchain-schema.mjs +2 -2
  40. package/dist/typecheck-parity-cli.cjs.map +1 -1
  41. package/dist/typecheck-parity-cli.mjs.map +1 -1
  42. package/dist/typecheck-parity.cjs +8 -7
  43. package/dist/typecheck-parity.cjs.map +1 -1
  44. package/dist/typecheck-parity.mjs +6 -5
  45. package/dist/typecheck-parity.mjs.map +1 -1
  46. package/dist/typecheck-probe-cli.cjs +1 -1
  47. package/dist/typecheck-probe-cli.cjs.map +1 -1
  48. package/dist/typecheck-probe-cli.mjs +1 -1
  49. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"publish-contract.cjs","names":["record","githubAutomationFileKind","consumerNodeSupportMatches"],"sources":["../src/consumer-release-pack.ts","../src/publish-contract.ts"],"sourcesContent":["import { parseDocument } from \"yaml\";\n\nimport { githubAutomationFileKind } from \"./toolchain-inputs\";\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst exactVersion = /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$/;\nconst outputDirectory = \"<consumer-release-pack-output>\";\nconst packerSetupExpression =\n /^npm\\s+install\\s+((?:(?:--global|-g|--ignore-scripts)\\s+)+)(npm|pnpm)@([^\\s]+)$/;\nconst defaultRunShell = (defaults: unknown) => {\n if (!record(defaults) || !record(defaults[\"run\"])) return undefined;\n return defaults[\"run\"][\"shell\"];\n};\n\nexport type ConsumerReleasePack = {\n manager: \"npm\" | \"pnpm\";\n version: string;\n arguments: string[];\n};\n\nconst packArguments = (line: string) => {\n const command = /^(npm|pnpm)\\s+pack(?:\\s+(.*))?$/.exec(line);\n const manager = command?.[1];\n if (manager !== \"npm\" && manager !== \"pnpm\")\n throw new Error(\"Unsupported release pack command\");\n const raw = command?.[2] ?? \"\";\n const tokens = raw.match(/\"[^\"\\n]*\"|'[^'\\n]*'|[^\\s]+/g) ?? [];\n const args: string[] = [];\n let destination = false;\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens.at(index);\n if (token === \"--pack-destination\") {\n if (destination) throw new Error(\"Repeated release pack destination\");\n const value = tokens.at(++index);\n if (\n value === undefined ||\n !/^(?:\"\\$GITHUB_WORKSPACE\\/[A-Za-z0-9_/-]+\"|[A-Za-z0-9_/-]+)$/.test(\n value,\n ) ||\n value.split(\"/\").includes(\"..\")\n )\n throw new Error(\"Unsupported release pack destination\");\n destination = true;\n args.push(token, outputDirectory);\n continue;\n }\n if (\n token !== \"--ignore-scripts\" &&\n !(manager === \"pnpm\" && token === \"--config.ignore-scripts=true\") &&\n token !== \"--json\" &&\n token !== \"--silent\"\n )\n throw new Error(\"Unsupported release pack arguments\");\n if (args.includes(token)) throw new Error(\"Repeated release pack flag\");\n args.push(token);\n }\n if (\n !destination ||\n (!args.includes(\"--ignore-scripts\") &&\n !args.includes(\"--config.ignore-scripts=true\"))\n )\n throw new Error(\n \"Release pack requires scripts disabled and --pack-destination\",\n );\n return { manager, arguments: args } satisfies Pick<\n ConsumerReleasePack,\n \"manager\" | \"arguments\"\n >;\n};\n\ntype ReleaseShellContextOptions = {\n step: Record<string, unknown>;\n kind: \"setup\" | \"pack\";\n location: string;\n inheritedShell: unknown;\n};\n\n/** Both setup provenance and packing require unconditional shell commands. */\nconst assertReleaseShellContext = ({\n step,\n kind,\n location,\n inheritedShell,\n}: ReleaseShellContextOptions) => {\n const run = step[\"run\"];\n if (typeof run !== \"string\")\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n const shell = step[\"shell\"] === undefined ? inheritedShell : step[\"shell\"];\n if (shell !== undefined && shell !== \"bash\" && shell !== \"sh\")\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n let quote: \"single\" | \"double\" | undefined;\n let code = \"\";\n for (let index = 0; index < run.length; index += 1) {\n const char = run[index];\n if (char === \"\\n\") {\n if (quote !== undefined)\n throw new Error(\n `Unsupported release ${kind} shell context: ${location}`,\n );\n code += \"\\n\";\n continue;\n }\n if (quote !== \"single\" && char === \"\\\\\") {\n if (\n run[index + 1] === \"\\n\" ||\n (run[index + 1] === \"\\r\" && run[index + 2] === \"\\n\")\n )\n throw new Error(\n `Unsupported release ${kind} shell context: ${location}`,\n );\n index += 1;\n code += \" \";\n continue;\n }\n if (\n quote !== \"single\" &&\n (char === \"`\" || (char === \"$\" && run[index + 1] === \"(\"))\n )\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n if (quote === \"single\") {\n if (char === \"'\") quote = undefined;\n code += \" \";\n continue;\n }\n if (quote === \"double\") {\n if (char === '\"') quote = undefined;\n code += \" \";\n continue;\n }\n if (char === \"'\") {\n quote = \"single\";\n code += \" \";\n continue;\n }\n if (char === '\"') {\n quote = \"double\";\n code += \" \";\n continue;\n }\n if (char === \"#\" && (index === 0 || /\\s/.test(run[index - 1] ?? \"\"))) {\n while (index + 1 < run.length && run[index + 1] !== \"\\n\") index += 1;\n continue;\n }\n code += char;\n }\n if (\n quote !== undefined ||\n /[;&|<>]/.test(code) ||\n code\n .split(\"\\n\")\n .some((line) =>\n /^\\s*(?:if|then|elif|else|fi|for|do|done|while|until|case|esac|function|select|exit|return|exec|break|continue|trap|eval|source|hash|alias|unalias)\\b/.test(\n line,\n ),\n ) ||\n /(?:^|\\n)\\s*\\.(?:\\s|$)/.test(code) ||\n /(?:^|\\n)\\s*[A-Za-z_]\\w*\\s*\\(\\s*\\)\\s*[{(]/.test(code) ||\n (kind === \"setup\" && /[(){}]/.test(code))\n )\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n if (kind !== \"setup\") return;\n for (const line of run.split(\"\\n\")) {\n const command = line.trim();\n if (command === \"\" || command.startsWith(\"#\")) continue;\n if (\n packerSetupExpression.test(command) ||\n /^(?:npm|pnpm)\\s+pack(?:\\s|$)/.test(command) ||\n [\"set -e\", \"set -eu\", \"set -euo pipefail\"].includes(command)\n )\n continue;\n throw new Error(`Unsupported release setup command context: ${location}`);\n }\n};\n\n/** Resolve the repository's release packer without substituting another manager. */\nexport const resolveConsumerReleasePack = (\n files: Record<string, string>,\n): ConsumerReleasePack => {\n const candidates: ConsumerReleasePack[] = [];\n for (const [file, text] of Object.entries(files)) {\n if (githubAutomationFileKind(file) !== \"workflow\") continue;\n const document = parseDocument(text, { uniqueKeys: true, merge: true });\n if (document.errors.length > 0)\n throw new Error(`Invalid release workflow YAML: ${file}`);\n const source: unknown = document.toJS({ maxAliasCount: 100 });\n if (!record(source) || !record(source[\"jobs\"])) continue;\n for (const [jobName, job] of Object.entries(source[\"jobs\"])) {\n if (!record(job) || !Array.isArray(job[\"steps\"])) continue;\n const packsRelease = job[\"steps\"].some(\n (step: unknown) =>\n record(step) &&\n typeof step[\"run\"] === \"string\" &&\n step[\"run\"]\n .split(\"\\n\")\n .some(\n (line) =>\n !line.trimStart().startsWith(\"#\") &&\n /\\b(?:npm|pnpm)\\s+pack\\b/.test(line),\n ),\n );\n if (!packsRelease) continue;\n const jobShell = defaultRunShell(job[\"defaults\"]);\n const inheritedShell =\n jobShell === undefined ? defaultRunShell(source[\"defaults\"]) : jobShell;\n const versions = new Map<string, string[]>();\n let packed: ConsumerReleasePack | undefined;\n for (const step of job[\"steps\"]) {\n if (!record(step)) continue;\n if (\n typeof step[\"uses\"] === \"string\" &&\n step[\"uses\"].startsWith(\"pnpm/action-setup@\")\n ) {\n if (\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined\n )\n throw new Error(\n `Conditional release packer setup: ${file}:${jobName}`,\n );\n const inputs = step[\"with\"];\n const version = record(inputs) ? inputs[\"version\"] : undefined;\n if (typeof version !== \"string\" || !exactVersion.test(version))\n throw new Error(\n `Release pnpm setup requires an exact version: ${file}:${jobName}`,\n );\n const values = versions.get(\"pnpm\") ?? [];\n values.push(version);\n versions.set(\"pnpm\", values);\n }\n if (typeof step[\"run\"] !== \"string\") continue;\n for (const rawLine of step[\"run\"].split(\"\\n\")) {\n const line = rawLine.trim();\n if (line.startsWith(\"#\")) continue;\n const setupCommand =\n /\\bnpm\\s+(?:install|i)\\b[^\\n]*\\b(?:npm|pnpm)@/.test(line);\n if (setupCommand)\n assertReleaseShellContext({\n step,\n kind: \"setup\",\n location: `${file}:${jobName}`,\n inheritedShell,\n });\n const setup = packerSetupExpression.exec(line);\n if (setupCommand && setup === null)\n throw new Error(\n `Unsupported release packer setup command: ${file}:${jobName}`,\n );\n if (\n setup !== null &&\n /(?:^|\\s)(?:--global|-g)(?:\\s|$)/.test(setup[1] ?? \"\")\n ) {\n if (\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined\n )\n throw new Error(\n `Conditional release packer setup: ${file}:${jobName}`,\n );\n const manager = setup[2];\n const version = setup[3];\n if (\n manager === undefined ||\n version === undefined ||\n !exactVersion.test(version)\n )\n throw new Error(\n `Release packer setup requires an exact version: ${file}:${jobName}`,\n );\n const values = versions.get(manager) ?? [];\n values.push(version);\n versions.set(manager, values);\n }\n if (!/\\b(?:npm|pnpm)\\s+pack\\b/.test(line)) continue;\n if (\n job[\"if\"] !== undefined ||\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined ||\n packed !== undefined\n )\n throw new Error(\n `Ambiguous release pack command: ${file}:${jobName}`,\n );\n assertReleaseShellContext({\n step,\n kind: \"pack\",\n location: `${file}:${jobName}`,\n inheritedShell,\n });\n const command = packArguments(line);\n const selected = versions.get(command.manager);\n const version = selected?.at(0);\n if (selected?.length !== 1 || version === undefined)\n throw new Error(\n `Missing or ambiguous exact release packer version: ${file}:${jobName}`,\n );\n packed = {\n manager: command.manager,\n version,\n arguments: command.arguments,\n };\n }\n }\n if (packed !== undefined) candidates.push(packed);\n }\n }\n const selected = candidates.at(0);\n if (candidates.length !== 1 || selected === undefined)\n throw new Error(\"Require exactly one identifiable release pack job\");\n return selected;\n};\n\ntype ConsumerReleasePackArgumentsOptions = {\n packer: ConsumerReleasePack;\n directory: string;\n};\nexport const consumerReleasePackArguments = ({\n packer,\n directory,\n}: ConsumerReleasePackArgumentsOptions) => {\n if (directory.length === 0)\n throw new Error(\"Release pack output directory is required\");\n return [\n \"pack\",\n ...packer.arguments.map((argument) =>\n argument === outputDirectory ? directory : argument,\n ),\n ];\n};\n","import { isDeepStrictEqual } from \"node:util\";\nimport { lte, parse, satisfies } from \"semver\";\n\nimport { consumerNodeSupportMatches } from \"./consumer-node-support\";\n\nexport type PublishTarget =\n | { type: \"javascript\"; targets: readonly string[] }\n | { type: \"types-only\" };\n\ntype ExportTarget =\n | string\n | null\n | ExportTarget[]\n | { [condition: string]: ExportTarget };\n\ntype EntryPoints = {\n type?: \"module\" | \"commonjs\";\n exports?: ExportTarget;\n main?: string;\n module?: string;\n types?: string;\n typings?: string;\n bin?: string | Record<string, string>;\n typesVersions?: Record<string, Record<string, string[]>>;\n};\n\nexport type PublishContract = {\n engines: Record<string, string>;\n peerDependencies: Record<string, string>;\n target: PublishTarget;\n entryPoints: EntryPoints;\n};\n\nexport type ConsumerPolicy = { node: string; typescript: string };\nexport type PublishContractDiagnostic = { field: string; message: string };\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst object = (value: unknown, field: string) => {\n if (!record(value)) throw new Error(`${field} must be an object`);\n return value;\n};\n\nconst closedKeys = (\n value: Record<string, unknown>,\n allowed: readonly string[],\n field: string,\n) => {\n for (const key of Object.keys(value))\n if (!allowed.includes(key))\n throw new Error(`${field}.${key} is unsupported`);\n};\n\nconst text = (value: unknown, field: string) => {\n if (typeof value !== \"string\" || value.trim() === \"\")\n throw new Error(`${field} must be a nonempty string`);\n return value;\n};\n\nconst stringMap = (value: unknown, field: string) => {\n const result = new Map<string, string>();\n for (const [key, entry] of Object.entries(object(value, field)))\n result.set(text(key, field), text(entry, `${field}.${key}`));\n return Object.fromEntries(result);\n};\n\nconst exportTarget = (value: unknown, field: string): ExportTarget => {\n if (value === null) return null;\n if (typeof value === \"string\") return text(value, field);\n if (Array.isArray(value))\n return value.map((entry: unknown, index) =>\n exportTarget(entry, `${field}[${index}]`),\n );\n const result = new Map<string, ExportTarget>();\n for (const [key, entry] of Object.entries(object(value, field)))\n result.set(text(key, field), exportTarget(entry, `${field}.${key}`));\n return Object.fromEntries(result);\n};\n\nconst typesVersions = (value: unknown) => {\n const result = new Map<string, Record<string, string[]>>();\n for (const [range, paths] of Object.entries(object(value, \"typesVersions\"))) {\n const mappings = new Map<string, string[]>();\n for (const [pattern, entries] of Object.entries(\n object(paths, `typesVersions.${range}`),\n )) {\n if (!Array.isArray(entries))\n throw new Error(`typesVersions.${range}.${pattern} must be an array`);\n mappings.set(\n text(pattern, \"typesVersions pattern\"),\n entries.map((entry: unknown) => text(entry, \"typesVersions path\")),\n );\n }\n result.set(\n text(range, \"typesVersions range\"),\n Object.fromEntries(mappings),\n );\n }\n return Object.fromEntries(result);\n};\n\nconst entryPointKeys = [\n \"type\",\n \"exports\",\n \"main\",\n \"module\",\n \"types\",\n \"typings\",\n \"bin\",\n \"typesVersions\",\n] as const;\n\nexport const publishConfigOverrideKeys = entryPointKeys.filter(\n (key) => key !== \"type\",\n);\n\nconst entryPoints = (value: unknown): EntryPoints => {\n const source = object(value, \"entryPoints\");\n closedKeys(source, entryPointKeys, \"entryPoints\");\n const result: EntryPoints = {};\n if (\"type\" in source) {\n if (source[\"type\"] !== \"module\" && source[\"type\"] !== \"commonjs\")\n throw new Error(\"entryPoints.type must be module or commonjs\");\n result.type = source[\"type\"];\n }\n if (\"exports\" in source)\n result.exports = exportTarget(source[\"exports\"], \"entryPoints.exports\");\n for (const key of [\"main\", \"module\", \"types\", \"typings\"] as const)\n if (key in source) result[key] = text(source[key], `entryPoints.${key}`);\n if (\"bin\" in source)\n result.bin =\n typeof source[\"bin\"] === \"string\"\n ? text(source[\"bin\"], \"entryPoints.bin\")\n : stringMap(source[\"bin\"], \"entryPoints.bin\");\n if (\"typesVersions\" in source)\n result.typesVersions = typesVersions(source[\"typesVersions\"]);\n return result;\n};\n\nconst publishTarget = (value: unknown): PublishTarget => {\n const source = object(value, \"target\");\n if (source[\"type\"] === \"types-only\") {\n closedKeys(source, [\"type\"], \"target\");\n return { type: \"types-only\" };\n }\n if (source[\"type\"] !== \"javascript\")\n throw new Error(\"target.type must be javascript or types-only\");\n closedKeys(source, [\"type\", \"targets\"], \"target\");\n if (!Array.isArray(source[\"targets\"]) || source[\"targets\"].length === 0)\n throw new Error(\"target.targets must be a nonempty array\");\n const targets = Array.from(source[\"targets\"]).map((entry: unknown) => {\n const target = text(entry, \"target.targets\");\n if (\n /[\\s,]/.test(target) ||\n Array.from(target).some(\n (character) =>\n character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127,\n )\n )\n throw new Error(\n \"target.targets must contain resolved target identifiers\",\n );\n return target;\n });\n return { type: \"javascript\", targets: [...new Set(targets)].sort() };\n};\n\nexport const parsePublishContract = (value: unknown): PublishContract => {\n const source = object(value, \"publish contract\");\n closedKeys(\n source,\n [\"engines\", \"peerDependencies\", \"target\", \"entryPoints\"],\n \"publish contract\",\n );\n return {\n engines: stringMap(source[\"engines\"], \"engines\"),\n peerDependencies: stringMap(source[\"peerDependencies\"], \"peerDependencies\"),\n target: publishTarget(source[\"target\"]),\n entryPoints: entryPoints(source[\"entryPoints\"]),\n };\n};\n\nconst publishPackers = [\"npm\", \"pnpm\"] as const;\nexport type PublishPacker = (typeof publishPackers)[number];\n\ntype ResolveManifestContractOptions = {\n packer: PublishPacker;\n manifest: unknown;\n target: PublishTarget;\n};\n\nexport const resolveManifestContract = ({\n packer,\n manifest,\n target,\n}: ResolveManifestContractOptions): PublishContract => {\n if (!publishPackers.includes(packer))\n throw new Error(\"publish packer must be npm or pnpm\");\n const source = object(manifest, \"package manifest\");\n const config =\n \"publishConfig\" in source\n ? object(source[\"publishConfig\"], \"publishConfig\")\n : {};\n closedKeys(\n config,\n [...publishConfigOverrideKeys, \"access\", \"registry\"],\n \"publishConfig\",\n );\n if (packer === \"npm\")\n for (const key of publishConfigOverrideKeys)\n if (\n Object.hasOwn(config, key) &&\n !(key === \"exports\" || key === \"typesVersions\"\n ? JSON.stringify(config[key]) === JSON.stringify(source[key])\n : isDeepStrictEqual(config[key], source[key]))\n )\n throw new Error(\n `npm pack does not apply differing publishConfig.${key}; move the published entry to package.json or use pnpm`,\n );\n for (const field of [\"browser\", \"esnext\", \"es2015\", \"unpkg\", \"umd:main\"])\n if (Object.hasOwn(source, field) || Object.hasOwn(config, field))\n throw new Error(`published entry field ${field} is unsupported`);\n const published: Record<string, unknown> = {};\n for (const key of entryPointKeys) {\n if (packer === \"pnpm\" && key !== \"type\" && key in config)\n published[key] = config[key];\n else if (key in source) published[key] = source[key];\n }\n if (typeof published[\"bin\"] === \"string\") {\n const name = text(source[\"name\"], \"package name for bin\");\n const command = name.split(\"/\").at(-1);\n if (command === undefined || command === \"\")\n throw new Error(\"package name must determine its bin command\");\n published[\"bin\"] = { [command]: published[\"bin\"] };\n }\n let engines: unknown = {};\n if (Object.hasOwn(source, \"engines\")) engines = source[\"engines\"];\n return parsePublishContract({\n engines,\n peerDependencies: Object.hasOwn(source, \"peerDependencies\")\n ? source[\"peerDependencies\"]\n : {},\n target,\n entryPoints: published,\n });\n};\n\nconst consumerPolicy = (policy: ConsumerPolicy) => {\n closedKeys(\n object(policy, \"consumer policy\"),\n [\"node\", \"typescript\"],\n \"consumer policy\",\n );\n for (const [field, major] of [\n [\"node\", 22],\n [\"typescript\", 6],\n ] as const) {\n const version = parse(policy[field]);\n if (\n version === null ||\n version.version !== policy[field] ||\n version.major !== major ||\n version.prerelease.length !== 0\n )\n throw new Error(\n `consumer policy ${field} must pin an exact stable ${major}.x release`,\n );\n }\n};\n\ntype CheckPublishContractOptions = ResolveManifestContractOptions & {\n contract: unknown;\n policy: ConsumerPolicy;\n};\n\n/** Share the accepted Node target grammar between static and packed checks. */\nexport const publishedNodeTargetSupportsConsumer = ({\n target,\n node,\n}: {\n target: string;\n node: string;\n}) => {\n const match = /^node([1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$/i.exec(\n target,\n );\n const version =\n match === null\n ? null\n : parse(`${match[1]}.${match[2] ?? \"0\"}.${match[3] ?? \"0\"}`);\n return version !== null && lte(version, node);\n};\n\nexport const checkPublishContract = ({\n packer,\n manifest,\n target,\n contract,\n policy,\n}: CheckPublishContractOptions) => {\n consumerPolicy(policy);\n const current = resolveManifestContract({ packer, manifest, target });\n const committed = parsePublishContract(contract);\n const diagnostics: PublishContractDiagnostic[] = [];\n const add = (field: string, message: string) =>\n diagnostics.push({ field, message });\n const compare = (field: string, expected: unknown, actual: unknown) => {\n if (\n field !== \"entryPoints.exports\" &&\n field !== \"entryPoints.typesVersions\" &&\n record(expected) &&\n record(actual)\n ) {\n for (const key of new Set([\n ...Object.keys(expected),\n ...Object.keys(actual),\n ]))\n compare(\n `${field}.${key}`,\n Object.hasOwn(expected, key) ? expected[key] : undefined,\n Object.hasOwn(actual, key) ? actual[key] : undefined,\n );\n return;\n }\n if (JSON.stringify(expected) !== JSON.stringify(actual))\n add(field, `published ${field} differs from the committed contract`);\n };\n for (const field of [\n \"engines\",\n \"peerDependencies\",\n \"target\",\n \"entryPoints\",\n ] as const)\n compare(field, committed[field], current[field]);\n const support = (\n field: string,\n range: string | undefined,\n version: string,\n ) => {\n if (range !== undefined && !satisfies(version, range))\n add(field, `${field} must support consumer version ${version}`);\n };\n if (\n !consumerNodeSupportMatches({\n range: current.engines[\"node\"],\n node: policy.node,\n })\n )\n add(\n \"engines.node\",\n `engines.node must support consumer version ${policy.node}`,\n );\n support(\n \"engines.typescript\",\n current.engines[\"typescript\"],\n policy.typescript,\n );\n support(\n \"peerDependencies.typescript\",\n current.peerDependencies[\"typescript\"],\n policy.typescript,\n );\n if (\"bun\" in current.engines)\n add(\"engines.bun\", \"published packages must not require Bun\");\n for (const peer of [\"bun\", \"bun-types\", \"@types/bun\", \"@typescript/native\"])\n if (Object.hasOwn(current.peerDependencies, peer))\n add(\n `peerDependencies.${peer}`,\n \"published packages must not require development runtime or compiler packages\",\n );\n if (current.target.type === \"javascript\")\n for (const selected of current.target.targets) {\n if (/^bun(?:$|[0-9])/i.test(selected)) {\n add(\"target\", \"published JavaScript must not require Bun\");\n continue;\n }\n if (!/^node/i.test(selected)) continue;\n if (\n !publishedNodeTargetSupportsConsumer({\n target: selected,\n node: policy.node,\n })\n )\n add(\n \"target\",\n `JavaScript target ${selected} must support consumer Node ${policy.node}`,\n );\n }\n return diagnostics;\n};\n"],"mappings":";;;;;;AAIA,MAAMA,YAAU,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AACrE,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,wBACJ;AACF,MAAM,mBAAmB,aAAsB;CAC7C,IAAI,CAACA,SAAO,QAAQ,KAAK,CAACA,SAAO,SAAS,MAAM,GAAG,OAAO,KAAA;CAC1D,OAAO,SAAS,MAAM,CAAC;AACzB;AAQA,MAAM,iBAAiB,SAAiB;CACtC,MAAM,UAAU,kCAAkC,KAAK,IAAI;CAC3D,MAAM,UAAU,UAAU;CAC1B,IAAI,YAAY,SAAS,YAAY,QACnC,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,UADM,UAAU,MAAM,GAAA,CACT,MAAM,6BAA6B,KAAK,CAAC;CAC5D,MAAM,OAAiB,CAAC;CACxB,IAAI,cAAc;CAClB,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EAClD,MAAM,QAAQ,OAAO,GAAG,KAAK;EAC7B,IAAI,UAAU,sBAAsB;GAClC,IAAI,aAAa,MAAM,IAAI,MAAM,mCAAmC;GACpE,MAAM,QAAQ,OAAO,GAAG,EAAE,KAAK;GAC/B,IACE,UAAU,KAAA,KACV,CAAC,8DAA8D,KAC7D,KACF,KACA,MAAM,MAAM,GAAG,C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A,IACE,CAACE,yBAAAA,2BAA2B;EAC1B,OAAO,QAAQ,QAAQ;EACvB,MAAM,OAAO;CACf,CAAC,GAED,IACE,gBACA,8CAA8C,OAAO,MACvD;CACF,QACE,sBACA,QAAQ,QAAQ,eAChB,OAAO,UACT;CACA,QACE,+BACA,QAAQ,iBAAiB,eACzB,OAAO,UACT;CACA,IAAI,SAAS,QAAQ,SACnB,IAAI,eAAe,yCAAyC;CAC9D,KAAK,MAAM,QAAQ;EAAC;EAAO;EAAa;EAAc;CAAoB,GACxE,IAAI,OAAO,OAAO,QAAQ,kBAAkB,IAAI,GAC9C,IACE,oBAAoB,QACpB,8EACF;CACJ,IAAI,QAAQ,OAAO,SAAS,cAC1B,KAAK,MAAM,YAAY,QAAQ,OAAO,SAAS;EAC7C,IAAI,mBAAmB,KAAK,QAAQ,GAAG;GACrC,IAAI,UAAU,2CAA2C;GACzD;EACF;EACA,IAAI,CAAC,SAAS,KAAK,QAAQ,GAAG;EAC9B,IACE,CAAC,oCAAoC;GACnC,QAAQ;GACR,MAAM,OAAO;EACf,CAAC,GAED,IACE,UACA,qBAAqB,SAAS,8BAA8B,OAAO,MACrE;CACJ;CACF,OAAO;AACT"}
1
+ {"version":3,"file":"publish-contract.cjs","names":["record","githubAutomationFileKind","parseDocument","isDeepStrictEqual","parse","lte","satisfies","consumerNodeSupportMatches"],"sources":["../src/consumer-release-pack.ts","../src/publish-contract.ts"],"sourcesContent":["import { parseDocument } from \"yaml\";\n\nimport { githubAutomationFileKind } from \"./toolchain-inputs\";\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst exactVersion = /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$/;\nconst outputDirectory = \"<consumer-release-pack-output>\";\nconst packerSetupExpression =\n /^npm\\s+install\\s+((?:(?:--global|-g|--ignore-scripts)\\s+)+)(npm|pnpm)@([^\\s]+)$/;\nconst defaultRunShell = (defaults: unknown) => {\n if (!record(defaults) || !record(defaults[\"run\"])) return undefined;\n return defaults[\"run\"][\"shell\"];\n};\n\nexport type ConsumerReleasePack = {\n manager: \"npm\" | \"pnpm\";\n version: string;\n arguments: string[];\n};\n\nconst packArguments = (line: string) => {\n const command = /^(npm|pnpm)\\s+pack(?:\\s+(.*))?$/.exec(line);\n const manager = command?.[1];\n if (manager !== \"npm\" && manager !== \"pnpm\")\n throw new Error(\"Unsupported release pack command\");\n const raw = command?.[2] ?? \"\";\n const tokens = raw.match(/\"[^\"\\n]*\"|'[^'\\n]*'|[^\\s]+/g) ?? [];\n const args: string[] = [];\n let destination = false;\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens.at(index);\n if (token === \"--pack-destination\") {\n if (destination) throw new Error(\"Repeated release pack destination\");\n const value = tokens.at(++index);\n if (\n value === undefined ||\n !/^(?:\"\\$GITHUB_WORKSPACE\\/[A-Za-z0-9_/-]+\"|[A-Za-z0-9_/-]+)$/.test(\n value,\n ) ||\n value.split(\"/\").includes(\"..\")\n )\n throw new Error(\"Unsupported release pack destination\");\n destination = true;\n args.push(token, outputDirectory);\n continue;\n }\n if (\n token !== \"--ignore-scripts\" &&\n !(manager === \"pnpm\" && token === \"--config.ignore-scripts=true\") &&\n token !== \"--json\" &&\n token !== \"--silent\"\n )\n throw new Error(\"Unsupported release pack arguments\");\n if (args.includes(token)) throw new Error(\"Repeated release pack flag\");\n args.push(token);\n }\n if (\n !destination ||\n (!args.includes(\"--ignore-scripts\") &&\n !args.includes(\"--config.ignore-scripts=true\"))\n )\n throw new Error(\n \"Release pack requires scripts disabled and --pack-destination\",\n );\n return { manager, arguments: args } satisfies Pick<\n ConsumerReleasePack,\n \"manager\" | \"arguments\"\n >;\n};\n\ntype ReleaseShellContextOptions = {\n step: Record<string, unknown>;\n kind: \"setup\" | \"pack\";\n location: string;\n inheritedShell: unknown;\n};\n\n/** Both setup provenance and packing require unconditional shell commands. */\nconst assertReleaseShellContext = ({\n step,\n kind,\n location,\n inheritedShell,\n}: ReleaseShellContextOptions) => {\n const run = step[\"run\"];\n if (typeof run !== \"string\")\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n const shell = step[\"shell\"] === undefined ? inheritedShell : step[\"shell\"];\n if (shell !== undefined && shell !== \"bash\" && shell !== \"sh\")\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n let quote: \"single\" | \"double\" | undefined;\n let code = \"\";\n for (let index = 0; index < run.length; index += 1) {\n const char = run[index];\n if (char === \"\\n\") {\n if (quote !== undefined)\n throw new Error(\n `Unsupported release ${kind} shell context: ${location}`,\n );\n code += \"\\n\";\n continue;\n }\n if (quote !== \"single\" && char === \"\\\\\") {\n if (\n run[index + 1] === \"\\n\" ||\n (run[index + 1] === \"\\r\" && run[index + 2] === \"\\n\")\n )\n throw new Error(\n `Unsupported release ${kind} shell context: ${location}`,\n );\n index += 1;\n code += \" \";\n continue;\n }\n if (\n quote !== \"single\" &&\n (char === \"`\" || (char === \"$\" && run[index + 1] === \"(\"))\n )\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n if (quote === \"single\") {\n if (char === \"'\") quote = undefined;\n code += \" \";\n continue;\n }\n if (quote === \"double\") {\n if (char === '\"') quote = undefined;\n code += \" \";\n continue;\n }\n if (char === \"'\") {\n quote = \"single\";\n code += \" \";\n continue;\n }\n if (char === '\"') {\n quote = \"double\";\n code += \" \";\n continue;\n }\n if (char === \"#\" && (index === 0 || /\\s/.test(run[index - 1] ?? \"\"))) {\n while (index + 1 < run.length && run[index + 1] !== \"\\n\") index += 1;\n continue;\n }\n code += char;\n }\n if (\n quote !== undefined ||\n /[;&|<>]/.test(code) ||\n code\n .split(\"\\n\")\n .some((line) =>\n /^\\s*(?:if|then|elif|else|fi|for|do|done|while|until|case|esac|function|select|exit|return|exec|break|continue|trap|eval|source|hash|alias|unalias)\\b/.test(\n line,\n ),\n ) ||\n /(?:^|\\n)\\s*\\.(?:\\s|$)/.test(code) ||\n /(?:^|\\n)\\s*[A-Za-z_]\\w*\\s*\\(\\s*\\)\\s*[{(]/.test(code) ||\n (kind === \"setup\" && /[(){}]/.test(code))\n )\n throw new Error(`Unsupported release ${kind} shell context: ${location}`);\n if (kind !== \"setup\") return;\n for (const line of run.split(\"\\n\")) {\n const command = line.trim();\n if (command === \"\" || command.startsWith(\"#\")) continue;\n if (\n packerSetupExpression.test(command) ||\n /^(?:npm|pnpm)\\s+pack(?:\\s|$)/.test(command) ||\n [\"set -e\", \"set -eu\", \"set -euo pipefail\"].includes(command)\n )\n continue;\n throw new Error(`Unsupported release setup command context: ${location}`);\n }\n};\n\n/** Resolve the repository's release packer without substituting another manager. */\nexport const resolveConsumerReleasePack = (\n files: Record<string, string>,\n): ConsumerReleasePack => {\n const candidates: ConsumerReleasePack[] = [];\n for (const [file, text] of Object.entries(files)) {\n if (githubAutomationFileKind(file) !== \"workflow\") continue;\n const document = parseDocument(text, { uniqueKeys: true, merge: true });\n if (document.errors.length > 0)\n throw new Error(`Invalid release workflow YAML: ${file}`);\n const source: unknown = document.toJS({ maxAliasCount: 100 });\n if (!record(source) || !record(source[\"jobs\"])) continue;\n for (const [jobName, job] of Object.entries(source[\"jobs\"])) {\n if (!record(job) || !Array.isArray(job[\"steps\"])) continue;\n const packsRelease = job[\"steps\"].some(\n (step: unknown) =>\n record(step) &&\n typeof step[\"run\"] === \"string\" &&\n step[\"run\"]\n .split(\"\\n\")\n .some(\n (line) =>\n !line.trimStart().startsWith(\"#\") &&\n /\\b(?:npm|pnpm)\\s+pack\\b/.test(line),\n ),\n );\n if (!packsRelease) continue;\n const jobShell = defaultRunShell(job[\"defaults\"]);\n const inheritedShell =\n jobShell === undefined ? defaultRunShell(source[\"defaults\"]) : jobShell;\n const versions = new Map<string, string[]>();\n let packed: ConsumerReleasePack | undefined;\n for (const step of job[\"steps\"]) {\n if (!record(step)) continue;\n if (\n typeof step[\"uses\"] === \"string\" &&\n step[\"uses\"].startsWith(\"pnpm/action-setup@\")\n ) {\n if (\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined\n )\n throw new Error(\n `Conditional release packer setup: ${file}:${jobName}`,\n );\n const inputs = step[\"with\"];\n const version = record(inputs) ? inputs[\"version\"] : undefined;\n if (typeof version !== \"string\" || !exactVersion.test(version))\n throw new Error(\n `Release pnpm setup requires an exact version: ${file}:${jobName}`,\n );\n const values = versions.get(\"pnpm\") ?? [];\n values.push(version);\n versions.set(\"pnpm\", values);\n }\n if (typeof step[\"run\"] !== \"string\") continue;\n for (const rawLine of step[\"run\"].split(\"\\n\")) {\n const line = rawLine.trim();\n if (line.startsWith(\"#\")) continue;\n const setupCommand =\n /\\bnpm\\s+(?:install|i)\\b[^\\n]*\\b(?:npm|pnpm)@/.test(line);\n if (setupCommand)\n assertReleaseShellContext({\n step,\n kind: \"setup\",\n location: `${file}:${jobName}`,\n inheritedShell,\n });\n const setup = packerSetupExpression.exec(line);\n if (setupCommand && setup === null)\n throw new Error(\n `Unsupported release packer setup command: ${file}:${jobName}`,\n );\n if (\n setup !== null &&\n /(?:^|\\s)(?:--global|-g)(?:\\s|$)/.test(setup[1] ?? \"\")\n ) {\n if (\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined\n )\n throw new Error(\n `Conditional release packer setup: ${file}:${jobName}`,\n );\n const manager = setup[2];\n const version = setup[3];\n if (\n manager === undefined ||\n version === undefined ||\n !exactVersion.test(version)\n )\n throw new Error(\n `Release packer setup requires an exact version: ${file}:${jobName}`,\n );\n const values = versions.get(manager) ?? [];\n values.push(version);\n versions.set(manager, values);\n }\n if (!/\\b(?:npm|pnpm)\\s+pack\\b/.test(line)) continue;\n if (\n job[\"if\"] !== undefined ||\n step[\"if\"] !== undefined ||\n step[\"continue-on-error\"] !== undefined ||\n packed !== undefined\n )\n throw new Error(\n `Ambiguous release pack command: ${file}:${jobName}`,\n );\n assertReleaseShellContext({\n step,\n kind: \"pack\",\n location: `${file}:${jobName}`,\n inheritedShell,\n });\n const command = packArguments(line);\n const selected = versions.get(command.manager);\n const version = selected?.at(0);\n if (selected?.length !== 1 || version === undefined)\n throw new Error(\n `Missing or ambiguous exact release packer version: ${file}:${jobName}`,\n );\n packed = {\n manager: command.manager,\n version,\n arguments: command.arguments,\n };\n }\n }\n if (packed !== undefined) candidates.push(packed);\n }\n }\n const selected = candidates.at(0);\n if (candidates.length !== 1 || selected === undefined)\n throw new Error(\"Require exactly one identifiable release pack job\");\n return selected;\n};\n\ntype ConsumerReleasePackArgumentsOptions = {\n packer: ConsumerReleasePack;\n directory: string;\n};\nexport const consumerReleasePackArguments = ({\n packer,\n directory,\n}: ConsumerReleasePackArgumentsOptions) => {\n if (directory.length === 0)\n throw new Error(\"Release pack output directory is required\");\n return [\n \"pack\",\n ...packer.arguments.map((argument) =>\n argument === outputDirectory ? directory : argument,\n ),\n ];\n};\n","import { isDeepStrictEqual } from \"node:util\";\nimport { lte, parse, satisfies } from \"semver\";\n\nimport { consumerNodeSupportMatches } from \"./consumer-node-support\";\n\nexport type PublishTarget =\n | { type: \"javascript\"; targets: readonly string[] }\n | { type: \"types-only\" };\n\ntype ExportTarget =\n | string\n | null\n | ExportTarget[]\n | { [condition: string]: ExportTarget };\n\ntype EntryPoints = {\n type?: \"module\" | \"commonjs\";\n exports?: ExportTarget;\n main?: string;\n module?: string;\n types?: string;\n typings?: string;\n bin?: string | Record<string, string>;\n typesVersions?: Record<string, Record<string, string[]>>;\n};\n\nexport type PublishContract = {\n engines: Record<string, string>;\n peerDependencies: Record<string, string>;\n target: PublishTarget;\n entryPoints: EntryPoints;\n};\n\nexport type ConsumerPolicy = { node: string; typescript: string };\nexport type PublishContractDiagnostic = { field: string; message: string };\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst object = (value: unknown, field: string) => {\n if (!record(value)) throw new Error(`${field} must be an object`);\n return value;\n};\n\nconst closedKeys = (\n value: Record<string, unknown>,\n allowed: readonly string[],\n field: string,\n) => {\n for (const key of Object.keys(value))\n if (!allowed.includes(key))\n throw new Error(`${field}.${key} is unsupported`);\n};\n\nconst text = (value: unknown, field: string) => {\n if (typeof value !== \"string\" || value.trim() === \"\")\n throw new Error(`${field} must be a nonempty string`);\n return value;\n};\n\nconst stringMap = (value: unknown, field: string) => {\n const result = new Map<string, string>();\n for (const [key, entry] of Object.entries(object(value, field)))\n result.set(text(key, field), text(entry, `${field}.${key}`));\n return Object.fromEntries(result);\n};\n\nconst exportTarget = (value: unknown, field: string): ExportTarget => {\n if (value === null) return null;\n if (typeof value === \"string\") return text(value, field);\n if (Array.isArray(value))\n return value.map((entry: unknown, index) =>\n exportTarget(entry, `${field}[${index}]`),\n );\n const result = new Map<string, ExportTarget>();\n for (const [key, entry] of Object.entries(object(value, field)))\n result.set(text(key, field), exportTarget(entry, `${field}.${key}`));\n return Object.fromEntries(result);\n};\n\nconst typesVersions = (value: unknown) => {\n const result = new Map<string, Record<string, string[]>>();\n for (const [range, paths] of Object.entries(object(value, \"typesVersions\"))) {\n const mappings = new Map<string, string[]>();\n for (const [pattern, entries] of Object.entries(\n object(paths, `typesVersions.${range}`),\n )) {\n if (!Array.isArray(entries))\n throw new Error(`typesVersions.${range}.${pattern} must be an array`);\n mappings.set(\n text(pattern, \"typesVersions pattern\"),\n entries.map((entry: unknown) => text(entry, \"typesVersions path\")),\n );\n }\n result.set(\n text(range, \"typesVersions range\"),\n Object.fromEntries(mappings),\n );\n }\n return Object.fromEntries(result);\n};\n\nconst entryPointKeys = [\n \"type\",\n \"exports\",\n \"main\",\n \"module\",\n \"types\",\n \"typings\",\n \"bin\",\n \"typesVersions\",\n] as const;\n\nexport const publishConfigOverrideKeys = entryPointKeys.filter(\n (key) => key !== \"type\",\n);\n\nconst entryPoints = (value: unknown): EntryPoints => {\n const source = object(value, \"entryPoints\");\n closedKeys(source, entryPointKeys, \"entryPoints\");\n const result: EntryPoints = {};\n if (\"type\" in source) {\n if (source[\"type\"] !== \"module\" && source[\"type\"] !== \"commonjs\")\n throw new Error(\"entryPoints.type must be module or commonjs\");\n result.type = source[\"type\"];\n }\n if (\"exports\" in source)\n result.exports = exportTarget(source[\"exports\"], \"entryPoints.exports\");\n for (const key of [\"main\", \"module\", \"types\", \"typings\"] as const)\n if (key in source) result[key] = text(source[key], `entryPoints.${key}`);\n if (\"bin\" in source)\n result.bin =\n typeof source[\"bin\"] === \"string\"\n ? text(source[\"bin\"], \"entryPoints.bin\")\n : stringMap(source[\"bin\"], \"entryPoints.bin\");\n if (\"typesVersions\" in source)\n result.typesVersions = typesVersions(source[\"typesVersions\"]);\n return result;\n};\n\nconst publishTarget = (value: unknown): PublishTarget => {\n const source = object(value, \"target\");\n if (source[\"type\"] === \"types-only\") {\n closedKeys(source, [\"type\"], \"target\");\n return { type: \"types-only\" };\n }\n if (source[\"type\"] !== \"javascript\")\n throw new Error(\"target.type must be javascript or types-only\");\n closedKeys(source, [\"type\", \"targets\"], \"target\");\n if (!Array.isArray(source[\"targets\"]) || source[\"targets\"].length === 0)\n throw new Error(\"target.targets must be a nonempty array\");\n const targets = Array.from(source[\"targets\"]).map((entry: unknown) => {\n const target = text(entry, \"target.targets\");\n if (\n /[\\s,]/.test(target) ||\n Array.from(target).some(\n (character) =>\n character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127,\n )\n )\n throw new Error(\n \"target.targets must contain resolved target identifiers\",\n );\n return target;\n });\n return { type: \"javascript\", targets: [...new Set(targets)].sort() };\n};\n\nexport const parsePublishContract = (value: unknown): PublishContract => {\n const source = object(value, \"publish contract\");\n closedKeys(\n source,\n [\"engines\", \"peerDependencies\", \"target\", \"entryPoints\"],\n \"publish contract\",\n );\n return {\n engines: stringMap(source[\"engines\"], \"engines\"),\n peerDependencies: stringMap(source[\"peerDependencies\"], \"peerDependencies\"),\n target: publishTarget(source[\"target\"]),\n entryPoints: entryPoints(source[\"entryPoints\"]),\n };\n};\n\nconst publishPackers = [\"npm\", \"pnpm\"] as const;\nexport type PublishPacker = (typeof publishPackers)[number];\n\ntype ResolveManifestContractOptions = {\n packer: PublishPacker;\n manifest: unknown;\n target: PublishTarget;\n};\n\nexport const resolveManifestContract = ({\n packer,\n manifest,\n target,\n}: ResolveManifestContractOptions): PublishContract => {\n if (!publishPackers.includes(packer))\n throw new Error(\"publish packer must be npm or pnpm\");\n const source = object(manifest, \"package manifest\");\n const config =\n \"publishConfig\" in source\n ? object(source[\"publishConfig\"], \"publishConfig\")\n : {};\n closedKeys(\n config,\n [...publishConfigOverrideKeys, \"access\", \"registry\"],\n \"publishConfig\",\n );\n if (packer === \"npm\")\n for (const key of publishConfigOverrideKeys)\n if (\n Object.hasOwn(config, key) &&\n !(key === \"exports\" || key === \"typesVersions\"\n ? JSON.stringify(config[key]) === JSON.stringify(source[key])\n : isDeepStrictEqual(config[key], source[key]))\n )\n throw new Error(\n `npm pack does not apply differing publishConfig.${key}; move the published entry to package.json or use pnpm`,\n );\n for (const field of [\"browser\", \"esnext\", \"es2015\", \"unpkg\", \"umd:main\"])\n if (Object.hasOwn(source, field) || Object.hasOwn(config, field))\n throw new Error(`published entry field ${field} is unsupported`);\n const published: Record<string, unknown> = {};\n for (const key of entryPointKeys) {\n if (packer === \"pnpm\" && key !== \"type\" && key in config)\n published[key] = config[key];\n else if (key in source) published[key] = source[key];\n }\n if (typeof published[\"bin\"] === \"string\") {\n const name = text(source[\"name\"], \"package name for bin\");\n const command = name.split(\"/\").at(-1);\n if (command === undefined || command === \"\")\n throw new Error(\"package name must determine its bin command\");\n published[\"bin\"] = { [command]: published[\"bin\"] };\n }\n let engines: unknown = {};\n if (Object.hasOwn(source, \"engines\")) engines = source[\"engines\"];\n return parsePublishContract({\n engines,\n peerDependencies: Object.hasOwn(source, \"peerDependencies\")\n ? source[\"peerDependencies\"]\n : {},\n target,\n entryPoints: published,\n });\n};\n\nconst consumerPolicy = (policy: ConsumerPolicy) => {\n closedKeys(\n object(policy, \"consumer policy\"),\n [\"node\", \"typescript\"],\n \"consumer policy\",\n );\n for (const [field, major] of [\n [\"node\", 22],\n [\"typescript\", 6],\n ] as const) {\n const version = parse(policy[field]);\n if (\n version === null ||\n version.version !== policy[field] ||\n version.major !== major ||\n version.prerelease.length !== 0\n )\n throw new Error(\n `consumer policy ${field} must pin an exact stable ${major}.x release`,\n );\n }\n};\n\ntype CheckPublishContractOptions = ResolveManifestContractOptions & {\n contract: unknown;\n policy: ConsumerPolicy;\n};\n\n/** Share the accepted Node target grammar between static and packed checks. */\nexport const publishedNodeTargetSupportsConsumer = ({\n target,\n node,\n}: {\n target: string;\n node: string;\n}) => {\n const match = /^node([1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$/i.exec(\n target,\n );\n const version =\n match === null\n ? null\n : parse(`${match[1]}.${match[2] ?? \"0\"}.${match[3] ?? \"0\"}`);\n return version !== null && lte(version, node);\n};\n\nexport const checkPublishContract = ({\n packer,\n manifest,\n target,\n contract,\n policy,\n}: CheckPublishContractOptions) => {\n consumerPolicy(policy);\n const current = resolveManifestContract({ packer, manifest, target });\n const committed = parsePublishContract(contract);\n const diagnostics: PublishContractDiagnostic[] = [];\n const add = (field: string, message: string) =>\n diagnostics.push({ field, message });\n const compare = (field: string, expected: unknown, actual: unknown) => {\n if (\n field !== \"entryPoints.exports\" &&\n field !== \"entryPoints.typesVersions\" &&\n record(expected) &&\n record(actual)\n ) {\n for (const key of new Set([\n ...Object.keys(expected),\n ...Object.keys(actual),\n ]))\n compare(\n `${field}.${key}`,\n Object.hasOwn(expected, key) ? expected[key] : undefined,\n Object.hasOwn(actual, key) ? actual[key] : undefined,\n );\n return;\n }\n if (JSON.stringify(expected) !== JSON.stringify(actual))\n add(field, `published ${field} differs from the committed contract`);\n };\n for (const field of [\n \"engines\",\n \"peerDependencies\",\n \"target\",\n \"entryPoints\",\n ] as const)\n compare(field, committed[field], current[field]);\n const support = (\n field: string,\n range: string | undefined,\n version: string,\n ) => {\n if (range !== undefined && !satisfies(version, range))\n add(field, `${field} must support consumer version ${version}`);\n };\n if (\n !consumerNodeSupportMatches({\n range: current.engines[\"node\"],\n node: policy.node,\n })\n )\n add(\n \"engines.node\",\n `engines.node must support consumer version ${policy.node}`,\n );\n support(\n \"engines.typescript\",\n current.engines[\"typescript\"],\n policy.typescript,\n );\n support(\n \"peerDependencies.typescript\",\n current.peerDependencies[\"typescript\"],\n policy.typescript,\n );\n if (\"bun\" in current.engines)\n add(\"engines.bun\", \"published packages must not require Bun\");\n for (const peer of [\"bun\", \"bun-types\", \"@types/bun\", \"@typescript/native\"])\n if (Object.hasOwn(current.peerDependencies, peer))\n add(\n `peerDependencies.${peer}`,\n \"published packages must not require development runtime or compiler packages\",\n );\n if (current.target.type === \"javascript\")\n for (const selected of current.target.targets) {\n if (/^bun(?:$|[0-9])/i.test(selected)) {\n add(\"target\", \"published JavaScript must not require Bun\");\n continue;\n }\n if (!/^node/i.test(selected)) continue;\n if (\n !publishedNodeTargetSupportsConsumer({\n target: selected,\n node: policy.node,\n })\n )\n add(\n \"target\",\n `JavaScript target ${selected} must support consumer Node ${policy.node}`,\n );\n }\n return diagnostics;\n};\n"],"mappings":";;;;;;AAIA,MAAMA,YAAU,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AACrE,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,wBACJ;AACF,MAAM,mBAAmB,aAAsB;CAC7C,IAAI,CAACA,SAAO,QAAQ,KAAK,CAACA,SAAO,SAAS,MAAM,GAAG,OAAO,KAAA;CAC1D,OAAO,SAAS,MAAM,CAAC;AACzB;AAQA,MAAM,iBAAiB,SAAiB;CACtC,MAAM,UAAU,kCAAkC,KAAK,IAAI;CAC3D,MAAM,UAAU,UAAU;CAC1B,IAAI,YAAY,SAAS,YAAY,QACnC,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,UADM,UAAU,MAAM,GAAA,CACT,MAAM,6BAA6B,KAAK,CAAC;CAC5D,MAAM,OAAiB,CAAC;CACxB,IAAI,cAA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AAK,UAAU,MAAM,GACpD,IAAI,OAAO,aAAa,MAAM,qCAAqC;CACvE;CACA,KAAK,MAAM,SAAS;EAClB;EACA;EACA;EACA;CACF,GACE,QAAQ,OAAO,UAAU,QAAQ,QAAQ,MAAM;CACjD,MAAM,WACJ,OACA,OACA,YACG;EACH,IAAI,UAAU,KAAA,KAAa,EAAA,GAACC,OAAAA,UAAAA,CAAU,SAAS,KAAK,GAClD,IAAI,OAAO,GAAG,MAAM,iCAAiC,SAAS;CAClE;CACA,IACE,CAACC,yBAAAA,2BAA2B;EAC1B,OAAO,QAAQ,QAAQ;EACvB,MAAM,OAAO;CACf,CAAC,GAED,IACE,gBACA,8CAA8C,OAAO,MACvD;CACF,QACE,sBACA,QAAQ,QAAQ,eAChB,OAAO,UACT;CACA,QACE,+BACA,QAAQ,iBAAiB,eACzB,OAAO,UACT;CACA,IAAI,SAAS,QAAQ,SACnB,IAAI,eAAe,yCAAyC;CAC9D,KAAK,MAAM,QAAQ;EAAC;EAAO;EAAa;EAAc;CAAoB,GACxE,IAAI,OAAO,OAAO,QAAQ,kBAAkB,IAAI,GAC9C,IACE,oBAAoB,QACpB,8EACF;CACJ,IAAI,QAAQ,OAAO,SAAS,cAC1B,KAAK,MAAM,YAAY,QAAQ,OAAO,SAAS;EAC7C,IAAI,mBAAmB,KAAK,QAAQ,GAAG;GACrC,IAAI,UAAU,2CAA2C;GACzD;EACF;EACA,IAAI,CAAC,SAAS,KAAK,QAAQ,GAAG;EAC9B,IACE,CAAC,oCAAoC;GACnC,QAAQ;GACR,MAAM,OAAO;EACf,CAAC,GAED,IACE,UACA,qBAAqB,SAAS,8BAA8B,OAAO,MACrE;CACJ;CACF,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
1
  import { t as githubAutomationFileKind } from "./toolchain-inputs.mjs";
2
2
  import { r as consumerNodeSupportMatches } from "./toolchain-schema.mjs";
3
3
  import { lte, parse, satisfies } from "semver";
4
- import { parseDocument } from "yaml";
5
4
  import { isDeepStrictEqual } from "node:util";
5
+ import { parseDocument } from "yaml";
6
6
  //#region src/consumer-release-pack.ts
7
7
  const record$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  const exactVersion = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
@@ -5,9 +5,9 @@ let node_child_process = require("node:child_process");
5
5
  let node_path = require("node:path");
6
6
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
7
7
  let semver = require("semver");
8
- let yaml = require("yaml");
9
- let node_util = require("node:util");
10
8
  let smol_toml = require("smol-toml");
9
+ let node_util = require("node:util");
10
+ let yaml = require("yaml");
11
11
  //#region src/toolchain-changed-locks.ts
12
12
  const toolchainChangedTools = [
13
13
  "bun",
@@ -204,11 +204,13 @@ const lockSourceProof = (raw) => {
204
204
  source(raw[0]);
205
205
  source(raw[1]);
206
206
  digest("integrity", raw[3]);
207
- } else if (changedRecord(raw)) if (changedRecord(raw["metadata"])) {
208
- metadata(raw["metadata"]);
209
- const descriptor = raw["descriptor"];
210
- source(typeof descriptor === "string" ? descriptor.replace(/^\//, "") : descriptor);
211
- } else metadata(raw);
207
+ } else if (changedRecord(raw)) {
208
+ if (changedRecord(raw["metadata"])) {
209
+ metadata(raw["metadata"]);
210
+ const descriptor = raw["descriptor"];
211
+ source(typeof descriptor === "string" ? descriptor.replace(/^\//, "") : descriptor);
212
+ } else metadata(raw);
213
+ }
212
214
  if (sources.some((value) => {
213
215
  if (/(?:^|@)(?:link:|portal:|workspace:)/i.test(value)) return true;
214
216
  const local = /(?:^|@)file:(.*)$/i.exec(value)?.[1];
@@ -276,12 +278,17 @@ const importerDependencies = (value) => {
276
278
  }
277
279
  return result;
278
280
  };
281
+ const BUN_TEXT_LOCKFILE_VERSIONS = /* @__PURE__ */ new Set([
282
+ 0,
283
+ 1,
284
+ 2
285
+ ]);
279
286
  const parseChangedLock = ({ file, text }) => {
280
287
  const resolutions = [];
281
288
  const importers = {};
282
289
  if (file.endsWith("bun.lock")) {
283
290
  const parsed = parseChangedJson(text);
284
- if (!changedRecord(parsed) || ![0, 1].includes(Number(parsed["lockfileVersion"])) || !changedRecord(parsed["packages"]) || !changedRecord(parsed["workspaces"])) throw new Error("Unsupported Bun lockfile shape");
291
+ if (!changedRecord(parsed) || !BUN_TEXT_LOCKFILE_VERSIONS.has(Number(parsed["lockfileVersion"])) || !changedRecord(parsed["packages"]) || !changedRecord(parsed["workspaces"])) throw new Error("Unsupported Bun lockfile shape");
285
292
  for (const [directory, workspace] of Object.entries(parsed["workspaces"])) importers[directory || "."] = importerDependencies(workspace);
286
293
  for (const [location, value] of Object.entries(parsed["packages"])) {
287
294
  const dependency = dependencyName(location);
@@ -503,7 +510,7 @@ const readTree = async ({ repo, ref }) => {
503
510
  ], {
504
511
  cwd: repo,
505
512
  encoding: "utf8",
506
- maxBuffer: 32 * 1024 * 1024
513
+ maxBuffer: 33554432
507
514
  });
508
515
  const entries = /* @__PURE__ */ new Map();
509
516
  for (const entry of stdout.split("\0")) {
@@ -536,7 +543,7 @@ const readBlobs = async ({ repo, oids }) => {
536
543
  let size = 0;
537
544
  child.stdout.on("data", (chunk) => {
538
545
  size += chunk.length;
539
- if (size > 128 * 1024 * 1024) {
546
+ if (size > 134217728) {
540
547
  child.kill();
541
548
  reject(/* @__PURE__ */ new Error("Toolchain Git snapshot exceeds the read limit"));
542
549
  return;
@@ -1095,10 +1102,11 @@ const parseSnapshot = (snapshot) => {
1095
1102
  const visit = (entry, at) => {
1096
1103
  if (!changedRecord(entry)) return;
1097
1104
  for (const [name, specifier] of Object.entries(entry)) {
1098
- if (changedPackageTool(typeof specifier === "string" ? packageTarget({
1105
+ const target = typeof specifier === "string" ? packageTarget({
1099
1106
  name,
1100
1107
  specifier
1101
- }) : name) === "typescript") tools.typescript.add(`${file}:${at}:${name}:${stableJson(specifier)}`);
1108
+ }) : name;
1109
+ if (changedPackageTool(target) === "typescript") tools.typescript.add(`${file}:${at}:${name}:${stableJson(specifier)}`);
1102
1110
  visit(specifier, `${at}:${name}`);
1103
1111
  }
1104
1112
  };
@@ -1205,7 +1213,8 @@ const parseSnapshot = (snapshot) => {
1205
1213
  if (require_toolchain_inputs.isComposeDefinitionPath(file) || /(?:^|\n)\s*(?:apiVersion|kind)\s*:/.test(text)) throw new Error(`Unreadable container declaration: ${file}`);
1206
1214
  continue;
1207
1215
  }
1208
- const container = require_toolchain_inputs.containerDocumentImages(document.toJS({ maxAliasCount: 100 }), file);
1216
+ const value = document.toJS({ maxAliasCount: 100 });
1217
+ const container = require_toolchain_inputs.containerDocumentImages(value, file);
1209
1218
  if (container === void 0) {
1210
1219
  if (require_toolchain_inputs.isComposeDefinitionPath(file)) throw new Error(`Unclassifiable Compose declaration: ${file}`);
1211
1220
  continue;
@@ -1306,10 +1315,11 @@ const parseSnapshot = (snapshot) => {
1306
1315
  if (!changedRecord(dependencies)) throw new Error(`Invalid manifest dependency table: ${file}`);
1307
1316
  for (const [dependency, specifier] of Object.entries(dependencies)) {
1308
1317
  if (typeof specifier !== "string") throw new Error(`Invalid dependency specifier: ${file}`);
1309
- if (changedPackageTool(packageTarget({
1318
+ const declaredTarget = packageTarget({
1310
1319
  name: dependency,
1311
1320
  specifier
1312
- })) === void 0 && changedPackageTool(dependency) === void 0 && !compilerNames.has(dependency)) continue;
1321
+ });
1322
+ if (changedPackageTool(declaredTarget) === void 0 && changedPackageTool(dependency) === void 0 && !compilerNames.has(dependency)) continue;
1313
1323
  const effectiveSpecifier = effectiveCatalogSpecifier({
1314
1324
  snapshot,
1315
1325
  file,