@@ -27,7 +27,7 @@ export interface ContentModelSeederOptions {
2727 stackUid : string | undefined ;
2828 stackName : string | undefined ;
2929 fetchLimit : string | undefined ;
30- skipStackConfirmation : string | undefined ;
30+ skipStackConfirmation : boolean | undefined ;
3131 isAuthenticated : boolean | false ;
3232 managementToken ?: string | undefined ;
3333 alias ?: string | undefined ;
@@ -181,52 +181,24 @@ export default class ContentModelSeeder {
181181 }
182182
183183 async shouldProceed ( api_key : string ) {
184- let count ;
185184 const stack_details = await this . csClient . getStack ( api_key ) ;
186- if ( this . options . master_locale != stack_details . master_locale ) {
187- cliux . print ( `Compass app requires the master locale to be set to English (en).` , {
188- color : "yellow" ,
189- bold : true ,
190- } ) ;
191- return false ;
192- }
193- const managementBody = {
194- "name" :"Checking roles for creating management token" ,
195- "description" :"This is a compass app management token." ,
196- "scope" :[
197- {
198- "module" :"content_type" ,
199- "acl" :{
200- "read" :true ,
201- "write" :true
202- }
203- } ,
204- {
205- "module" :"branch" ,
206- "branches" :[
207- "main"
208- ] ,
209- "acl" :{
210- "read" :true
211- }
212- }
213- ] ,
214- "expires_on" : "3000-01-01" ,
215- "is_email_notification_enabled" :false
216- }
217- let managementTokenResult = await this . csClient . createManagementToken ( api_key , this . managementToken , managementBody ) ;
218- if ( managementTokenResult ?. response_code == "161" || managementTokenResult ?. response_code == "401" ) {
185+ const repoMasterLocale = await this . ghClient . getMasterLocaleFromRepo ( this . ghRepo as string ) ;
186+ const expectedLocale = repoMasterLocale || this . options . master_locale || ENGLISH_LOCALE ;
187+
188+ if ( stack_details . master_locale !== expectedLocale ) {
219189 cliux . print (
220- `Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support .` ,
190+ `Repository ' ${ this . ghRepo } ' requires the master locale to be set to ' ${ expectedLocale } ', but your stack has ' ${ stack_details . master_locale } ' .` ,
221191 {
222- color : 'red' ,
192+ color : 'yellow' ,
193+ bold : true ,
223194 } ,
224195 ) ;
225196 return false ;
226- }
227- count = await this . csClient . getContentTypeCount ( api_key , this . managementToken ) ;
197+ }
198+
199+ const count = await this . csClient . getContentTypeCount ( api_key , this . managementToken ) ;
228200
229- if ( count > 0 && this . _options . skipStackConfirmation !== 'yes' ) {
201+ if ( count > 0 && ! this . _options . skipStackConfirmation ) {
230202 const proceed = await inquireProceed ( ) ;
231203
232204 if ( ! proceed ) {
0 commit comments