From 251d8df3364ba928bf514086c363dfa6b8e7a739 Mon Sep 17 00:00:00 2001 From: gboutte Date: Thu, 26 Jun 2025 13:49:39 +0200 Subject: [PATCH] feat: avoid compilation is project already compiled --- server/cli.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/cli.js b/server/cli.js index 18f8102..7e900cd 100644 --- a/server/cli.js +++ b/server/cli.js @@ -8,6 +8,7 @@ import inquirer from 'inquirer'; import isEmpty from 'lodash/isEmpty'; import { createStrapi, compileStrapi } from '@strapi/strapi'; import gitDiff from 'git-diff'; +import tsUtils from '@strapi/typescript-utils'; import warnings from './warnings'; import packageJSON from '../package.json'; @@ -17,7 +18,17 @@ const program = new Command(); const getStrapiApp = async () => { process.env.CONFIG_SYNC_CLI = 'true'; - const appContext = await compileStrapi(); + const appDir = process.cwd(); + const isTSProject = await tsUtils.isUsingTypeScript(appDir); + const outDir = await tsUtils.resolveOutDir(appDir); + const alreadyCompiled = await fs.existsSync(outDir); + + let appContext; + if (!isTSProject || !alreadyCompiled) { + appContext = await compileStrapi(); + } else { + appContext = { appDir, outDir }; + } const app = await createStrapi(appContext).load(); return app; };