@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
43 lines (40 loc) • 1.59 kB
JavaScript
import { createCommand } from 'commander';
import fs from 'fs';
import path from 'path';
import { createStrapi } from '@strapi/core';
import { runAction } from '../utils/helpers.mjs';
import { tryQuickOutDir } from '../utils/try-quick-outdir.mjs';
const action = async ()=>{
const appDir = process.cwd();
const tsconfigPath = path.join(appDir, 'tsconfig.json');
let distDir;
if (!fs.existsSync(tsconfigPath)) {
distDir = appDir;
} else {
const quickOutDir = tryQuickOutDir(appDir, tsconfigPath);
if (quickOutDir && fs.existsSync(path.join(quickOutDir, 'src', 'index.js'))) {
// Built output at configured outDir — skip loading `@strapi/typescript-utils`
distDir = quickOutDir;
} else {
// Custom/extended tsconfig or unbuilt project — fall back to the slow correct path
// eslint-disable-next-line @typescript-eslint/no-var-requires
const tsUtils = require('@strapi/typescript-utils');
const outDir = await tsUtils.resolveOutDir(appDir);
if (!fs.existsSync(outDir)) {
throw new Error(`${outDir} directory not found. Please run the build command before starting your application`);
}
distDir = outDir;
}
}
createStrapi({
appDir,
distDir
}).start();
};
/**
* `$ strapi start`
*/ const command = ()=>{
return createCommand('start').description('Start your Strapi application').action(runAction('start', action));
};
export { command };
//# sourceMappingURL=start.mjs.map