@stll/oxlint-config 1.8.0 → 2.0.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 +99 -67
- package/dist/cloud-setup-cli.cjs +5 -1
- package/dist/cloud-setup-cli.cjs.map +1 -1
- package/dist/cloud-setup-cli.mjs +6 -2
- package/dist/cloud-setup-cli.mjs.map +1 -1
- package/dist/dependabot.d.cts +0 -19
- package/dist/dependabot.d.mts +0 -19
- package/dist/git-tracked-output.cjs +1 -1
- package/dist/git-tracked-output.mjs +1 -1
- package/dist/publish-artifact-syntax.cjs +1 -1
- package/dist/publish-artifact-syntax.mjs +1 -1
- package/dist/publish-contract-cli.cjs +2 -2
- package/dist/publish-contract-cli.mjs +2 -2
- package/dist/quarantine-cli.cjs +3 -2
- package/dist/quarantine-cli.cjs.map +1 -1
- package/dist/quarantine-cli.mjs +3 -2
- package/dist/quarantine-cli.mjs.map +1 -1
- package/dist/quarantine-policy.d.cts +25 -2
- package/dist/quarantine-policy.d.mts +25 -2
- package/dist/quarantine-policy2.cjs +177 -5
- package/dist/quarantine-policy2.cjs.map +1 -1
- package/dist/quarantine-policy2.mjs +166 -6
- package/dist/quarantine-policy2.mjs.map +1 -1
- package/dist/toolchain-changed-cli.cjs +1477 -2
- package/dist/toolchain-changed-cli.cjs.map +1 -1
- package/dist/toolchain-changed-cli.mjs +1474 -1
- package/dist/toolchain-changed-cli.mjs.map +1 -1
- package/dist/toolchain-check-cli.cjs +2 -0
- package/dist/toolchain-check-cli.cjs.map +1 -1
- package/dist/toolchain-check-cli.mjs +2 -0
- package/dist/toolchain-check-cli.mjs.map +1 -1
- package/dist/toolchain-guard.cjs +355 -241
- package/dist/toolchain-guard.cjs.map +1 -1
- package/dist/toolchain-guard.mjs +352 -244
- package/dist/toolchain-guard.mjs.map +1 -1
- package/dist/toolchain-inputs.cjs +13 -40
- package/dist/toolchain-inputs.cjs.map +1 -1
- package/dist/toolchain-inputs.mjs +13 -40
- package/dist/toolchain-inputs.mjs.map +1 -1
- package/dist/toolchain-schema.cjs +69 -46
- package/dist/toolchain-schema.cjs.map +1 -1
- package/dist/toolchain-schema.mjs +69 -47
- package/dist/toolchain-schema.mjs.map +1 -1
- package/dist/typecheck-probe-cli.cjs +40 -2
- package/dist/typecheck-probe-cli.cjs.map +1 -1
- package/dist/typecheck-probe-cli.mjs +39 -1
- package/dist/typecheck-probe-cli.mjs.map +1 -1
- package/package.json +3 -4
- package/toolchain.json +2 -28
- package/dist/toolchain-changed.cjs +0 -1484
- package/dist/toolchain-changed.cjs.map +0 -1
- package/dist/toolchain-changed.mjs +0 -1477
- package/dist/toolchain-changed.mjs.map +0 -1
- package/dist/typecheck-parity-cli.cjs +0 -71
- package/dist/typecheck-parity-cli.cjs.map +0 -1
- package/dist/typecheck-parity-cli.d.cts +0 -1
- package/dist/typecheck-parity-cli.d.mts +0 -1
- package/dist/typecheck-parity-cli.mjs +0 -71
- package/dist/typecheck-parity-cli.mjs.map +0 -1
- package/dist/typecheck-parity.cjs +0 -907
- package/dist/typecheck-parity.cjs.map +0 -1
- package/dist/typecheck-parity.mjs +0 -896
- package/dist/typecheck-parity.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolchain-schema.mjs","names":["record","parseToml"],"sources":["../src/toolchain-formatter.ts","../src/toolchain-schema.ts"],"sourcesContent":["import path from \"node:path\";\nimport { parse as parseToml } from \"smol-toml\";\nimport { parseDocument } from \"yaml\";\n\nimport {\n githubAutomationFileKind,\n isDockerDefinitionPath,\n isFormatterConfigPath,\n isLefthookConfigPath,\n isShellScript,\n} from \"./toolchain-inputs\";\n\nexport const formatterRule = \"formatter-policy\" as const;\n\ntype Diagnostic = {\n rule: typeof formatterRule;\n path: string;\n line: number;\n message: string;\n};\n\nexport type FormatterStyle = Readonly<Record<string, unknown>>;\n\nexport type FormatterPolicy = {\n command: \"bun fmt\";\n style: FormatterStyle;\n /** Generated files every repository leaves to their generators. */\n ignorePatterns: readonly string[];\n};\n\n/** Repository-owned [fmt] keys: what to skip, and the Tailwind entry point. */\nexport const repositoryFormatKeys = [\n \"ignorePatterns\",\n \"sortTailwindcss\",\n] as const;\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** One style for every repository; only repository-owned keys may differ. */\nexport const parseFormatterPolicy = (input: unknown): FormatterPolicy => {\n if (\n !record(input) ||\n Object.keys(input).some(\n (key) => key !== \"command\" && key !== \"style\" && key !== \"ignorePatterns\",\n )\n )\n throw new Error(\n \"toolchain.json formatter accepts only command, style and ignorePatterns\",\n );\n if (input[\"command\"] !== \"bun fmt\")\n throw new Error(\"toolchain.json formatter command must be bun fmt\");\n const style = input[\"style\"];\n if (!record(style) || Object.keys(style).length === 0)\n throw new Error(\"toolchain.json formatter style must be a nonempty table\");\n for (const key of Object.keys(style))\n if (repositoryFormatKeys.some((owned) => owned === key))\n throw new Error(\n `toolchain.json formatter style cannot own the repository key ${key}`,\n );\n const ignorePatterns = input[\"ignorePatterns\"];\n if (\n !Array.isArray(ignorePatterns) ||\n !ignorePatterns.every(\n (pattern): pattern is string =>\n typeof pattern === \"string\" && pattern !== \"\",\n )\n )\n throw new Error(\n \"toolchain.json formatter ignorePatterns must be nonempty strings\",\n );\n return { command: \"bun fmt\", style, ignorePatterns };\n};\n\nconst tomlValue = (value: unknown): string => {\n if (Array.isArray(value)) return `[${value.map(tomlValue).join(\", \")}]`;\n if (record(value))\n return `{ ${Object.entries(value)\n .map(([key, entry]) => `${key} = ${tomlValue(entry)}`)\n .join(\", \")} }`;\n return JSON.stringify(value);\n};\n\nconst tomlLines = (entries: readonly (readonly [string, unknown])[]) =>\n entries.map(([key, value]) => `${key} = ${tomlValue(value)}\\n`).join(\"\");\n\n/** Render the shared bunfig.toml [fmt] tables. */\nexport const sharedFormatTables = (policy: FormatterPolicy) => {\n const entries = Object.entries(policy.style);\n let output = `[fmt]\\n${tomlLines(\n entries.filter(([, value]) => !record(value)),\n )}ignorePatterns = ${tomlValue(policy.ignorePatterns)}\\n`;\n for (const [name, table] of entries)\n if (record(table))\n output += `\\n[fmt.${name}]\\n${tomlLines(Object.entries(table))}`;\n return output;\n};\n\nconst stableJson = (value: unknown): string =>\n JSON.stringify(value, (_key, entry: unknown) =>\n record(entry)\n ? Object.fromEntries(\n Object.entries(entry).toSorted(([left], [right]) =>\n left.localeCompare(right),\n ),\n )\n : entry,\n );\n\n// Every alternative formatter is rejected, not only the one being replaced.\nconst formatterPackage = (name: string) =>\n name === \"oxfmt\" ||\n name === \"prettier\" ||\n name === \"dprint\" ||\n name === \"@biomejs/biome\" ||\n name.startsWith(\"@dprint/\") ||\n /^(?:@[^/]+\\/)?prettier-plugin-/.test(name);\n\nconst dependencyFields = [\n \"dependencies\",\n \"devDependencies\",\n \"optionalDependencies\",\n \"peerDependencies\",\n \"overrides\",\n \"resolutions\",\n \"catalog\",\n] as const;\n\nconst declaredPackages = (manifest: Record<string, unknown>) => {\n const tables: unknown[] = dependencyFields.map((field) => manifest[field]);\n const workspaces = manifest[\"workspaces\"];\n for (const owner of [manifest, record(workspaces) ? workspaces : {}]) {\n if (owner !== manifest) tables.push(owner[\"catalog\"]);\n const catalogs = owner[\"catalogs\"];\n if (record(catalogs)) tables.push(...Object.values(catalogs));\n }\n return tables.flatMap((table) => (record(table) ? Object.keys(table) : []));\n};\n\nconst shellWords = (command: string) =>\n command\n .split(/[\\s;&|()<>`]+/u)\n .map((word) => word.replace(/^[\"']+|[\"']+$/gu, \"\"))\n .filter((word) => word !== \"\");\n\n/** Over-approximate: any formatter executable named as a word is an invocation. */\nconst invokesFormatter = (command: string) => {\n const words = shellWords(command);\n return words.some((word, index) => {\n const name = path.posix.basename(word);\n if (name === \"oxfmt\" || name === \"prettier\" || name === \"dprint\")\n return true;\n return (\n name === \"biome\" &&\n [\"format\", \"check\", \"ci\"].includes(words.at(index + 1) ?? \"\")\n );\n });\n};\n\nconst lineOf = (text: string, needle: string) =>\n Math.max(\n 1,\n text.split(/\\r?\\n/u).findIndex((line) => line.includes(needle)) + 1,\n );\n\n/** Collect every `run` string of a workflow, composite action or hook config. */\nconst runValues = (value: unknown): string[] => {\n if (Array.isArray(value)) return value.flatMap(runValues);\n if (!record(value)) return [];\n return Object.entries(value).flatMap(([key, entry]) =>\n key === \"run\" && typeof entry === \"string\" ? [entry] : runValues(entry),\n );\n};\n\nconst commandLines = (commands: readonly string[]) =>\n commands.flatMap((command) =>\n command\n .replace(/\\\\\\r?\\n/gu, \" \")\n .split(/\\r?\\n|&&|;/u)\n .map((line) => line.trim()),\n );\n\nconst isBunFormat = (line: string, flag: \"--check\" | \"--staged\") => {\n const words = shellWords(line);\n // Only flags may follow: a path operand narrows the check below the repository.\n return (\n words[0] === \"bun\" &&\n words[1] === \"fmt\" &&\n words.slice(2).includes(flag) &&\n words.slice(2).every((word) => word.startsWith(\"-\"))\n );\n};\n\nconst checkFormatConfig = (\n bunfig: string,\n policy: FormatterPolicy,\n): string[] => {\n let parsed: Record<string, unknown>;\n try {\n parsed = parseToml(bunfig);\n } catch {\n return [\"bunfig.toml must be valid TOML\"];\n }\n const fmt = parsed[\"fmt\"];\n if (!record(fmt))\n return [\n `bunfig.toml requires a [fmt] table: bun fmt reads its configuration only from there; start from:\\n${sharedFormatTables(policy)}`,\n ];\n const errors: string[] = [];\n for (const key of Object.keys(fmt))\n if (\n !Object.hasOwn(policy.style, key) &&\n !repositoryFormatKeys.some((owned) => owned === key)\n )\n errors.push(\n `bunfig.toml [fmt] ${key} is not part of the shared style; every repository formats alike`,\n );\n const ignored = Array.isArray(fmt[\"ignorePatterns\"])\n ? fmt[\"ignorePatterns\"]\n : [];\n const missing = policy.ignorePatterns.filter(\n (pattern) => !ignored.includes(pattern),\n );\n if (missing.length > 0)\n errors.push(\n `bunfig.toml [fmt] ignorePatterns must include the shared generated files: ${missing.join(\", \")}`,\n );\n for (const [key, value] of Object.entries(policy.style))\n if (stableJson(fmt[key]) !== stableJson(value))\n errors.push(\n `bunfig.toml [fmt] ${key} must equal the shared style:\\n${sharedFormatTables(policy)}`,\n );\n return errors;\n};\n\ntype CheckFormatterOptions = {\n files: Record<string, string>;\n policy: FormatterPolicy;\n usesBun: boolean;\n};\n\n/** bun fmt is the only formatter: one config table, staged hooks and a full CI check. */\nexport const checkFormatter = ({\n files,\n policy,\n usesBun,\n}: CheckFormatterOptions): Diagnostic[] => {\n const diagnostics: Diagnostic[] = [];\n const add = (file: string, line: number, message: string) =>\n diagnostics.push({ rule: formatterRule, path: file, line, message });\n const workflowCommands: string[] = [];\n for (const [file, text] of Object.entries(files)) {\n const name = path.posix.basename(file);\n if (isFormatterConfigPath(file))\n add(\n file,\n 1,\n \"formatter configuration belongs in bunfig.toml [fmt]; remove this file\",\n );\n if (name === \"package.json\") {\n let manifest: unknown;\n try {\n manifest = JSON.parse(text);\n } catch {\n // Package diagnostics already reject malformed manifests.\n continue;\n }\n if (!record(manifest)) continue;\n for (const dependency of declaredPackages(manifest))\n if (formatterPackage(dependency))\n add(\n file,\n lineOf(text, JSON.stringify(dependency)),\n `${dependency} is not allowed: bun fmt is the only formatter`,\n );\n if (manifest[\"prettier\"] !== undefined)\n add(\n file,\n lineOf(text, '\"prettier\"'),\n \"package.json prettier configuration belongs in bunfig.toml [fmt]\",\n );\n const scripts = manifest[\"scripts\"];\n if (record(scripts))\n for (const [script, command] of Object.entries(scripts)) {\n if (script === \"fmt\")\n add(\n file,\n lineOf(text, '\"fmt\"'),\n \"a package script named fmt shadows bun fmt; remove it\",\n );\n if (typeof command === \"string\" && invokesFormatter(command))\n add(\n file,\n lineOf(text, JSON.stringify(script)),\n `script ${script} runs another formatter; use bun fmt`,\n );\n }\n continue;\n }\n if (file === \".changeset/config.json\") {\n try {\n const config: unknown = JSON.parse(text);\n if (record(config) && config[\"format\"] !== false)\n add(\n file,\n lineOf(text, '\"format\"'),\n \"changesets must not run a formatter (format: false); format releases with bun fmt\",\n );\n } catch {\n add(file, 1, \"changeset configuration must be valid JSON\");\n }\n continue;\n }\n const automation = githubAutomationFileKind(file);\n if (automation !== undefined || isLefthookConfigPath(file)) {\n const document = parseDocument(text);\n if (document.errors.length > 0) continue;\n const parsed: unknown = document.toJS();\n const commands = runValues(parsed);\n for (const command of commands)\n if (invokesFormatter(command))\n add(\n file,\n lineOf(text, command.split(/\\r?\\n/u)[0] ?? command),\n \"command runs another formatter; use bun fmt\",\n );\n if (automation === \"workflow\") workflowCommands.push(...commands);\n if (isLefthookConfigPath(file) && usesBun) {\n const preCommit = record(parsed) ? parsed[\"pre-commit\"] : undefined;\n if (\n !commandLines(runValues(preCommit)).some((line) =>\n isBunFormat(line, \"--staged\"),\n )\n )\n add(\n file,\n lineOf(text, \"pre-commit\"),\n \"lefthook pre-commit must run bun fmt --staged\",\n );\n }\n continue;\n }\n if (\n text !== \"\" &&\n (isDockerDefinitionPath(file) || isShellScript(file, text))\n )\n for (const [index, line] of text.split(/\\r?\\n/u).entries())\n if (!line.trimStart().startsWith(\"#\") && invokesFormatter(line))\n add(file, index + 1, \"command runs another formatter; use bun fmt\");\n }\n if (!usesBun) return diagnostics;\n const bunfig = files[\"bunfig.toml\"];\n if (bunfig !== undefined)\n for (const message of checkFormatConfig(bunfig, policy))\n add(\"bunfig.toml\", lineOf(bunfig, \"[fmt\"), message);\n const hasWorkflows = Object.keys(files).some(\n (file) => githubAutomationFileKind(file) === \"workflow\",\n );\n if (\n hasWorkflows &&\n !commandLines(workflowCommands).some((line) => isBunFormat(line, \"--check\"))\n )\n add(\n \".github/workflows\",\n 1,\n \"a workflow must run bun fmt --check over the whole repository\",\n );\n return diagnostics;\n};\n","import { valid } from \"semver\";\n\nimport { parseFormatterPolicy } from \"./toolchain-formatter\";\nimport { nodePolicyValid } from \"./toolchain-node\";\n\nexport const packagePinKeys = [\n \"oxlint\",\n \"oxlint-tsgolint\",\n \"@oxlint/plugins\",\n \"@stll/oxlint-plugin\",\n \"lefthook\",\n] as const;\n\nexport const valkeyArchitectures = [\"amd64\", \"arm64\"] as const;\nexport const valkeyArtifactPackages = {\n server: \"valkey-server\",\n tools: \"valkey-tools\",\n} as const;\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst artifactRecord = (value: unknown, keys: readonly string[]) => {\n if (\n !record(value) ||\n Object.keys(value).some((key) => !keys.includes(key)) ||\n keys.some((key) => !Object.hasOwn(value, key))\n )\n throw new Error(\n \"valkeyArtifacts requires complete, closed artifact objects\",\n );\n return value;\n};\n\nconst parseValkeyArtifacts = (input: unknown, version: string) => {\n const architectures = artifactRecord(input, valkeyArchitectures);\n const line = version.split(\".\").slice(0, 2).join(\".\");\n const parseArchitecture = (\n architecture: (typeof valkeyArchitectures)[number],\n ) => {\n const packages = artifactRecord(\n architectures[architecture],\n Object.keys(valkeyArtifactPackages),\n );\n const parseArtifact = (kind: keyof typeof valkeyArtifactPackages) => {\n const artifact = artifactRecord(packages[kind], [\"url\", \"sha256\"]);\n const url = artifact[\"url\"];\n const sha256 = artifact[\"sha256\"];\n const expected = `https://download.valkey.io/packaging/valkey-${line}/deb/ubuntu2404/${architecture}/${valkeyArtifactPackages[kind]}_${version}-1.noble_${architecture}.deb`;\n if (typeof url !== \"string\" || url !== expected)\n throw new Error(\n \"valkeyArtifacts URL must select the exact official versioned Ubuntu artifact\",\n );\n if (typeof sha256 !== \"string\" || !/^[a-f0-9]{64}$/.test(sha256))\n throw new Error(\"valkeyArtifacts requires a lowercase SHA256 pin\");\n return { url, sha256 };\n };\n return {\n server: parseArtifact(\"server\"),\n tools: parseArtifact(\"tools\"),\n } satisfies Record<\n keyof typeof valkeyArtifactPackages,\n ReturnType<typeof parseArtifact>\n >;\n };\n return {\n amd64: parseArchitecture(\"amd64\"),\n arm64: parseArchitecture(\"arm64\"),\n } satisfies Record<\n (typeof valkeyArchitectures)[number],\n ReturnType<typeof parseArchitecture>\n >;\n};\n\n/** Reject unsupported or incomplete installed policies before inspecting a consumer. */\nexport const parseToolchainPolicy = (input: unknown) => {\n if (!record(input) || input[\"schemaVersion\"] !== 1)\n throw new Error(\"toolchain.json must use schemaVersion 1\");\n const string = (object: Record<string, unknown>, key: string) => {\n const value = object[key];\n if (typeof value !== \"string\" || value.trim() === \"\")\n throw new Error(`toolchain.json requires a nonempty ${key}`);\n return value;\n };\n const packages: Record<string, string> = {};\n for (const key of packagePinKeys) packages[key] = string(input, key);\n const bun = string(input, \"bun\");\n const typescript = string(input, \"typescript\");\n const node = string(input, \"node\");\n const consumerNode = string(input, \"consumerNode\");\n const consumerNpm = string(input, \"consumerNpm\");\n const consumerPnpm = string(input, \"consumerPnpm\");\n const consumerTypescript = string(input, \"consumerTypescript\");\n const python = string(input, \"python\");\n const postgres = string(input, \"postgres\");\n const valkey = string(input, \"valkey\");\n const rust = string(input, \"rust\");\n for (const [name, value] of Object.entries({\n ...packages,\n bun,\n typescript,\n consumerNpm,\n consumerPnpm,\n consumerTypescript,\n }))\n if (valid(value) !== value)\n throw new Error(`toolchain.json ${name} must be an exact release`);\n if (!/^[1-9]\\d*$/.test(postgres) || !Number.isSafeInteger(Number(postgres)))\n throw new Error(\"PostgreSQL must be a canonical positive major\");\n if (valid(valkey) !== valkey || !/^\\d+\\.\\d+\\.\\d+$/.test(valkey))\n throw new Error(\"Valkey must be an exact stable release\");\n const valkeyArtifacts = parseValkeyArtifacts(\n input[\"valkeyArtifacts\"],\n valkey,\n );\n if (!nodePolicyValid(node))\n throw new Error(\"Node must be a canonical major N.x series\");\n if (\n valid(consumerNode) !== consumerNode ||\n !consumerNode.startsWith(\"22.\") ||\n consumerNode.includes(\"-\") ||\n consumerNode.includes(\"+\")\n )\n throw new Error(\"consumerNode must be an exact stable Node 22 release\");\n if (!/^\\d+\\.\\d+(?:\\.\\d+)?$/.test(python))\n throw new Error(\"Python must be an exact minor or patch release\");\n if (!/^\\d+\\.\\d+\\.\\d+$/.test(rust))\n throw new Error(\"Rust must be an exact stable release\");\n if (\n !consumerTypescript.startsWith(\"6.\") ||\n consumerTypescript.includes(\"-\") ||\n consumerTypescript.includes(\"+\")\n )\n throw new Error(\n \"consumerTypescript must be an exact stable TypeScript 6 release\",\n );\n const compatibility = input[\"typescript6Compatibility\"];\n if (!record(compatibility))\n throw new Error(\"missing TypeScript compatibility policy\");\n const version = string(compatibility, \"version\");\n const packageAlias = string(compatibility, \"packageAlias\");\n if (valid(version) !== version)\n throw new Error(\"TypeScript compatibility must be an exact release\");\n const layouts = input[\"typescriptInstallLayouts\"];\n if (!Array.isArray(layouts) || layouts.length === 0)\n throw new Error(\"missing TypeScript install layouts\");\n const typescriptInstallLayouts = layouts.map((layout: unknown) => {\n if (!record(layout)) throw new Error(\"invalid TypeScript install layout\");\n const compilerPackage = string(layout, \"compilerPackage\");\n const compilerSpecifier = string(layout, \"compilerSpecifier\");\n const typecheckCommand = string(layout, \"typecheckCommand\");\n switch (layout[\"type\"]) {\n case \"direct\":\n if (\n compilerSpecifier !== typescript ||\n compilerPackage !== \"typescript\"\n )\n throw new Error(\n \"direct TypeScript layout differs from shared version\",\n );\n return {\n type: \"direct\",\n compilerPackage,\n compilerSpecifier,\n typecheckCommand,\n } as const;\n case \"split-compatibility\": {\n const compatibilityPackage = string(layout, \"compatibilityPackage\");\n const compatibilitySpecifier = string(layout, \"compatibilitySpecifier\");\n if (\n compilerSpecifier !== `npm:typescript@${typescript}` ||\n compatibilitySpecifier !== version\n )\n throw new Error(\n \"split TypeScript layout differs from shared versions\",\n );\n return {\n type: \"split-compatibility\",\n compilerPackage,\n compilerSpecifier,\n compatibilityPackage,\n compatibilitySpecifier,\n typecheckCommand,\n } as const;\n }\n default:\n throw new Error(\"unsupported TypeScript install layout\");\n }\n });\n const actionsInput = input[\"actions\"];\n if (!record(actionsInput) || Object.keys(actionsInput).length === 0)\n throw new Error(\"missing approved actions\");\n const actions: Record<string, { sha: string; version: string }> = {};\n for (const [name, action] of Object.entries(actionsInput)) {\n if (!record(action)) throw new Error(`invalid action policy: ${name}`);\n const sha = string(action, \"sha\");\n const actionVersion = string(action, \"version\");\n if (!/^[a-f0-9]{40}$/.test(sha) || !/^v\\d+(?:\\.\\d+)*$/.test(actionVersion))\n throw new Error(`invalid action SHA/version: ${name}`);\n actions[name] = { sha, version: actionVersion };\n }\n const dependabotInput = input[\"dependabot\"];\n if (\n !record(dependabotInput) ||\n !record(dependabotInput[\"schedule\"]) ||\n !record(dependabotInput[\"cooldown\"]) ||\n !record(dependabotInput[\"groups\"])\n )\n throw new Error(\"missing Dependabot policy\");\n const scheduleInput = dependabotInput[\"schedule\"];\n const schedule = {\n interval: string(scheduleInput, \"interval\"),\n day: string(scheduleInput, \"day\"),\n time: string(scheduleInput, \"time\"),\n timezone: string(scheduleInput, \"timezone\"),\n };\n const defaultDays = dependabotInput[\"cooldown\"][\"defaultDays\"];\n if (\n typeof defaultDays !== \"number\" ||\n !Number.isInteger(defaultDays) ||\n defaultDays < 5\n )\n throw new Error(\"Dependabot cooldown must be at least five days\");\n const strings = (value: unknown): string[] => {\n if (\n !Array.isArray(value) ||\n !value.every((entry: unknown) => typeof entry === \"string\")\n )\n throw new Error(\"Dependabot group values must be string arrays\");\n return value;\n };\n // First-party reusable workflows move by commit, without a semver update\n // type, and must land together; they precede the shared semver groups.\n const actionGroupsInput = dependabotInput[\"actionGroups\"];\n if (!record(actionGroupsInput))\n throw new Error(\"missing Dependabot action groups\");\n const actionGroups: Record<string, { patterns: string[] }> = {};\n for (const [name, group] of Object.entries(actionGroupsInput)) {\n if (!record(group) || Object.keys(group).some((key) => key !== \"patterns\"))\n throw new Error(`invalid Dependabot action group: ${name}`);\n actionGroups[name] = { patterns: strings(group[\"patterns\"]) };\n }\n const groups: Record<string, { patterns: string[]; updateTypes: string[] }> =\n {};\n for (const [name, group] of Object.entries(dependabotInput[\"groups\"])) {\n if (!record(group)) throw new Error(`invalid Dependabot group: ${name}`);\n groups[name] = {\n patterns: strings(group[\"patterns\"]),\n updateTypes: strings(group[\"updateTypes\"]),\n };\n }\n return {\n bun,\n formatter: parseFormatterPolicy(input[\"formatter\"]),\n typescript,\n node,\n postgres,\n valkey,\n valkeyArtifacts,\n consumerNode,\n consumerNpm,\n consumerPnpm,\n consumerTypescript,\n python,\n rust,\n packages,\n actions,\n typescriptInstallLayouts,\n typescript6Compatibility: { version, packageAlias },\n dependabot: {\n schedule,\n cooldown: { defaultDays },\n actionGroups,\n groups,\n ignoredPackages: [\n ...new Set([\n ...Object.keys(packages),\n // The consumer package managers move only with a reviewed\n // consumerNpm or consumerPnpm change.\n \"npm\",\n \"pnpm\",\n ...typescriptInstallLayouts.flatMap((layout) =>\n layout.type === \"direct\"\n ? [layout.compilerPackage]\n : [layout.compilerPackage, layout.compatibilityPackage],\n ),\n packageAlias,\n \"bun-types\",\n ]),\n ],\n ignoredActions: Object.keys(actions),\n ignoredImages: [\"node\", \"python\", \"oven/bun\"],\n },\n };\n};\n"],"mappings":";;;;;;AAYA,MAAa,gBAAgB;;AAmB7B,MAAa,uBAAuB,CAClC,kBACA,iBACF;AAEA,MAAMA,YAAU,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;AAGrE,MAAa,wBAAwB,UAAoC;CACvE,IACE,CAACA,SAAO,KAAK,KACb,OAAO,KAAK,KAAK,CAAC,CAAC,MAChB,QAAQ,QAAQ,aAAa,QAAQ,WAAW,QAAQ,gBAC3D,GAEA,MAAM,IAAI,MACR,yEACF;CACF,IAAI,MAAM,eAAe,WACvB,MAAM,IAAI,MAAM,kDAAkD;CACpE,MAAM,QAAQ,MAAM;CACpB,IAAI,CAACA,SAAO,KAAK,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,GAClD,MAAM,IAAI,MAAM,yDAAyD;CAC3E,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GACjC,IAAI,qBAAqB,MAAM,UAAU,UAAU,GAAG,GACpD,MAAM,IAAI,MACR,gEAAgE,KAClE;CACJ,MAAM,iBAAiB,MAAM;CAC7B,IACE,CAAC,MAAM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AiB,CACf,mBAAG,IAAI,IAAI;IACT,GAAG,OAAO,KAAK,QAAQ;IAGvB;IACA;IACA,GAAG,yBAAyB,SAAS,WACnC,OAAO,SAAS,WACZ,CAAC,OAAO,eAAe,IACvB,CAAC,OAAO,iBAAiB,OAAO,oBAAoB,CAC1D;IACA;IACA;GACF,CAAC,CACH;GACA,gBAAgB,OAAO,KAAK,OAAO;GACnC,eAAe;IAAC;IAAQ;IAAU;GAAU;EAC9C;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"toolchain-schema.mjs","names":["record","parseToml"],"sources":["../src/toolchain-formatter.ts","../src/toolchain-schema.ts"],"sourcesContent":["import path from \"node:path\";\nimport picomatch from \"picomatch\";\nimport { parse as parseToml } from \"smol-toml\";\nimport { parseDocument } from \"yaml\";\n\nimport {\n githubAutomationFileKind,\n isDockerDefinitionPath,\n isFormatterConfigPath,\n isLefthookConfigPath,\n isShellScript,\n} from \"./toolchain-inputs\";\nimport { workspaceContains } from \"./toolchain-workspaces\";\n\nexport const formatterRule = \"formatter-policy\" as const;\n\ntype Diagnostic = {\n rule: typeof formatterRule;\n path: string;\n line: number;\n message: string;\n};\n\nexport type FormatterStyle = Readonly<Record<string, unknown>>;\n\nexport type FormatterPolicy = {\n command: \"bun fmt\";\n style: FormatterStyle;\n /** Generated files every repository leaves to their generators. */\n ignorePatterns: readonly string[];\n};\n\n/** Repository-owned [fmt] keys: what to skip, and the Tailwind entry point. */\nexport const repositoryFormatKeys = [\n \"ignorePatterns\",\n \"sortTailwindcss\",\n] as const;\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** One style for every repository; only repository-owned keys may differ. */\nexport const parseFormatterPolicy = (input: unknown): FormatterPolicy => {\n if (\n !record(input) ||\n Object.keys(input).some(\n (key) => key !== \"command\" && key !== \"style\" && key !== \"ignorePatterns\",\n )\n )\n throw new Error(\n \"toolchain.json formatter accepts only command, style and ignorePatterns\",\n );\n if (input[\"command\"] !== \"bun fmt\")\n throw new Error(\"toolchain.json formatter command must be bun fmt\");\n const style = input[\"style\"];\n if (!record(style) || Object.keys(style).length === 0)\n throw new Error(\"toolchain.json formatter style must be a nonempty table\");\n for (const key of Object.keys(style))\n if (repositoryFormatKeys.some((owned) => owned === key))\n throw new Error(\n `toolchain.json formatter style cannot own the repository key ${key}`,\n );\n const ignorePatterns = input[\"ignorePatterns\"];\n if (\n !Array.isArray(ignorePatterns) ||\n !ignorePatterns.every(\n (pattern): pattern is string =>\n typeof pattern === \"string\" && pattern !== \"\",\n )\n )\n throw new Error(\n \"toolchain.json formatter ignorePatterns must be nonempty strings\",\n );\n return { command: \"bun fmt\", style, ignorePatterns };\n};\n\nconst tomlValue = (value: unknown): string => {\n if (Array.isArray(value)) return `[${value.map(tomlValue).join(\", \")}]`;\n if (record(value))\n return `{ ${Object.entries(value)\n .map(([key, entry]) => `${key} = ${tomlValue(entry)}`)\n .join(\", \")} }`;\n return JSON.stringify(value);\n};\n\nconst tomlLines = (entries: readonly (readonly [string, unknown])[]) =>\n entries.map(([key, value]) => `${key} = ${tomlValue(value)}\\n`).join(\"\");\n\n/** Render the shared bunfig.toml [fmt] tables. */\nexport const sharedFormatTables = (policy: FormatterPolicy) => {\n const entries = Object.entries(policy.style);\n let output = `[fmt]\\n${tomlLines(\n entries.filter(([, value]) => !record(value)),\n )}ignorePatterns = ${tomlValue(policy.ignorePatterns)}\\n`;\n for (const [name, table] of entries)\n if (record(table))\n output += `\\n[fmt.${name}]\\n${tomlLines(Object.entries(table))}`;\n return output;\n};\n\nconst stableJson = (value: unknown): string =>\n JSON.stringify(value, (_key, entry: unknown) =>\n record(entry)\n ? Object.fromEntries(\n Object.entries(entry).toSorted(([left], [right]) =>\n left.localeCompare(right),\n ),\n )\n : entry,\n );\n\n// Every alternative formatter is rejected, not only the one being replaced.\nconst formatterPackage = (name: string) =>\n name === \"oxfmt\" ||\n name === \"prettier\" ||\n name === \"dprint\" ||\n name === \"@biomejs/biome\" ||\n name.startsWith(\"@dprint/\") ||\n /^(?:@[^/]+\\/)?prettier-plugin-/.test(name);\n\nconst dependencyFields = [\n \"dependencies\",\n \"devDependencies\",\n \"optionalDependencies\",\n \"peerDependencies\",\n \"overrides\",\n \"resolutions\",\n \"catalog\",\n] as const;\n\nconst declaredPackages = (manifest: Record<string, unknown>) => {\n const tables: unknown[] = dependencyFields.map((field) => manifest[field]);\n const workspaces = manifest[\"workspaces\"];\n for (const owner of [manifest, record(workspaces) ? workspaces : {}]) {\n if (owner !== manifest) tables.push(owner[\"catalog\"]);\n const catalogs = owner[\"catalogs\"];\n if (record(catalogs)) tables.push(...Object.values(catalogs));\n }\n return tables.flatMap((table) => (record(table) ? Object.keys(table) : []));\n};\n\nconst shellWords = (command: string) =>\n command\n .split(/[\\s;&|()<>`]+/u)\n .map((word) => word.replace(/^[\"']+|[\"']+$/gu, \"\"))\n .filter((word) => word !== \"\");\n\n/** Over-approximate: any formatter executable named as a word is an invocation. */\nconst invokesFormatter = (command: string) => {\n const words = shellWords(command);\n return words.some((word, index) => {\n const name = path.posix.basename(word);\n if (name === \"oxfmt\" || name === \"prettier\" || name === \"dprint\")\n return true;\n return (\n name === \"biome\" &&\n [\"format\", \"check\", \"ci\"].includes(words.at(index + 1) ?? \"\")\n );\n });\n};\n\nconst lineOf = (text: string, needle: string) =>\n Math.max(\n 1,\n text.split(/\\r?\\n/u).findIndex((line) => line.includes(needle)) + 1,\n );\n\n/** Collect every `run` string of a workflow, composite action or hook config. */\nconst runValues = (value: unknown): string[] => {\n if (Array.isArray(value)) return value.flatMap(runValues);\n if (!record(value)) return [];\n return Object.entries(value).flatMap(([key, entry]) =>\n key === \"run\" && typeof entry === \"string\" ? [entry] : runValues(entry),\n );\n};\n\nconst commandLines = (commands: readonly string[]) =>\n commands.flatMap((command) =>\n command\n .replace(/\\\\\\r?\\n/gu, \" \")\n .split(/\\r?\\n|&&|;/u)\n .map((line) => line.trim()),\n );\n\nconst isBunFormat = (line: string, flag: \"--check\" | \"--staged\") => {\n const words = shellWords(line);\n // Only flags may follow: a path operand narrows the check below the repository.\n return (\n words[0] === \"bun\" &&\n words[1] === \"fmt\" &&\n words.slice(2).includes(flag) &&\n words.slice(2).every((word) => word.startsWith(\"-\"))\n );\n};\n\n/** Package directories that the root workspaces patterns select. */\nconst workspacePackageRoots = (files: Record<string, string>) => {\n let manifest: unknown;\n try {\n manifest = JSON.parse(files[\"package.json\"] ?? \"\");\n } catch {\n return [];\n }\n if (!record(manifest)) return [];\n const declared = manifest[\"workspaces\"];\n // Bun accepts the array form and the { packages } object form.\n const patterns = record(declared) ? declared[\"packages\"] : declared;\n return Object.keys(files)\n .filter(\n (file) =>\n file.endsWith(\"/package.json\") &&\n workspaceContains({\n directory: \".\",\n file,\n patterns,\n rootMembership: \"patterns\",\n }),\n )\n .map((file) => path.posix.dirname(file));\n};\n\n// Representative package files: the manifest and common source layouts and\n// extensions. An ignore that matches any of them drops package sources.\nconst packageSourceProbes = [\n \"package.json\",\n \"index.ts\",\n \"index.js\",\n \"src/index.ts\",\n \"src/index.tsx\",\n \"src/index.js\",\n \"src/index.mjs\",\n \"src/main.ts\",\n \"src/nested/module.ts\",\n \"src/nested/component.tsx\",\n \"lib/index.ts\",\n \"lib/index.js\",\n] as const;\n\n/**\n * Ignore-file matching at one path level: a trailing slash limits a pattern to\n * directories, and a leading or inner slash anchors it at the root; otherwise\n * it matches at any depth.\n */\nconst matchesLevel = (pattern: string, level: string, directory: boolean) => {\n if (pattern.endsWith(\"/\") && !directory) return false;\n const anchored = pattern.replace(/\\/+$/u, \"\").includes(\"/\");\n const body = pattern.replace(/^\\/+|\\/+$/gu, \"\");\n // An empty pattern (\"/\") matches nothing.\n if (body === \"\") return false;\n const globs = anchored ? [body] : [body, `**/${body}`];\n return globs.some((glob) => picomatch.isMatch(level, glob, { dot: true }));\n};\n\n/** The patterns that match a path or one of its directories. */\nconst ignoringPatterns = (patterns: readonly string[], file: string) => {\n const parts = file.split(\"/\");\n return patterns.filter((pattern) =>\n parts.some((_, index) =>\n matchesLevel(\n pattern,\n parts.slice(0, index + 1).join(\"/\"),\n index < parts.length - 1,\n ),\n ),\n );\n};\n\nconst checkFormatConfig = (\n bunfig: string,\n policy: FormatterPolicy,\n packageRoots: readonly string[],\n): string[] => {\n let parsed: Record<string, unknown>;\n try {\n parsed = parseToml(bunfig);\n } catch {\n return [\"bunfig.toml must be valid TOML\"];\n }\n const fmt = parsed[\"fmt\"];\n if (!record(fmt))\n return [\n `bunfig.toml requires a [fmt] table: bun fmt reads its configuration only from there; start from:\\n${sharedFormatTables(policy)}`,\n ];\n const errors: string[] = [];\n for (const key of Object.keys(fmt))\n if (\n !Object.hasOwn(policy.style, key) &&\n !repositoryFormatKeys.some((owned) => owned === key)\n )\n errors.push(\n `bunfig.toml [fmt] ${key} is not part of the shared style; every repository formats alike`,\n );\n const ignored = Array.isArray(fmt[\"ignorePatterns\"])\n ? fmt[\"ignorePatterns\"]\n : [];\n const missing = policy.ignorePatterns.filter(\n (pattern) => !ignored.includes(pattern),\n );\n if (missing.length > 0)\n errors.push(\n `bunfig.toml [fmt] ignorePatterns must include the shared generated files: ${missing.join(\", \")}`,\n );\n // Ignores are for generated or vendored paths; one that covers a workspace\n // package silently drops its sources from bun fmt --check. Negations are not\n // accepted, so every listed pattern only ever removes files.\n const patterns = ignored.filter(\n (pattern): pattern is string => typeof pattern === \"string\",\n );\n for (const pattern of patterns)\n if (pattern.startsWith(\"!\"))\n errors.push(\n `bunfig.toml [fmt] ignorePatterns entry ${pattern} re-includes files; list only generated or vendored paths`,\n );\n const positives = patterns.filter((pattern) => !pattern.startsWith(\"!\"));\n const covered = new Map<string, string[]>();\n for (const root of packageRoots)\n for (const probe of packageSourceProbes) {\n for (const pattern of ignoringPatterns(positives, `${root}/${probe}`)) {\n if (policy.ignorePatterns.includes(pattern)) continue;\n const roots = covered.get(pattern) ?? [];\n if (!roots.includes(root)) roots.push(root);\n covered.set(pattern, roots);\n }\n }\n for (const pattern of patterns) {\n const roots = covered.get(pattern);\n if (roots !== undefined)\n errors.push(\n `bunfig.toml [fmt] ignorePatterns entry ${pattern} covers workspace packages (${roots.join(\", \")}); ignore only their generated or vendored paths`,\n );\n }\n for (const [key, value] of Object.entries(policy.style))\n if (stableJson(fmt[key]) !== stableJson(value))\n errors.push(\n `bunfig.toml [fmt] ${key} must equal the shared style:\\n${sharedFormatTables(policy)}`,\n );\n return errors;\n};\n\ntype CheckFormatterOptions = {\n files: Record<string, string>;\n policy: FormatterPolicy;\n usesBun: boolean;\n};\n\n/** bun fmt is the only formatter: one config table, staged hooks and a full CI check. */\nexport const checkFormatter = ({\n files,\n policy,\n usesBun,\n}: CheckFormatterOptions): Diagnostic[] => {\n const diagnostics: Diagnostic[] = [];\n const add = (file: string, line: number, message: string) =>\n diagnostics.push({ rule: formatterRule, path: file, line, message });\n const workflowCommands: string[] = [];\n for (const [file, text] of Object.entries(files)) {\n const name = path.posix.basename(file);\n if (isFormatterConfigPath(file))\n add(\n file,\n 1,\n \"formatter configuration belongs in bunfig.toml [fmt]; remove this file\",\n );\n if (name === \"package.json\") {\n let manifest: unknown;\n try {\n manifest = JSON.parse(text);\n } catch {\n // Package diagnostics already reject malformed manifests.\n continue;\n }\n if (!record(manifest)) continue;\n for (const dependency of declaredPackages(manifest))\n if (formatterPackage(dependency))\n add(\n file,\n lineOf(text, JSON.stringify(dependency)),\n `${dependency} is not allowed: bun fmt is the only formatter`,\n );\n if (manifest[\"prettier\"] !== undefined)\n add(\n file,\n lineOf(text, '\"prettier\"'),\n \"package.json prettier configuration belongs in bunfig.toml [fmt]\",\n );\n const scripts = manifest[\"scripts\"];\n if (record(scripts))\n for (const [script, command] of Object.entries(scripts)) {\n if (script === \"fmt\")\n add(\n file,\n lineOf(text, '\"fmt\"'),\n \"a package script named fmt shadows bun fmt; remove it\",\n );\n if (typeof command === \"string\" && invokesFormatter(command))\n add(\n file,\n lineOf(text, JSON.stringify(script)),\n `script ${script} runs another formatter; use bun fmt`,\n );\n }\n continue;\n }\n if (file === \".changeset/config.json\") {\n try {\n const config: unknown = JSON.parse(text);\n if (record(config) && config[\"format\"] !== false)\n add(\n file,\n lineOf(text, '\"format\"'),\n \"changesets must not run a formatter (format: false); format releases with bun fmt\",\n );\n } catch {\n add(file, 1, \"changeset configuration must be valid JSON\");\n }\n continue;\n }\n const automation = githubAutomationFileKind(file);\n if (automation !== undefined || isLefthookConfigPath(file)) {\n const document = parseDocument(text);\n if (document.errors.length > 0) continue;\n const parsed: unknown = document.toJS();\n const commands = runValues(parsed);\n for (const command of commands)\n if (invokesFormatter(command))\n add(\n file,\n lineOf(text, command.split(/\\r?\\n/u)[0] ?? command),\n \"command runs another formatter; use bun fmt\",\n );\n if (automation === \"workflow\") workflowCommands.push(...commands);\n if (isLefthookConfigPath(file) && usesBun) {\n const preCommit = record(parsed) ? parsed[\"pre-commit\"] : undefined;\n if (\n !commandLines(runValues(preCommit)).some((line) =>\n isBunFormat(line, \"--staged\"),\n )\n )\n add(\n file,\n lineOf(text, \"pre-commit\"),\n \"lefthook pre-commit must run bun fmt --staged\",\n );\n }\n continue;\n }\n if (\n text !== \"\" &&\n (isDockerDefinitionPath(file) || isShellScript(file, text))\n )\n for (const [index, line] of text.split(/\\r?\\n/u).entries())\n if (!line.trimStart().startsWith(\"#\") && invokesFormatter(line))\n add(file, index + 1, \"command runs another formatter; use bun fmt\");\n }\n if (!usesBun) return diagnostics;\n const bunfig = files[\"bunfig.toml\"];\n if (bunfig !== undefined)\n for (const message of checkFormatConfig(\n bunfig,\n policy,\n workspacePackageRoots(files),\n ))\n add(\"bunfig.toml\", lineOf(bunfig, \"[fmt\"), message);\n const hasWorkflows = Object.keys(files).some(\n (file) => githubAutomationFileKind(file) === \"workflow\",\n );\n if (\n hasWorkflows &&\n !commandLines(workflowCommands).some((line) => isBunFormat(line, \"--check\"))\n )\n add(\n \".github/workflows\",\n 1,\n \"a workflow must run bun fmt --check over the whole repository\",\n );\n return diagnostics;\n};\n","import { valid } from \"semver\";\n\nimport { parseFormatterPolicy } from \"./toolchain-formatter\";\nimport { nodePolicyValid } from \"./toolchain-node\";\n\nexport const packagePinKeys = [\n \"oxlint\",\n \"oxlint-tsgolint\",\n \"@oxlint/plugins\",\n \"@stll/oxlint-plugin\",\n \"lefthook\",\n] as const;\n\nexport const valkeyArchitectures = [\"amd64\", \"arm64\"] as const;\nexport const valkeyArtifactPackages = {\n server: \"valkey-server\",\n tools: \"valkey-tools\",\n} as const;\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst artifactRecord = (value: unknown, keys: readonly string[]) => {\n if (\n !record(value) ||\n Object.keys(value).some((key) => !keys.includes(key)) ||\n keys.some((key) => !Object.hasOwn(value, key))\n )\n throw new Error(\n \"valkeyArtifacts requires complete, closed artifact objects\",\n );\n return value;\n};\n\nconst parseValkeyArtifacts = (input: unknown, version: string) => {\n const architectures = artifactRecord(input, valkeyArchitectures);\n const line = version.split(\".\").slice(0, 2).join(\".\");\n const parseArchitecture = (\n architecture: (typeof valkeyArchitectures)[number],\n ) => {\n const packages = artifactRecord(\n architectures[architecture],\n Object.keys(valkeyArtifactPackages),\n );\n const parseArtifact = (kind: keyof typeof valkeyArtifactPackages) => {\n const artifact = artifactRecord(packages[kind], [\"url\", \"sha256\"]);\n const url = artifact[\"url\"];\n const sha256 = artifact[\"sha256\"];\n const expected = `https://download.valkey.io/packaging/valkey-${line}/deb/ubuntu2404/${architecture}/${valkeyArtifactPackages[kind]}_${version}-1.noble_${architecture}.deb`;\n if (typeof url !== \"string\" || url !== expected)\n throw new Error(\n \"valkeyArtifacts URL must select the exact official versioned Ubuntu artifact\",\n );\n if (typeof sha256 !== \"string\" || !/^[a-f0-9]{64}$/.test(sha256))\n throw new Error(\"valkeyArtifacts requires a lowercase SHA256 pin\");\n return { url, sha256 };\n };\n return {\n server: parseArtifact(\"server\"),\n tools: parseArtifact(\"tools\"),\n } satisfies Record<\n keyof typeof valkeyArtifactPackages,\n ReturnType<typeof parseArtifact>\n >;\n };\n return {\n amd64: parseArchitecture(\"amd64\"),\n arm64: parseArchitecture(\"arm64\"),\n } satisfies Record<\n (typeof valkeyArchitectures)[number],\n ReturnType<typeof parseArchitecture>\n >;\n};\n\n/** Reject unsupported or incomplete installed policies before inspecting a consumer. */\nexport const parseToolchainPolicy = (input: unknown) => {\n if (!record(input) || input[\"schemaVersion\"] !== 1)\n throw new Error(\"toolchain.json must use schemaVersion 1\");\n const string = (object: Record<string, unknown>, key: string) => {\n const value = object[key];\n if (typeof value !== \"string\" || value.trim() === \"\")\n throw new Error(`toolchain.json requires a nonempty ${key}`);\n return value;\n };\n const packages: Record<string, string> = {};\n for (const key of packagePinKeys) packages[key] = string(input, key);\n const bun = string(input, \"bun\");\n const typescript = string(input, \"typescript\");\n const node = string(input, \"node\");\n const consumerNode = string(input, \"consumerNode\");\n const consumerNpm = string(input, \"consumerNpm\");\n const consumerPnpm = string(input, \"consumerPnpm\");\n const consumerTypescript = string(input, \"consumerTypescript\");\n const python = string(input, \"python\");\n const postgres = string(input, \"postgres\");\n const valkey = string(input, \"valkey\");\n const rust = string(input, \"rust\");\n for (const [name, value] of Object.entries({\n ...packages,\n bun,\n typescript,\n consumerNpm,\n consumerPnpm,\n consumerTypescript,\n }))\n if (valid(value) !== value)\n throw new Error(`toolchain.json ${name} must be an exact release`);\n if (!/^[1-9]\\d*$/.test(postgres) || !Number.isSafeInteger(Number(postgres)))\n throw new Error(\"PostgreSQL must be a canonical positive major\");\n if (valid(valkey) !== valkey || !/^\\d+\\.\\d+\\.\\d+$/.test(valkey))\n throw new Error(\"Valkey must be an exact stable release\");\n const valkeyArtifacts = parseValkeyArtifacts(\n input[\"valkeyArtifacts\"],\n valkey,\n );\n if (!nodePolicyValid(node))\n throw new Error(\"Node must be a canonical major N.x series\");\n if (\n valid(consumerNode) !== consumerNode ||\n !consumerNode.startsWith(\"22.\") ||\n consumerNode.includes(\"-\") ||\n consumerNode.includes(\"+\")\n )\n throw new Error(\"consumerNode must be an exact stable Node 22 release\");\n if (!/^\\d+\\.\\d+(?:\\.\\d+)?$/.test(python))\n throw new Error(\"Python must be an exact minor or patch release\");\n if (!/^\\d+\\.\\d+\\.\\d+$/.test(rust))\n throw new Error(\"Rust must be an exact stable release\");\n if (\n !consumerTypescript.startsWith(\"6.\") ||\n consumerTypescript.includes(\"-\") ||\n consumerTypescript.includes(\"+\")\n )\n throw new Error(\n \"consumerTypescript must be an exact stable TypeScript 6 release\",\n );\n const actionsInput = input[\"actions\"];\n if (!record(actionsInput) || Object.keys(actionsInput).length === 0)\n throw new Error(\"missing approved actions\");\n const actions: Record<string, { sha: string; version: string }> = {};\n for (const [name, action] of Object.entries(actionsInput)) {\n if (!record(action)) throw new Error(`invalid action policy: ${name}`);\n const sha = string(action, \"sha\");\n const actionVersion = string(action, \"version\");\n if (!/^[a-f0-9]{40}$/.test(sha) || !/^v\\d+(?:\\.\\d+)*$/.test(actionVersion))\n throw new Error(`invalid action SHA/version: ${name}`);\n actions[name] = { sha, version: actionVersion };\n }\n const dependabotInput = input[\"dependabot\"];\n if (\n !record(dependabotInput) ||\n !record(dependabotInput[\"schedule\"]) ||\n !record(dependabotInput[\"cooldown\"]) ||\n !record(dependabotInput[\"groups\"])\n )\n throw new Error(\"missing Dependabot policy\");\n const scheduleInput = dependabotInput[\"schedule\"];\n const schedule = {\n interval: string(scheduleInput, \"interval\"),\n day: string(scheduleInput, \"day\"),\n time: string(scheduleInput, \"time\"),\n timezone: string(scheduleInput, \"timezone\"),\n };\n const defaultDays = dependabotInput[\"cooldown\"][\"defaultDays\"];\n if (\n typeof defaultDays !== \"number\" ||\n !Number.isInteger(defaultDays) ||\n defaultDays < 5\n )\n throw new Error(\"Dependabot cooldown must be at least five days\");\n const strings = (value: unknown): string[] => {\n if (\n !Array.isArray(value) ||\n !value.every((entry: unknown) => typeof entry === \"string\")\n )\n throw new Error(\"Dependabot group values must be string arrays\");\n return value;\n };\n // First-party reusable workflows move by commit, without a semver update\n // type, and must land together; they precede the shared semver groups.\n const actionGroupsInput = dependabotInput[\"actionGroups\"];\n if (!record(actionGroupsInput))\n throw new Error(\"missing Dependabot action groups\");\n const actionGroups: Record<string, { patterns: string[] }> = {};\n for (const [name, group] of Object.entries(actionGroupsInput)) {\n if (!record(group) || Object.keys(group).some((key) => key !== \"patterns\"))\n throw new Error(`invalid Dependabot action group: ${name}`);\n actionGroups[name] = { patterns: strings(group[\"patterns\"]) };\n }\n const groups: Record<string, { patterns: string[]; updateTypes: string[] }> =\n {};\n for (const [name, group] of Object.entries(dependabotInput[\"groups\"])) {\n if (!record(group)) throw new Error(`invalid Dependabot group: ${name}`);\n groups[name] = {\n patterns: strings(group[\"patterns\"]),\n updateTypes: strings(group[\"updateTypes\"]),\n };\n }\n return {\n bun,\n formatter: parseFormatterPolicy(input[\"formatter\"]),\n typescript,\n node,\n postgres,\n valkey,\n valkeyArtifacts,\n consumerNode,\n consumerNpm,\n consumerPnpm,\n consumerTypescript,\n python,\n rust,\n packages,\n actions,\n dependabot: {\n schedule,\n cooldown: { defaultDays },\n actionGroups,\n groups,\n ignoredPackages: [\n ...new Set([\n ...Object.keys(packages),\n // The consumer package managers move only with a reviewed\n // consumerNpm or consumerPnpm change.\n \"npm\",\n \"pnpm\",\n // A repository's TypeScript install moves only with a reviewed\n // typescriptAllowlist change in stll-toolchain.json.\n \"typescript\",\n \"@typescript/native\",\n \"bun-types\",\n ]),\n ],\n ignoredActions: Object.keys(actions),\n ignoredImages: [\"node\", \"python\", \"oven/bun\"],\n },\n };\n};\n"],"mappings":";;;;;;;AAcA,MAAa,gBAAgB;;AAmB7B,MAAa,uBAAuB,CAClC,kBACA,iBACF;AAEA,MAAMA,YAAU,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;AAGrE,MAAa,wBAAwB,UAAoC;CACvE,IACE,CAACA,SAAO,KAAK,KACb,OAAO,KAAK,KAAK,CAAC,CAAC,MAChB,QAAQ,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ACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;GACV;GACA,UAAU,EAAE,YAAY;GACxB;GACA;GACA,iBAAiB,CACf,mBAAG,IAAI,IAAI;IACT,GAAG,OAAO,KAAK,QAAQ;IAGvB;IACA;IAGA;IACA;IACA;GACF,CAAC,CACH;GACA,gBAAgB,OAAO,KAAK,OAAO;GACnC,eAAe;IAAC;IAAQ;IAAU;GAAU;EAC9C;CACF;AACF"}
|
|
@@ -1,13 +1,51 @@
|
|
|
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_typecheck_parity = require("./typecheck-parity.cjs");
|
|
5
4
|
let node_fs_promises = require("node:fs/promises");
|
|
6
5
|
let node_path = require("node:path");
|
|
7
6
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
7
|
let node_child_process = require("node:child_process");
|
|
9
8
|
let node_crypto = require("node:crypto");
|
|
9
|
+
let node_util = require("node:util");
|
|
10
10
|
//#region src/typecheck-probe.ts
|
|
11
|
+
const diagnosticLocation = (file, repo) => {
|
|
12
|
+
const normalized = file.replaceAll("\\", "/");
|
|
13
|
+
const bundled = /^bundled:\/\/\/libs\/(lib\.[^/]+\.d\.ts)$/.exec(normalized);
|
|
14
|
+
const installed = /(?:^|\/)node_modules\/(?:typescript|@typescript\/(?:native|typescript-[^/]+))\/(?:.*\/)?(lib\.[^/]+\.d\.ts)$/.exec(normalized);
|
|
15
|
+
const library = bundled?.at(1) ?? installed?.at(1);
|
|
16
|
+
return library === void 0 ? (0, node_path.relative)(repo, (0, node_path.resolve)(repo, file)).replaceAll("\\", "/") : `<lib>/${library}`;
|
|
17
|
+
};
|
|
18
|
+
const globalDiagnosticKey = (code, message) => `<config>:0:${code}:${message.trim().replaceAll(/\s+/g, " ")}`;
|
|
19
|
+
/** Normalizes checker output to sorted `file:line:code` keys. */
|
|
20
|
+
const diagnosticSet = (output, repo) => {
|
|
21
|
+
const clean = (0, node_util.stripVTControlCharacters)(output);
|
|
22
|
+
const diagnostics = /* @__PURE__ */ new Set();
|
|
23
|
+
for (const block of clean.matchAll(/<error\b([^>]*)>([\s\S]*?)<\/error>/g)) {
|
|
24
|
+
const attributes = new Map([...(block.at(1) ?? "").matchAll(/(\w+)="([^"]*)"/g)].map((match) => [match.at(1), match.at(2)]));
|
|
25
|
+
const file = attributes.get("file");
|
|
26
|
+
const row = attributes.get("line");
|
|
27
|
+
const code = attributes.get("code");
|
|
28
|
+
if (code === void 0 || !/^TS\d+$/.test(code)) continue;
|
|
29
|
+
if (file !== void 0 && row !== void 0 && row !== "0") diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`);
|
|
30
|
+
else {
|
|
31
|
+
const message = (block.at(2) ?? "").split(/<(?:source|related)\b/).at(0) ?? "";
|
|
32
|
+
diagnostics.add(globalDiagnosticKey(code.slice(2), message));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const rawLine of clean.split("\n")) {
|
|
36
|
+
const line = rawLine.replace(/^(?!(?:error|warning) TS\d+:)(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]* [a-zA-Z0-9_.:-]+: /, "");
|
|
37
|
+
if (line.startsWith("<error ")) continue;
|
|
38
|
+
const match = /^(.*?)\((\d+),\d+\):\s*(?:error|warning) TS(\d+)/.exec(line) ?? /^(.*?):(\d+):\d+:\s*(?:error|warning) (?:TS)?(\d+)/.exec(line);
|
|
39
|
+
if (match) {
|
|
40
|
+
const [, file = "", row = "", code = ""] = match;
|
|
41
|
+
diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);
|
|
42
|
+
} else {
|
|
43
|
+
const global = /^(?:error|warning) TS(\d+):\s*(.*)/.exec(line);
|
|
44
|
+
if (global) diagnostics.add(globalDiagnosticKey(global.at(1) ?? "", global.at(2) ?? ""));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return [...diagnostics].sort();
|
|
48
|
+
};
|
|
11
49
|
const runProbeCommand = ({ command, cwd, signal }) => new Promise((done, reject) => {
|
|
12
50
|
const executable = command.at(0);
|
|
13
51
|
if (executable === void 0) {
|
|
@@ -120,7 +158,7 @@ const runTypecheckProbe = async ({ repo, project, seedDirectory, command, output
|
|
|
120
158
|
}
|
|
121
159
|
const seeded = await execute();
|
|
122
160
|
if (seeded.status === null || seeded.status === 0) throw new Error(`typecheck probe expected the seeded command to fail: ${seedLocation}`);
|
|
123
|
-
if (![.../* @__PURE__ */ new Set([root, (0, node_path.dirname)(config)])].some((origin) =>
|
|
161
|
+
if (![.../* @__PURE__ */ new Set([root, (0, node_path.dirname)(config)])].some((origin) => diagnosticSet(seeded.output, origin).includes(`${(0, node_path.relative)(origin, seed).replaceAll("\\", "/")}:1:2322`))) throw new Error(`typecheck probe expected TS2322 attributed to ${seedLocation}; the declared project may exclude the seed`);
|
|
124
162
|
await removeSeed();
|
|
125
163
|
const clean = await execute();
|
|
126
164
|
if (clean.status !== 0) throw new Error(`typecheck probe clean command failed with status ${clean.status ?? "unknown"}: ${project}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-probe-cli.cjs","names":["spawn","path","realpath","resolve","stat","dirname","isAbsolute","join","randomUUID","relative","unlink","open","diagnosticSet"],"sources":["../src/typecheck-probe.ts","../src/typecheck-probe-args.ts","../src/typecheck-probe-cli.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { open, realpath, stat, unlink } from \"node:fs/promises\";\nimport path, { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\n\nimport { diagnosticSet } from \"./typecheck-parity\";\n\ntype ProbeCommandOptions = {\n command: readonly string[];\n cwd: string;\n signal: AbortSignal;\n};\ntype ProbeCommandResult = { status: number | null; output: string };\n\nconst runProbeCommand = ({ command, cwd, signal }: ProbeCommandOptions) =>\n new Promise<ProbeCommandResult>((done, reject) => {\n const executable = command.at(0);\n if (executable === undefined) {\n reject(new Error(\"typecheck probe command is empty\"));\n return;\n }\n const child = spawn(executable, command.slice(1), {\n cwd,\n signal,\n shell: false,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let output = \"\";\n child.stdout.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.once(\"error\", reject);\n child.once(\"close\", (status) => done({ status, output }));\n });\n\ntype ProbePathContainmentOptions = {\n root: string;\n candidate: string;\n paths?: Pick<typeof path, \"relative\" | \"isAbsolute\" | \"sep\">;\n};\n\nexport const insideProbePath = ({\n root,\n candidate,\n paths = path,\n}: ProbePathContainmentOptions) => {\n const location = paths.relative(root, candidate);\n return (\n location !== \"..\" &&\n !location.startsWith(\"..\" + paths.sep) &&\n !paths.isAbsolute(location)\n );\n};\n\ntype RunTypecheckProbeOptions = {\n repo: string;\n project: string;\n seedDirectory?: string | undefined;\n command: readonly string[];\n output?: (text: string) => void;\n run?: (options: ProbeCommandOptions) => Promise<ProbeCommandResult>;\n};\n\nexport const runTypecheckProbe = async ({\n repo,\n project,\n seedDirectory,\n command,\n output,\n run = runProbeCommand,\n}: RunTypecheckProbeOptions) => {\n const executable = command.at(0);\n if (\n executable === undefined ||\n executable === \"\" ||\n command.some((argument) => argument.includes(\"\\0\"))\n )\n throw new Error(\n \"typecheck probe requires a nonempty command argv without NUL bytes\",\n );\n if (project === \"\")\n throw new Error(\"typecheck probe requires an explicit project file\");\n const root = await realpath(repo);\n const requested = resolve(root, project);\n if (!insideProbePath({ root, candidate: requested }))\n throw new Error(\n `typecheck probe project is outside the repository: ${project}`,\n );\n const config = await realpath(requested);\n if (!insideProbePath({ root, candidate: config }))\n throw new Error(\n `typecheck probe project resolves outside the repository: ${project}`,\n );\n if (!(await stat(config)).isFile())\n throw new Error(`typecheck probe project must be a file: ${project}`);\n let seedParent = dirname(config);\n if (seedDirectory !== undefined) {\n if (seedDirectory === \"\" || isAbsolute(seedDirectory))\n throw new Error(\n \"typecheck probe seed directory must be repository-relative\",\n );\n const requestedSeedParent = resolve(root, seedDirectory);\n if (!insideProbePath({ root, candidate: requestedSeedParent }))\n throw new Error(\n `typecheck probe seed directory is outside the repository: ${seedDirectory}`,\n );\n seedParent = await realpath(requestedSeedParent);\n if (\n !insideProbePath({ root, candidate: seedParent }) ||\n !insideProbePath({ root: dirname(config), candidate: seedParent })\n )\n throw new Error(\n `typecheck probe seed directory must be inside the declared project: ${seedDirectory}`,\n );\n if (!(await stat(seedParent)).isDirectory())\n throw new Error(\n `typecheck probe seed directory must be a directory: ${seedDirectory}`,\n );\n }\n const seed = join(seedParent, `stll-typecheck-probe-${randomUUID()}.ts`);\n const seedLocation = relative(root, seed).replaceAll(\"\\\\\", \"/\");\n const controller = new AbortController();\n const interrupt = (signal: string) =>\n controller.abort(new Error(`typecheck probe interrupted by ${signal}`));\n const onInterrupt = () => interrupt(\"SIGINT\");\n const onTerminate = () => interrupt(\"SIGTERM\");\n process.on(\"SIGINT\", onInterrupt);\n process.on(\"SIGTERM\", onTerminate);\n let created = false;\n const removeSeed = async () => {\n if (!created) return;\n await unlink(seed);\n created = false;\n };\n const execute = async () => {\n controller.signal.throwIfAborted();\n let onAbort: (() => void) | undefined;\n const aborted = new Promise<never>((_done, reject) => {\n onAbort = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n try {\n const result = await Promise.race([\n run({ command, cwd: root, signal: controller.signal }),\n aborted,\n ]);\n controller.signal.throwIfAborted();\n output?.(result.output);\n return result;\n } finally {\n if (onAbort !== undefined)\n controller.signal.removeEventListener(\"abort\", onAbort);\n }\n };\n try {\n controller.signal.throwIfAborted();\n const file = await open(seed, \"wx\", 0o600);\n created = true;\n try {\n await file.writeFile('export const typecheckProbe: number = \"wrong\";\\n');\n } finally {\n await file.close();\n }\n const seeded = await execute();\n if (seeded.status === null || seeded.status === 0)\n throw new Error(\n `typecheck probe expected the seeded command to fail: ${seedLocation}`,\n );\n // Workspace runners may report compiler paths from the declared project.\n // Only the exact owned seed under either known command origin is accepted.\n const origins = new Set([root, dirname(config)]);\n const attributed = [...origins].some((origin) =>\n diagnosticSet(seeded.output, origin).includes(\n `${relative(origin, seed).replaceAll(\"\\\\\", \"/\")}:1:2322`,\n ),\n );\n if (!attributed)\n throw new Error(\n `typecheck probe expected TS2322 attributed to ${seedLocation}; the declared project may exclude the seed`,\n );\n await removeSeed();\n const clean = await execute();\n if (clean.status !== 0)\n throw new Error(\n `typecheck probe clean command failed with status ${clean.status ?? \"unknown\"}: ${project}`,\n );\n } finally {\n try {\n await removeSeed();\n } finally {\n process.removeListener(\"SIGINT\", onInterrupt);\n process.removeListener(\"SIGTERM\", onTerminate);\n }\n }\n};\n","export const probeUsage =\n \"Usage: stll-typecheck-probe --project <tsconfig> [--seed-dir <directory>] -- <command> [args...]\\n stll-typecheck-probe --help\";\n\nexport const parseProbeArguments = (args: readonly string[]) => {\n if (args.length === 1 && args.at(0) === \"--help\")\n return { mode: \"help\" } as const;\n const project = args.at(1);\n const seedDirectory = args.at(2) === \"--seed-dir\" ? args.at(3) : undefined;\n const separator = seedDirectory === undefined ? 2 : 4;\n const command = args.slice(separator + 1);\n if (\n args.at(0) !== \"--project\" ||\n project === undefined ||\n project.trim() === \"\" ||\n project.startsWith(\"-\") ||\n args.at(separator) !== \"--\" ||\n (seedDirectory !== undefined &&\n (seedDirectory.trim() === \"\" || seedDirectory.startsWith(\"-\"))) ||\n command.length === 0 ||\n command.some((value) => value.trim() === \"\")\n )\n throw new Error(probeUsage);\n return {\n mode: \"probe\",\n project,\n command,\n ...(seedDirectory === undefined ? {} : { seedDirectory }),\n } as const;\n};\n","#!/usr/bin/env node\nimport { runTypecheckProbe } from \"./typecheck-probe\";\nimport { parseProbeArguments, probeUsage } from \"./typecheck-probe-args\";\n\nconst main = async () => {\n const args = parseProbeArguments(process.argv.slice(2));\n if (args.mode === \"help\") {\n process.stdout.write(`${probeUsage}\\n`);\n return;\n }\n await runTypecheckProbe({\n repo: process.cwd(),\n project: args.project,\n command: args.command,\n seedDirectory: args.seedDirectory,\n output: (text) => process.stdout.write(text),\n });\n process.stdout.write(\n \"typecheck probe passed: seeded TS2322 detected and clean typecheck passed\\n\",\n );\n};\n\nmain().catch((error: unknown) => {\n process.stderr.write(\n `typecheck-probe: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;AAcA,MAAM,mBAAmB,EAAE,SAAS,KAAK,aACvC,IAAI,SAA6B,MAAM,WAAW;CAChD,MAAM,aAAa,QAAQ,GAAG,CAAC;CAC/B,IAAI,eAAe,KAAA,GAAW;EAC5B,uBAAO,IAAI,MAAM,kCAAkC,CAAC;EACpD;CACF;CACA,MAAM,SAAA,GAAQA,mBAAAA,MAAAA,CAAM,YAAY,QAAQ,MAAM,CAAC,GAAG;EAChD;EACA;EACA,OAAO;EACP,OAAO;GAAC;GAAU;GAAQ;EAAM;CAClC,CAAC;CACD,IAAI,SAAS;CACb,MAAM,OAAO,GAAG,SAAS,UAAkB;EACzC,UAAU,MAAM,SAAS;CAC3B,CAAC;CACD,MAAM,OAAO,GAAG,SAAS,UAAkB;EACzC,UAAU,MAAM,SAAS;CAC3B,CAAC;CACD,MAAM,KAAK,SAAS,MAAM;CAC1B,MAAM,KAAK,UAAU,WAAW,KAAK;EAAE;EAAQ;CAAO,CAAC,CAAC;AAC1D,CAAC;AAQH,MAAa,mBAAmB,EAC9B,MACA,WACA,QAAQC,UAAAA,cACyB;CACjC,MAAM,WAAW,MAAM,SAAS,MAAM,SAAS;CAC/C,OACE,aAAa,QACb,CAAC,SAAS,WAAW,OAAO,MAAM,GAAG,KACrC,CAAC,MAAM,WAAW,QAAQ;AAE9B;AAWA,MAAa,oBAAoB,OAAO,EACtC,MACA,SACA,eACA,SACA,QACA,MAAM,sBACwB;CAC9B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KACZ,QAAQ,KAAK,MAAM,MACnB,QAAQ,WAAW,GAAG,KACtB,KAAK,GAAG,SAAS,MAAM,QACtB,kBAAkB,KAAA,MAChB,cAAc,KAAK,MAAM,MAAM,cAAc,WAAW,GAAG,MAC9D,QAAQ,WAAW,KACnB,QAAQ,MAAM,UAAU,MAAM,KAAK,MAAM,EAAE,GAE3C,MAAM,IAAI,MAAM,UAAU;CAC5B,OAAO;EACL,MAAM;EACN;EACA;EACA,GAAI,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc;CACzD;AACF;;;ACxBA,MAAM,OAAO,YAAY;CACvB,MAAM,OAAO,oBAAoB,QAAQ,KAAK,MAAM,CAAC,CAAC;CACtD,IAAI,KAAK,SAAS,QAAQ;EACxB,QAAQ,OAAO,MAAM,GAAG,WAAW,GAAG;EACtC;CACF;CACA,MAAM,kBAAkB;EACtB,MAAM,QAAQ,IAAI;EAClB,SAAS,KAAK;EACd,SAAS,KAAK;EACd,eAAe,KAAK;EACpB,SAAS,SAAS,QAAQ,OAAO,MAAM,IAAI;CAC7C,CAAC;CACD,QAAQ,OAAO,MACb,6EACF;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,OAAO,MACb,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC7E;CACA,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"typecheck-probe-cli.cjs","names":["relative","resolve","stripVTControlCharacters","spawn","path","realpath","stat","dirname","isAbsolute","join","randomUUID","unlink","open"],"sources":["../src/typecheck-probe.ts","../src/typecheck-probe-args.ts","../src/typecheck-probe-cli.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { open, realpath, stat, unlink } from \"node:fs/promises\";\nimport path, { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { stripVTControlCharacters } from \"node:util\";\n\nconst diagnosticLocation = (file: string, repo: string) => {\n const normalized = file.replaceAll(\"\\\\\", \"/\");\n const bundled = /^bundled:\\/\\/\\/libs\\/(lib\\.[^/]+\\.d\\.ts)$/.exec(normalized);\n const installed =\n /(?:^|\\/)node_modules\\/(?:typescript|@typescript\\/(?:native|typescript-[^/]+))\\/(?:.*\\/)?(lib\\.[^/]+\\.d\\.ts)$/.exec(\n normalized,\n );\n const library = bundled?.at(1) ?? installed?.at(1);\n return library === undefined\n ? relative(repo, resolve(repo, file)).replaceAll(\"\\\\\", \"/\")\n : `<lib>/${library}`;\n};\nconst globalDiagnosticKey = (code: string, message: string) =>\n `<config>:0:${code}:${message.trim().replaceAll(/\\s+/g, \" \")}`;\n\n/** Normalizes checker output to sorted `file:line:code` keys. */\nexport const diagnosticSet = (output: string, repo: string): string[] => {\n const clean = stripVTControlCharacters(output);\n const diagnostics = new Set<string>();\n for (const block of clean.matchAll(/<error\\b([^>]*)>([\\s\\S]*?)<\\/error>/g)) {\n const attributes = new Map(\n [...(block.at(1) ?? \"\").matchAll(/(\\w+)=\"([^\"]*)\"/g)].map((match) => [\n match.at(1),\n match.at(2),\n ]),\n );\n const file = attributes.get(\"file\");\n const row = attributes.get(\"line\");\n const code = attributes.get(\"code\");\n if (code === undefined || !/^TS\\d+$/.test(code)) continue;\n if (file !== undefined && row !== undefined && row !== \"0\")\n diagnostics.add(\n `${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`,\n );\n else {\n const message =\n (block.at(2) ?? \"\").split(/<(?:source|related)\\b/).at(0) ?? \"\";\n diagnostics.add(globalDiagnosticKey(code.slice(2), message));\n }\n }\n for (const rawLine of clean.split(\"\\n\")) {\n const line = rawLine.replace(\n /^(?!(?:error|warning) TS\\d+:)(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]* [a-zA-Z0-9_.:-]+: /,\n \"\",\n );\n if (line.startsWith(\"<error \")) continue;\n const match =\n /^(.*?)\\((\\d+),\\d+\\):\\s*(?:error|warning) TS(\\d+)/.exec(line) ??\n /^(.*?):(\\d+):\\d+:\\s*(?:error|warning) (?:TS)?(\\d+)/.exec(line);\n if (match) {\n const [, file = \"\", row = \"\", code = \"\"] = match;\n diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);\n } else {\n const global = /^(?:error|warning) TS(\\d+):\\s*(.*)/.exec(line);\n if (global)\n diagnostics.add(\n globalDiagnosticKey(global.at(1) ?? \"\", global.at(2) ?? \"\"),\n );\n }\n }\n return [...diagnostics].sort();\n};\n\ntype ProbeCommandOptions = {\n command: readonly string[];\n cwd: string;\n signal: AbortSignal;\n};\ntype ProbeCommandResult = { status: number | null; output: string };\n\nconst runProbeCommand = ({ command, cwd, signal }: ProbeCommandOptions) =>\n new Promise<ProbeCommandResult>((done, reject) => {\n const executable = command.at(0);\n if (executable === undefined) {\n reject(new Error(\"typecheck probe command is empty\"));\n return;\n }\n const child = spawn(executable, command.slice(1), {\n cwd,\n signal,\n shell: false,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let output = \"\";\n child.stdout.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.once(\"error\", reject);\n child.once(\"close\", (status) => done({ status, output }));\n });\n\ntype ProbePathContainmentOptions = {\n root: string;\n candidate: string;\n paths?: Pick<typeof path, \"relative\" | \"isAbsolute\" | \"sep\">;\n};\n\nexport const insideProbePath = ({\n root,\n candidate,\n paths = path,\n}: ProbePathContainmentOptions) => {\n const location = paths.relative(root, candidate);\n return (\n location !== \"..\" &&\n !location.startsWith(\"..\" + paths.sep) &&\n !paths.isAbsolute(location)\n );\n};\n\ntype RunTypecheckProbeOptions = {\n repo: string;\n project: string;\n seedDirectory?: string | undefined;\n command: readonly string[];\n output?: (text: string) => void;\n run?: (options: ProbeCommandOptions) => Promise<ProbeCommandResult>;\n};\n\nexport const runTypecheckProbe = async ({\n repo,\n project,\n seedDirectory,\n command,\n output,\n run = runProbeCommand,\n}: RunTypecheckProbeOptions) => {\n const executable = command.at(0);\n if (\n executable === undefined ||\n executable === \"\" ||\n command.some((argument) => argument.includes(\"\\0\"))\n )\n throw new Error(\n \"typecheck probe requires a nonempty command argv without NUL bytes\",\n );\n if (project === \"\")\n throw new Error(\"typecheck probe requires an explicit project file\");\n const root = await realpath(repo);\n const requested = resolve(root, project);\n if (!insideProbePath({ root, candidate: requested }))\n throw new Error(\n `typecheck probe project is outside the repository: ${project}`,\n );\n const config = await realpath(requested);\n if (!insideProbePath({ root, candidate: config }))\n throw new Error(\n `typecheck probe project resolves outside the repository: ${project}`,\n );\n if (!(await stat(config)).isFile())\n throw new Error(`typecheck probe project must be a file: ${project}`);\n let seedParent = dirname(config);\n if (seedDirectory !== undefined) {\n if (seedDirectory === \"\" || isAbsolute(seedDirectory))\n throw new Error(\n \"typecheck probe seed directory must be repository-relative\",\n );\n const requestedSeedParent = resolve(root, seedDirectory);\n if (!insideProbePath({ root, candidate: requestedSeedParent }))\n throw new Error(\n `typecheck probe seed directory is outside the repository: ${seedDirectory}`,\n );\n seedParent = await realpath(requestedSeedParent);\n if (\n !insideProbePath({ root, candidate: seedParent }) ||\n !insideProbePath({ root: dirname(config), candidate: seedParent })\n )\n throw new Error(\n `typecheck probe seed directory must be inside the declared project: ${seedDirectory}`,\n );\n if (!(await stat(seedParent)).isDirectory())\n throw new Error(\n `typecheck probe seed directory must be a directory: ${seedDirectory}`,\n );\n }\n const seed = join(seedParent, `stll-typecheck-probe-${randomUUID()}.ts`);\n const seedLocation = relative(root, seed).replaceAll(\"\\\\\", \"/\");\n const controller = new AbortController();\n const interrupt = (signal: string) =>\n controller.abort(new Error(`typecheck probe interrupted by ${signal}`));\n const onInterrupt = () => interrupt(\"SIGINT\");\n const onTerminate = () => interrupt(\"SIGTERM\");\n process.on(\"SIGINT\", onInterrupt);\n process.on(\"SIGTERM\", onTerminate);\n let created = false;\n const removeSeed = async () => {\n if (!created) return;\n await unlink(seed);\n created = false;\n };\n const execute = async () => {\n controller.signal.throwIfAborted();\n let onAbort: (() => void) | undefined;\n const aborted = new Promise<never>((_done, reject) => {\n onAbort = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n try {\n const result = await Promise.race([\n run({ command, cwd: root, signal: controller.signal }),\n aborted,\n ]);\n controller.signal.throwIfAborted();\n output?.(result.output);\n return result;\n } finally {\n if (onAbort !== undefined)\n controller.signal.removeEventListener(\"abort\", onAbort);\n }\n };\n try {\n controller.signal.throwIfAborted();\n const file = await open(seed, \"wx\", 0o600);\n created = true;\n try {\n await file.writeFile('export const typecheckProbe: number = \"wrong\";\\n');\n } finally {\n await file.close();\n }\n const seeded = await execute();\n if (seeded.status === null || seeded.status === 0)\n throw new Error(\n `typecheck probe expected the seeded command to fail: ${seedLocation}`,\n );\n // Workspace runners may report compiler paths from the declared project.\n // Only the exact owned seed under either known command origin is accepted.\n const origins = new Set([root, dirname(config)]);\n const attributed = [...origins].some((origin) =>\n diagnosticSet(seeded.output, origin).includes(\n `${relative(origin, seed).replaceAll(\"\\\\\", \"/\")}:1:2322`,\n ),\n );\n if (!attributed)\n throw new Error(\n `typecheck probe expected TS2322 attributed to ${seedLocation}; the declared project may exclude the seed`,\n );\n await removeSeed();\n const clean = await execute();\n if (clean.status !== 0)\n throw new Error(\n `typecheck probe clean command failed with status ${clean.status ?? \"unknown\"}: ${project}`,\n );\n } finally {\n try {\n await removeSeed();\n } finally {\n process.removeListener(\"SIGINT\", onInterrupt);\n process.removeListener(\"SIGTERM\", onTerminate);\n }\n }\n};\n","export const probeUsage =\n \"Usage: stll-typecheck-probe --project <tsconfig> [--seed-dir <directory>] -- <command> [args...]\\n stll-typecheck-probe --help\";\n\nexport const parseProbeArguments = (args: readonly string[]) => {\n if (args.length === 1 && args.at(0) === \"--help\")\n return { mode: \"help\" } as const;\n const project = args.at(1);\n const seedDirectory = args.at(2) === \"--seed-dir\" ? args.at(3) : undefined;\n const separator = seedDirectory === undefined ? 2 : 4;\n const command = args.slice(separator + 1);\n if (\n args.at(0) !== \"--project\" ||\n project === undefined ||\n project.trim() === \"\" ||\n project.startsWith(\"-\") ||\n args.at(separator) !== \"--\" ||\n (seedDirectory !== undefined &&\n (seedDirectory.trim() === \"\" || seedDirectory.startsWith(\"-\"))) ||\n command.length === 0 ||\n command.some((value) => value.trim() === \"\")\n )\n throw new Error(probeUsage);\n return {\n mode: \"probe\",\n project,\n command,\n ...(seedDirectory === undefined ? {} : { seedDirectory }),\n } as const;\n};\n","#!/usr/bin/env node\nimport { runTypecheckProbe } from \"./typecheck-probe\";\nimport { parseProbeArguments, probeUsage } from \"./typecheck-probe-args\";\n\nconst main = async () => {\n const args = parseProbeArguments(process.argv.slice(2));\n if (args.mode === \"help\") {\n process.stdout.write(`${probeUsage}\\n`);\n return;\n }\n await runTypecheckProbe({\n repo: process.cwd(),\n project: args.project,\n command: args.command,\n seedDirectory: args.seedDirectory,\n output: (text) => process.stdout.write(text),\n });\n process.stdout.write(\n \"typecheck probe passed: seeded TS2322 detected and clean typecheck passed\\n\",\n );\n};\n\nmain().catch((error: unknown) => {\n process.stderr.write(\n `typecheck-probe: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;AAMA,MAAM,sBAAsB,MAAc,SAAiB;CACzD,MAAM,aAAa,KAAK,WAAW,MAAM,GAAG;CAC5C,MAAM,UAAU,4CAA4C,KAAK,UAAU;CAC3E,MAAM,YACJ,+GAA+G,KAC7G,UACF;CACF,MAAM,UAAU,SAAS,GAAG,CAAC,KAAK,WAAW,GAAG,CAAC;CACjD,OAAO,YAAY,KAAA,KAAA,GACfA,UAAAA,SAAAA,CAAS,OAAA,GAAMC,UAAAA,QAAAA,CAAQ,MAAM,IAAI,CAAC,CAAC,CAAC,WAAW,MAAM,GAAG,IACxD,SAAS;AACf;AACA,MAAM,uBAAuB,MAAc,YACzC,cAAc,KAAK,GAAG,QAAQ,KAAK,CAAC,CAAC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AQ,WAAW,KACnB,QAAQ,MAAM,UAAU,MAAM,KAAK,MAAM,EAAE,GAE3C,MAAM,IAAI,MAAM,UAAU;CAC5B,OAAO;EACL,MAAM;EACN;EACA;EACA,GAAI,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc;CACzD;AACF;;;ACxBA,MAAM,OAAO,YAAY;CACvB,MAAM,OAAO,oBAAoB,QAAQ,KAAK,MAAM,CAAC,CAAC;CACtD,IAAI,KAAK,SAAS,QAAQ;EACxB,QAAQ,OAAO,MAAM,GAAG,WAAW,GAAG;EACtC;CACF;CACA,MAAM,kBAAkB;EACtB,MAAM,QAAQ,IAAI;EAClB,SAAS,KAAK;EACd,SAAS,KAAK;EACd,eAAe,KAAK;EACpB,SAAS,SAAS,QAAQ,OAAO,MAAM,IAAI;CAC7C,CAAC;CACD,QAAQ,OAAO,MACb,6EACF;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,OAAO,MACb,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC7E;CACA,QAAQ,WAAW;AACrB,CAAC"}
|
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as diagnosticSet } from "./typecheck-parity.mjs";
|
|
3
2
|
import { open, realpath, stat, unlink } from "node:fs/promises";
|
|
4
3
|
import path, { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
4
|
import { spawn } from "node:child_process";
|
|
6
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { stripVTControlCharacters } from "node:util";
|
|
7
7
|
//#region src/typecheck-probe.ts
|
|
8
|
+
const diagnosticLocation = (file, repo) => {
|
|
9
|
+
const normalized = file.replaceAll("\\", "/");
|
|
10
|
+
const bundled = /^bundled:\/\/\/libs\/(lib\.[^/]+\.d\.ts)$/.exec(normalized);
|
|
11
|
+
const installed = /(?:^|\/)node_modules\/(?:typescript|@typescript\/(?:native|typescript-[^/]+))\/(?:.*\/)?(lib\.[^/]+\.d\.ts)$/.exec(normalized);
|
|
12
|
+
const library = bundled?.at(1) ?? installed?.at(1);
|
|
13
|
+
return library === void 0 ? relative(repo, resolve(repo, file)).replaceAll("\\", "/") : `<lib>/${library}`;
|
|
14
|
+
};
|
|
15
|
+
const globalDiagnosticKey = (code, message) => `<config>:0:${code}:${message.trim().replaceAll(/\s+/g, " ")}`;
|
|
16
|
+
/** Normalizes checker output to sorted `file:line:code` keys. */
|
|
17
|
+
const diagnosticSet = (output, repo) => {
|
|
18
|
+
const clean = stripVTControlCharacters(output);
|
|
19
|
+
const diagnostics = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const block of clean.matchAll(/<error\b([^>]*)>([\s\S]*?)<\/error>/g)) {
|
|
21
|
+
const attributes = new Map([...(block.at(1) ?? "").matchAll(/(\w+)="([^"]*)"/g)].map((match) => [match.at(1), match.at(2)]));
|
|
22
|
+
const file = attributes.get("file");
|
|
23
|
+
const row = attributes.get("line");
|
|
24
|
+
const code = attributes.get("code");
|
|
25
|
+
if (code === void 0 || !/^TS\d+$/.test(code)) continue;
|
|
26
|
+
if (file !== void 0 && row !== void 0 && row !== "0") diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`);
|
|
27
|
+
else {
|
|
28
|
+
const message = (block.at(2) ?? "").split(/<(?:source|related)\b/).at(0) ?? "";
|
|
29
|
+
diagnostics.add(globalDiagnosticKey(code.slice(2), message));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const rawLine of clean.split("\n")) {
|
|
33
|
+
const line = rawLine.replace(/^(?!(?:error|warning) TS\d+:)(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]* [a-zA-Z0-9_.:-]+: /, "");
|
|
34
|
+
if (line.startsWith("<error ")) continue;
|
|
35
|
+
const match = /^(.*?)\((\d+),\d+\):\s*(?:error|warning) TS(\d+)/.exec(line) ?? /^(.*?):(\d+):\d+:\s*(?:error|warning) (?:TS)?(\d+)/.exec(line);
|
|
36
|
+
if (match) {
|
|
37
|
+
const [, file = "", row = "", code = ""] = match;
|
|
38
|
+
diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);
|
|
39
|
+
} else {
|
|
40
|
+
const global = /^(?:error|warning) TS(\d+):\s*(.*)/.exec(line);
|
|
41
|
+
if (global) diagnostics.add(globalDiagnosticKey(global.at(1) ?? "", global.at(2) ?? ""));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return [...diagnostics].sort();
|
|
45
|
+
};
|
|
8
46
|
const runProbeCommand = ({ command, cwd, signal }) => new Promise((done, reject) => {
|
|
9
47
|
const executable = command.at(0);
|
|
10
48
|
if (executable === void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-probe-cli.mjs","names":[],"sources":["../src/typecheck-probe.ts","../src/typecheck-probe-args.ts","../src/typecheck-probe-cli.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { open, realpath, stat, unlink } from \"node:fs/promises\";\nimport path, { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\n\nimport { diagnosticSet } from \"./typecheck-parity\";\n\ntype ProbeCommandOptions = {\n command: readonly string[];\n cwd: string;\n signal: AbortSignal;\n};\ntype ProbeCommandResult = { status: number | null; output: string };\n\nconst runProbeCommand = ({ command, cwd, signal }: ProbeCommandOptions) =>\n new Promise<ProbeCommandResult>((done, reject) => {\n const executable = command.at(0);\n if (executable === undefined) {\n reject(new Error(\"typecheck probe command is empty\"));\n return;\n }\n const child = spawn(executable, command.slice(1), {\n cwd,\n signal,\n shell: false,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let output = \"\";\n child.stdout.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.once(\"error\", reject);\n child.once(\"close\", (status) => done({ status, output }));\n });\n\ntype ProbePathContainmentOptions = {\n root: string;\n candidate: string;\n paths?: Pick<typeof path, \"relative\" | \"isAbsolute\" | \"sep\">;\n};\n\nexport const insideProbePath = ({\n root,\n candidate,\n paths = path,\n}: ProbePathContainmentOptions) => {\n const location = paths.relative(root, candidate);\n return (\n location !== \"..\" &&\n !location.startsWith(\"..\" + paths.sep) &&\n !paths.isAbsolute(location)\n );\n};\n\ntype RunTypecheckProbeOptions = {\n repo: string;\n project: string;\n seedDirectory?: string | undefined;\n command: readonly string[];\n output?: (text: string) => void;\n run?: (options: ProbeCommandOptions) => Promise<ProbeCommandResult>;\n};\n\nexport const runTypecheckProbe = async ({\n repo,\n project,\n seedDirectory,\n command,\n output,\n run = runProbeCommand,\n}: RunTypecheckProbeOptions) => {\n const executable = command.at(0);\n if (\n executable === undefined ||\n executable === \"\" ||\n command.some((argument) => argument.includes(\"\\0\"))\n )\n throw new Error(\n \"typecheck probe requires a nonempty command argv without NUL bytes\",\n );\n if (project === \"\")\n throw new Error(\"typecheck probe requires an explicit project file\");\n const root = await realpath(repo);\n const requested = resolve(root, project);\n if (!insideProbePath({ root, candidate: requested }))\n throw new Error(\n `typecheck probe project is outside the repository: ${project}`,\n );\n const config = await realpath(requested);\n if (!insideProbePath({ root, candidate: config }))\n throw new Error(\n `typecheck probe project resolves outside the repository: ${project}`,\n );\n if (!(await stat(config)).isFile())\n throw new Error(`typecheck probe project must be a file: ${project}`);\n let seedParent = dirname(config);\n if (seedDirectory !== undefined) {\n if (seedDirectory === \"\" || isAbsolute(seedDirectory))\n throw new Error(\n \"typecheck probe seed directory must be repository-relative\",\n );\n const requestedSeedParent = resolve(root, seedDirectory);\n if (!insideProbePath({ root, candidate: requestedSeedParent }))\n throw new Error(\n `typecheck probe seed directory is outside the repository: ${seedDirectory}`,\n );\n seedParent = await realpath(requestedSeedParent);\n if (\n !insideProbePath({ root, candidate: seedParent }) ||\n !insideProbePath({ root: dirname(config), candidate: seedParent })\n )\n throw new Error(\n `typecheck probe seed directory must be inside the declared project: ${seedDirectory}`,\n );\n if (!(await stat(seedParent)).isDirectory())\n throw new Error(\n `typecheck probe seed directory must be a directory: ${seedDirectory}`,\n );\n }\n const seed = join(seedParent, `stll-typecheck-probe-${randomUUID()}.ts`);\n const seedLocation = relative(root, seed).replaceAll(\"\\\\\", \"/\");\n const controller = new AbortController();\n const interrupt = (signal: string) =>\n controller.abort(new Error(`typecheck probe interrupted by ${signal}`));\n const onInterrupt = () => interrupt(\"SIGINT\");\n const onTerminate = () => interrupt(\"SIGTERM\");\n process.on(\"SIGINT\", onInterrupt);\n process.on(\"SIGTERM\", onTerminate);\n let created = false;\n const removeSeed = async () => {\n if (!created) return;\n await unlink(seed);\n created = false;\n };\n const execute = async () => {\n controller.signal.throwIfAborted();\n let onAbort: (() => void) | undefined;\n const aborted = new Promise<never>((_done, reject) => {\n onAbort = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n try {\n const result = await Promise.race([\n run({ command, cwd: root, signal: controller.signal }),\n aborted,\n ]);\n controller.signal.throwIfAborted();\n output?.(result.output);\n return result;\n } finally {\n if (onAbort !== undefined)\n controller.signal.removeEventListener(\"abort\", onAbort);\n }\n };\n try {\n controller.signal.throwIfAborted();\n const file = await open(seed, \"wx\", 0o600);\n created = true;\n try {\n await file.writeFile('export const typecheckProbe: number = \"wrong\";\\n');\n } finally {\n await file.close();\n }\n const seeded = await execute();\n if (seeded.status === null || seeded.status === 0)\n throw new Error(\n `typecheck probe expected the seeded command to fail: ${seedLocation}`,\n );\n // Workspace runners may report compiler paths from the declared project.\n // Only the exact owned seed under either known command origin is accepted.\n const origins = new Set([root, dirname(config)]);\n const attributed = [...origins].some((origin) =>\n diagnosticSet(seeded.output, origin).includes(\n `${relative(origin, seed).replaceAll(\"\\\\\", \"/\")}:1:2322`,\n ),\n );\n if (!attributed)\n throw new Error(\n `typecheck probe expected TS2322 attributed to ${seedLocation}; the declared project may exclude the seed`,\n );\n await removeSeed();\n const clean = await execute();\n if (clean.status !== 0)\n throw new Error(\n `typecheck probe clean command failed with status ${clean.status ?? \"unknown\"}: ${project}`,\n );\n } finally {\n try {\n await removeSeed();\n } finally {\n process.removeListener(\"SIGINT\", onInterrupt);\n process.removeListener(\"SIGTERM\", onTerminate);\n }\n }\n};\n","export const probeUsage =\n \"Usage: stll-typecheck-probe --project <tsconfig> [--seed-dir <directory>] -- <command> [args...]\\n stll-typecheck-probe --help\";\n\nexport const parseProbeArguments = (args: readonly string[]) => {\n if (args.length === 1 && args.at(0) === \"--help\")\n return { mode: \"help\" } as const;\n const project = args.at(1);\n const seedDirectory = args.at(2) === \"--seed-dir\" ? args.at(3) : undefined;\n const separator = seedDirectory === undefined ? 2 : 4;\n const command = args.slice(separator + 1);\n if (\n args.at(0) !== \"--project\" ||\n project === undefined ||\n project.trim() === \"\" ||\n project.startsWith(\"-\") ||\n args.at(separator) !== \"--\" ||\n (seedDirectory !== undefined &&\n (seedDirectory.trim() === \"\" || seedDirectory.startsWith(\"-\"))) ||\n command.length === 0 ||\n command.some((value) => value.trim() === \"\")\n )\n throw new Error(probeUsage);\n return {\n mode: \"probe\",\n project,\n command,\n ...(seedDirectory === undefined ? {} : { seedDirectory }),\n } as const;\n};\n","#!/usr/bin/env node\nimport { runTypecheckProbe } from \"./typecheck-probe\";\nimport { parseProbeArguments, probeUsage } from \"./typecheck-probe-args\";\n\nconst main = async () => {\n const args = parseProbeArguments(process.argv.slice(2));\n if (args.mode === \"help\") {\n process.stdout.write(`${probeUsage}\\n`);\n return;\n }\n await runTypecheckProbe({\n repo: process.cwd(),\n project: args.project,\n command: args.command,\n seedDirectory: args.seedDirectory,\n output: (text) => process.stdout.write(text),\n });\n process.stdout.write(\n \"typecheck probe passed: seeded TS2322 detected and clean typecheck passed\\n\",\n );\n};\n\nmain().catch((error: unknown) => {\n process.stderr.write(\n `typecheck-probe: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.exitCode = 1;\n});\n"],"mappings":";;;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,OAAO,MACb,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC7E;CACA,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"typecheck-probe-cli.mjs","names":[],"sources":["../src/typecheck-probe.ts","../src/typecheck-probe-args.ts","../src/typecheck-probe-cli.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { open, realpath, stat, unlink } from \"node:fs/promises\";\nimport path, { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { stripVTControlCharacters } from \"node:util\";\n\nconst diagnosticLocation = (file: string, repo: string) => {\n const normalized = file.replaceAll(\"\\\\\", \"/\");\n const bundled = /^bundled:\\/\\/\\/libs\\/(lib\\.[^/]+\\.d\\.ts)$/.exec(normalized);\n const installed =\n /(?:^|\\/)node_modules\\/(?:typescript|@typescript\\/(?:native|typescript-[^/]+))\\/(?:.*\\/)?(lib\\.[^/]+\\.d\\.ts)$/.exec(\n normalized,\n );\n const library = bundled?.at(1) ?? installed?.at(1);\n return library === undefined\n ? relative(repo, resolve(repo, file)).replaceAll(\"\\\\\", \"/\")\n : `<lib>/${library}`;\n};\nconst globalDiagnosticKey = (code: string, message: string) =>\n `<config>:0:${code}:${message.trim().replaceAll(/\\s+/g, \" \")}`;\n\n/** Normalizes checker output to sorted `file:line:code` keys. */\nexport const diagnosticSet = (output: string, repo: string): string[] => {\n const clean = stripVTControlCharacters(output);\n const diagnostics = new Set<string>();\n for (const block of clean.matchAll(/<error\\b([^>]*)>([\\s\\S]*?)<\\/error>/g)) {\n const attributes = new Map(\n [...(block.at(1) ?? \"\").matchAll(/(\\w+)=\"([^\"]*)\"/g)].map((match) => [\n match.at(1),\n match.at(2),\n ]),\n );\n const file = attributes.get(\"file\");\n const row = attributes.get(\"line\");\n const code = attributes.get(\"code\");\n if (code === undefined || !/^TS\\d+$/.test(code)) continue;\n if (file !== undefined && row !== undefined && row !== \"0\")\n diagnostics.add(\n `${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`,\n );\n else {\n const message =\n (block.at(2) ?? \"\").split(/<(?:source|related)\\b/).at(0) ?? \"\";\n diagnostics.add(globalDiagnosticKey(code.slice(2), message));\n }\n }\n for (const rawLine of clean.split(\"\\n\")) {\n const line = rawLine.replace(\n /^(?!(?:error|warning) TS\\d+:)(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]* [a-zA-Z0-9_.:-]+: /,\n \"\",\n );\n if (line.startsWith(\"<error \")) continue;\n const match =\n /^(.*?)\\((\\d+),\\d+\\):\\s*(?:error|warning) TS(\\d+)/.exec(line) ??\n /^(.*?):(\\d+):\\d+:\\s*(?:error|warning) (?:TS)?(\\d+)/.exec(line);\n if (match) {\n const [, file = \"\", row = \"\", code = \"\"] = match;\n diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);\n } else {\n const global = /^(?:error|warning) TS(\\d+):\\s*(.*)/.exec(line);\n if (global)\n diagnostics.add(\n globalDiagnosticKey(global.at(1) ?? \"\", global.at(2) ?? \"\"),\n );\n }\n }\n return [...diagnostics].sort();\n};\n\ntype ProbeCommandOptions = {\n command: readonly string[];\n cwd: string;\n signal: AbortSignal;\n};\ntype ProbeCommandResult = { status: number | null; output: string };\n\nconst runProbeCommand = ({ command, cwd, signal }: ProbeCommandOptions) =>\n new Promise<ProbeCommandResult>((done, reject) => {\n const executable = command.at(0);\n if (executable === undefined) {\n reject(new Error(\"typecheck probe command is empty\"));\n return;\n }\n const child = spawn(executable, command.slice(1), {\n cwd,\n signal,\n shell: false,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let output = \"\";\n child.stdout.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr.on(\"data\", (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.once(\"error\", reject);\n child.once(\"close\", (status) => done({ status, output }));\n });\n\ntype ProbePathContainmentOptions = {\n root: string;\n candidate: string;\n paths?: Pick<typeof path, \"relative\" | \"isAbsolute\" | \"sep\">;\n};\n\nexport const insideProbePath = ({\n root,\n candidate,\n paths = path,\n}: ProbePathContainmentOptions) => {\n const location = paths.relative(root, candidate);\n return (\n location !== \"..\" &&\n !location.startsWith(\"..\" + paths.sep) &&\n !paths.isAbsolute(location)\n );\n};\n\ntype RunTypecheckProbeOptions = {\n repo: string;\n project: string;\n seedDirectory?: string | undefined;\n command: readonly string[];\n output?: (text: string) => void;\n run?: (options: ProbeCommandOptions) => Promise<ProbeCommandResult>;\n};\n\nexport const runTypecheckProbe = async ({\n repo,\n project,\n seedDirectory,\n command,\n output,\n run = runProbeCommand,\n}: RunTypecheckProbeOptions) => {\n const executable = command.at(0);\n if (\n executable === undefined ||\n executable === \"\" ||\n command.some((argument) => argument.includes(\"\\0\"))\n )\n throw new Error(\n \"typecheck probe requires a nonempty command argv without NUL bytes\",\n );\n if (project === \"\")\n throw new Error(\"typecheck probe requires an explicit project file\");\n const root = await realpath(repo);\n const requested = resolve(root, project);\n if (!insideProbePath({ root, candidate: requested }))\n throw new Error(\n `typecheck probe project is outside the repository: ${project}`,\n );\n const config = await realpath(requested);\n if (!insideProbePath({ root, candidate: config }))\n throw new Error(\n `typecheck probe project resolves outside the repository: ${project}`,\n );\n if (!(await stat(config)).isFile())\n throw new Error(`typecheck probe project must be a file: ${project}`);\n let seedParent = dirname(config);\n if (seedDirectory !== undefined) {\n if (seedDirectory === \"\" || isAbsolute(seedDirectory))\n throw new Error(\n \"typecheck probe seed directory must be repository-relative\",\n );\n const requestedSeedParent = resolve(root, seedDirectory);\n if (!insideProbePath({ root, candidate: requestedSeedParent }))\n throw new Error(\n `typecheck probe seed directory is outside the repository: ${seedDirectory}`,\n );\n seedParent = await realpath(requestedSeedParent);\n if (\n !insideProbePath({ root, candidate: seedParent }) ||\n !insideProbePath({ root: dirname(config), candidate: seedParent })\n )\n throw new Error(\n `typecheck probe seed directory must be inside the declared project: ${seedDirectory}`,\n );\n if (!(await stat(seedParent)).isDirectory())\n throw new Error(\n `typecheck probe seed directory must be a directory: ${seedDirectory}`,\n );\n }\n const seed = join(seedParent, `stll-typecheck-probe-${randomUUID()}.ts`);\n const seedLocation = relative(root, seed).replaceAll(\"\\\\\", \"/\");\n const controller = new AbortController();\n const interrupt = (signal: string) =>\n controller.abort(new Error(`typecheck probe interrupted by ${signal}`));\n const onInterrupt = () => interrupt(\"SIGINT\");\n const onTerminate = () => interrupt(\"SIGTERM\");\n process.on(\"SIGINT\", onInterrupt);\n process.on(\"SIGTERM\", onTerminate);\n let created = false;\n const removeSeed = async () => {\n if (!created) return;\n await unlink(seed);\n created = false;\n };\n const execute = async () => {\n controller.signal.throwIfAborted();\n let onAbort: (() => void) | undefined;\n const aborted = new Promise<never>((_done, reject) => {\n onAbort = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n try {\n const result = await Promise.race([\n run({ command, cwd: root, signal: controller.signal }),\n aborted,\n ]);\n controller.signal.throwIfAborted();\n output?.(result.output);\n return result;\n } finally {\n if (onAbort !== undefined)\n controller.signal.removeEventListener(\"abort\", onAbort);\n }\n };\n try {\n controller.signal.throwIfAborted();\n const file = await open(seed, \"wx\", 0o600);\n created = true;\n try {\n await file.writeFile('export const typecheckProbe: number = \"wrong\";\\n');\n } finally {\n await file.close();\n }\n const seeded = await execute();\n if (seeded.status === null || seeded.status === 0)\n throw new Error(\n `typecheck probe expected the seeded command to fail: ${seedLocation}`,\n );\n // Workspace runners may report compiler paths from the declared project.\n // Only the exact owned seed under either known command origin is accepted.\n const origins = new Set([root, dirname(config)]);\n const attributed = [...origins].some((origin) =>\n diagnosticSet(seeded.output, origin).includes(\n `${relative(origin, seed).replaceAll(\"\\\\\", \"/\")}:1:2322`,\n ),\n );\n if (!attributed)\n throw new Error(\n `typecheck probe expected TS2322 attributed to ${seedLocation}; the declared project may exclude the seed`,\n );\n await removeSeed();\n const clean = await execute();\n if (clean.status !== 0)\n throw new Error(\n `typecheck probe clean command failed with status ${clean.status ?? \"unknown\"}: ${project}`,\n );\n } finally {\n try {\n await removeSeed();\n } finally {\n process.removeListener(\"SIGINT\", onInterrupt);\n process.removeListener(\"SIGTERM\", onTerminate);\n }\n }\n};\n","export const probeUsage =\n \"Usage: stll-typecheck-probe --project <tsconfig> [--seed-dir <directory>] -- <command> [args...]\\n stll-typecheck-probe --help\";\n\nexport const parseProbeArguments = (args: readonly string[]) => {\n if (args.length === 1 && args.at(0) === \"--help\")\n return { mode: \"help\" } as const;\n const project = args.at(1);\n const seedDirectory = args.at(2) === \"--seed-dir\" ? args.at(3) : undefined;\n const separator = seedDirectory === undefined ? 2 : 4;\n const command = args.slice(separator + 1);\n if (\n args.at(0) !== \"--project\" ||\n project === undefined ||\n project.trim() === \"\" ||\n project.startsWith(\"-\") ||\n args.at(separator) !== \"--\" ||\n (seedDirectory !== undefined &&\n (seedDirectory.trim() === \"\" || seedDirectory.startsWith(\"-\"))) ||\n command.length === 0 ||\n command.some((value) => value.trim() === \"\")\n )\n throw new Error(probeUsage);\n return {\n mode: \"probe\",\n project,\n command,\n ...(seedDirectory === undefined ? {} : { seedDirectory }),\n } as const;\n};\n","#!/usr/bin/env node\nimport { runTypecheckProbe } from \"./typecheck-probe\";\nimport { parseProbeArguments, probeUsage } from \"./typecheck-probe-args\";\n\nconst main = async () => {\n const args = parseProbeArguments(process.argv.slice(2));\n if (args.mode === \"help\") {\n process.stdout.write(`${probeUsage}\\n`);\n return;\n }\n await runTypecheckProbe({\n repo: process.cwd(),\n project: args.project,\n command: args.command,\n seedDirectory: args.seedDirectory,\n output: (text) => process.stdout.write(text),\n });\n process.stdout.write(\n \"typecheck probe passed: seeded TS2322 detected and clean typecheck passed\\n\",\n );\n};\n\nmain().catch((error: unknown) => {\n process.stderr.write(\n `typecheck-probe: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;AAMA,MAAM,sBAAsB,MAAc,SAAiB;CACzD,M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,MAAM,IAAI,MAAM,UAAU;CAC5B,OAAO;EACL,MAAM;EACN;EACA;EACA,GAAI,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc;CACzD;AACF;;;ACxBA,MAAM,OAAO,YAAY;CACvB,MAAM,OAAO,oBAAoB,QAAQ,KAAK,MAAM,CAAC,CAAC;CACtD,IAAI,KAAK,SAAS,QAAQ;EACxB,QAAQ,OAAO,MAAM,GAAG,WAAW,GAAG;EACtC;CACF;CACA,MAAM,kBAAkB;EACtB,MAAM,QAAQ,IAAI;EAClB,SAAS,KAAK;EACd,SAAS,KAAK;EACd,eAAe,KAAK;EACpB,SAAS,SAAS,QAAQ,OAAO,MAAM,IAAI;CAC7C,CAAC;CACD,QAAQ,OAAO,MACb,6EACF;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,OAAO,MACb,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC7E;CACA,QAAQ,WAAW;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/oxlint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Shared general oxlint configuration for stella packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"stll-quarantine": "./dist/quarantine-cli.mjs",
|
|
18
18
|
"stll-toolchain-changed": "./dist/toolchain-changed-cli.mjs",
|
|
19
19
|
"stll-toolchain-check": "./dist/toolchain-check-cli.mjs",
|
|
20
|
-
"stll-typecheck-parity": "./dist/typecheck-parity-cli.mjs",
|
|
21
20
|
"stll-typecheck-probe": "./dist/typecheck-probe-cli.mjs",
|
|
22
21
|
"stll-normalize-wasi-loaders": "./dist/wasi-loader-normalizer-cli.mjs"
|
|
23
22
|
},
|
|
@@ -125,7 +124,7 @@
|
|
|
125
124
|
},
|
|
126
125
|
"scripts": {
|
|
127
126
|
"build": "tsdown",
|
|
128
|
-
"typecheck": "bun check",
|
|
127
|
+
"typecheck": "bun check --no-pretty --all --project=tsconfig.json",
|
|
129
128
|
"test": "bun test"
|
|
130
129
|
},
|
|
131
130
|
"dependencies": {
|
|
@@ -138,6 +137,7 @@
|
|
|
138
137
|
"picomatch": "4.0.7",
|
|
139
138
|
"semver": "7.8.5",
|
|
140
139
|
"smol-toml": "1.9.1",
|
|
140
|
+
"tsrs": "0.18.0-ts7.1.0-dev.20260929",
|
|
141
141
|
"tsx": "4.23.15",
|
|
142
142
|
"yaml": "2.9.1"
|
|
143
143
|
},
|
|
@@ -146,7 +146,6 @@
|
|
|
146
146
|
"@types/picomatch": "4.0.3",
|
|
147
147
|
"@types/semver": "7.8.0",
|
|
148
148
|
"oxlint": "1.87.0",
|
|
149
|
-
"typescript": "7.0.2",
|
|
150
149
|
"unplugin-dts": "1.1.2",
|
|
151
150
|
"vite": "8.3.4",
|
|
152
151
|
"vite-plugin-dts": "5.1.2"
|
package/toolchain.json
CHANGED
|
@@ -55,34 +55,8 @@
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
"type": "direct",
|
|
61
|
-
"compilerPackage": "typescript",
|
|
62
|
-
"compilerSpecifier": "7.0.2",
|
|
63
|
-
"typecheckCommand": "bun check"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"type": "split-compatibility",
|
|
67
|
-
"compilerPackage": "@typescript/native",
|
|
68
|
-
"compilerSpecifier": "npm:typescript@7.0.2",
|
|
69
|
-
"compatibilityPackage": "typescript",
|
|
70
|
-
"compatibilitySpecifier": "6.0.3",
|
|
71
|
-
"typecheckCommand": "bun check"
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
"typescript6Compatibility": {
|
|
75
|
-
"version": "6.0.3",
|
|
76
|
-
"packageAlias": "typescript-compat",
|
|
77
|
-
"apiConsumers": ["TypeScript compiler API"],
|
|
78
|
-
"peerBlockers": [
|
|
79
|
-
"@astrojs/check",
|
|
80
|
-
"@typescript-eslint/utils",
|
|
81
|
-
"dependency-cruiser"
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
|
-
"@stll/oxlint-plugin": "0.6.1",
|
|
85
|
-
"lefthook": "2.1.16",
|
|
58
|
+
"@stll/oxlint-plugin": "0.6.3",
|
|
59
|
+
"lefthook": "2.2.2",
|
|
86
60
|
"node": "26.x",
|
|
87
61
|
"postgres": "18",
|
|
88
62
|
"valkey": "9.1.1",
|