Skip to content

Commit da4a73c

Browse files
committed
remove "yes" flag and add "minimal" flag
1 parent 7833496 commit da4a73c

File tree

2 files changed

+20
-38
lines changed

2 files changed

+20
-38
lines changed

src/commands/database/database.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,20 @@ export const createDatabaseCommand = (program: BaseCommand) => {
2424
.command('db')
2525
.alias('database')
2626
.description(`Provision a production ready Postgres database with a single command`)
27-
.addExamples([
28-
'netlify db status',
29-
'netlify db init',
30-
'netlify db init --drizzle',
31-
'netlify db init --drizzle --overwrite',
32-
])
27+
.addExamples(['netlify db status', 'netlify db init', 'netlify db init --help'])
3328

3429
dbCommand
3530
.command('init')
3631
.description(`Initialize a new database for the current site`)
3732
.option(`--drizzle`, 'Initialize basic drizzle config and schema boilerplate')
38-
.option('--no-drizzle', 'Skips drizzle')
39-
.option('-y, --yes', 'Skip prompts and use default values')
33+
.option('--no-drizzle', 'Does not initialize drizzle and skips any related prompts')
34+
.option(
35+
'--minimal',
36+
'Minimal non-interactive setup. Does not initialize drizzle or any boilerplate. Ideal for CI or AI tools.',
37+
)
4038
.option('-o, --overwrite', 'Overwrites existing files that would be created when setting up drizzle')
4139
.action(init)
40+
.addExamples([`netlify db init --minimal`, `netlify db init --drizzle --overwrite`])
4241

4342
dbCommand.command('status').description(`Check the status of the database`).action(status)
44-
45-
return dbCommand
4643
}

src/commands/database/init.ts

+13-28
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ export const init = async (_options: OptionValues, command: BaseCommand) => {
1717

1818
const initialOpts = command.opts()
1919

20-
type Answers = {
21-
drizzle: boolean
22-
installExtension: boolean
23-
}
24-
2520
const opts = command.opts<{
2621
drizzle?: boolean | undefined
27-
/**
28-
* Skip prompts and use default values (answer yes to all prompts)
29-
*/
30-
yes?: true | undefined
22+
overwrite?: boolean | undefined
23+
minimal?: boolean | undefined
3124
}>()
3225

3326
if (!command.netlify.api.accessToken || !siteInfo.account_id || !siteInfo.name) {
3427
throw new Error(`Please login with netlify login before running this command`)
3528
}
3629

30+
if (opts.minimal === true) {
31+
command.setOptionValue('drizzle', false)
32+
}
33+
3734
const account = await getAccount(command, { accountId: siteInfo.account_id })
3835

3936
const netlifyToken = command.netlify.api.accessToken.replace('Bearer ', '')
@@ -63,28 +60,17 @@ export const init = async (_options: OptionValues, command: BaseCommand) => {
6360
log(`Extension "${extension.name}" successfully installed on team "${account.name}"`)
6461
}
6562

66-
if (!extension.installedOnTeam && !opts.yes) {
67-
const answers = await inquirer.prompt<Answers>([
68-
{
69-
type: 'confirm',
70-
name: 'installExtension',
71-
message: `The required extension "${extension.name}" is not installed on team "${account.name}", would you like to install it now?`,
72-
},
73-
])
74-
if (answers.installExtension) {
75-
await installNeonExtension()
76-
} else {
77-
return
78-
}
79-
}
80-
if (!extension.installedOnTeam && opts.yes) {
63+
if (!extension.installedOnTeam) {
8164
await installNeonExtension()
8265
}
66+
8367
/**
8468
* Only prompt for drizzle if the user did not pass in the `--drizzle` or `--no-drizzle` option
8569
*/
86-
if (initialOpts.drizzle !== false && initialOpts.drizzle !== true && !initialOpts.yes) {
87-
const answers = await inquirer.prompt<Answers>([
70+
if (initialOpts.drizzle !== false && initialOpts.drizzle !== true) {
71+
const answers = await inquirer.prompt<{
72+
drizzle: boolean
73+
}>([
8874
{
8975
type: 'confirm',
9076
name: 'drizzle',
@@ -93,8 +79,7 @@ export const init = async (_options: OptionValues, command: BaseCommand) => {
9379
])
9480
command.setOptionValue('drizzle', answers.drizzle)
9581
}
96-
97-
if (opts.drizzle || (opts.yes && opts.drizzle !== false)) {
82+
if (opts.drizzle) {
9883
log(`Initializing drizzle...`)
9984
await initDrizzle(command)
10085
}

0 commit comments

Comments
 (0)