Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 9873808

Browse files
author
Akash Jain
committed
fix: default regions across environments
1 parent 5e844cc commit 9873808

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/deploy-backend.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {flags} from '@oclif/command'
44
import fetch from 'node-fetch'
55
import sleep = require('sleep-promise')
66

7+
const defaultRegion: Record<string, string> = {dev: 'us-test-1', stg: 'us-east-1', prod: 'us-west-2'}
8+
79
export default class DeployBackend extends BaseCommand {
810
static description = 'Launch a new Backend'
911

@@ -15,10 +17,10 @@ export default class DeployBackend extends BaseCommand {
1517

1618
static flags = {
1719
...BaseCommand.commonFlags,
18-
region: flags.string({char: 'r', description: 'Region', default: 'us-west-2'}),
20+
region: flags.string({char: 'r', description: 'Region'}),
1921
organizationId: flags.string({char: 'o', description: 'Organization ID', default: ''}),
2022
subdomain: flags.string({char: 's', description: 'Subdomain'}),
21-
'deployment-mode': flags.string({char: 'm', description: 'Deployment Mode', default: 'graphql', options: ['readonly', 'graphql', 'flexible']}),
23+
mode: flags.string({char: 'm', description: 'Backend Mode', default: 'graphql', options: ['readonly', 'graphql', 'flexible']}),
2224
}
2325

2426
static args = [{name: 'name', description: 'Backend Name', required: true}]
@@ -41,14 +43,14 @@ export default class DeployBackend extends BaseCommand {
4143
},
4244
body: JSON.stringify({
4345
name: opts.args.name,
44-
zone: opts.flags.region,
46+
zone: opts.flags.region || defaultRegion[opts.flags.environment],
4547
subdomain: opts.flags.subdomain,
46-
deploymentMode: opts.flags['deployment-mode'],
48+
deploymentMode: opts.flags.mode,
4749
organizationId: opts.flags.organizationId,
4850
}),
4951
})
5052
if (response.status !== 200) {
51-
this.error(`Unable to create backend. Try logging in again\n${await response.text()}`)
53+
this.error(`Unable to create backend. ${response.status} ${await response.text()}`)
5254
}
5355
const deployment = await response.json() as APIBackend
5456
const endpoint = `https://${deployment.url}/graphql`

0 commit comments

Comments
 (0)