diff --git a/fly.js b/fly.js index 3f2d901..20f7860 100755 --- a/fly.js +++ b/fly.js @@ -25,7 +25,7 @@ GDF.extend(class extends GDF { if (this.remix) { this.flyRemixSecrets(this.flyApp) this.flyHealthCheck('/healthcheck') - if (this.postgres) this.flyRelease('npx prisma migrate deploy') + if (this.postgres) this.flyRelease(`${this.npx} prisma migrate deploy`) } // set secrets for AdonisJS apps diff --git a/gdf.js b/gdf.js index 6378a71..de0d54f 100755 --- a/gdf.js +++ b/gdf.js @@ -587,6 +587,10 @@ export class GDF { if (this.options.nginxRoot) return true } + get npx() { + return this.bun ? "bunx" : "npx" + } + // command to start the web server get startCommand() { if (this.options.cmd) return this.options.cmd @@ -602,7 +606,7 @@ export class GDF { } if (this.gatsby) { - return ['npx', 'gatsby', 'serve', '-H', '0.0.0.0'] + return [this.npx, 'gatsby', 'serve', '-H', '0.0.0.0'] } else if (this.runtime === 'Node.js' && this.#pj.scripts?.start?.includes('fastify')) { let start = this.#pj.scripts.start if (!start.includes('-a') && !start.includes('--address')) { @@ -610,7 +614,7 @@ export class GDF { } start = start.split(' ') - start.unshift('npx') + start.unshift(this.npx) return start } else if (this.#pj.scripts?.start) { return [this.packager, 'run', 'start'] diff --git a/templates/Dockerfile.ejs b/templates/Dockerfile.ejs index 0cb2831..5ced0bb 100644 --- a/templates/Dockerfile.ejs +++ b/templates/Dockerfile.ejs @@ -77,7 +77,7 @@ RUN <%- buildCache %><%= packagerInstall %> <% if (prisma) { -%> # Generate Prisma Client COPY<% if (options.link) { %> --link<% } %> prisma . -RUN <%= packager === "bun" ? 'bunx' : 'npx' %> prisma generate +RUN <%= npx %> prisma generate <% } -%> # Copy application code @@ -217,7 +217,7 @@ EXPOSE <%= port %> <%- emitEnv(deployEnv) %> <% } -%> <% if (foreman) { -%> -CMD [ "<%= packager === "bun" ? 'bunx' : 'npx' %>", "foreman", "start", "--procfile", "Procfile.prod" ] +CMD [ "<%= npx %>", "foreman", "start", "--procfile", "Procfile.prod" ] <% } else if (Array.isArray(startCommand)) { -%> CMD <%- JSON.stringify(startCommand, null, 1).replaceAll(/\n\s*/g, " ") %> <% } else { -%> diff --git a/templates/docker-entrypoint.ejs b/templates/docker-entrypoint.ejs index 8a6d7c1..732d165 100755 --- a/templates/docker-entrypoint.ejs +++ b/templates/docker-entrypoint.ejs @@ -45,10 +45,10 @@ if (process.env.DATABASE_URL) { <%= tab(1) %>// If running the web server then migrate existing database <%= tab(1) %>if (process.argv.slice(2).join(' ') === '<%= packager %> run start'<% if (litefs) { %> && process.env.FLY_REGION === process.env.PRIMARY_REGION<% } %>) { <% if (prisma) { -%> -<%= tab(2) %>await exec('npx prisma migrate deploy') +<%= tab(2) %>await exec('<%= npx %> prisma migrate deploy') <% } -%> <% if (build && options.deferBuild) { -%> -<%= tab(2) %>await exec('npm run build') +<%= tab(2) %>await exec('<%= packager %> run build') <% } -%> <%= tab(1) %>}