Files
wehub-resource-sync e2bed4b5a2
CI / Public checks (push) Failing after 0s
chore: import upstream snapshot with attribution
2026-07-13 12:27:29 +08:00

52 lines
1.4 KiB
TypeScript

import { mkdir, rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const e2eDir = path.resolve(scriptDir, "..");
const uiDir = path.join(e2eDir, "ui");
type Command = () => Promise<void>;
const commands: Record<string, Command> = {
clean: cleanArtifacts,
help: async () => printUsage(),
};
const commandName = process.argv[2] ?? "help";
const command = commands[commandName];
if (command == null) {
console.error(`Unknown e2e Playwright helper command: ${commandName}`);
printUsage();
process.exitCode = 1;
} else {
await command();
}
async function cleanArtifacts(): Promise<void> {
const reportsDir = path.join(uiDir, "reports");
const targets = [
path.join(uiDir, "test-results"),
path.join(reportsDir, "test-results"),
path.join(reportsDir, "playwright-html-report"),
path.join(reportsDir, "results.json"),
path.join(reportsDir, "junit.xml"),
path.join(uiDir, ".DS_Store"),
];
await Promise.all(targets.map((target) => rm(target, { recursive: true, force: true })));
await mkdir(path.join(reportsDir, "test-results"), { recursive: true });
console.log("Cleaned e2e UI Playwright artifacts.");
}
function printUsage(): void {
console.log(`Usage: tsx scripts/playwright.ts <command>
Commands:
clean Remove e2e UI Playwright runtime data and reports
help Show this help
`);
}