@flydotio/dockerfile
Advanced tools
Comparing version 0.3.1 to 0.3.2
68
gdf.js
@@ -14,2 +14,3 @@ import fs from 'node:fs' | ||
export const defaults = { | ||
dev: false, | ||
distroless: false, | ||
@@ -263,11 +264,17 @@ ignoreScripts: false, | ||
// optionally include dev dependencies | ||
if (this.devDependencies) { | ||
if (this.yarn) { | ||
install += ' --production=false' | ||
} else if (this.pnpm) { | ||
install += ' --prod=false' | ||
} else if (!this.bunVersion) { | ||
install += ' --include=dev' | ||
// optionally include dev dependencies if a build is defined | ||
if (this.build || this.dev) { | ||
if (this.devDependencies) { | ||
if (this.yarn) { | ||
install += ' --production=false' | ||
} else if (this.pnpm) { | ||
install += ' --prod=false' | ||
} else if (!this.bunVersion) { | ||
install += ' --include=dev' | ||
} | ||
} | ||
} else { | ||
if (this.bunVersion) { | ||
install += ' --production' | ||
} | ||
} | ||
@@ -340,2 +347,13 @@ | ||
// Include devDependencies? | ||
get dev() { | ||
if (!this.devDependencies) return false | ||
// frameworks that include migration dependencies in devDependencies | ||
if (this.nestjs) return true | ||
if (this.adonisjs) return true | ||
return this.options.dev | ||
} | ||
// Is there a build script? | ||
@@ -390,4 +408,12 @@ get build() { | ||
return start | ||
} else if (this.#pj.scripts?.start) { | ||
return [this.packager, 'run', 'start'] | ||
} else if (this.#pj.type === 'module' && this.#pj.module) { | ||
return [this.packager === 'bun' ? 'bun' : 'node', this.#pj.module] | ||
} else if (this.#pj.main) { | ||
return [this.packager === 'bun' ? 'bun' : 'node', this.#pj.main] | ||
} else if (this.packager === 'bun') { | ||
return ['bun', 'index.ts'] | ||
} else { | ||
return [this.packager, 'run', 'start'] | ||
return ['node', 'index.js'] | ||
} | ||
@@ -517,12 +543,16 @@ } | ||
prompt = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}) | ||
if (typeof Bun === 'undefined') { | ||
prompt = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}) | ||
// support node 16 which doesn't have a promisfied readline interface | ||
question = query => { | ||
return new Promise(resolve => { | ||
prompt.question(query, resolve) | ||
}) | ||
// support node 16 which doesn't have a promisfied readline interface | ||
question = query => { | ||
return new Promise(resolve => { | ||
prompt.question(query, resolve) | ||
}) | ||
} | ||
} else { | ||
question = query => global.prompt(query) || '' | ||
} | ||
@@ -566,3 +596,3 @@ } | ||
} finally { | ||
if (prompt) prompt.close() | ||
if (prompt && typeof Bun === 'undefined') prompt.close() | ||
} | ||
@@ -569,0 +599,0 @@ } else { |
@@ -23,2 +23,6 @@ #!/usr/bin/env node | ||
.epilog('Options are saved between runs into package.json. more info:\n https://github.com/fly-apps/dockerfile-node#readme') | ||
.option('dev', { | ||
describe: 'install devDependencies in production', | ||
type: 'boolean' | ||
}) | ||
.option('distroless', { | ||
@@ -25,0 +29,0 @@ describe: 'use base image from gcr.io/distroless', |
{ | ||
"name": "@flydotio/dockerfile", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Dockerfile generator", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
Sorry, the diff of this file is not supported yet
40876
758