diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3329b1dad9..0bd87925c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,9 @@ jobs: - name: Build desktop pipeline run: bun run build:desktop + - name: Smoke test bundled CLI + run: bun --filter=t3 run smoke:cli-bundle + - name: Verify preload bundle output run: | test -f apps/desktop/dist-electron/preload.cjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 367ce867dc3..a5914d875ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -449,6 +449,9 @@ jobs: - name: Build CLI package run: bun --filter=t3 run build + - name: Smoke test bundled CLI + run: bun --filter=t3 run smoke:cli-bundle + - name: Publish CLI package run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose diff --git a/apps/server/package.json b/apps/server/package.json index c045331dd4d..bf290f52d7f 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -18,6 +18,7 @@ "dev": "node --watch src/bin.ts", "build": "node scripts/cli.ts build", "build:bundle": "tsdown", + "smoke:cli-bundle": "node scripts/smoke-cli-bundle.ts", "start": "node dist/bin.mjs", "typecheck": "tsc --noEmit", "test": "vitest run", diff --git a/apps/server/scripts/smoke-cli-bundle.ts b/apps/server/scripts/smoke-cli-bundle.ts new file mode 100644 index 00000000000..058650ca8fe --- /dev/null +++ b/apps/server/scripts/smoke-cli-bundle.ts @@ -0,0 +1,48 @@ +// @effect-diagnostics nodeBuiltinImport:off +import { execFileSync } from "node:child_process"; +import { existsSync, mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import * as Console from "effect/Console"; +import * as Effect from "effect/Effect"; + +const serverRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const bundledCliPath = resolve(serverRoot, "dist/bin.mjs"); + +if (!existsSync(bundledCliPath)) { + throw new Error(`Missing bundled CLI at ${bundledCliPath}. Run the server build first.`); +} + +const baseDir = mkdtempSync(join(tmpdir(), "t3-cli-bundle-smoke-base-")); +const workspaceRoot = mkdtempSync(join(tmpdir(), "t3-cli-bundle-smoke-workspace-")); + +try { + const output = execFileSync( + process.execPath, + [ + bundledCliPath, + "project", + "add", + workspaceRoot, + "--title", + "Bundle Smoke", + "--base-dir", + baseDir, + ], + { + cwd: serverRoot, + encoding: "utf8", + stdio: ["ignore", "pipe", "inherit"], + }, + ); + + if (!output.includes("Added project")) { + throw new Error(`Bundled CLI smoke did not add a project. Output:\n${output}`); + } + + Effect.runSync(Console.log("Bundled CLI smoke checks passed.")); +} finally { + rmSync(baseDir, { recursive: true, force: true }); + rmSync(workspaceRoot, { recursive: true, force: true }); +}