Skip to content

Commit

Permalink
consistently recognize packager
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Sep 16, 2023
1 parent 44b8035 commit e47b010
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ export class GDF {
if (this.options.nginxRoot) return true
}

get npx() {
return this.bun ? "bunx" : "npx"

Check failure on line 591 in gdf.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 591 in gdf.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
}

// command to start the web server
get startCommand() {
if (this.options.cmd) return this.options.cmd
Expand All @@ -602,15 +606,15 @@ 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')) {
start = start.replace('start', 'start --address 0.0.0.0')
}

start = start.split(' ')
start.unshift('npx')
start.unshift(this.npx)
return start
} else if (this.#pj.scripts?.start) {
return [this.packager, 'run', 'start']
Expand Down
4 changes: 2 additions & 2 deletions templates/Dockerfile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 { -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/docker-entrypoint.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>}

Expand Down

0 comments on commit e47b010

Please sign in to comment.