Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest]
platform: [ubuntu-latest]
node: ['12']

runs-on: ${{ matrix.platform }}
Expand Down
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

import { build } from 'gluegun'

process.removeAllListeners('unhandledRejection')
process.on('unhandledRejection', () => {
process.exit(1)
})

build('supabase').src(__dirname).create().run()
5 changes: 4 additions & 1 deletion src/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export default {
},
})
)
)
).catch(() => {
spinner.fail('Error writing Docker setup files.')
process.exit(1)
})

spinner.succeed('Supabase Docker ejected.')
},
Expand Down
19 changes: 18 additions & 1 deletion src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ export default {
spin,
},
prompt: { ask },
system: { run, which },
}: GluegunToolbox) => {
if (exists('.supabase')) {
error(`Project already initialized. Remove ${highlight('.supabase')} to reinitialize.`)
process.exit(1)
}

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
error(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

// Add .supabase to .gitignore
const gitignore = read('.gitignore')
if (gitignore) {
Expand Down Expand Up @@ -72,7 +79,17 @@ export default {
},
})
)
)
).catch(() => {
spinner.fail('Error writing Docker setup files.')
process.exit(1)
})

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase build --no-cache --parallel --quiet'
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Project initialized.')
fancy(`Supabase URL: ${highlight(`http://localhost:${kongPort}`)}
Expand Down
20 changes: 17 additions & 3 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ import { GluegunToolbox } from 'gluegun'
export default {
name: 'start',
run: async ({
filesystem: { exists },
print: {
colors: { highlight },
error,
spin,
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Starting local Supabase...')
if (!exists('.supabase')) {
error(
`Cannot find ${highlight(
'.supabase'
)} in the current directory. Perhaps you meant to run ${highlight('supabase init')} first?`
)
process.exit(1)
}

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
error(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

const spinner = spin('Starting local Supabase...')

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase up --detach'
)
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Started local Supabase.')
},
Expand Down
22 changes: 19 additions & 3 deletions src/commands/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,37 @@ import { GluegunToolbox } from 'gluegun'
export default {
name: 'stop',
run: async ({
filesystem: { exists },
print: {
colors: { highlight },
error,
spin,
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Stopping local Supabase...')
if (!exists('.supabase')) {
error(
`Cannot find ${highlight(
'.supabase'
)} in the current directory. Perhaps you meant to run ${highlight('supabase init')} first?`
)
process.exit(1)
}

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
error(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

await run('docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase down')
const spinner = spin('Stopping local Supabase...')

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase down'
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Stopped local Supabase.')
},
Expand Down
13 changes: 12 additions & 1 deletion src/templates/init/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
Supabase instructions.
> Why do I have a directory named ".supabase" in my project?

The ".supabase" directory is created by the Supabase CLI.

> What does the "docker" directory contain?

It contains the Docker Compose file and build files for running Supabase locally.

> Should I commit the ".supabase" directory?

No, you should not share the ".supabase" directory with anyone.
Upon creation, it will be automatically added to your ".gitignore" file.
1 change: 1 addition & 0 deletions src/templates/init/docker/postgres/auth-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ $$ language sql stable;
GRANT ALL PRIVILEGES ON SCHEMA auth TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA auth TO postgres;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA auth TO postgres;
ALTER ROLE postgres SET search_path = "$user", public, auth;