mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 00:47:57 +00:00
fix: stabilize package catalog search and contract verify
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user