fix: stabilize package catalog search and contract verify

This commit is contained in:
Peter Steinberger
2026-03-22 11:04:20 -07:00
parent 801cc550ab
commit 9ea750852f
+14 -7
View File
@@ -1,5 +1,6 @@
import { spawnSync } from "node:child_process";
import { readFileSync, readdirSync } from "node:fs";
import { mkdtempSync, readFileSync, readdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, relative } from "node:path";
import ts from "typescript";
@@ -55,8 +56,9 @@ function getExpectedIdentifiers() {
}
function getRemoteIdentifiers(cliArgs: string[]) {
const result = spawnSync("bunx", ["convex", "function-spec", ...cliArgs], {
cwd: root,
const tempDir = mkdtempSync(join(tmpdir(), "clawhub-function-spec-"));
const result = spawnSync("bunx", ["convex", "function-spec", "--file", ...cliArgs], {
cwd: tempDir,
encoding: "utf8",
});
if (result.status !== 0) {
@@ -64,11 +66,16 @@ function getRemoteIdentifiers(cliArgs: string[]) {
process.exit(result.status ?? 1);
}
const stdout = result.stdout.trim();
const jsonStart = stdout.search(/[\[{]/);
const jsonPayload = jsonStart >= 0 ? stdout.slice(jsonStart) : stdout;
const fileName = readdirSync(tempDir)
.filter((entry) => entry.startsWith("function_spec_") && entry.endsWith(".json"))
.sort()
.at(-1);
if (!fileName) {
process.stderr.write(result.stderr || result.stdout || "Missing function spec output\n");
process.exit(1);
}
const parsed = JSON.parse(jsonPayload) as {
const parsed = JSON.parse(readFileSync(join(tempDir, fileName), "utf8")) as {
functions?: Array<{ identifier?: string }>;
};
return new Set(