@flydotio/dockerfile
Advanced tools
Comparing version 0.7.5 to 0.7.6
56
fly.js
import crypto from 'node:crypto' | ||
import fs from 'node:fs' | ||
import inquirer from 'inquirer' | ||
import path from 'node:path' | ||
@@ -12,3 +13,3 @@ import { execSync } from 'node:child_process' | ||
GDF.extend(class extends GDF { | ||
run() { | ||
async run() { | ||
if (!this.flySetup()) return | ||
@@ -31,4 +32,7 @@ | ||
if (this.shopify) { | ||
this.flyShopifyEnv(this.flyApp) | ||
this.flyShopifyConfig(this.flyApp) | ||
const shopifyConfig = await this.selectShopifyConfig() | ||
if (shopifyConfig) { | ||
this.flyShopifyEnv(this.flyApp, shopifyConfig) | ||
this.flyShopifyConfig(this.flyApp, shopifyConfig) | ||
} | ||
} else if (this.remix) { | ||
@@ -316,7 +320,37 @@ this.flyRemixSecrets(this.flyApp) | ||
async selectShopifyConfig() { | ||
// Search for both shopify.app.toml and shopify.app.*.toml | ||
const files = fs.readdirSync('.') | ||
.filter(file => file.startsWith('shopify.app.') && file.endsWith('.toml')) | ||
.sort() | ||
if (files.length === 0) { | ||
return null | ||
} | ||
if (files.length === 1) { | ||
return files[0] | ||
} | ||
// Multiple files found, prompt user to select one | ||
const { selectedFile } = await inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'selectedFile', | ||
message: 'Multiple configuration files found. Please select one:', | ||
choices: files.map(file => ({ | ||
name: file, | ||
value: file | ||
})) | ||
} | ||
]) | ||
return selectedFile | ||
} | ||
// set environment and secrets for Shopify apps | ||
flyShopifyEnv(app) { | ||
flyShopifyEnv(app, configFile) { | ||
let toml = '' | ||
if (fs.existsSync('shopify.app.toml')) { | ||
toml = fs.readFileSync('shopify.app.toml', 'utf-8') | ||
if (fs.existsSync(configFile)) { | ||
toml = fs.readFileSync(configFile, 'utf-8') | ||
} | ||
@@ -326,3 +360,3 @@ | ||
this.setExit(42) | ||
console.log(`${chalk.bold.red('shopify.app.toml')} is not complete; run ${chalk.bold.blue('shopify app config create')} first.`) | ||
console.log(`${chalk.bold.red(configFile)} is not complete; run ${chalk.bold.blue('shopify app config create')} first.`) | ||
return | ||
@@ -337,3 +371,3 @@ } | ||
try { | ||
console.log(`${chalk.bold.green('execute'.padStart(11))} shopify app env show`) | ||
console.log(`${chalk.bold.green('execute'.padStart(11))} shopify app env show --config ${configFile}`) | ||
const stdout = execSync('shopify app env show', { encoding: 'utf8' }) | ||
@@ -356,4 +390,4 @@ for (const match of stdout.matchAll(/^\s*(\w+)=(.*)/mg)) { | ||
// update config for Shopify apps | ||
flyShopifyConfig(app) { | ||
const original = fs.readFileSync('shopify.app.toml', 'utf-8') | ||
flyShopifyConfig(app, configFile) { | ||
const original = fs.readFileSync(configFile, 'utf-8') | ||
const url = `https://${app}.fly.dev` | ||
@@ -365,3 +399,3 @@ const config = original.replaceAll(/"https:\/\/[-\w.]+/g, '"' + url) | ||
console.log(`${chalk.bold.green('update'.padStart(11, ' '))} shopify.app.toml`) | ||
fs.writeFileSync('shopify.app.toml', config) | ||
fs.writeFileSync(configFile, config) | ||
console.log(`${chalk.bold.green('execute'.padStart(11))} shopify app deploy --force`) | ||
@@ -368,0 +402,0 @@ execSync('shopify app deploy --force', { stdio: 'inherit' }) |
@@ -1045,3 +1045,3 @@ import fs from 'node:fs' | ||
for (const runner of GDF.runners) { | ||
runner.apply(this) | ||
await runner.apply(this) | ||
} | ||
@@ -1048,0 +1048,0 @@ |
{ | ||
"name": "@flydotio/dockerfile", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "Dockerfile generator", | ||
@@ -25,2 +25,3 @@ "main": "./index.js", | ||
"ejs": "^3.1.10", | ||
"inquirer": "^12.4.1", | ||
"shell-quote": "^1.8.2", | ||
@@ -27,0 +28,0 @@ "yargs": "^17.7.2" |
80779
1597
6
+ Addedinquirer@^12.4.1
+ Added@inquirer/checkbox@4.1.2(transitive)
+ Added@inquirer/confirm@5.1.6(transitive)
+ Added@inquirer/core@10.1.7(transitive)
+ Added@inquirer/editor@4.2.7(transitive)
+ Added@inquirer/expand@4.0.9(transitive)
+ Added@inquirer/figures@1.0.10(transitive)
+ Added@inquirer/input@4.1.6(transitive)
+ Added@inquirer/number@3.0.9(transitive)
+ Added@inquirer/password@4.0.9(transitive)
+ Added@inquirer/prompts@7.3.2(transitive)
+ Added@inquirer/rawlist@4.0.9(transitive)
+ Added@inquirer/search@3.0.9(transitive)
+ Added@inquirer/select@4.0.9(transitive)
+ Added@inquirer/type@3.0.4(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-width@4.1.0(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinquirer@12.4.2(transitive)
+ Addedmute-stream@2.0.0(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedrun-async@3.0.0(transitive)
+ Addedrxjs@7.8.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)