@@ -4,6 +4,8 @@ import {flags} from '@oclif/command'
44import fetch from 'node-fetch'
55import sleep = require( 'sleep-promise' )
66
7+ const defaultRegion : Record < string , string > = { dev : 'us-test-1' , stg : 'us-east-1' , prod : 'us-west-2' }
8+
79export 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