Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,31 @@
import { describe, it, expect } from "vitest";
import { spawnSync } from "node:child_process";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const here = dirname(fileURLToPath(import.meta.url));
const scriptPath = resolve(here, "generate-spec.ts");
/**
* Smoke test: the script exits 0 in write mode, then `--check` mode confirms
* the file is in sync. We do not exercise the network or invoke the heavy
* Hono import here — these tests run alongside vitest's default include.
*
* This file deliberately lives under scripts/ so the package's vitest config
* (which only globs src/**) skips it during regular `pnpm test`. It is kept
* here as documentation + smoke for manual / CI invocation:
*
* pnpm exec vitest run packages/api-client-ts/scripts/generate-spec.test.ts
*/
describe("generate-spec script", () => {
it("compiles via tsx --check without throwing", () => {
// Just verify the script is importable / syntactically valid by running --help-equivalent.
// We invoke the file with --check, which only succeeds when openapi.json already exists;
// when it doesn't, the script exits with code 1 (missing) or 2 (drift). Either is a "ran" signal.
const result = spawnSync("pnpm", ["exec", "tsx", scriptPath, "--check"], {
cwd: resolve(here, ".."),
encoding: "utf8",
});
expect([0, 1, 2]).toContain(result.status ?? -1);
});
});
@@ -0,0 +1,64 @@
#!/usr/bin/env tsx
/**
* generate-spec — capture the boilerplate's OpenAPI document into a local file.
*
* Invokes the headless `createOpenApiDocument` factory from `@toolctrl/api` and
* writes the result to `packages/api-client-ts/openapi.json`. This file feeds
* `@hey-api/openapi-ts` (see `openapi-ts.config.ts`) which then regenerates
* `src/generated/`.
*
* Usage:
* pnpm --filter @toolctrl/api-client-ts generate-spec
* pnpm --filter @toolctrl/api-client-ts generate-spec -- --check
*
* `--check` re-runs the generation and exits non-zero if the on-disk
* `openapi.json` would change — useful as a CI drift gate.
*
* Refs: docs/improvement-plan/08-mobile-cli-storybook-sdk/ts-sdk.md
*/
import { writeFileSync, readFileSync, existsSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { createOpenApiDocument } from "@toolctrl/api/openapi";
const here = dirname(fileURLToPath(import.meta.url));
const outputPath = resolve(here, "..", "openapi.json");
function buildSpec(): string {
const document = createOpenApiDocument({
routing: {
protocol: "https",
apiHost: "api.toolctrl.de",
} as never,
});
return `${JSON.stringify(document, null, 2)}\n`;
}
function main(): void {
const checkMode = process.argv.includes("--check");
const next = buildSpec();
if (checkMode) {
if (!existsSync(outputPath)) {
process.stderr.write(`openapi.json missing at ${outputPath} — run \`pnpm --filter @toolctrl/api-client-ts generate-spec\`.\n`);
process.exit(1);
}
const current = readFileSync(outputPath, "utf8");
if (current !== next) {
process.stderr.write(
`openapi.json is stale — the upstream OpenAPI document has changed.\n` +
`Run \`pnpm --filter @toolctrl/api-client-ts generate:all\` and commit the result.\n`,
);
process.exit(2);
}
process.stdout.write("openapi.json is in sync with the upstream document.\n");
return;
}
writeFileSync(outputPath, next, "utf8");
process.stdout.write(`Wrote ${outputPath} (${(next.length / 1024).toFixed(1)} KiB)\n`);
}
main();