@@ -15,38 +15,39 @@ export default new Command()
1515 . description ( 'Process i18n with Replexica' )
1616 . helpOption ( '-h, --help' , 'Show help' )
1717 . option ( '--cache-only' , 'Only use cached data, and fail if there is new i18n data to process' )
18+ . option ( '--skip-cache' , 'Skip using cached data and process all i18n data' )
1819 . action ( async ( options ) => {
1920 const spinner = Ora ( ) ;
2021
2122 try {
23+ if ( options . cacheOnly && options . skipCache ) {
24+ throw new Error ( `Cannot use both --cache-only and --skip-cache options at the same time.` ) ;
25+ }
26+
2227 const authStatus = await checkAuth ( ) ;
2328 if ( ! authStatus ) {
24- return process . exit ( 1 ) ;
29+ throw new Error ( `You are not authenticated. Please run 'replexica auth' to authenticate.` ) ;
2530 }
2631
2732 spinner . start ( 'Loading Replexica build data...' ) ;
2833 const buildData = await loadBuildData ( ) ;
2934 if ( ! buildData ) {
30- spinner . fail ( `Couldn't load Replexica build data. Did you forget to build your app?` ) ;
31- return process . exit ( 1 ) ;
35+ throw new Error ( `Couldn't load Replexica build data. Did you forget to build your app?` ) ;
3236 }
3337
3438 const localeSource = buildData . settings ?. locale ?. source ;
3539 if ( ! localeSource ) {
36- spinner . fail ( `No source locale found in Replexica build data. Please check your Replexica configuration and try again.` ) ;
37- return process . exit ( 1 ) ;
40+ throw new Error ( `No source locale found in Replexica build data. Please check your Replexica configuration and try again.` ) ;
3841 }
3942
4043 const localeTargets = buildData . settings ?. locale ?. targets || [ ] ;
4144 if ( ! localeTargets . length ) {
42- spinner . fail ( `No target locales found in Replexica build data. Please check your Replexica configuration and try again.` ) ;
43- return process . exit ( 1 ) ;
45+ throw new Error ( `No target locales found in Replexica build data. Please check your Replexica configuration and try again.` ) ;
4446 }
4547
4648 const localeSourceData = await loadLocaleData ( localeSource ) ;
4749 if ( ! localeSourceData ) {
48- spinner . fail ( `Couldn't load source locale data for source locale ${ localeSource } . Did you forget to build your app?` ) ;
49- return process . exit ( 1 ) ;
50+ throw new Error ( `Couldn't load source locale data for source locale ${ localeSource } . Did you forget to build your app?` ) ;
5051 }
5152
5253 spinner . succeed ( 'Replexica data loaded!' ) ;
@@ -63,7 +64,7 @@ export default new Command()
6364
6465 const partialLocaleData = { [ localeFileId ] : localeFileData } ;
6566 const result = await processI18n (
66- { workflowId, cacheOnly : ! ! options . cacheOnly } ,
67+ { workflowId, cacheOnly : ! ! options . cacheOnly , skipCache : ! ! options . skipCache } ,
6768 { source : localeSource , target : targetLocale } ,
6869 buildData . meta ,
6970 partialLocaleData ,
@@ -79,13 +80,13 @@ export default new Command()
7980
8081 spinner . succeed ( 'Replexica processing complete!' ) ;
8182 } catch ( error : any ) {
82- spinner . fail ( `Failed to process i18n: ${ error . message } ` ) ;
83+ spinner . fail ( error . message ) ;
8384 return process . exit ( 1 ) ;
8485 }
8586 } ) ;
8687
8788async function processI18n (
88- params : { workflowId : string , cacheOnly : boolean } ,
89+ params : { workflowId : string , cacheOnly : boolean , skipCache : boolean } ,
8990 locale : { source : string , target : string } ,
9091 meta : any ,
9192 data : any ,
0 commit comments