|
4 | 4 | import { spawnSync } from "node:child_process"; |
5 | 5 | import { appendFileSync, existsSync, readFileSync, writeSync } from "node:fs"; |
6 | 6 | import { join, resolve } from "node:path"; |
| 7 | +import { selectComposerCommand } from "./composer.mjs"; |
7 | 8 | import { resolveCredential } from "./credentials.mjs"; |
8 | 9 | import { deployedUrlFromOutput } from "./deployment.mjs"; |
9 | 10 | import { guardReport, makeReporter, mapPhase } from "./report.mjs"; |
@@ -136,6 +137,16 @@ if (mode === "destroy" && !stage) { |
136 | 137 | } |
137 | 138 | log(stage ? `${mode} target: --stage ${stage}` : `${mode} target: production (default branch, no --stage)`); |
138 | 139 |
|
| 140 | +// Bun is required: composer runs under Bun, not Node. The generated Prisma |
| 141 | +// deploy workflow adds `oven-sh/setup-bun@v2` for every project. |
| 142 | +const bunVersionCheck = spawnSync("bun", ["--version"], { stdio: "pipe" }); |
| 143 | +if (bunVersionCheck.error?.code === "ENOENT") { |
| 144 | + failEarly( |
| 145 | + "config", |
| 146 | + "bun not found on PATH: add `- uses: oven-sh/setup-bun@v2` before this action step; the generated Prisma deploy workflow includes this automatically", |
| 147 | + ); |
| 148 | +} |
| 149 | + |
139 | 150 | const installCommand = (() => { |
140 | 151 | const explicit = input("install-command"); |
141 | 152 | if (explicit) return explicit; |
@@ -228,13 +239,15 @@ await runPhase("build", input("build-command") || "npm run build"); |
228 | 239 | // The CLI bin is named prisma-composer. From 0.7.0 it ships inside |
229 | 240 | // @prisma/composer-cli (previously @prisma/composer); there is no npm package |
230 | 241 | // named prisma-composer, so `npx prisma-composer@v` 404s. The repo's own |
231 | | -// install already provides the bin, so prefer the local bin; fall back to |
232 | | -// fetching the pinned package only when the repo does not carry it. |
| 242 | +// install already provides the bin, so prefer the local bin under Bun; fall |
| 243 | +// back to bunx fetching the pinned package when the repo does not carry it. |
233 | 244 | const localBin = join(workdir, "node_modules", ".bin", "prisma-composer"); |
234 | | -const [composerCmd, composerLead] = existsSync(localBin) |
235 | | - ? [localBin, []] |
236 | | - : ["npx", [`--package=@prisma/composer-cli@${composerVersion}`, "prisma-composer"]]; |
237 | | -log(composerCmd === localBin ? "composer=local bin" : `composer=${composerVersion} (npx fallback)`); |
| 245 | +const [composerCmd, composerLead, composerLabel] = selectComposerCommand( |
| 246 | + localBin, |
| 247 | + composerVersion, |
| 248 | + existsSync(localBin), |
| 249 | +); |
| 250 | +log(composerLabel); |
238 | 251 | const composerArgs = [ |
239 | 252 | ...composerLead, |
240 | 253 | ...(mode === "deploy" |
|
0 commit comments