Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ module.exports = {
root: true,
env: {
browser: true,
es2021: true,
mocha: true,
es2021: true
},
extends: ['standard'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
sourceType: 'module'
},
rules: {
'space-before-function-paren': ['error', 'never'],
},
}
'space-before-function-paren': ['error', 'never']
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Args and environment variables can be tailored to a specific build phase by addi
Techniques such as static site generation using databases may require access to secrets at build time. To enable this you will need to _mount_ the secret:

* `--mount-secret=name` - add _name_ to the list of secrets to mount when running the build script
* `--unmount-secret-name` - remove _name_ from the list of secrets to mount when running the build script
* `--unmount-secret=name` - remove _name_ from the list of secrets to mount when running the build script

See [Secret to expose to the build](https://docs.docker.com/engine/reference/commandline/buildx_build/#secret) for examples on how to pass secrets to a docker build.

Expand Down
23 changes: 11 additions & 12 deletions fly.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import fs from 'node:fs'
import inquirer from 'inquirer'
import path from 'node:path'
import { execSync } from 'node:child_process'

import chalk from 'chalk'
import { styleText } from 'node:util'

import { GDF } from './gdf.js'

Expand Down Expand Up @@ -53,7 +52,7 @@ GDF.extend(class extends GDF {
if (this.prismaFile && !fs.existsSync(path.join(this._appdir, 'prisma', this.prismaFile)) && fs.existsSync(path.join(this._appdir, 'node_modules'))) {
execSync(`${this.npx} prisma migrate dev --name init --create-only`, { stdio: 'inherit' })
} else {
console.error(chalk.bold.red('\nNo migrations found. Please run `npx prisma migrate dev` to create an initial migration.'))
console.error(styleText(['bold', 'red'], '\nNo migrations found. Please run `npx prisma migrate dev` to create an initial migration.'))
this.setExit(42)
}
}
Expand Down Expand Up @@ -201,7 +200,7 @@ GDF.extend(class extends GDF {
// see if secret is already set?
if (this.flySecrets.includes('FLY_CONSUL_URL')) return

console.log(`${chalk.bold.green('execute'.padStart(11))} flyctl consul attach`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} flyctl consul attach`)
execSync(
`${this.flyctl} consul attach --app ${app}`,
{ stdio: 'inherit' }
Expand Down Expand Up @@ -266,7 +265,7 @@ GDF.extend(class extends GDF {

const value = crypto.randomBytes(32).toString('hex')

console.log(`${chalk.bold.green('execute'.padStart(11))} flyctl secrets set ${name}`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} flyctl secrets set ${name}`)
execSync(
`${this.flyctl} secrets set ${name}=${value} --app ${app}`,
{ stdio: 'inherit' }
Expand Down Expand Up @@ -354,7 +353,7 @@ GDF.extend(class extends GDF {

if (!toml.includes('client_id')) {
this.setExit(42)
console.log(`${chalk.bold.red(configFile)} is not complete; run ${chalk.bold.blue('shopify app config create')} first.`)
console.log(`${styleText(['bold', 'red'], configFile)} is not complete; run ${styleText(['bold', 'blue'], 'shopify app config create')} first.`)
return
}

Expand All @@ -364,11 +363,11 @@ GDF.extend(class extends GDF {
}

try {
console.log(`${chalk.bold.green('execute'.padStart(11))} shopify app env show --config ${configFile}`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} shopify app env show --config ${configFile}`)
const stdout = execSync('shopify app env show', { encoding: 'utf8' })
for (const match of stdout.matchAll(/^\s*(\w+)=(.*)/mg)) {
if (match[1] === 'SHOPIFY_API_SECRET') {
console.log(`${chalk.bold.green('execute'.padStart(11))} flyctl secrets set SHOPIFY_API_SECRET`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} flyctl secrets set SHOPIFY_API_SECRET`)
execSync(`${this.flyctl} secrets set SHOPIFY_API_SECRET=${match[2]} --app ${app}`, { stdio: 'inherit' })
} else {
env[match[1]] = match[2]
Expand All @@ -389,9 +388,9 @@ GDF.extend(class extends GDF {
.replace(/(redirect_urls\s*=\s*\[).*?\]/s,
`$1\n "${url}/auth/callback",\n "${url}/auth/shopify/callback",\n "${url}/api/auth/callback"\n]`)
if (original !== config) {
console.log(`${chalk.bold.green('update'.padStart(11, ' '))} ${configFile}`)
console.log(`${styleText(['bold', 'green'], 'update'.padStart(11, ' '))} ${configFile}`)
fs.writeFileSync(configFile, config)
console.log(`${chalk.bold.green('execute'.padStart(11))} shopify app deploy --force --config ${configFile}`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} shopify app deploy --force --config ${configFile}`)
execSync(`shopify app deploy --force --config ${configFile}`, { stdio: 'inherit' })
}
}
Expand All @@ -401,7 +400,7 @@ GDF.extend(class extends GDF {
const deploy = fs.readFileSync('.github/workflows/deploy.yml', 'utf-8')

if (!fs.existsSync('.git')) {
console.log(`${chalk.bold.green('execute'.padStart(11))} git init`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} git init`)
execSync('git init', { stdio: 'inherit' })
}

Expand All @@ -417,7 +416,7 @@ GDF.extend(class extends GDF {

if (base && !apps.find(app => app.Name === stagingApp)) {
const cmd = `apps create ${stagingApp} --org ${base.Organization.Slug}`
console.log(`${chalk.bold.green('execute'.padStart(11))} flyctl ${cmd}`)
console.log(`${styleText(['bold', 'green'], 'execute'.padStart(11))} flyctl ${cmd}`)
execSync(`${this.flyctl} ${cmd}`, { stdio: 'inherit' })
}
} catch {
Expand Down
14 changes: 7 additions & 7 deletions gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import url from 'node:url'
import path from 'node:path'
import * as readline from 'node:readline'
import { execSync } from 'node:child_process'
import { styleText } from 'node:util'

import * as ejs from 'ejs'
import chalk from 'chalk'
import * as Diff from 'diff'
import * as ShellQuote from 'shell-quote'

Expand Down Expand Up @@ -1065,10 +1065,10 @@ export class GDF {
const current = fs.readFileSync(dest, 'utf-8')

if (current === proposed) {
console.log(`${chalk.bold.blue('identical'.padStart(11))} ${name}`)
console.log(`${styleText(['bold', 'blue'], 'identical'.padStart(11))} ${name}`)
return dest
} else if (this.options.skip) {
console.log(`${chalk.bold.yellow('skip'.padStart(11))} ${name}`)
console.log(`${styleText(['bold', 'yellow'], 'skip'.padStart(11))} ${name}`)
return current
}

Expand All @@ -1077,7 +1077,7 @@ export class GDF {

try {
if (this.#answer !== 'a') {
console.log(`${chalk.bold.red('conflict'.padStart(11))} ${name}`)
console.log(`${styleText(['bold', 'red'], 'conflict'.padStart(11))} ${name}`)

if (typeof Bun === 'undefined') {
prompt = readline.createInterface({
Expand Down Expand Up @@ -1105,12 +1105,12 @@ export class GDF {
case '':
case 'y':
case 'a':
console.log(`${chalk.bold.yellow('force'.padStart(11, ' '))} ${name}`)
console.log(`${styleText(['bold', 'yellow'], 'force'.padStart(11, ' '))} ${name}`)
fs.writeFileSync(dest, proposed)
return dest

case 'n':
console.log(`${chalk.bold.yellow('skip'.padStart(11, ' '))} ${name}`)
console.log(`${styleText(['bold', 'yellow'], 'skip'.padStart(11, ' '))} ${name}`)
return dest

case 'q':
Expand All @@ -1134,7 +1134,7 @@ export class GDF {
if (prompt && typeof Bun === 'undefined') prompt.close()
}
} else {
console.log(`${chalk.bold.green('create'.padStart(11, ' '))} ${name}`)
console.log(`${styleText(['bold', 'green'], 'create'.padStart(11, ' '))} ${name}`)
fs.writeFileSync(dest, proposed)
}

Expand Down
Loading