mirror of
https://github.com/przeprogramowani/10x-cli.git
synced 2026-09-19 03:30:01 +08:00
b0c789af70
* docs(10xdevs4-cli-access): record membership gates and bootstrap context (p1) Add canonical access plan, accepted decisions and supporting context. Record phase 1 verification, Toolkit revision and remaining evidence gaps. * docs(10xdevs4-cli-access): record course access gates and scoped review (p2) Update canonical Progress, change status, evidence and implementation review. Record Toolkit revisions, inherited typecheck limitation and phase 3 prerequisites. * docs(10xdevs4-cli-access): persist reviewed revisions and phase 3 boundary Record final reviewed Toolkit and CLI context revisions. Persist Progress attribution and unresolved W04/W05/W08 prerequisites. Keep phases 3–6, phase 7 and Manual criteria open. * docs(10xdevs4-cli-access): record squash-safe source prerequisite Record PR #30, verified gates, permanent-pin lessons and the remaining merge dependency. Keep phase 3 and all manual rollout criteria pending. * docs(10xdevs4-cli-access): record source prerequisite review Record independent review of PR #30 and verified CI evidence. Keep the master pin and delivery phase completion pending. * docs(10xdevs4-cli-access): distinguish candidate checks from final master pins Record passing pre-merge v4 checks and defer workflow suspension. Keep the final v3 maintenance pin dependent on the resulting master SHA. * feat: prepare v4 course delivery and protected project sync Capture the reviewed implementation and manual rehearsal for draft PR review. Master source prerequisites, full clean verification and coordinated Windows CI remain open; production rollout is separate. * fix: keep paid CI evidence private and converge cumulative sync * docs: record merged source prerequisite and passing clean gate * fix: preserve generated API type line endings on Windows --------- Co-authored-by: Claude <noreply@anthropic.com>
53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
#!/usr/bin/env bun
|
|
/**
|
|
* Fetches the delivery API OpenAPI spec and regenerates
|
|
* src/generated/api-types.ts. Commit the result to git.
|
|
*
|
|
* Override the source URL with API_BASE_URL in the environment:
|
|
* API_BASE_URL=http://localhost:8787 bun run generate-types
|
|
*/
|
|
import { mkdir, writeFile, readFile } from "node:fs/promises";
|
|
import { dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import openapiTS, { astToString } from "openapi-typescript";
|
|
|
|
const apiBase = process.env["API_BASE_URL"] ?? "https://10x-toolkit-api.przeprogramowani.workers.dev";
|
|
const specUrl = `${apiBase.replace(/\/$/, "")}/openapi.json`;
|
|
|
|
const outPath = fileURLToPath(new URL("../src/generated/api-types.ts", import.meta.url));
|
|
|
|
async function main() {
|
|
process.stderr.write(`[generate-types] Reading ${process.env["OPENAPI_SPEC_PATH"] ?? specUrl}\n`);
|
|
const localSpec = process.env["OPENAPI_SPEC_PATH"];
|
|
const check = process.argv.includes("--check");
|
|
if (check && !localSpec) throw new Error("--check requires OPENAPI_SPEC_PATH exported from the exact candidate backend; deployed/latest is not a candidate contract.");
|
|
const ast = await openapiTS(localSpec ? JSON.parse(await readFile(localSpec, "utf8")) : new URL(specUrl));
|
|
const body = astToString(ast);
|
|
|
|
const header = [
|
|
"/* eslint-disable */",
|
|
"/**",
|
|
" * Auto-generated from the delivery API OpenAPI spec.",
|
|
" * Do not edit by hand — run `bun run generate-types` to regenerate.",
|
|
" */",
|
|
"",
|
|
].join("\n");
|
|
|
|
const generated = `${header}${body}`;
|
|
if (check) {
|
|
if (await readFile(outPath, "utf8") !== generated) throw new Error("Committed API types differ from the candidate OpenAPI schema. Regenerate with the same OPENAPI_SPEC_PATH.");
|
|
process.stderr.write("[generate-types] Candidate schema matches committed types\n");
|
|
return;
|
|
}
|
|
await mkdir(dirname(outPath), { recursive: true });
|
|
await writeFile(outPath, generated, "utf8");
|
|
|
|
process.stderr.write(`[generate-types] Wrote ${outPath}\n`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
process.stderr.write(`[generate-types] FAILED: ${message}\n`);
|
|
process.exit(1);
|
|
});
|