Skip to content

Commit 6c8bca3

Browse files
committed
address review comment: remove default region
1 parent 2e44d03 commit 6c8bca3

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

src/commands/app/deploy.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,28 @@ class Deploy extends BuildCommand {
305305
}
306306

307307
async provisionDatabase (config, spinner, flags) {
308-
const region = config.manifest?.full?.database?.region || 'amer'
308+
const region = config.manifest?.full?.database?.region
309+
const args = ['--yes']
309310

310-
if (!config.manifest?.full?.database?.region) {
311-
spinner.info(chalk.green('No region is configured for the database, deploying in default region amer'))
311+
if (region) {
312+
args.unshift('--region', region)
312313
}
313314

314-
const message = `Deploying database for region '${region}'`
315+
const message = region ? `Deploying database in region '${region}'` : 'Deploying database in default region'
315316

316317
try {
317318
spinner.start(message)
318319

319320
if (flags.verbose) {
320-
spinner.info(chalk.dim(`Running: aio app db provision --region ${region} --yes`))
321+
const commandStr = region ? `aio app db provision --region ${region} --yes` : 'aio app db provision --yes'
322+
spinner.info(chalk.dim(`Running: ${commandStr}`))
321323
spinner.start(message)
322324
}
323325

324-
await this.config.runCommand('app:db:provision', ['--region', region, '--yes'])
326+
await this.config.runCommand('app:db:provision', args)
325327

326-
spinner.succeed(chalk.green(`Deployed database for application in region '${region}'`))
328+
const successMessage = region ? `Deployed database for application in region '${region}'` : 'Deployed database for application'
329+
spinner.succeed(chalk.green(successMessage))
327330
} catch (error) {
328331
spinner.fail(chalk.red('Database deployment failed'))
329332
throw error

test/commands/app/deploy.test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,10 +1698,9 @@ describe('database provisioning', () => {
16981698

16991699
const { spinner } = await runProvisionTest(config, flags)
17001700

1701-
expect(spinner.info).toHaveBeenCalledWith(expect.stringContaining('No region is configured for the database, deploying in default region amer'))
1702-
expect(spinner.start).toHaveBeenCalledWith('Deploying database for region \'amer\'')
1703-
expect(command.config.runCommand).toHaveBeenCalledWith('app:db:provision', ['--region', 'amer', '--yes'])
1704-
expect(spinner.succeed).toHaveBeenCalledWith(expect.stringContaining('Deployed database for application in region \'amer\''))
1701+
expect(spinner.start).toHaveBeenCalledWith('Deploying database in default region')
1702+
expect(command.config.runCommand).toHaveBeenCalledWith('app:db:provision', ['--yes'])
1703+
expect(spinner.succeed).toHaveBeenCalledWith(expect.stringContaining('Deployed database for application'))
17051704
})
17061705

17071706
test('should use configured region when specified in manifest', async () => {
@@ -1710,8 +1709,7 @@ describe('database provisioning', () => {
17101709

17111710
const { spinner } = await runProvisionTest(config, flags)
17121711

1713-
expect(spinner.info).not.toHaveBeenCalledWith(expect.stringContaining('No region is configured for the database'))
1714-
expect(spinner.start).toHaveBeenCalledWith('Deploying database for region \'emea\'')
1712+
expect(spinner.start).toHaveBeenCalledWith('Deploying database in region \'emea\'')
17151713
expect(command.config.runCommand).toHaveBeenCalledWith('app:db:provision', ['--region', 'emea', '--yes'])
17161714
expect(spinner.succeed).toHaveBeenCalledWith(expect.stringContaining('Deployed database for application in region \'emea\''))
17171715
})
@@ -1723,11 +1721,21 @@ describe('database provisioning', () => {
17231721
const { spinner } = await runProvisionTest(config, flags)
17241722

17251723
expect(spinner.info).toHaveBeenCalledWith(expect.stringContaining('Running: aio app db provision --region amer --yes'))
1726-
expect(spinner.info).not.toHaveBeenCalledWith(expect.stringContaining('No region is configured for the database'))
17271724
expect(spinner.start).toHaveBeenCalledTimes(2) // Once initially, once after verbose info
17281725
expect(spinner.succeed).toHaveBeenCalledWith(expect.stringContaining('Deployed database for application in region \'amer\''))
17291726
})
17301727

1728+
test('should show verbose output without region when no region configured', async () => {
1729+
const config = createDatabaseConfig()
1730+
const flags = { verbose: true }
1731+
1732+
const { spinner } = await runProvisionTest(config, flags)
1733+
1734+
expect(spinner.info).toHaveBeenCalledWith(expect.stringContaining('Running: aio app db provision --yes'))
1735+
expect(spinner.start).toHaveBeenCalledTimes(2) // Once initially, once after verbose info
1736+
expect(spinner.succeed).toHaveBeenCalledWith(expect.stringContaining('Deployed database for application'))
1737+
})
1738+
17311739
test('should handle provision command failure', async () => {
17321740
const config = createDatabaseConfig('amer')
17331741
const flags = { verbose: false }

0 commit comments

Comments
 (0)