Commit 43eb29a5 authored by edy's avatar edy

test: add mac workspace startup smoke

parent 43d6c777
#!/usr/bin/env node
import { execFileSync } from "node:child_process"
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
import { dirname, join, resolve } from "node:path"
const repoRoot = resolve(import.meta.dirname, "..", "..")
const desktopAppRoot = join(repoRoot, "apps", "desktop")
const sourcePath = join(repoRoot, "build", "scripts", "workspace-startup-smoke.ts")
const tempRoot = join(repoRoot, ".tmp", "workspace-startup-smoke")
const compileRoot = join(tempRoot, "compiled")
const entryPath = join(compileRoot, "build", "scripts", "workspace-startup-smoke.js")
const compilePackagePath = join(compileRoot, "package.json")
const resultPath = resolve(process.argv[2] ?? join(tempRoot, "result.json"))
function writeUtf8File(filePath, content) {
mkdirSync(dirname(filePath), { recursive: true })
writeFileSync(filePath, content, "utf8")
}
if (!existsSync(sourcePath)) {
throw new Error(`Workspace startup smoke source was not found: ${sourcePath}`)
}
rmSync(compileRoot, { recursive: true, force: true })
mkdirSync(compileRoot, { recursive: true })
console.log("Compiling workspace startup smoke with local TypeScript")
execFileSync("corepack", [
"pnpm",
"--dir",
desktopAppRoot,
"exec",
"tsc",
"--module",
"ES2022",
"--moduleResolution",
"node",
"--target",
"ES2022",
"--lib",
"ES2022",
"--types",
"node",
"--esModuleInterop",
"--allowSyntheticDefaultImports",
"--skipLibCheck",
"--outDir",
compileRoot,
sourcePath,
], {
cwd: repoRoot,
stdio: "inherit",
})
if (!existsSync(entryPath)) {
throw new Error(`Workspace startup smoke entry was not emitted: ${entryPath}`)
}
writeUtf8File(compilePackagePath, '{"type":"module"}')
console.log("Running workspace startup smoke")
execFileSync("node", [entryPath, resultPath], {
cwd: repoRoot,
stdio: "inherit",
})
if (!existsSync(resultPath)) {
throw new Error(`Workspace startup smoke did not produce a result file: ${resultPath}`)
}
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"smoke:mac:package": "node build/scripts/mac-package-smoke.mjs", "smoke:mac:package": "node build/scripts/mac-package-smoke.mjs",
"smoke:mac:workspace-entry": "node build/scripts/mac-workspace-entry-smoke.mjs", "smoke:mac:workspace-entry": "node build/scripts/mac-workspace-entry-smoke.mjs",
"smoke:mac:workspace-service": "node build/scripts/mac-workspace-service-smoke.mjs", "smoke:mac:workspace-service": "node build/scripts/mac-workspace-service-smoke.mjs",
"smoke:mac:workspace-startup": "node build/scripts/mac-workspace-startup-smoke.mjs",
"smoke:bundled-runtime": "powershell -ExecutionPolicy Bypass -File build/scripts/bundled-runtime-smoke.ps1", "smoke:bundled-runtime": "powershell -ExecutionPolicy Bypass -File build/scripts/bundled-runtime-smoke.ps1",
"smoke:workspace-entry": "powershell -ExecutionPolicy Bypass -File build/scripts/workspace-entry-smoke.ps1", "smoke:workspace-entry": "powershell -ExecutionPolicy Bypass -File build/scripts/workspace-entry-smoke.ps1",
"smoke:cloud-bundle": "powershell -ExecutionPolicy Bypass -File build/scripts/cloud-bundle-smoke.ps1", "smoke:cloud-bundle": "powershell -ExecutionPolicy Bypass -File build/scripts/cloud-bundle-smoke.ps1",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment