first commit
This commit is contained in:
19
app/asc/utils.ts
Normal file
19
app/asc/utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
export async function runAscCommand(command: string) {
|
||||
// Use environment variables for authentication
|
||||
// The asc CLI usually looks for these or can be passed as flags
|
||||
const authFlags = `--issuer ${process.env.ASC_ISSUER_ID} --key-id ${process.env.ASC_KEY_ID} --key "${process.env.ASC_PRIVATE_KEY?.replace(/\\n/g, '\n')}"`;
|
||||
|
||||
try {
|
||||
const { stdout, stderr } = await execAsync(`asc ${command} ${authFlags}`);
|
||||
if (stderr) console.error("ASC Error:", stderr);
|
||||
return { data: stdout, error: stderr };
|
||||
} catch (error: any) {
|
||||
console.error("Exec Error:", error);
|
||||
return { data: null, error: error.message };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user