{"version":3,"file":"index-uXEcUT9H.mjs","sources":["../../_internal/cli/index.ts","../../_internal/node/core/managers.ts","../../_internal/node/core/dependencies.ts","../../_internal/node/core/timer.ts","../../admin/src/components/NoJavascript.tsx","../../admin/src/components/DefaultDocument.tsx","../../_internal/node/staticFiles.ts","../../_internal/node/core/files.ts","../../_internal/node/core/env.ts","../../_internal/node/core/errors.ts","../../_internal/node/core/plugins.ts","../../_internal/node/core/admin-customisations.ts","../../_internal/node/createBuildContext.ts","../../_internal/node/build.ts","../../_internal/node/develop.ts"],"sourcesContent":["import type { StrapiCommand } from '@strapi/strapi';\nimport type { BuildCLIOptions } from './commands/build';\nimport type { DevelopCLIOptions } from './commands/develop';\n\n/**\n * `$ strapi build`\n */\nconst build: StrapiCommand = ({ command, ctx }) => {\n  command\n    .command('build')\n    .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'webpack')\n    .option('--ignore-prompts', 'Ignore all prompts', false)\n    .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n    .option('--ignore-prompts', 'Ignore all prompts', false)\n    .option('--minify', 'Minify the output', true)\n    .option('--no-optimization', '[deprecated]: use minify instead')\n    .option('--silent', \"Don't log anything\", false)\n    .option('--sourcemap', 'Produce sourcemaps', false)\n    .option('--stats', 'Print build statistics to the console', false)\n    .description('Build the strapi admin app')\n    .action(async (options: BuildCLIOptions) => {\n      const { build } = await import('./commands/build');\n\n      return build({ ...options, ...ctx });\n    });\n};\n\n/**\n * `$ strapi develop`\n */\nconst develop: StrapiCommand = ({ command, ctx }) => {\n  command\n    .command('develop')\n    .alias('dev')\n    .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'webpack')\n    .option('--ignore-prompts', 'Ignore all prompts', false)\n    .option('--watch-admin', 'Watch the admin panel for hot changes', false)\n    .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n    .option('--silent', \"Don't log anything\", false)\n    .option('--ignore-prompts', 'Ignore all prompts', false)\n    .option('--polling', 'Watch for file changes in network directories', false)\n    .option('--watch-admin', 'Watch the admin panel for hot changes', false)\n    .option(\n      '--no-build',\n      '[deprecated]: there is middleware for the server, it is no longer a separate process'\n    )\n    .option(\n      '--watch-admin',\n      '[deprecated]: there is now middleware for watching, it is no longer a separate process'\n    )\n    .option('--browser <name>', '[deprecated]: use open instead')\n    .option('--open', 'Open the admin in your browser', true)\n    .description('Start your Strapi application in development mode')\n    .action(async (options: DevelopCLIOptions) => {\n      const { develop } = await import('./commands/develop');\n\n      return develop({ ...options, ...ctx });\n    });\n};\n\nexport { build, develop };\n","/**\n * @description Supports the following managers:\n * – npm\n * – yarn\n * – pnpm\n */\nconst getPackageManager = () => {\n  // Yes, the env var is lowercase - it is set by the package managers themselves\n  const agent = process.env.npm_config_user_agent || '';\n\n  if (agent.includes('yarn')) {\n    return 'yarn';\n  }\n\n  if (agent.includes('pnpm')) {\n    return 'pnpm';\n  }\n\n  // Both yarn and pnpm does a `npm/?` thing, thus the slightly different match here\n  // Theoretically not needed since we check for yarn/pnpm above, but in case other\n  // package managers do the same thing, we'll (hopefully) catch them here.\n  if (/^npm\\/\\d/.test(agent)) {\n    return 'npm';\n  }\n\n  return undefined;\n};\n\nexport { getPackageManager };\n","import os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport inquirer from 'inquirer';\nimport semver, { SemVer } from 'semver';\nimport resolveFrom from 'resolve-from';\nimport execa, { CommonOptions, ExecaReturnValue } from 'execa';\nimport readPkgUp, { PackageJson } from 'read-pkg-up';\nimport type { BuildOptions } from '../build';\nimport { getPackageManager } from './managers';\n\n/**\n * From V5 this will be imported from the package.json of `@strapi/strapi`.\n */\nconst PEER_DEPS = {\n  react: '^18.0.0',\n  'react-dom': '^18.0.0',\n  'react-router-dom': '^5.2.0',\n  'styled-components': '^5.2.1',\n};\n\ninterface CheckRequiredDependenciesResult {\n  didInstall: boolean;\n}\n\ninterface DepToInstall {\n  name: string;\n  wantedVersion: string;\n  declaredVersion?: never;\n}\n\n/**\n * Checks the user's project that it has declared and installed the required dependencies\n * needed by the Strapi admin project. Whilst generally speaking most modules will be\n * declared by the actual packages there are some packages where you only really want one of\n * and thus they are declared as peer dependencies – react / styled-components / etc.\n *\n * If these deps are not installed or declared, then we prompt the user to correct this. In\n * V4 this is not a hard requirement, but in V5 it will be. Might as well get people started now.\n */\nconst checkRequiredDependencies = async ({\n  cwd,\n  logger,\n  ignorePrompts,\n}: Pick<\n  BuildOptions,\n  'cwd' | 'logger' | 'ignorePrompts'\n>): Promise<CheckRequiredDependenciesResult> => {\n  const pkg = await readPkgUp({ cwd });\n\n  if (!pkg) {\n    throw new Error(`Could not find package.json at path: ${cwd}`);\n  }\n\n  logger.debug('Loaded package.json:', os.EOL, pkg.packageJson);\n\n  interface DepToReview {\n    name: string;\n    wantedVersion: string;\n    declaredVersion: string;\n  }\n\n  /**\n   * Run through each of the peer deps and figure out if they need to be\n   * installed or they need their version checked against.\n   */\n  const { install, review } = Object.entries(PEER_DEPS).reduce<{\n    install: DepToInstall[];\n    review: DepToReview[];\n  }>(\n    (acc, [name, version]) => {\n      if (!pkg.packageJson.dependencies) {\n        throw new Error(`Could not find dependencies in package.json at path: ${cwd}`);\n      }\n\n      const declaredVersion = pkg.packageJson.dependencies[name];\n\n      if (!declaredVersion) {\n        acc.install.push({\n          name,\n          wantedVersion: version,\n        });\n      } else {\n        acc.review.push({\n          name,\n          wantedVersion: version,\n          declaredVersion,\n        });\n      }\n\n      return acc;\n    },\n    {\n      install: [],\n      review: [],\n    }\n  );\n\n  if (install.length > 0) {\n    logger.info(\n      'The Strapi admin needs to install the following dependencies:',\n      os.EOL,\n      install.map(({ name, wantedVersion }) => `  - ${name}@${wantedVersion}`).join(os.EOL)\n    );\n\n    /**\n     * temporary until V5 when we _will_ be enforcing these dependencies as required.\n     */\n    if (process.env.NODE_ENV !== 'development' || ignorePrompts) {\n      return { didInstall: false };\n    }\n\n    /**\n     * This prompt can be removed in V5 & therefore the code underneath can be refactored to\n     * only install the deps and return that we installed deps.\n     */\n    const { install: installAns } = await inquirer.prompt({\n      type: 'confirm',\n      name: 'install',\n      default: true,\n      message:\n        'Would you like to install these dependencies now? These are not required but are recommended, from V5 these will be required.',\n    });\n\n    if (installAns) {\n      await installDependencies(install, {\n        cwd,\n        logger,\n      });\n\n      const [file, ...args] = process.argv;\n\n      /**\n       * Re-run the same command after installation e.g. strapi build because the yarn.lock might\n       * not be the same and could break installations. It's not the best solution, but it works.\n       */\n      await execa(file, args, { cwd, stdio: 'inherit' });\n      return { didInstall: true };\n    } else {\n      return { didInstall: false };\n    }\n  }\n\n  if (review.length) {\n    const errors: string[] = [];\n\n    for (const dep of review) {\n      // The version specified in package.json could be incorrect, eg `foo`\n      let minDeclaredVersion: SemVer | null = null;\n      try {\n        minDeclaredVersion = semver.minVersion(dep.declaredVersion);\n      } catch (err) {\n        // Intentional fall-through (variable will be left as null, throwing below)\n      }\n\n      if (!minDeclaredVersion) {\n        errors.push(\n          `The declared dependency, ${dep.name} has an invalid version in package.json: ${dep.declaredVersion}`\n        );\n      } else if (!semver.satisfies(minDeclaredVersion, dep.wantedVersion)) {\n        /**\n         * The delcared version should be semver compatible with our required version\n         * of the dependency. If it's not, we should advise the user to change it.\n         */\n        logger.warn(\n          [\n            `Declared version of ${dep.name} (${minDeclaredVersion}) is not compatible with the version required by Strapi (${dep.wantedVersion}).`,\n            'You may experience issues, we recommend you change this.',\n          ].join(os.EOL)\n        );\n      }\n\n      const installedVersion = await getModuleVersion(dep.name, cwd);\n\n      if (!installedVersion) {\n        /**\n         * TODO: when we know the packageManager we can advise the actual install command.\n         */\n        errors.push(\n          `The declared dependency, ${dep.name} is not installed. You should install before re-running this command`\n        );\n      } else if (!semver.satisfies(installedVersion, dep.wantedVersion)) {\n        logger.warn(\n          [\n            `Declared version of ${dep.name} (${installedVersion}) is not compatible with the version required by Strapi (${dep.wantedVersion}).`,\n            'You may experience issues, we recommend you change this.',\n          ].join(os.EOL)\n        );\n      }\n    }\n\n    if (errors.length > 0 && process.env.NODE_ENV === 'development') {\n      throw new Error(`${os.EOL}- ${errors.join(`${os.EOL}- `)}`);\n    }\n  }\n\n  return { didInstall: false };\n};\n\nconst getModule = async (name: string, cwd: string): Promise<PackageJson | null> => {\n  const modulePackagePath = resolveFrom.silent(cwd, path.join(name, 'package.json'));\n  if (!modulePackagePath) {\n    return null;\n  }\n  const file = await fs.readFile(modulePackagePath, 'utf8').then((res) => JSON.parse(res));\n\n  return file;\n};\n\nconst getModuleVersion = async (name: string, cwd: string): Promise<string | null> => {\n  const pkg = await getModule(name, cwd);\n\n  return pkg?.version || null;\n};\n\nconst installDependencies = async (\n  install: DepToInstall[],\n  { cwd, logger }: Pick<BuildOptions, 'cwd' | 'logger'>\n) => {\n  const packageManager = getPackageManager();\n\n  if (!packageManager) {\n    logger.error(\n      'Could not find a supported package manager, please install the dependencies manually.'\n    );\n    process.exit(1);\n  }\n\n  const execOptions: CommonOptions<'utf8'> = {\n    encoding: 'utf8',\n    cwd,\n    stdio: 'inherit',\n  };\n\n  const packages = install.map(({ name, wantedVersion }) => `${name}@${wantedVersion}`);\n\n  let result: ExecaReturnValue<string> | undefined;\n\n  if (packageManager === 'npm') {\n    const npmArgs = ['install', '--legacy-peer-deps', '--save', ...packages];\n    logger.info(`Running 'npm ${npmArgs.join(' ')}'`);\n    result = await execa('npm', npmArgs, execOptions);\n  } else if (packageManager === 'yarn') {\n    const yarnArgs = ['add', ...packages];\n    logger.info(`Running 'yarn ${yarnArgs.join(' ')}'`);\n    result = await execa('yarn', yarnArgs, execOptions);\n  } else if (packageManager === 'pnpm') {\n    const pnpmArgs = ['add', '--save-prod', ...packages];\n    logger.info(`Running 'pnpm ${pnpmArgs.join(' ')}'`);\n    result = await execa('pnpm', pnpmArgs, execOptions);\n  }\n\n  if (result?.exitCode || result?.failed) {\n    throw new Error('Package installation failed');\n  }\n};\n\nexport { checkRequiredDependencies, getModule };\nexport type { CheckRequiredDependenciesResult, PackageJson };\n","import { performance } from 'perf_hooks';\n\nexport interface TimeMeasurer {\n  start: (name: string) => void;\n  end: (name: string) => number;\n  getTimings: () => Record<string, number>;\n}\n\nexport function getTimer(): TimeMeasurer {\n  const timings: Record<string, number> = {};\n  const startTimes: Record<string, number> = {};\n\n  function start(name: string): void {\n    if (typeof startTimes[name] !== 'undefined') {\n      throw new Error(`Timer \"${name}\" already started, cannot overwrite`);\n    }\n\n    startTimes[name] = performance.now();\n  }\n\n  function end(name: string): number {\n    if (typeof startTimes[name] === 'undefined') {\n      throw new Error(`Timer \"${name}\" never started, cannot end`);\n    }\n\n    timings[name] = performance.now() - startTimes[name];\n    return timings[name];\n  }\n\n  return { start, end, getTimings: () => timings };\n}\n\nexport const prettyTime = (timeInMs: number): string => {\n  return Math.ceil(timeInMs) + 'ms';\n};\n","const styles = `\n.strapi--root {\n  position: absolute;\n  top: 0;\n  right: 0;\n  left: 0;\n  bottom: 0;\n  background: #fff;\n}\n\n.strapi--no-js {\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  text-align: center;\n  font-family: helvetica, arial, sans-serif;\n}\n`;\n\n/**\n * @internal\n *\n * @description this belongs to our default document that we render.\n */\nconst NoJavascript = () => {\n  return (\n    <noscript>\n      <div className=\"strapi--root\">\n        <div className=\"strapi--no-js\">\n          <style type=\"text/css\">{styles}</style>\n          <h1>JavaScript disabled</h1>\n          <p>\n            Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n            browser and reload the page to proceed.\n          </p>\n        </div>\n      </div>\n    </noscript>\n  );\n};\n\nexport { NoJavascript };\n","import { NoJavascript } from './NoJavascript';\n\n/**\n * TODO: add favicons.........\n */\n\nconst globalStyles = `\n  html,\n  body,\n  #strapi {\n    height: 100%;\n  }\n  body {\n    margin: 0;\n    -webkit-font-smoothing: antialiased;\n  }\n`;\n\ninterface DefaultDocumentProps {\n  entryPath?: string;\n}\n\n/**\n * @internal\n */\nconst DefaultDocument = ({ entryPath }: DefaultDocumentProps) => {\n  return (\n    <html lang=\"en\">\n      <head>\n        <meta charSet=\"utf-8\" />\n        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\" />\n        <meta name=\"robots\" content=\"noindex\" />\n        <meta name=\"referrer\" content=\"same-origin\" />\n\n        <title>Strapi Admin</title>\n        <style>{globalStyles}</style>\n      </head>\n      <body>\n        <div id=\"strapi\" />\n        <NoJavascript />\n        {entryPath ? <script type=\"module\" src={entryPath} /> : null}\n      </body>\n    </html>\n  );\n};\n\nexport { DefaultDocument };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport outdent from 'outdent';\nimport { format } from 'prettier';\nimport { createElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport { DefaultDocument } from '../../admin/src/components/DefaultDocument';\n\nimport type { BuildContext } from './createBuildContext';\n\nconst getEntryModule = (ctx: BuildContext): string => {\n  const pluginsObject = ctx.plugins\n    .map(({ name, importName }) => `'${name}': ${importName}`)\n    .join(',\\n');\n\n  const pluginsImport = ctx.plugins\n    .map(({ importName, modulePath }) => `import ${importName} from '${modulePath}';`)\n    .join('\\n');\n\n  return outdent`\n        /**\n         * This file was automatically generated by Strapi.\n         * Any modifications made will be discarded.\n         */\n        ${pluginsImport}\n        import { renderAdmin } from \"@strapi/strapi/admin\"\n\n        ${\n          ctx.customisations?.modulePath\n            ? `import customisations from '${ctx.customisations.modulePath}'`\n            : ''\n        }\n\n        renderAdmin(\n          document.getElementById(\"strapi\"),\n          {\n            ${ctx.customisations?.modulePath ? 'customisations,' : ''}\n            ${ctx.features ? `features: ${JSON.stringify(ctx.features)},` : ''}\n            plugins: {\n        ${pluginsObject}\n            }\n        })\n      `;\n};\n\ninterface GetDocumentHTMLArgs extends Pick<BuildContext, 'logger'> {\n  props?: {\n    entryPath?: string;\n  };\n}\n\n/**\n * TODO: Here in the future we could add the ability\n * to load a user's Document component?\n */\nconst getDocumentHTML = ({ logger, props = {} }: GetDocumentHTMLArgs) => {\n  const result = renderToStaticMarkup(createElement(DefaultDocument, props));\n  logger.debug('Rendered the HTML');\n\n  return outdent`<!DOCTYPE html>${result}`;\n};\n\nconst AUTO_GENERATED_WARNING = `\nThis file was automatically generated by Strapi.\nAny modifications made will be discarded.\n`.trim();\n\n/**\n * Because we now auto-generate the index.html file,\n * we should be clear that people _should not_ modify it.\n *\n * @internal\n */\nconst decorateHTMLWithAutoGeneratedWarning = (htmlTemplate: string): string =>\n  htmlTemplate.replace(/<head/, `\\n<!--\\n${AUTO_GENERATED_WARNING}\\n-->\\n<head`);\n\nconst writeStaticClientFiles = async (ctx: BuildContext) => {\n  /**\n   * For everything to work effectively we create a client folder in `.strapi` at the cwd level.\n   * We then use the function we need to \"createAdmin\" as well as generate the Document index.html as well.\n   *\n   * All this links together an imaginary \"src/index\" that then allows vite to correctly build the admin panel.\n   */\n\n  await fs.mkdir(ctx.runtimeDir, { recursive: true });\n  ctx.logger.debug('Created the runtime directory');\n\n  const indexHtml = decorateHTMLWithAutoGeneratedWarning(\n    await getDocumentHTML({\n      logger: ctx.logger,\n      props:\n        ctx.bundler === 'vite'\n          ? {\n              entryPath: `/${ctx.entry}`,\n            }\n          : undefined,\n    })\n  );\n\n  await fs.writeFile(\n    path.join(ctx.runtimeDir, 'index.html'),\n    format(indexHtml, {\n      parser: 'html',\n    })\n  );\n  ctx.logger.debug('Wrote the index.html file');\n  await fs.writeFile(\n    path.join(ctx.runtimeDir, 'app.js'),\n    format(getEntryModule(ctx), {\n      parser: 'babel',\n    })\n  );\n  ctx.logger.debug('Wrote the app.js file');\n};\n\nexport { writeStaticClientFiles, getDocumentHTML };\n","import path from 'node:path';\nimport { access } from 'node:fs/promises';\nimport { register } from 'esbuild-register/dist/node';\n\n/**\n * @internal\n */\nconst pathExists = async (path: string) => {\n  try {\n    await access(path);\n    return true;\n  } catch (error) {\n    return false;\n  }\n};\n\n/**\n * @internal\n */\nconst loadFile = async (path: string): Promise<undefined | any> => {\n  if (await pathExists(path)) {\n    const esbuildOptions: Parameters<typeof register>[0] = {\n      extensions: ['.js', '.mjs', '.ts'],\n    };\n\n    const { unregister } = register(esbuildOptions);\n\n    // eslint-disable-next-line @typescript-eslint/no-var-requires\n    const mod = require(path);\n\n    unregister();\n\n    /**\n     * handles esm or cjs exporting.\n     */\n    const file = mod?.default || mod || undefined;\n\n    return file;\n  }\n\n  return undefined;\n};\n\n/**\n * @internal\n *\n * @description Converts a system path to a module path mainly for `Windows` systems.\n * where the path separator is `\\` instead of `/`, on linux systems the path separator\n * is identical to the module path separator.\n */\nconst convertSystemPathToModulePath = (sysPath: string) => {\n  if (process.platform === 'win32') {\n    return sysPath.split(path.sep).join(path.posix.sep);\n  } else {\n    return sysPath;\n  }\n};\n\n/**\n * @internal\n *\n * @description Converts a module path to a system path, again largely used for Windows systems.\n * The original use case was plugins where the resolve path was in module format but we want to\n * have it relative to the runtime directory.\n */\nconst convertModulePathToSystemPath = (modulePath: string) => {\n  if (process.platform === 'win32') {\n    return modulePath.split(path.posix.sep).join(path.sep);\n  } else {\n    return modulePath;\n  }\n};\n\nexport { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };\n","import path from 'node:path';\nimport dotenv from 'dotenv';\nimport { pathExists } from './files';\n\n/**\n * This is the base of _any_ env set for a strapi project,\n * to build a strapi admin panel we require these env variables.\n */\ninterface DefaultEnv {\n  ADMIN_PATH: string;\n  STRAPI_ADMIN_BACKEND_URL: string;\n  STRAPI_TELEMETRY_DISABLED: string;\n}\n\n/**\n * @internal\n *\n * @description Load the .env file if it exists\n */\nconst loadEnv = async (cwd: string) => {\n  const pathToEnv = path.resolve(cwd, '.env');\n\n  if (await pathExists(pathToEnv)) {\n    dotenv.config({ path: pathToEnv });\n  }\n};\n\n/**\n * @internal\n *\n * @description Get all the environment variables that start with `STRAPI_ADMIN_`\n */\nconst getStrapiAdminEnvVars = (defaultEnv: DefaultEnv): Record<string, string> => {\n  return Object.keys(process.env)\n    .filter((key) => key.toUpperCase().startsWith('STRAPI_ADMIN_'))\n    .reduce((acc, key) => {\n      acc[key] = process.env[key] as string;\n\n      return acc;\n    }, defaultEnv as unknown as Record<string, string>);\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n","import boxen from 'boxen';\nimport chalk from 'chalk';\nimport os from 'node:os';\n\nconst isError = (err: unknown): err is Error => err instanceof Error;\n\n/**\n * @description Handle unexpected errors. No, but really, your CLI should anticipate error cases.\n * If a user hits an error we don't expect, then we need to flag to them that this is not normal\n * and they should use the `--debug` flag to get more information (assuming you've implemented this\n * in your action).\n */\nconst handleUnexpectedError = (err: unknown) => {\n  console.error(\n    chalk.red(\n      `[ERROR] `,\n      'There seems to be an unexpected error, try again with --debug for more information',\n      os.EOL\n    )\n  );\n\n  if (isError(err) && err.stack) {\n    // eslint-disable-next-line no-console\n    console.log(\n      chalk.red(\n        boxen(err.stack, {\n          padding: 1,\n          align: 'left',\n        })\n      )\n    );\n  }\n\n  process.exit(1);\n};\n\nexport { handleUnexpectedError, isError };\n","import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport camelCase from 'lodash/camelCase';\nimport { env } from '@strapi/utils';\nimport { getModule, PackageJson } from './dependencies';\nimport { convertModulePathToSystemPath, convertSystemPathToModulePath, loadFile } from './files';\nimport { BuildContext } from '../createBuildContext';\nimport { isError } from './errors';\n\ninterface LocalPluginMeta {\n  name: string;\n  /**\n   * camelCased version of the plugin name\n   */\n  importName: string;\n  /**\n   * The path to the plugin, relative to the app's root directory\n   * in system format\n   */\n  path: string;\n  /**\n   * The path to the plugin, relative to the runtime directory\n   * in module format (i.e. with forward slashes) because thats\n   * where it should be used as an import\n   */\n  modulePath: string;\n  type: 'local';\n}\n\ninterface ModulePluginMeta {\n  name: string;\n  /**\n   * camelCased version of the plugin name\n   */\n  importName: string;\n  /**\n   * Modules don't have a path because we never resolve them to their node_modules\n   * because we simply do not require it.\n   */\n  path?: never;\n  /**\n   * The path to the plugin, relative to the app's root directory\n   * in module format (i.e. with forward slashes)\n   */\n  modulePath: string;\n  type: 'module';\n}\n\ntype PluginMeta = LocalPluginMeta | ModulePluginMeta;\n\ninterface StrapiPlugin extends PackageJson {\n  strapi: {\n    description?: string;\n    displayName?: string;\n    kind: 'plugin';\n    name?: string;\n    required?: boolean;\n  };\n}\n\nconst validatePackageHasStrapi = (\n  pkg: PackageJson\n): pkg is PackageJson & { strapi: Record<string, unknown> } =>\n  'strapi' in pkg &&\n  typeof pkg.strapi === 'object' &&\n  !Array.isArray(pkg.strapi) &&\n  pkg.strapi !== null;\n\nconst validatePackageIsPlugin = (pkg: PackageJson): pkg is StrapiPlugin =>\n  validatePackageHasStrapi(pkg) && pkg.strapi.kind === 'plugin';\n\nconst getEnabledPlugins = async ({\n  cwd,\n  logger,\n  runtimeDir,\n  strapi,\n}: Pick<BuildContext, 'cwd' | 'logger' | 'strapi' | 'runtimeDir'>): Promise<\n  Record<string, PluginMeta>\n> => {\n  const plugins: Record<string, PluginMeta> = {};\n\n  /**\n   * This is the list of dependencies that are installed in the user's project.\n   * It will include libraries like \"react\", so we need to collect the ones that\n   * are plugins.\n   */\n  const deps = strapi.config.get('info.dependencies', {});\n\n  logger.debug(\"Dependencies from user's project\", os.EOL, deps);\n\n  for (const dep of Object.keys(deps)) {\n    const pkg = await getModule(dep, cwd);\n\n    if (pkg && validatePackageIsPlugin(pkg)) {\n      const name = pkg.strapi.name || pkg.name;\n\n      if (!name) {\n        /**\n         * Unlikely to happen, but you never know.\n         */\n        throw Error(\n          \"You're trying to import a plugin that doesn't have a name – check the package.json of that plugin!\"\n        );\n      }\n\n      plugins[name] = {\n        name,\n        importName: camelCase(name),\n        type: 'module',\n        modulePath: dep,\n      };\n    }\n  }\n\n  const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);\n\n  logger.debug(\"User's plugins file\", os.EOL, userPluginsFile);\n\n  for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)) {\n    if (userPluginConfig.enabled && userPluginConfig.resolve) {\n      const sysPath = convertModulePathToSystemPath(userPluginConfig.resolve);\n      plugins[userPluginName] = {\n        name: userPluginName,\n        importName: camelCase(userPluginName),\n        type: 'local',\n        /**\n         * User plugin paths are resolved from the entry point\n         * of the app, because that's how you import them.\n         */\n        modulePath: convertSystemPathToModulePath(path.relative(runtimeDir, sysPath)),\n        path: sysPath,\n      };\n    }\n  }\n\n  return plugins;\n};\n\nconst PLUGIN_CONFIGS = ['plugins.js', 'plugins.mjs', 'plugins.ts'];\n\ntype UserPluginConfigFile = Record<string, { enabled: boolean; resolve: string }>;\n\nconst loadUserPluginsFile = async (root: string): Promise<UserPluginConfigFile> => {\n  for (const file of PLUGIN_CONFIGS) {\n    const filePath = path.join(root, file);\n    const configFile = await loadFile(filePath);\n\n    if (configFile) {\n      /**\n       * Configs can be a function or they can be just an object!\n       */\n      return typeof configFile === 'function' ? configFile({ env }) : configFile;\n    }\n  }\n\n  return {};\n};\n\nconst getMapOfPluginsWithAdmin = (plugins: Record<string, PluginMeta>) =>\n  Object.values(plugins)\n    .filter((plugin) => {\n      if (!plugin) {\n        return false;\n      }\n\n      /**\n       * There are two ways a plugin should be imported, either it's local to the strapi app,\n       * or it's an actual npm module that's installed and resolved via node_modules.\n       *\n       * We first check if the plugin is local to the strapi app, using a regular `fs.existsSync` because\n       * the pathToPlugin will be relative i.e. `/Users/my-name/strapi-app/src/plugins/my-plugin`.\n       *\n       * If the file doesn't exist well then it's probably a node_module, so instead we use `require.resolve`\n       * which will resolve the path to the module in node_modules. If it fails with the specific code `MODULE_NOT_FOUND`\n       * then it doesn't have an admin part to the package.\n       */\n      try {\n        const isLocalPluginWithLegacyAdminFile =\n          plugin.path && fs.existsSync(path.join(plugin.path, 'strapi-admin.js'));\n\n        if (!isLocalPluginWithLegacyAdminFile) {\n          const isModuleWithFE = require.resolve(`${plugin.modulePath}/strapi-admin`);\n\n          return isModuleWithFE;\n        }\n\n        return isLocalPluginWithLegacyAdminFile;\n      } catch (err) {\n        if (\n          isError(err) &&\n          'code' in err &&\n          (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n        ) {\n          /**\n           * the plugin does not contain FE code, so we\n           * don't want to import it anyway\n           */\n          return false;\n        }\n\n        throw err;\n      }\n    })\n    .map((plugin) => ({\n      ...plugin,\n      modulePath: `${plugin.modulePath}/strapi-admin`,\n    }));\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n","import path from 'node:path';\nimport { convertSystemPathToModulePath, pathExists } from '../core/files';\nimport { BuildContext } from '../createBuildContext';\n\nconst ADMIN_APP_FILES = ['app.js', 'app.mjs', 'app.ts', 'app.jsx', 'app.tsx'];\n\ninterface AdminCustomisations {\n  config?: {\n    locales?: string[];\n  };\n  bootstrap?: Function;\n}\n\ninterface AppFile {\n  /**\n   * The system path to the file\n   */\n  path: string;\n  /**\n   * The module path to the file i.e. how you would import it\n   */\n  modulePath: string;\n}\n\nconst loadUserAppFile = async ({\n  runtimeDir,\n  appDir,\n}: Pick<BuildContext, 'appDir' | 'runtimeDir'>): Promise<AppFile | undefined> => {\n  for (const file of ADMIN_APP_FILES) {\n    const filePath = path.join(appDir, 'src', 'admin', file);\n\n    if (await pathExists(filePath)) {\n      return {\n        path: filePath,\n        modulePath: convertSystemPathToModulePath(path.relative(runtimeDir, filePath)),\n      };\n    }\n  }\n\n  return undefined;\n};\n\nexport { loadUserAppFile };\nexport type { AdminCustomisations, AppFile };\n","import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport strapiFactory, { CLIContext } from '@strapi/strapi';\nimport { getConfigUrls } from '@strapi/utils';\n\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport type { BuildOptions } from './build';\nimport { DevelopOptions } from './develop';\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { Strapi, FeaturesService } from '@strapi/types';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\n\ninterface BuildContext {\n  /**\n   * The absolute path to the app directory defined by the Strapi instance\n   */\n  appDir: string;\n  /**\n   * If a user is deploying the project under a nested public path, we use\n   * this path so all asset paths will be rewritten accordingly\n   */\n  basePath: string;\n  /**\n   * The customisations defined by the user in their app.js file\n   */\n  customisations?: AppFile;\n  /**\n   * The bundler to use for building & watching\n   */\n  bundler: Pick<Required<BuildOptions>, 'bundler'>['bundler'];\n  /**\n   * The current working directory\n   */\n  cwd: string;\n  /**\n   * The absolute path to the dist directory\n   */\n  distPath: string;\n  /**\n   * The relative path to the dist directory\n   */\n  distDir: string;\n  /**\n   * The absolute path to the entry file\n   */\n  entry: string;\n  /**\n   * The environment variables to be included in the JS bundle\n   */\n  env: Record<string, string>;\n  /**\n   * Features object with future flags\n   */\n  features?: FeaturesService['config'];\n  logger: CLIContext['logger'];\n  /**\n   * The build options\n   */\n  options: Pick<BuildOptions, 'minify' | 'sourcemaps' | 'stats'> & Pick<DevelopOptions, 'open'>;\n  /**\n   * The plugins to be included in the JS bundle\n   * incl. internal plugins, third party plugins & local plugins\n   */\n  plugins: PluginMeta[];\n  /**\n   * The absolute path to the runtime directory\n   */\n  runtimeDir: string;\n  /**\n   * The Strapi instance\n   */\n  strapi: Strapi;\n  /**\n   * The browserslist target either loaded from the user's workspace or falling back to the default\n   */\n  target: string[];\n  tsconfig?: CLIContext['tsconfig'];\n}\n\ninterface CreateBuildContextArgs extends CLIContext {\n  strapi?: Strapi;\n  options?: BuildContext['options'] & { bundler?: BuildOptions['bundler'] };\n}\n\nconst DEFAULT_BROWSERSLIST = [\n  'last 3 major versions',\n  'Firefox ESR',\n  'last 2 Opera versions',\n  'not dead',\n];\n\nconst createBuildContext = async ({\n  cwd,\n  logger,\n  tsconfig,\n  strapi,\n  options = {},\n}: CreateBuildContextArgs): Promise<BuildContext> => {\n  /**\n   * If you make a new strapi instance when one already exists,\n   * you will overwrite the global and the app will _most likely_\n   * crash and die.\n   */\n  const strapiInstance =\n    strapi ??\n    strapiFactory({\n      // Directories\n      appDir: cwd,\n      distDir: tsconfig?.config.options.outDir ?? '',\n      // Options\n      autoReload: true,\n      serveAdminPanel: false,\n    });\n\n  const { serverUrl, adminPath } = getConfigUrls(strapiInstance.config, true);\n\n  const appDir = strapiInstance.dirs.app.root;\n\n  await loadEnv(cwd);\n\n  const env = getStrapiAdminEnvVars({\n    ADMIN_PATH: adminPath,\n    STRAPI_ADMIN_BACKEND_URL: serverUrl,\n    STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n  });\n\n  const envKeys = Object.keys(env);\n\n  if (envKeys.length > 0) {\n    logger.info(\n      [\n        'Including the following ENV variables as part of the JS bundle:',\n        ...envKeys.map((key) => `    - ${key}`),\n      ].join(os.EOL)\n    );\n  }\n\n  const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n  const distDir = path.relative(cwd, distPath);\n\n  /**\n   * If the distPath already exists, clean it\n   */\n  try {\n    logger.debug(`Cleaning dist folder: ${distPath}`);\n    await fs.rm(distPath, { recursive: true, force: true });\n    logger.debug('Cleaned dist folder');\n  } catch {\n    // do nothing, it will fail if the folder does not exist\n    logger.debug('There was no dist folder to clean');\n  }\n\n  const runtimeDir = path.join(cwd, '.strapi', 'client');\n  const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n  const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n  logger.debug('Enabled plugins', os.EOL, plugins);\n\n  const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n  logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n  const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n  const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n  const features = strapiInstance.config.get('features', undefined);\n\n  const serveAdminPanel = strapiInstance.config.get('admin.serveAdminPanel', true);\n\n  const { bundler = 'webpack', ...restOptions } = options;\n\n  const buildContext = {\n    appDir,\n    // If serveAdminPanel is false, use relative paths for separate deployment\n    basePath: serveAdminPanel\n      ? `${adminPath}/`\n      : strapiInstance.config.get('admin.url', `${adminPath}/`),\n    bundler,\n    customisations,\n    cwd,\n    distDir,\n    distPath,\n    entry,\n    env,\n    logger,\n    options: restOptions,\n    plugins: pluginsWithFront,\n    runtimeDir,\n    strapi: strapiInstance,\n    target,\n    tsconfig,\n    features,\n  } satisfies BuildContext;\n\n  return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n","import type { CLIContext } from '@strapi/strapi';\nimport EE from '@strapi/strapi/dist/utils/ee';\nimport * as tsUtils from '@strapi/typescript-utils';\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime } from './core/timer';\nimport { writeStaticClientFiles } from './staticFiles';\nimport { createBuildContext } from './createBuildContext';\n\ninterface BuildOptions extends CLIContext {\n  /**\n   * @default false\n   */\n  ignorePrompts?: boolean;\n  /**\n   * Which bundler to use for building.\n   *\n   * @default webpack\n   */\n  bundler?: 'webpack' | 'vite';\n  /**\n   * Minify the output\n   *\n   * @default true\n   */\n  minify?: boolean;\n  /**\n   * Generate sourcemaps – useful for debugging bugs in the admin panel UI.\n   */\n  sourcemaps?: boolean;\n  /**\n   * Print stats for build\n   */\n  stats?: boolean;\n}\n\n/**\n * @example `$ strapi build`\n *\n * @description Builds the admin panel of the strapi application.\n */\nconst build = async ({ logger, cwd, tsconfig, ignorePrompts, ...options }: BuildOptions) => {\n  const timer = getTimer();\n\n  const { didInstall } = await checkRequiredDependencies({ cwd, logger, ignorePrompts }).catch(\n    (err) => {\n      logger.error(err.message);\n      process.exit(1);\n    }\n  );\n\n  if (didInstall) {\n    return;\n  }\n\n  if (tsconfig?.config) {\n    timer.start('compilingTS');\n    const compilingTsSpinner = logger.spinner(`Compiling TS`).start();\n\n    tsUtils.compile(cwd, { configOptions: { ignoreDiagnostics: false } });\n\n    const compilingDuration = timer.end('compilingTS');\n    compilingTsSpinner.text = `Compiling TS (${prettyTime(compilingDuration)})`;\n    compilingTsSpinner.succeed();\n  }\n\n  timer.start('createBuildContext');\n  const contextSpinner = logger.spinner(`Building build context`).start();\n  console.log('');\n\n  const ctx = await createBuildContext({\n    cwd,\n    logger,\n    tsconfig,\n    options,\n  });\n  const contextDuration = timer.end('createBuildContext');\n  contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n  contextSpinner.succeed();\n\n  timer.start('buildAdmin');\n  const buildingSpinner = logger.spinner(`Building admin panel`).start();\n  console.log('');\n\n  try {\n    EE.init(cwd);\n\n    await writeStaticClientFiles(ctx);\n\n    if (ctx.bundler === 'webpack') {\n      const { build: buildWebpack } = await import('./webpack/build');\n      await buildWebpack(ctx);\n    } else if (ctx.bundler === 'vite') {\n      const { build: buildVite } = await import('./vite/build');\n      await buildVite(ctx);\n    }\n\n    const buildDuration = timer.end('buildAdmin');\n    buildingSpinner.text = `Building admin panel (${prettyTime(buildDuration)})`;\n    buildingSpinner.succeed();\n  } catch (err) {\n    buildingSpinner.fail();\n    throw err;\n  }\n};\n\nexport { build };\nexport type { BuildOptions };\n","import type { CLIContext } from '@strapi/strapi';\nimport * as tsUtils from '@strapi/typescript-utils';\nimport { joinBy } from '@strapi/utils';\nimport chokidar from 'chokidar';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport cluster from 'node:cluster';\nimport strapiFactory from '@strapi/strapi';\n\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport { createBuildContext } from './createBuildContext';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\n\nimport EE from '@strapi/strapi/dist/utils/ee';\nimport { writeStaticClientFiles } from './staticFiles';\n\ninterface DevelopOptions extends CLIContext {\n  /**\n   * @default false\n   */\n  ignorePrompts?: boolean;\n  /**\n   * Which bundler to use for building.\n   *\n   * @default webpack\n   */\n  bundler?: 'webpack' | 'vite';\n  polling?: boolean;\n  open?: boolean;\n  watchAdmin?: boolean;\n}\n\n// This method removes all non-admin build files from the dist directory\nconst cleanupDistDirectory = async ({\n  tsconfig,\n  logger,\n  timer,\n}: Pick<DevelopOptions, 'tsconfig' | 'logger'> & { timer: TimeMeasurer }) => {\n  const distDir = tsconfig?.config?.options?.outDir;\n\n  if (\n    !distDir || // we don't have a dist dir\n    (await fs\n      .access(distDir)\n      .then(() => false)\n      .catch(() => true)) // it doesn't exist -- if it does but no access, that will be caught later\n  ) {\n    return;\n  }\n\n  const timerName = 'cleaningDist' + Date.now();\n  timer.start(timerName);\n  const cleaningSpinner = logger.spinner(`Cleaning dist dir ${distDir}`).start();\n\n  try {\n    const dirContent = await fs.readdir(distDir);\n    const validFilenames = dirContent\n      // Ignore the admin build folder\n      .filter((filename) => filename !== 'build');\n    for (const filename of validFilenames) {\n      await fs.rm(path.resolve(distDir, filename), { recursive: true });\n    }\n  } catch (err: unknown) {\n    const generatingDuration = timer.end(timerName);\n    cleaningSpinner.text = `Error cleaning dist dir: ${err} (${prettyTime(generatingDuration)})`;\n    cleaningSpinner?.fail();\n    return;\n  }\n\n  const generatingDuration = timer.end(timerName);\n  cleaningSpinner.text = `Cleaning dist dir (${prettyTime(generatingDuration)})`;\n  cleaningSpinner?.succeed();\n};\n\nconst develop = async ({\n  cwd,\n  polling,\n  logger,\n  tsconfig,\n  ignorePrompts,\n  watchAdmin,\n  ...options\n}: DevelopOptions) => {\n  const timer = getTimer();\n\n  if (cluster.isPrimary) {\n    const { didInstall } = await checkRequiredDependencies({ cwd, logger, ignorePrompts }).catch(\n      (err) => {\n        logger.error(err.message);\n        process.exit(1);\n      }\n    );\n\n    if (didInstall) {\n      return;\n    }\n\n    if (tsconfig?.config) {\n      // Build without diagnostics in case schemas have changed\n      await cleanupDistDirectory({ tsconfig, logger, timer });\n      await tsUtils.compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n    }\n\n    /**\n     * IF we're not watching the admin we're going to build it, this makes\n     * sure that at least the admin is built for users & they can interact\n     * with the application.\n     */\n    if (!watchAdmin) {\n      timer.start('createBuildContext');\n      const contextSpinner = logger.spinner(`Building build context`).start();\n      console.log('');\n\n      const ctx = await createBuildContext({\n        cwd,\n        logger,\n        tsconfig,\n        options,\n      });\n      const contextDuration = timer.end('createBuildContext');\n      contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n      contextSpinner.succeed();\n\n      timer.start('creatingAdmin');\n      const adminSpinner = logger.spinner(`Creating admin`).start();\n\n      EE.init(cwd);\n      await writeStaticClientFiles(ctx);\n\n      if (ctx.bundler === 'webpack') {\n        const { build: buildWebpack } = await import('./webpack/build');\n        await buildWebpack(ctx);\n      } else if (ctx.bundler === 'vite') {\n        const { build: buildVite } = await import('./vite/build');\n        await buildVite(ctx);\n      }\n\n      const adminDuration = timer.end('creatingAdmin');\n      adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n      adminSpinner.succeed();\n    }\n\n    cluster.on('message', async (worker, message) => {\n      switch (message) {\n        case 'reload': {\n          if (tsconfig?.config) {\n            // Build without diagnostics in case schemas have changed\n            await cleanupDistDirectory({ tsconfig, logger, timer });\n            await tsUtils.compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n          }\n          logger.debug('cluster has the reload message, sending the worker kill message');\n          worker.send('kill');\n          break;\n        }\n        case 'killed': {\n          logger.debug('cluster has the killed message, forking the cluster');\n          cluster.fork();\n          break;\n        }\n        case 'stop': {\n          process.exit(1);\n          break;\n        }\n        default:\n          break;\n      }\n    });\n\n    cluster.fork();\n  }\n\n  if (cluster.isWorker) {\n    timer.start('loadStrapi');\n    const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start();\n\n    const strapi = strapiFactory({\n      appDir: cwd,\n      distDir: tsconfig?.config.options.outDir ?? '',\n      autoReload: true,\n      serveAdminPanel: !watchAdmin,\n    });\n\n    /**\n     * If we're watching the admin panel then we're going to attach the watcher\n     * as a strapi middleware.\n     */\n    let bundleWatcher: WebpackWatcher | ViteWatcher | undefined;\n\n    if (watchAdmin) {\n      timer.start('createBuildContext');\n      const contextSpinner = logger.spinner(`Building build context`).start();\n      console.log('');\n\n      const ctx = await createBuildContext({\n        cwd,\n        logger,\n        strapi,\n        tsconfig,\n        options,\n      });\n      const contextDuration = timer.end('createBuildContext');\n      contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n      contextSpinner.succeed();\n\n      timer.start('creatingAdmin');\n      const adminSpinner = logger.spinner(`Creating admin`).start();\n\n      EE.init(cwd);\n      await writeStaticClientFiles(ctx);\n\n      if (ctx.bundler === 'webpack') {\n        const { watch: watchWebpack } = await import('./webpack/watch');\n        bundleWatcher = await watchWebpack(ctx);\n      } else if (ctx.bundler === 'vite') {\n        const { watch: watchVite } = await import('./vite/watch');\n        bundleWatcher = await watchVite(ctx);\n      }\n\n      const adminDuration = timer.end('creatingAdmin');\n      adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n      adminSpinner.succeed();\n    }\n\n    const strapiInstance = await strapi.load();\n\n    const loadStrapiDuration = timer.end('loadStrapi');\n    loadStrapiSpinner.text = `Loading Strapi (${prettyTime(loadStrapiDuration)})`;\n    loadStrapiSpinner.succeed();\n\n    // For TS projects, type generation is a requirement for the develop command so that the server can restart\n    // For JS projects, we respect the experimental autogenerate setting\n    if (tsconfig?.config || strapi.config.get('typescript.autogenerate') !== false) {\n      timer.start('generatingTS');\n      const generatingTsSpinner = logger.spinner(`Generating types`).start();\n\n      await tsUtils.generators.generate({\n        strapi: strapiInstance,\n        pwd: cwd,\n        rootDir: undefined,\n        logger: { silent: true, debug: false },\n        artifacts: { contentTypes: true, components: true },\n      });\n\n      const generatingDuration = timer.end('generatingTS');\n      generatingTsSpinner.text = `Generating types (${prettyTime(generatingDuration)})`;\n      generatingTsSpinner.succeed();\n    }\n\n    if (tsconfig?.config) {\n      timer.start('compilingTS');\n      const compilingTsSpinner = logger.spinner(`Compiling TS`).start();\n\n      await cleanupDistDirectory({ tsconfig, logger, timer });\n      await tsUtils.compile(cwd, { configOptions: { ignoreDiagnostics: false } });\n\n      const compilingDuration = timer.end('compilingTS');\n      compilingTsSpinner.text = `Compiling TS (${prettyTime(compilingDuration)})`;\n      compilingTsSpinner.succeed();\n    }\n\n    const restart = async () => {\n      if (strapiInstance.reload.isWatching && !strapiInstance.reload.isReloading) {\n        strapiInstance.reload.isReloading = true;\n        strapiInstance.reload();\n      }\n    };\n\n    const watcher = chokidar\n      .watch(cwd, {\n        ignoreInitial: true,\n        usePolling: polling,\n        ignored: [\n          /(^|[/\\\\])\\../, // dot files\n          /tmp/,\n          '**/src/admin/**',\n          '**/src/plugins/**/admin/**',\n          '**/dist/src/plugins/test/admin/**',\n          '**/documentation',\n          '**/documentation/**',\n          '**/node_modules',\n          '**/node_modules/**',\n          '**/plugins.json',\n          '**/build',\n          '**/build/**',\n          '**/index.html',\n          '**/public',\n          '**/public/**',\n          strapiInstance.dirs.static.public,\n          joinBy('/', strapiInstance.dirs.static.public, '**'),\n          '**/*.db*',\n          '**/exports/**',\n          '**/dist/**',\n          '**/*.d.ts',\n          '**/.yalc/**',\n          '**/yalc.lock',\n          ...strapiInstance.config.get('admin.watchIgnoreFiles', []),\n        ],\n      })\n      .on('add', (path) => {\n        strapiInstance.log.info(`File created: ${path}`);\n        restart();\n      })\n      .on('change', (path) => {\n        strapiInstance.log.info(`File changed: ${path}`);\n        restart();\n      })\n      .on('unlink', (path) => {\n        strapiInstance.log.info(`File deleted: ${path}`);\n        restart();\n      });\n\n    process.on('message', async (message) => {\n      switch (message) {\n        case 'kill': {\n          logger.debug(\n            'child process has the kill message, destroying the strapi instance and sending the killed process message'\n          );\n          await watcher.close();\n\n          await strapiInstance.destroy();\n\n          if (bundleWatcher) {\n            bundleWatcher.close();\n          }\n          process.send?.('killed');\n          break;\n        }\n        default:\n          break;\n      }\n    });\n\n    strapiInstance.start();\n  }\n};\n\nexport { develop };\nexport type { DevelopOptions };\n"],"names":["build","develop","path","fs","env","generatingDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,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