@@ -36,48 +36,46 @@ export const setupEnvironments = async (
3636 . find ( ) ;
3737
3838 //create management token if not present
39- if ( ! managementToken ) {
39+ if ( ! managementToken ) {
4040 const managementBody = {
41- "token" :{
42- "name" :"sample app" ,
43- "description" :"This is a sample management token." ,
44- "scope" :[
45- {
46- "module" :"content_type" ,
47- "acl" :{
48- "read" :true ,
49- "write" :true
50- }
51- } ,
52- {
53- "module" :"branch" ,
54- "branches" :[
55- "main"
56- ] ,
57- "acl" :{
58- "read" :true
59- }
60- }
61- ] ,
62- "expires_on" : "3000-01-01" ,
63- "is_email_notification_enabled" :false
64- }
65- }
66- managementTokenResult = await managementAPIClient
67- . stack ( { api_key : api_key } )
68- . managementToken ( )
69- . create ( managementBody ) ;
70- if ( ! managementTokenResult . uid ) {
71- cliux . print (
72- `Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.` ,
73- {
74- color : 'yellow' ,
41+ token : {
42+ name : 'sample app' ,
43+ description : 'This is a sample management token.' ,
44+ scope : [
45+ {
46+ module : 'content_type' ,
47+ acl : {
48+ read : true ,
49+ write : true ,
50+ } ,
51+ } ,
52+ {
53+ module : 'branch' ,
54+ branches : [ 'main' ] ,
55+ acl : {
56+ read : true ,
57+ } ,
58+ } ,
59+ ] ,
60+ expires_on : '3000-01-01' ,
61+ is_email_notification_enabled : false ,
7562 } ,
76- ) ;
77- if ( ( await continueBootstrapCommand ( ) ) === 'no' ) {
78- return ;
63+ } ;
64+ managementTokenResult = await managementAPIClient
65+ . stack ( { api_key : api_key } )
66+ . managementToken ( )
67+ . create ( managementBody ) ;
68+ if ( ! managementTokenResult . uid ) {
69+ cliux . print (
70+ `Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.` ,
71+ {
72+ color : 'yellow' ,
73+ } ,
74+ ) ;
75+ if ( ( await continueBootstrapCommand ( ) ) === 'no' ) {
76+ return ;
77+ }
7978 }
80- }
8179 }
8280 if ( Array . isArray ( environmentResult . items ) && environmentResult . items . length > 0 ) {
8381 for ( const environment of environmentResult . items ) {
@@ -184,13 +182,11 @@ const envFileHandler = async (
184182 let filePath ;
185183 let fileName ;
186184 let customHost ;
187- let previewHost : string ;
188- let appHost : string ;
189185 const managementAPIHost = region ?. cma ?. substring ( '8' ) ;
190186 const regionName = region && region . name && region . name . toLowerCase ( ) ;
191- previewHost = region ?. uiHost ?. substring ( 8 ) ?. replace ( 'app' , 'rest-preview' ) ;
187+ const previewHost = region ?. uiHost ?. substring ( 8 ) ?. replace ( 'app' , 'rest-preview' ) ;
192188 const cdnHost = region ?. cda ?. substring ( '8' ) ;
193- appHost = region ?. uiHost ?. substring ( 8 ) ;
189+ const appHost = region ?. uiHost ?. substring ( 8 ) ;
194190 const isUSRegion = regionName === 'us' || regionName === 'na' ;
195191 if ( regionName !== 'eu' && ! isUSRegion ) {
196192 customHost = region ?. cma ?. substring ( 8 ) ;
@@ -252,8 +248,11 @@ const envFileHandler = async (
252248 customHost ? customHost : managementAPIHost
253249 } ${
254250 ! isUSRegion && ! customHost ? '\nCONTENTSTACK_REGION=' + region . name : ''
255- } \nCONTENTSTACK_APP_HOST=${ appHost } \nCONTENTSTACK_MANAGEMENT_TOKEN=${ managementTokenResult . uid } \nCONTENTSTACK_HOST=${ cdnHost } `;
251+ } \nCONTENTSTACK_APP_HOST=${ appHost } \nCONTENTSTACK_MANAGEMENT_TOKEN=${
252+ managementTokenResult . uid
253+ } \nCONTENTSTACK_HOST=${ cdnHost } `;
256254 result = await writeEnvFile ( content , filePath ) ;
255+ break ;
257256 case 'gatsby' :
258257 case 'gatsby-starter' :
259258 fileName = `.env.${ environmentVariables . environment } ` ;
0 commit comments