1- import { Command , Flags } from '@oclif/core'
2- import { table } from 'table'
1+ import { Command , Flags } from '@oclif/core'
2+ import { table } from 'table'
33
4- import { Environment , EnvironmentDetail } from '../../../types/environment.js'
5- import { camelCaseToTitleCase } from '../../../util/internal.js'
6- import { ScConnection } from '../../../util/sc-connection.js'
4+ import { Environment , EnvironmentDetail } from '../../../types/environment.js'
5+ import { camelCaseToTitleCase } from '../../../util/internal.js'
6+ import { ScConnection } from '../../../util/sc-connection.js'
77
88export default class PlatformEnvCreate extends Command {
99 static override args = { }
@@ -12,28 +12,36 @@ export default class PlatformEnvCreate extends Command {
1212 Token Permissions: [ environments:edit ]`
1313 static override examples = [ '<%= config.bin %> <%= command.id %> --name=MyEnvironment --desc="My environment description" --isDefault --isProduction' ]
1414 static override flags = {
15- desc : Flags . string ( { char : 'd' , description : 'Description of the environment to create.' } ) ,
16- // flag with no value (--isDefault)
17- isDefault : Flags . boolean ( { description : 'Indicates this is the organization’s default environment.' } ) ,
15+ desc : Flags . string ( {
16+ char : 'd' ,
17+ description : 'Description of the environment to create.'
18+ } ) ,
19+ isDefault : Flags . boolean ( {
20+ description : 'Indicates this is the organization’s default environment.'
21+ } ) ,
1822 isProduction : Flags . boolean ( {
1923 description : `Indicates this is an organization’s production environment.
2024 This is an immutable field. If an environment needs to be migrated,
2125 architecture can be migrated to a new environment with the desired
2226 environment type instead.` ,
2327 } ) ,
24- // flag with a value (-n, --name=VALUE)
25- name : Flags . string ( { char : 'n' , description : 'Name of the environment to create.' , required : true } ) ,
28+ name : Flags . string ( {
29+ char : 'n' ,
30+ description : 'Name of the environment to create.' ,
31+ required : true
32+ } ) ,
2633 }
2734
2835 public async run ( ) : Promise < void > {
29- const { flags} = await this . parse ( PlatformEnvCreate )
36+ const { flags } = await this . parse ( PlatformEnvCreate )
3037
3138 const name = flags . name ?? ''
3239 const desc = flags . desc ?? ''
3340 const isDefault = flags . isDefault ?? false
3441 const isProduction = flags . isProduction ?? false
3542
3643 const conn = new ScConnection ( )
44+
3745 // API url
3846 const apiUrl : string = `/platform/environments`
3947 // API body
@@ -43,8 +51,10 @@ export default class PlatformEnvCreate extends Command {
4351 isProduction,
4452 name,
4553 }
54+
4655 // API call
4756 const resp = await conn . post < EnvironmentDetail > ( apiUrl , body )
57+
4858 // Display results
4959 this . log ( 'Environment created successfully.' )
5060 this . print ( resp . data )
@@ -60,7 +70,7 @@ export default class PlatformEnvCreate extends Command {
6070 // Table config
6171 const config = {
6272 columns : {
63- 1 : { width : 50 , wrapWord : true } ,
73+ 1 : { width : 50 , wrapWord : true } ,
6474 } ,
6575 drawHorizontalLine ( lineIndex : number , rowCount : number ) {
6676 return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount
0 commit comments