@@ -6,7 +6,7 @@ const Table = require('cli-table');
66const chalk = require ( 'chalk' ) ;
77const inquirer = require ( 'inquirer' ) ;
88const { isEmpty } = require ( 'lodash' ) ;
9- const { createStrapi } = require ( '@strapi/strapi' ) ;
9+ const { createStrapi, compileStrapi } = require ( '@strapi/strapi' ) ;
1010const gitDiff = require ( 'git-diff' ) ;
1111
1212const warnings = require ( './warnings' ) ;
@@ -17,31 +17,9 @@ const program = new Command();
1717const getStrapiApp = async ( ) => {
1818 process . env . CONFIG_SYNC_CLI = 'true' ;
1919
20- try {
21- const tsUtils = require ( '@strapi/typescript-utils' ) ; // eslint-disable-line
22-
23- const appDir = process . cwd ( ) ;
24- const isTSProject = await tsUtils . isUsingTypeScript ( appDir ) ;
25- const outDir = await tsUtils . resolveOutDir ( appDir ) ;
26- const alreadyCompiled = await fs . existsSync ( outDir ) ;
27-
28- if ( isTSProject && ! alreadyCompiled ) {
29- await tsUtils . compile ( appDir , {
30- watch : false ,
31- configOptions : { options : { incremental : true } } ,
32- } ) ;
33- }
34-
35- const distDir = isTSProject ? outDir : appDir ;
36-
37- const app = await createStrapi ( { appDir, distDir } ) . load ( ) ;
38-
39- return app ;
40- } catch ( e ) {
41- // Fallback for pre Strapi 4.2.
42- const app = await createStrapi ( ) . load ( ) ;
43- return app ;
44- }
20+ const appContext = await compileStrapi ( ) ;
21+ const app = await createStrapi ( appContext ) . load ( ) ;
22+ return app ;
4523} ;
4624
4725const initTable = ( head ) => {
0 commit comments