f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
import { spawnSync } from "node:child_process";
|
|
import {
|
|
mkdtempSync,
|
|
rmSync,
|
|
writeFileSync,
|
|
} from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import {
|
|
dirname,
|
|
join,
|
|
resolve,
|
|
} from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const frontendDir = resolve(
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
"..",
|
|
);
|
|
const repoRoot = resolve(frontendDir, "..");
|
|
|
|
function run(cmd, args, options = {}) {
|
|
const result = spawnSync(cmd, args, {
|
|
cwd: options.cwd,
|
|
encoding: "utf8",
|
|
stdio: options.capture ? ["ignore", "pipe", "pipe"] : "inherit",
|
|
});
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) {
|
|
throw new Error(`${cmd} ${args.join(" ")} exited ${result.status}`);
|
|
}
|
|
return result.stdout ?? "";
|
|
}
|
|
|
|
const tempDir = mkdtempSync(join(tmpdir(), "agentsview-openapi-"));
|
|
try {
|
|
const specPath = join(tempDir, "openapi.json");
|
|
const spec = run("go", ["run", "./cmd/agentsview", "openapi"], {
|
|
cwd: repoRoot,
|
|
capture: true,
|
|
});
|
|
writeFileSync(specPath, spec);
|
|
const openapiArgs = [
|
|
"openapi",
|
|
"-i",
|
|
specPath,
|
|
"-o",
|
|
"src/lib/api/generated",
|
|
"-c",
|
|
"fetch",
|
|
"--useOptions",
|
|
"--indent",
|
|
"2",
|
|
];
|
|
if (process.platform === "win32") {
|
|
run(
|
|
process.env.ComSpec ?? "cmd.exe",
|
|
["/d", "/s", "/c", "npx.cmd", ...openapiArgs],
|
|
{ cwd: frontendDir },
|
|
);
|
|
} else {
|
|
run("npx", openapiArgs, { cwd: frontendDir });
|
|
}
|
|
} finally {
|
|
rmSync(tempDir, { recursive: true, force: true });
|
|
}
|