Skip to content

Commit

Permalink
feat: add back eject
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Mar 31, 2021
1 parent ac94fbc commit bb76bc3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
65 changes: 65 additions & 0 deletions src/commands/eject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { GluegunToolbox } from 'gluegun'
import ignore from 'ignore'

export default {
name: 'eject',
run: async ({
filesystem: { exists },
template: { generate },
print: {
colors: { highlight },
error,
spin,
},
prompt: { ask },
}: GluegunToolbox) => {
if (exists('docker')) {
error(`${highlight('docker')} exists in the current directory. Remove it to eject.`)
process.exit(1)
}

const { kongPort, dbPort } = await ask([
{
type: 'input',
name: 'kongPort',
message: 'Port for Supabase URL:',
initial: '8000',
},
{
type: 'input',
name: 'dbPort',
message: 'Port for PostgreSQL database:',
initial: '5432',
},
])

const apiKey =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U'

const spinner = spin('Ejecting...')

// Write templates
await Promise.all(
[
'kong/Dockerfile',
'kong/kong.yml',
'postgres/00-initial-schema.sql',
'postgres/Dockerfile',
'postgres/auth-schema.sql',
'docker-compose.yml',
].map((f) =>
generate({
template: `init/emulator/${f}`,
target: `docker/${f}`,
props: {
kongPort,
dbPort,
apiKey,
},
})
)
)

spinner.succeed('Supabase Docker ejected.')
},
}
8 changes: 7 additions & 1 deletion src/commands/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
error,
info,
fancy,
colors: { bold, green, muted },
colors: { bold, green, muted, highlight },
},
}: GluegunToolbox) => {
const printHelp = () =>
Expand All @@ -22,6 +22,12 @@ export default {
init Initialize project
start Start local emulator
stop Stop local emulator
eject Create a ${highlight(
'docker'
)} directory with the Docker setup for the emulator.
See ${highlight(
'https://supabase.io/docs/guides/self-hosting'
)} for details.
Options:
Expand Down

0 comments on commit bb76bc3

Please sign in to comment.