34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import {
|
|
parseSmokeArgs,
|
|
printSmokeHelp,
|
|
runDevCloudWorkbenchMobileSmoke,
|
|
runDevCloudWorkbenchSmoke
|
|
} from "./src/dev-cloud-workbench-smoke-lib.mjs";
|
|
|
|
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
try {
|
|
const args = parseSmokeArgs(process.argv.slice(2));
|
|
const report = args.help
|
|
? printSmokeHelp()
|
|
: args.mobile
|
|
? await runDevCloudWorkbenchMobileSmoke()
|
|
: await runDevCloudWorkbenchSmoke(process.argv.slice(2));
|
|
if (args.reportPath && report.status !== "usage") {
|
|
const reportPath = path.resolve(process.cwd(), args.reportPath);
|
|
await mkdir(path.dirname(reportPath), { recursive: true });
|
|
report.artifacts = { ...(report.artifacts ?? {}), reportPath };
|
|
await writeFile(reportPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
}
|
|
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
process.exitCode = report.status === "pass" || report.status === "usage" || report.status === "skip" ? 0 : 2;
|
|
} catch (error) {
|
|
process.stderr.write(`[dev-cloud-workbench-smoke] ${error instanceof Error ? error.stack : String(error)}\n`);
|
|
process.exitCode = 1;
|
|
}
|
|
}
|