mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
3693f7dacb
Replace tools/release.mjs with two workflow_dispatch flows: - stable: production environment gate (Required Reviewers) + lightweight git tag. Trusted Publishing (OIDC) removes the need for an npm token. - channel beta: disposable 0.0.0-beta-<sha>-<date> versions on the corresponding dist-tag, no tag, no commit. Any collaborator can dispatch without npm credentials. Pack-time scans via publint, attw, gitleaks; weekly Dependabot for npm + actions.
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { spawnSync } from "child_process";
|
|
|
|
import { ROOT } from "./packages.mjs";
|
|
|
|
export function run(command, args, options = {}) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: options.cwd ?? ROOT,
|
|
stdio: options.stdio ?? "inherit",
|
|
env: { ...process.env, ...options.env },
|
|
encoding: "utf-8",
|
|
});
|
|
if (result.status !== 0) {
|
|
const detail = result.stderr?.trim() || result.stdout?.trim();
|
|
throw new Error(`${command} ${args.join(" ")} failed${detail ? `\n${detail}` : ""}`);
|
|
}
|
|
return result.stdout ?? "";
|
|
}
|
|
|
|
export function runCapture(command, args, options = {}) {
|
|
return run(command, args, { ...options, stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
}
|
|
|
|
export function tryRun(command, args, options = {}) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: options.cwd ?? ROOT,
|
|
stdio: options.stdio ?? ["ignore", "pipe", "pipe"],
|
|
env: { ...process.env, ...options.env },
|
|
encoding: "utf-8",
|
|
});
|
|
return {
|
|
status: result.status,
|
|
stdout: (result.stdout ?? "").trim(),
|
|
stderr: (result.stderr ?? "").trim(),
|
|
};
|
|
}
|