@strapi/strapi 5.4.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-test.js +4 -5
- package/dist/admin-test.js.map +1 -1
- package/dist/admin.js +4 -5
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs.map +1 -1
- package/dist/cli/commands/admin/create-user.js.map +1 -1
- package/dist/cli/commands/admin/create-user.mjs.map +1 -1
- package/dist/cli/commands/admin/reset-user-password.js.map +1 -1
- package/dist/cli/commands/admin/reset-user-password.mjs.map +1 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/build.mjs.map +1 -1
- package/dist/cli/commands/components/list.js.map +1 -1
- package/dist/cli/commands/components/list.mjs.map +1 -1
- package/dist/cli/commands/configuration/dump.js.map +1 -1
- package/dist/cli/commands/configuration/dump.mjs.map +1 -1
- package/dist/cli/commands/configuration/restore.js +1 -2
- package/dist/cli/commands/configuration/restore.js.map +1 -1
- package/dist/cli/commands/configuration/restore.mjs +1 -2
- package/dist/cli/commands/configuration/restore.mjs.map +1 -1
- package/dist/cli/commands/console.js.map +1 -1
- package/dist/cli/commands/console.mjs.map +1 -1
- package/dist/cli/commands/content-types/list.js.map +1 -1
- package/dist/cli/commands/content-types/list.mjs.map +1 -1
- package/dist/cli/commands/controllers/list.js.map +1 -1
- package/dist/cli/commands/controllers/list.mjs.map +1 -1
- package/dist/cli/commands/develop.js.map +1 -1
- package/dist/cli/commands/develop.mjs.map +1 -1
- package/dist/cli/commands/export/action.js.map +1 -1
- package/dist/cli/commands/export/action.mjs.map +1 -1
- package/dist/cli/commands/export/command.js.map +1 -1
- package/dist/cli/commands/export/command.mjs.map +1 -1
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/hooks/list.js.map +1 -1
- package/dist/cli/commands/hooks/list.mjs.map +1 -1
- package/dist/cli/commands/import/action.js.map +1 -1
- package/dist/cli/commands/import/action.mjs.map +1 -1
- package/dist/cli/commands/import/command.js.map +1 -1
- package/dist/cli/commands/import/command.mjs.map +1 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/middlewares/list.js.map +1 -1
- package/dist/cli/commands/middlewares/list.mjs.map +1 -1
- package/dist/cli/commands/policies/list.js.map +1 -1
- package/dist/cli/commands/policies/list.mjs.map +1 -1
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/report.mjs.map +1 -1
- package/dist/cli/commands/routes/list.js.map +1 -1
- package/dist/cli/commands/routes/list.mjs.map +1 -1
- package/dist/cli/commands/services/list.js.map +1 -1
- package/dist/cli/commands/services/list.mjs.map +1 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/start.mjs.map +1 -1
- package/dist/cli/commands/telemetry/disable.js.map +1 -1
- package/dist/cli/commands/telemetry/disable.mjs.map +1 -1
- package/dist/cli/commands/telemetry/enable.js.map +1 -1
- package/dist/cli/commands/telemetry/enable.mjs.map +1 -1
- package/dist/cli/commands/transfer/action.js.map +1 -1
- package/dist/cli/commands/transfer/action.mjs.map +1 -1
- package/dist/cli/commands/transfer/command.js.map +1 -1
- package/dist/cli/commands/transfer/command.mjs.map +1 -1
- package/dist/cli/commands/ts/generate-types.js.map +1 -1
- package/dist/cli/commands/ts/generate-types.mjs.map +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/utils/commander.js +1 -2
- package/dist/cli/utils/commander.js.map +1 -1
- package/dist/cli/utils/commander.mjs +1 -2
- package/dist/cli/utils/commander.mjs.map +1 -1
- package/dist/cli/utils/data-transfer.js +2 -2
- package/dist/cli/utils/data-transfer.js.map +1 -1
- package/dist/cli/utils/data-transfer.mjs +2 -2
- package/dist/cli/utils/data-transfer.mjs.map +1 -1
- package/dist/cli/utils/helpers.js.map +1 -1
- package/dist/cli/utils/helpers.mjs.map +1 -1
- package/dist/cli/utils/logger.js +1 -2
- package/dist/cli/utils/logger.js.map +1 -1
- package/dist/cli/utils/logger.mjs.map +1 -1
- package/dist/cli/utils/telemetry.js.map +1 -1
- package/dist/cli/utils/telemetry.mjs.map +1 -1
- package/dist/cli/utils/tsconfig.js.map +1 -1
- package/dist/cli/utils/tsconfig.mjs.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/node/build.js +1 -2
- package/dist/node/build.js.map +1 -1
- package/dist/node/build.mjs.map +1 -1
- package/dist/node/core/admin-customisations.js.map +1 -1
- package/dist/node/core/admin-customisations.mjs.map +1 -1
- package/dist/node/core/aliases.js.map +1 -1
- package/dist/node/core/aliases.mjs.map +1 -1
- package/dist/node/core/config.js.map +1 -1
- package/dist/node/core/config.mjs.map +1 -1
- package/dist/node/core/dependencies.js.map +1 -1
- package/dist/node/core/dependencies.mjs.map +1 -1
- package/dist/node/core/env.js.map +1 -1
- package/dist/node/core/env.mjs.map +1 -1
- package/dist/node/core/errors.js.map +1 -1
- package/dist/node/core/errors.mjs.map +1 -1
- package/dist/node/core/files.js.map +1 -1
- package/dist/node/core/files.mjs.map +1 -1
- package/dist/node/core/managers.js.map +1 -1
- package/dist/node/core/managers.mjs.map +1 -1
- package/dist/node/core/monorepo.js.map +1 -1
- package/dist/node/core/monorepo.mjs.map +1 -1
- package/dist/node/core/plugins.js.map +1 -1
- package/dist/node/core/plugins.mjs.map +1 -1
- package/dist/node/core/timer.js.map +1 -1
- package/dist/node/core/timer.mjs.map +1 -1
- package/dist/node/create-build-context.js.map +1 -1
- package/dist/node/create-build-context.mjs.map +1 -1
- package/dist/node/develop.js +1 -2
- package/dist/node/develop.js.map +1 -1
- package/dist/node/develop.mjs.map +1 -1
- package/dist/node/staticFiles.js.map +1 -1
- package/dist/node/staticFiles.mjs.map +1 -1
- package/dist/node/vite/build.js.map +1 -1
- package/dist/node/vite/build.mjs.map +1 -1
- package/dist/node/vite/config.js.map +1 -1
- package/dist/node/vite/config.mjs.map +1 -1
- package/dist/node/vite/plugins.js.map +1 -1
- package/dist/node/vite/plugins.mjs.map +1 -1
- package/dist/node/vite/watch.js.map +1 -1
- package/dist/node/vite/watch.mjs.map +1 -1
- package/dist/node/webpack/build.js.map +1 -1
- package/dist/node/webpack/build.mjs.map +1 -1
- package/dist/node/webpack/config.js.map +1 -1
- package/dist/node/webpack/config.mjs.map +1 -1
- package/dist/node/webpack/watch.js +2 -4
- package/dist/node/webpack/watch.js.map +1 -1
- package/dist/node/webpack/watch.mjs +2 -4
- package/dist/node/webpack/watch.mjs.map +1 -1
- package/package.json +23 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.mjs","sources":["../../../src/node/core/dependencies.ts"],"sourcesContent":["import os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\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': '^6.0.0',\n 'styled-components': '^6.0.0',\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}: Pick<BuildOptions, 'cwd' | 'logger'>): Promise<CheckRequiredDependenciesResult> => {\n /**\n * This enables us to use experimental deps for libraries like\n * react or styled-components. This is useful for testing against.\n */\n if (process.env.USE_EXPERIMENTAL_DEPENDENCIES === 'true') {\n logger.warn('You are using experimental dependencies that may not be compatible with Strapi.');\n return { didInstall: false };\n }\n\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 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 }\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"],"names":[],"mappings":";;;;;;;;AAaA,MAAM,YAAY;AAAA,EAChB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AACvB;AAqBA,MAAM,4BAA4B,OAAO;AAAA,EACvC;AAAA,EACA;AACF,MAAsF;AAKhF,MAAA,QAAQ,IAAI,kCAAkC,QAAQ;AACxD,WAAO,KAAK,iFAAiF;AACtF,WAAA,EAAE,YAAY;EACvB;AAEA,QAAM,MAAM,MAAM,UAAU,EAAE,IAAK,CAAA;AAEnC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,wCAAwC,GAAG,EAAE;AAAA,EAC/D;AAEA,SAAO,MAAM,wBAAwB,GAAG,KAAK,IAAI,WAAW;AAY5D,QAAM,EAAE,SAAS,WAAW,OAAO,QAAQ,SAAS,EAAE;AAAA,IAIpD,CAAC,KAAK,CAAC,MAAM,OAAO,MAAM;AACpB,UAAA,CAAC,IAAI,YAAY,cAAc;AACjC,cAAM,IAAI,MAAM,wDAAwD,GAAG,EAAE;AAAA,MAC/E;AAEA,YAAM,kBAAkB,IAAI,YAAY,aAAa,IAAI;AAEzD,UAAI,CAAC,iBAAiB;AACpB,YAAI,QAAQ,KAAK;AAAA,U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mBAAmB,OAAO;AAC5B,UAAM,UAAU,CAAC,WAAW,sBAAsB,UAAU,GAAG,QAAQ;AACvE,WAAO,KAAK,gBAAgB,QAAQ,KAAK,GAAG,CAAC,GAAG;AAChD,aAAS,MAAM,MAAM,OAAO,SAAS,WAAW;AAAA,EAAA,WACvC,mBAAmB,QAAQ;AACpC,UAAM,WAAW,CAAC,OAAO,GAAG,QAAQ;AACpC,WAAO,KAAK,iBAAiB,SAAS,KAAK,GAAG,CAAC,GAAG;AAClD,aAAS,MAAM,MAAM,QAAQ,UAAU,WAAW;AAAA,EAAA,WACzC,mBAAmB,QAAQ;AACpC,UAAM,WAAW,CAAC,OAAO,eAAe,GAAG,QAAQ;AACnD,WAAO,KAAK,iBAAiB,SAAS,KAAK,GAAG,CAAC,GAAG;AAClD,aAAS,MAAM,MAAM,QAAQ,UAAU,WAAW;AAAA,EACpD;AAEI,MAAA,QAAQ,YAAY,QAAQ,QAAQ;AAChC,UAAA,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACF;"}
|
|
1
|
+
{"version":3,"file":"dependencies.mjs","sources":["../../../src/node/core/dependencies.ts"],"sourcesContent":["import os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\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': '^6.0.0',\n 'styled-components': '^6.0.0',\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}: Pick<BuildOptions, 'cwd' | 'logger'>): Promise<CheckRequiredDependenciesResult> => {\n /**\n * This enables us to use experimental deps for libraries like\n * react or styled-components. This is useful for testing against.\n */\n if (process.env.USE_EXPERIMENTAL_DEPENDENCIES === 'true') {\n logger.warn('You are using experimental dependencies that may not be compatible with Strapi.');\n return { didInstall: false };\n }\n\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 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 }\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"],"names":[],"mappings":";;;;;;;;AAaA,MAAM,YAAY;AAAA,EAChB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AACvB;AAqBA,MAAM,4BAA4B,OAAO;AAAA,EACvC;AAAA,EACA;AACF,MAAsF;AAKhF,MAAA,QAAQ,IAAI,kCAAkC,QAAQ;AACxD,WAAO,KAAK,iFAAiF;AACtF,WAAA,EAAE,YAAY,MAAM;AAAA,EAAA;AAG7B,QAAM,MAAM,MAAM,UAAU,EAAE,KAAK;AAEnC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,wCAAwC,GAAG,EAAE;AAAA,EAAA;AAG/D,SAAO,MAAM,wBAAwB,GAAG,KAAK,IAAI,WAAW;AA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AK,aACJ;AACH,QAAM,iBAAiB,kBAAkB;AAEzC,MAAI,CAAC,gBAAgB;AACZ,WAAA;AAAA,MACL;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAAA;AAGhB,QAAM,cAAqC;AAAA,IACzC,UAAU;AAAA,IACV;AAAA,IACA,OAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,IAAI,CAAC,EAAE,MAAM,cAAc,MAAM,GAAG,IAAI,IAAI,aAAa,EAAE;AAEhF,MAAA;AAEJ,MAAI,mBAAmB,OAAO;AAC5B,UAAM,UAAU,CAAC,WAAW,sBAAsB,UAAU,GAAG,QAAQ;AACvE,WAAO,KAAK,gBAAgB,QAAQ,KAAK,GAAG,CAAC,GAAG;AAChD,aAAS,MAAM,MAAM,OAAO,SAAS,WAAW;AAAA,EAAA,WACvC,mBAAmB,QAAQ;AACpC,UAAM,WAAW,CAAC,OAAO,GAAG,QAAQ;AACpC,WAAO,KAAK,iBAAiB,SAAS,KAAK,GAAG,CAAC,GAAG;AAClD,aAAS,MAAM,MAAM,QAAQ,UAAU,WAAW;AAAA,EAAA,WACzC,mBAAmB,QAAQ;AACpC,UAAM,WAAW,CAAC,OAAO,eAAe,GAAG,QAAQ;AACnD,WAAO,KAAK,iBAAiB,SAAS,KAAK,GAAG,CAAC,GAAG;AAClD,aAAS,MAAM,MAAM,QAAQ,UAAU,WAAW;AAAA,EAAA;AAGhD,MAAA,QAAQ,YAAY,QAAQ,QAAQ;AAChC,UAAA,IAAI,MAAM,6BAA6B;AAAA,EAAA;AAEjD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sources":["../../../src/node/core/env.ts"],"sourcesContent":["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(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["path","pathExists","dotenv"],"mappings":";;;;;;;;AAmBM,MAAA,UAAU,OAAO,QAAgB;AACrC,QAAM,YAAYA,cAAA,QAAK,QAAQ,KAAK,MAAM;AAEtC,MAAA,MAAMC,MAAAA,WAAW,SAAS,GAAG;AAC/BC,oBAAAA,QAAO,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"env.js","sources":["../../../src/node/core/env.ts"],"sourcesContent":["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(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["path","pathExists","dotenv"],"mappings":";;;;;;;;AAmBM,MAAA,UAAU,OAAO,QAAgB;AACrC,QAAM,YAAYA,cAAA,QAAK,QAAQ,KAAK,MAAM;AAEtC,MAAA,MAAMC,MAAAA,WAAW,SAAS,GAAG;AAC/BC,oBAAAA,QAAO,OAAO,EAAE,MAAM,UAAA,CAAW;AAAA,EAAA;AAErC;AAOM,MAAA,wBAAwB,CAAC,eAAmD;AAChF,SAAO,OAAO,KAAK,QAAQ,GAAG,EAC3B,OAAO,CAAC,QAAQ,IAAI,YAAY,EAAE,WAAW,eAAe,CAAC,EAC7D;AAAA,IACC,CAAC,KAAK,QAAQ;AACZ,UAAI,GAAG,IAAI,QAAQ,IAAI,GAAG;AAEnB,aAAA;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","sources":["../../../src/node/core/env.ts"],"sourcesContent":["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(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":[],"mappings":";;;AAmBM,MAAA,UAAU,OAAO,QAAgB;AACrC,QAAM,YAAY,KAAK,QAAQ,KAAK,MAAM;AAEtC,MAAA,MAAM,WAAW,SAAS,GAAG;AAC/B,WAAO,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"env.mjs","sources":["../../../src/node/core/env.ts"],"sourcesContent":["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(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":[],"mappings":";;;AAmBM,MAAA,UAAU,OAAO,QAAgB;AACrC,QAAM,YAAY,KAAK,QAAQ,KAAK,MAAM;AAEtC,MAAA,MAAM,WAAW,SAAS,GAAG;AAC/B,WAAO,OAAO,EAAE,MAAM,UAAA,CAAW;AAAA,EAAA;AAErC;AAOM,MAAA,wBAAwB,CAAC,eAAmD;AAChF,SAAO,OAAO,KAAK,QAAQ,GAAG,EAC3B,OAAO,CAAC,QAAQ,IAAI,YAAY,EAAE,WAAW,eAAe,CAAC,EAC7D;AAAA,IACC,CAAC,KAAK,QAAQ;AACZ,UAAI,GAAG,IAAI,QAAQ,IAAI,GAAG;AAEnB,aAAA;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../../src/node/core/errors.ts"],"sourcesContent":["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"],"names":["chalk","os","boxen"],"mappings":";;;;;;;;;AAIM,MAAA,UAAU,CAAC,QAA+B,eAAe;AAQzD,MAAA,wBAAwB,CAAC,QAAiB;AACtC,UAAA;AAAA,IACNA,eAAAA,QAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACAC,
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../../src/node/core/errors.ts"],"sourcesContent":["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"],"names":["chalk","os","boxen"],"mappings":";;;;;;;;;AAIM,MAAA,UAAU,CAAC,QAA+B,eAAe;AAQzD,MAAA,wBAAwB,CAAC,QAAiB;AACtC,UAAA;AAAA,IACNA,eAAAA,QAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACAC,oBAAG;AAAA,IAAA;AAAA,EAEP;AAEA,MAAI,QAAQ,GAAG,KAAK,IAAI,OAAO;AAErB,YAAA;AAAA,MACND,eAAAA,QAAM;AAAA,QACJE,eAAA,QAAM,IAAI,OAAO;AAAA,UACf,SAAS;AAAA,UACT,OAAO;AAAA,QACR,CAAA;AAAA,MAAA;AAAA,IAEL;AAAA,EAAA;AAGF,UAAQ,KAAK,CAAC;AAChB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sources":["../../../src/node/core/errors.ts"],"sourcesContent":["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"],"names":[],"mappings":";;;AAIM,MAAA,UAAU,CAAC,QAA+B,eAAe;AAQzD,MAAA,wBAAwB,CAAC,QAAiB;AACtC,UAAA;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,GAAG;AAAA,
|
|
1
|
+
{"version":3,"file":"errors.mjs","sources":["../../../src/node/core/errors.ts"],"sourcesContent":["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"],"names":[],"mappings":";;;AAIM,MAAA,UAAU,CAAC,QAA+B,eAAe;AAQzD,MAAA,wBAAwB,CAAC,QAAiB;AACtC,UAAA;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EAEP;AAEA,MAAI,QAAQ,GAAG,KAAK,IAAI,OAAO;AAErB,YAAA;AAAA,MACN,MAAM;AAAA,QACJ,MAAM,IAAI,OAAO;AAAA,UACf,SAAS;AAAA,UACT,OAAO;AAAA,QACR,CAAA;AAAA,MAAA;AAAA,IAEL;AAAA,EAAA;AAGF,UAAQ,KAAK,CAAC;AAChB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sources":["../../../src/node/core/files.ts"],"sourcesContent":["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 }\n\n return sysPath;\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 }\n\n return modulePath;\n};\n\nexport { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };\n"],"names":["path","access","register"],"mappings":";;;;;;;AAOM,MAAA,aAAa,OAAOA,UAAiB;AACrC,MAAA;AACF,UAAMC,GAAAA,OAAOD,KAAI;AACV,WAAA;AAAA,WACA,OAAO;AACP,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"files.js","sources":["../../../src/node/core/files.ts"],"sourcesContent":["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 }\n\n return sysPath;\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 }\n\n return modulePath;\n};\n\nexport { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };\n"],"names":["path","access","register"],"mappings":";;;;;;;AAOM,MAAA,aAAa,OAAOA,UAAiB;AACrC,MAAA;AACF,UAAMC,GAAAA,OAAOD,KAAI;AACV,WAAA;AAAA,WACA,OAAO;AACP,WAAA;AAAA,EAAA;AAEX;AAKM,MAAA,WAAW,OAAOA,UAA2C;AAC7D,MAAA,MAAM,WAAWA,KAAI,GAAG;AAC1B,UAAM,iBAAiD;AAAA,MACrD,YAAY,CAAC,OAAO,QAAQ,KAAK;AAAA,IACnC;AAEA,UAAM,EAAE,WAAA,IAAeE,KAAA,SAAS,cAAc;AAGxC,UAAA,MAAM,QAAQF,KAAI;AAEb,eAAA;AAKL,UAAA,OAAO,KAAK,WAAW,OAAO;AAE7B,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AASM,MAAA,gCAAgC,CAAC,YAAoB;AACrD,MAAA,QAAQ,aAAa,SAAS;AACzB,WAAA,QAAQ,MAAMA,sBAAK,GAAG,EAAE,KAAKA,cAAAA,QAAK,MAAM,GAAG;AAAA,EAAA;AAG7C,SAAA;AACT;AASM,MAAA,gCAAgC,CAAC,eAAuB;AACxD,MAAA,QAAQ,aAAa,SAAS;AACzB,WAAA,WAAW,MAAMA,sBAAK,MAAM,GAAG,EAAE,KAAKA,sBAAK,GAAG;AAAA,EAAA;AAGhD,SAAA;AACT;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.mjs","sources":["../../../src/node/core/files.ts"],"sourcesContent":["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 }\n\n return sysPath;\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 }\n\n return modulePath;\n};\n\nexport { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };\n"],"names":["path"],"mappings":";;;AAOM,MAAA,aAAa,OAAOA,UAAiB;AACrC,MAAA;AACF,UAAM,OAAOA,KAAI;AACV,WAAA;AAAA,WACA,OAAO;AACP,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"files.mjs","sources":["../../../src/node/core/files.ts"],"sourcesContent":["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 }\n\n return sysPath;\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 }\n\n return modulePath;\n};\n\nexport { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };\n"],"names":["path"],"mappings":";;;AAOM,MAAA,aAAa,OAAOA,UAAiB;AACrC,MAAA;AACF,UAAM,OAAOA,KAAI;AACV,WAAA;AAAA,WACA,OAAO;AACP,WAAA;AAAA,EAAA;AAEX;AAKM,MAAA,WAAW,OAAOA,UAA2C;AAC7D,MAAA,MAAM,WAAWA,KAAI,GAAG;AAC1B,UAAM,iBAAiD;AAAA,MACrD,YAAY,CAAC,OAAO,QAAQ,KAAK;AAAA,IACnC;AAEA,UAAM,EAAE,WAAA,IAAe,SAAS,cAAc;AAGxC,UAAA,MAAM,QAAQA,KAAI;AAEb,eAAA;AAKL,UAAA,OAAO,KAAK,WAAW,OAAO;AAE7B,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AASM,MAAA,gCAAgC,CAAC,YAAoB;AACrD,MAAA,QAAQ,aAAa,SAAS;AACzB,WAAA,QAAQ,MAAM,KAAK,GAAG,EAAE,KAAK,KAAK,MAAM,GAAG;AAAA,EAAA;AAG7C,SAAA;AACT;AASM,MAAA,gCAAgC,CAAC,eAAuB;AACxD,MAAA,QAAQ,aAAa,SAAS;AACzB,WAAA,WAAW,MAAM,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,GAAG;AAAA,EAAA;AAGhD,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managers.js","sources":["../../../src/node/core/managers.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":";;AAMA,MAAM,oBAAoB,MAAM;AAExB,QAAA,QAAQ,QAAQ,IAAI,yBAAyB;AAE/C,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"managers.js","sources":["../../../src/node/core/managers.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":";;AAMA,MAAM,oBAAoB,MAAM;AAExB,QAAA,QAAQ,QAAQ,IAAI,yBAAyB;AAE/C,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,EAAA;AAGL,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,EAAA;AAML,MAAA,WAAW,KAAK,KAAK,GAAG;AACnB,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managers.mjs","sources":["../../../src/node/core/managers.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":"AAMA,MAAM,oBAAoB,MAAM;AAExB,QAAA,QAAQ,QAAQ,IAAI,yBAAyB;AAE/C,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"managers.mjs","sources":["../../../src/node/core/managers.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":"AAMA,MAAM,oBAAoB,MAAM;AAExB,QAAA,QAAQ,QAAQ,IAAI,yBAAyB;AAE/C,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,EAAA;AAGL,MAAA,MAAM,SAAS,MAAM,GAAG;AACnB,WAAA;AAAA,EAAA;AAML,MAAA,WAAW,KAAK,KAAK,GAAG;AACnB,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorepo.js","sources":["../../../src/node/core/monorepo.ts"],"sourcesContent":["import path from 'path';\nimport readPkgUp from 'read-pkg-up';\n\ninterface StrapiMonorepo {\n path: string;\n}\n\n/**\n * Load information about the strapi CMS monorepo (if applicable)\n *\n * @internal\n */\nasync function loadStrapiMonorepo(cwd: string): Promise<StrapiMonorepo | undefined> {\n let p = cwd;\n\n while (p !== '/') {\n const readResult = await readPkgUp({ cwd: p });\n\n if (!readResult) {\n return undefined;\n }\n\n if (readResult.packageJson.isStrapiMonorepo) {\n return { path: path.dirname(readResult.path) };\n }\n\n p = path.dirname(path.dirname(readResult.path));\n }\n\n return undefined;\n}\n\nexport { loadStrapiMonorepo };\nexport type { StrapiMonorepo };\n"],"names":["readPkgUp","path"],"mappings":";;;;;;;AAYA,eAAe,mBAAmB,KAAkD;AAClF,MAAI,IAAI;AAER,SAAO,MAAM,KAAK;AAChB,UAAM,aAAa,MAAMA,
|
|
1
|
+
{"version":3,"file":"monorepo.js","sources":["../../../src/node/core/monorepo.ts"],"sourcesContent":["import path from 'path';\nimport readPkgUp from 'read-pkg-up';\n\ninterface StrapiMonorepo {\n path: string;\n}\n\n/**\n * Load information about the strapi CMS monorepo (if applicable)\n *\n * @internal\n */\nasync function loadStrapiMonorepo(cwd: string): Promise<StrapiMonorepo | undefined> {\n let p = cwd;\n\n while (p !== '/') {\n const readResult = await readPkgUp({ cwd: p });\n\n if (!readResult) {\n return undefined;\n }\n\n if (readResult.packageJson.isStrapiMonorepo) {\n return { path: path.dirname(readResult.path) };\n }\n\n p = path.dirname(path.dirname(readResult.path));\n }\n\n return undefined;\n}\n\nexport { loadStrapiMonorepo };\nexport type { StrapiMonorepo };\n"],"names":["readPkgUp","path"],"mappings":";;;;;;;AAYA,eAAe,mBAAmB,KAAkD;AAClF,MAAI,IAAI;AAER,SAAO,MAAM,KAAK;AAChB,UAAM,aAAa,MAAMA,mBAAAA,QAAU,EAAE,KAAK,GAAG;AAE7C,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAGL,QAAA,WAAW,YAAY,kBAAkB;AAC3C,aAAO,EAAE,MAAMC,cAAA,QAAK,QAAQ,WAAW,IAAI,EAAE;AAAA,IAAA;AAG/C,QAAIA,sBAAK,QAAQA,cAAAA,QAAK,QAAQ,WAAW,IAAI,CAAC;AAAA,EAAA;AAGzC,SAAA;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorepo.mjs","sources":["../../../src/node/core/monorepo.ts"],"sourcesContent":["import path from 'path';\nimport readPkgUp from 'read-pkg-up';\n\ninterface StrapiMonorepo {\n path: string;\n}\n\n/**\n * Load information about the strapi CMS monorepo (if applicable)\n *\n * @internal\n */\nasync function loadStrapiMonorepo(cwd: string): Promise<StrapiMonorepo | undefined> {\n let p = cwd;\n\n while (p !== '/') {\n const readResult = await readPkgUp({ cwd: p });\n\n if (!readResult) {\n return undefined;\n }\n\n if (readResult.packageJson.isStrapiMonorepo) {\n return { path: path.dirname(readResult.path) };\n }\n\n p = path.dirname(path.dirname(readResult.path));\n }\n\n return undefined;\n}\n\nexport { loadStrapiMonorepo };\nexport type { StrapiMonorepo };\n"],"names":[],"mappings":";;AAYA,eAAe,mBAAmB,KAAkD;AAClF,MAAI,IAAI;AAER,SAAO,MAAM,KAAK;AAChB,UAAM,aAAa,MAAM,UAAU,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"monorepo.mjs","sources":["../../../src/node/core/monorepo.ts"],"sourcesContent":["import path from 'path';\nimport readPkgUp from 'read-pkg-up';\n\ninterface StrapiMonorepo {\n path: string;\n}\n\n/**\n * Load information about the strapi CMS monorepo (if applicable)\n *\n * @internal\n */\nasync function loadStrapiMonorepo(cwd: string): Promise<StrapiMonorepo | undefined> {\n let p = cwd;\n\n while (p !== '/') {\n const readResult = await readPkgUp({ cwd: p });\n\n if (!readResult) {\n return undefined;\n }\n\n if (readResult.packageJson.isStrapiMonorepo) {\n return { path: path.dirname(readResult.path) };\n }\n\n p = path.dirname(path.dirname(readResult.path));\n }\n\n return undefined;\n}\n\nexport { loadStrapiMonorepo };\nexport type { StrapiMonorepo };\n"],"names":[],"mappings":";;AAYA,eAAe,mBAAmB,KAAkD;AAClF,MAAI,IAAI;AAER,SAAO,MAAM,KAAK;AAChB,UAAM,aAAa,MAAM,UAAU,EAAE,KAAK,GAAG;AAE7C,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAGL,QAAA,WAAW,YAAY,kBAAkB;AAC3C,aAAO,EAAE,MAAM,KAAK,QAAQ,WAAW,IAAI,EAAE;AAAA,IAAA;AAG/C,QAAI,KAAK,QAAQ,KAAK,QAAQ,WAAW,IAAI,CAAC;AAAA,EAAA;AAGzC,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sources":["../../../src/node/core/plugins.ts"],"sourcesContent":["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 type { BaseContext } from '../types';\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<BaseContext, '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 /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return 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 localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\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}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":["os","getModule","camelCase","convertModulePathToSystemPath","convertSystemPathToModulePath","path","loadFile","env","fs","isError"],"mappings":";;;;;;;;;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAA;AAO5C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoCA,YAAG,QAAA,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAMC,aAAAA,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAEJ;AAEA,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAYC,2BAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MAAA;AAAA,IAEhB;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM,oBA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,iBAAiB,aAAa,UAAU,gBAAgB,GAAG;AAEjE,cAAI,gBAAgB;AACA,8BAAA,OAAO,UAAU,IAAI;AAChC,mBAAA;AAAA,UACT;AAAA,QACF;AAGA,YAAIA,YAAAA,QAAG,WAAWH,cAAA,QAAK,KAAK,iBAAiB,iBAAiB,CAAC,GAAG;AAC9C,4BAAA,OAAO,UAAU,IAAI;AAChC,iBAAA;AAAA,QACT;AAAA,MACF;AAGA,UAAI,QAAQ,QAAQ,GAAG,OAAO,UAAU,eAAe,GAAG;AACtC,0BAAA,OAAO,UAAU,IAAI;AAChC,eAAA;AAAA,MACT;AAEO,aAAA;AAAA,aACA,KAAK;AAEV,UAAAI,eAAQ,GAAG,KACX,UAAU,QACT,IAAI,SAAS,sBAAsB,IAAI,SAAS,kCACjD;AAKO,eAAA;AAAA,MACT;AAEM,YAAA;AAAA,IACR;AAAA,EAAA,CACD,EACA,IAAI,CAAC,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY,GAAG,OAAO,UAAU,IAAI,kBAAkB,OAAO,UAAU,CAAC;AAAA,EACxE,EAAA;AACN;;;"}
|
|
1
|
+
{"version":3,"file":"plugins.js","sources":["../../../src/node/core/plugins.ts"],"sourcesContent":["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 type { BaseContext } from '../types';\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<BaseContext, '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 /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return 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 localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\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}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":["os","getModule","camelCase","convertModulePathToSystemPath","convertSystemPathToModulePath","path","loadFile","env","fs","isError"],"mappings":";;;;;;;;;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAC;AAO7C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoCA,YAAAA,QAA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: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 type { BaseContext } from '../types';\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<BaseContext, '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 /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return 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 localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\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}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":[],"mappings":";;;;;;;;AA6D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AAEM,YAAA;AAAA,IACR;AAAA,EAAA,CACD,EACA,IAAI,CAAC,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY,GAAG,OAAO,UAAU,IAAI,kBAAkB,OAAO,UAAU,CAAC;AAAA,EACxE,EAAA;AACN;"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","sources":["../../../src/node/core/plugins.ts"],"sourcesContent":["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 type { BaseContext } from '../types';\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<BaseContext, '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 /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return 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 localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\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}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":[],"mappings":";;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAC;AAO7C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoC,GAAG,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAM,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QACF;AAAA,MAAA;AAGF,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAY,UAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MACd;AAAA,IAAA;AAAA,EACF;AAGF,QAAM,kBAAkB,MAAM,oBAAoB,OAAO,KAAK,IAAI,MAAM;AAExE,SAAO,MAAM,uBAAuB,GAAG,KAAK,eAAe;AAE3D,aAAW,CAAC,gBAAgB,gBAAgB,KAAK,OAAO,QAAQ,eAAe,GAAG;AAC5E,QAAA,iBAAiB,WAAW,iBAAi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AA;AAAA,MACT;AAIF,UAAI,QAAQ,QAAQ,GAAG,OAAO,UAAU,eAAe,GAAG;AACtC,0BAAA,OAAO,UAAU,IAAI;AAChC,eAAA;AAAA,MAAA;AAGF,aAAA;AAAA,aACA,KAAK;AAEV,UAAA,QAAQ,GAAG,KACX,UAAU,QACT,IAAI,SAAS,sBAAsB,IAAI,SAAS,kCACjD;AAKO,eAAA;AAAA,MAAA;AAGH,YAAA;AAAA,IAAA;AAAA,EACR,CACD,EACA,IAAI,CAAC,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY,GAAG,OAAO,UAAU,IAAI,kBAAkB,OAAO,UAAU,CAAC;AAAA,EAAA,EACxE;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timer.js","sources":["../../../src/node/core/timer.ts"],"sourcesContent":["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"],"names":["performance"],"mappings":";;;AAQO,SAAS,WAAyB;AACvC,QAAM,UAAkC,
|
|
1
|
+
{"version":3,"file":"timer.js","sources":["../../../src/node/core/timer.ts"],"sourcesContent":["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"],"names":["performance"],"mappings":";;;AAQO,SAAS,WAAyB;AACvC,QAAM,UAAkC,CAAC;AACzC,QAAM,aAAqC,CAAC;AAE5C,WAAS,MAAM,MAAoB;AACjC,QAAI,OAAO,WAAW,IAAI,MAAM,aAAa;AAC3C,YAAM,IAAI,MAAM,UAAU,IAAI,qCAAqC;AAAA,IAAA;AAG1D,eAAA,IAAI,IAAIA,WAAA,YAAY,IAAI;AAAA,EAAA;AAGrC,WAAS,IAAI,MAAsB;AACjC,QAAI,OAAO,WAAW,IAAI,MAAM,aAAa;AAC3C,YAAM,IAAI,MAAM,UAAU,IAAI,6BAA6B;AAAA,IAAA;AAG7D,YAAQ,IAAI,IAAIA,WAAAA,YAAY,IAAI,IAAI,WAAW,IAAI;AACnD,WAAO,QAAQ,IAAI;AAAA,EAAA;AAGrB,SAAO,EAAE,OAAO,KAAK,YAAY,MAAM,QAAQ;AACjD;AAEa,MAAA,aAAa,CAAC,aAA6B;AACtD,SAAO,GAAG,KAAK,KAAK,QAAQ,CAAC;AAC/B;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timer.mjs","sources":["../../../src/node/core/timer.ts"],"sourcesContent":["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"],"names":[],"mappings":";AAQO,SAAS,WAAyB;AACvC,QAAM,UAAkC,
|
|
1
|
+
{"version":3,"file":"timer.mjs","sources":["../../../src/node/core/timer.ts"],"sourcesContent":["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"],"names":[],"mappings":";AAQO,SAAS,WAAyB;AACvC,QAAM,UAAkC,CAAC;AACzC,QAAM,aAAqC,CAAC;AAE5C,WAAS,MAAM,MAAoB;AACjC,QAAI,OAAO,WAAW,IAAI,MAAM,aAAa;AAC3C,YAAM,IAAI,MAAM,UAAU,IAAI,qCAAqC;AAAA,IAAA;AAG1D,eAAA,IAAI,IAAI,YAAY,IAAI;AAAA,EAAA;AAGrC,WAAS,IAAI,MAAsB;AACjC,QAAI,OAAO,WAAW,IAAI,MAAM,aAAa;AAC3C,YAAM,IAAI,MAAM,UAAU,IAAI,6BAA6B;AAAA,IAAA;AAG7D,YAAQ,IAAI,IAAI,YAAY,IAAI,IAAI,WAAW,IAAI;AACnD,WAAO,QAAQ,IAAI;AAAA,EAAA;AAGrB,SAAO,EAAE,OAAO,KAAK,YAAY,MAAM,QAAQ;AACjD;AAEa,MAAA,aAAa,CAAC,aAA6B;AACtD,SAAO,GAAG,KAAK,KAAK,QAAQ,CAAC;AAC/B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.js","sources":["../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\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\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\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 <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\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 createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\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 { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n basePath: `${adminPath}/`,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["createStrapi","loadEnv","env","getStrapiAdminEnvVars","os","path","fs","plugins","getEnabledPlugins","getMapOfPluginsWithAdmin","browserslist","loadUserAppFile"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,qBAAqB,OAAqC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,
|
|
1
|
+
{"version":3,"file":"create-build-context.js","sources":["../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\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\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\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 <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\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 createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\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 { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n basePath: `${adminPath}/`,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["createStrapi","loadEnv","env","getStrapiAdminEnvVars","os","path","fs","plugins","getEnabledPlugins","getMapOfPluginsWithAdmin","browserslist","loadUserAppFile"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,qBAAqB,OAAqC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAA;AACZ,MAAyE;AAMjE,QAAA,iBACJ,UACAA,kBAAa;AAAA;AAAA,IAEX,QAAQ;AAAA,IACR,SAAS,UAAU,OAAO,QAAQ,UAAU;AAAA;AAAA,IAE5C,YAAY;AAAA,IACZ,iBAAiB;AAAA,EAAA,CAClB;AAEH,QAAM,YAAY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A,QAAa,WAAW,EAAE,MAAM,IAAK,CAAA,KAAK;AAEzD,QAAM,iBAAiB,MAAMC,oBAAAA,gBAAgB,EAAE,QAAQ,YAAY;AAEnE,QAAM,WAAW,eAAe,OAAO,IAAI,YAAY,MAAS;AAEhE,QAAM,EAAE,UAAU,QAAQ,GAAG,YAAgB,IAAA;AAE7C,QAAM,eAAe;AAAA,IACnB;AAAA,IACA,UAAU,GAAG,SAAS;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAAA,KACAT;AAAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACF;AAEO,SAAA;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.mjs","sources":["../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\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\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\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 <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\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 createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\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 { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n basePath: `${adminPath}/`,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":[],"mappings":";;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,qBAAqB,OAAqC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,
|
|
1
|
+
{"version":3,"file":"create-build-context.mjs","sources":["../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\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\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\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 <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\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 createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\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 { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n basePath: `${adminPath}/`,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":[],"mappings":";;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,qBAAqB,OAAqC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAA;AACZ,MAAyE;AAMjE,QAAA,iBACJ,UACA,aAAa;AAAA;AAAA,IAEX,QAAQ;AAAA,IACR,SAAS,UAAU,OAAO,QAAQ,UAAU;AAAA;AAAA,IAE5C,YAAY;AAAA,IACZ,iBAAiB;AAAA,EAAA,CAClB;AAEH,QAAM,YAAY,eAAe,OAAO,IAAY,YAAY;AAChE,QAAM,YAAY,eAAe,OAAO,IAA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E,UAAU,QAAQ,GAAG,YAAgB,IAAA;AAE7C,QAAM,eAAe;AAAA,IACnB;AAAA,IACA,UAAU,GAAG,SAAS;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACF;AAEO,SAAA;AACT;"}
|
package/dist/node/develop.js
CHANGED
|
@@ -13,8 +13,7 @@ const createBuildContext = require("./create-build-context.js");
|
|
|
13
13
|
const staticFiles = require("./staticFiles.js");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule)
|
|
17
|
-
return e;
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
18
17
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
19
18
|
if (e) {
|
|
20
19
|
for (const k in e) {
|
package/dist/node/develop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"develop.js","sources":["../../src/node/develop.ts"],"sourcesContent":["import * as tsUtils from '@strapi/typescript-utils';\nimport { strings } from '@strapi/utils';\nimport chokidar from 'chokidar';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\nimport { createStrapi } from '@strapi/core';\n\nimport type { CLIContext } from '../cli/types';\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport { createBuildContext } from './create-build-context';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\n\nimport { writeStaticClientFiles } from './staticFiles';\n\ninterface DevelopOptions extends CLIContext {\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 watchAdmin,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const { didInstall } = await checkRequiredDependencies({ cwd, logger }).catch((err) => {\n logger.error(err.message);\n process.exit(1);\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 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 = createStrapi({\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 const strapiInstance = await strapi.load();\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 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 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 '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\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":["timer","fs","path","generatingDuration","prettyTime","getTimer","cluster","checkRequiredDependencies","tsUtils","createBuildContext","writeStaticClientFiles","createStrapi","chokidar","strings"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EAAA,OACAA;AACF,MAA6E;AACrE,QAAA,UAAU,UAAU,QAAQ,SAAS;AAE3C,MACE,CAAC;AAAA,EACA,MAAMC,YAAA,QACJ,OAAO,OAAO,EACd,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;AAAA,QACF;AAAA,MAGF;AAAA,IAAA,CACD;AAED,mBAAe,MAAM;AAAA,EACvB;AACF;;"}
|
|
1
|
+
{"version":3,"file":"develop.js","sources":["../../src/node/develop.ts"],"sourcesContent":["import * as tsUtils from '@strapi/typescript-utils';\nimport { strings } from '@strapi/utils';\nimport chokidar from 'chokidar';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\nimport { createStrapi } from '@strapi/core';\n\nimport type { CLIContext } from '../cli/types';\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport { createBuildContext } from './create-build-context';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\n\nimport { writeStaticClientFiles } from './staticFiles';\n\ninterface DevelopOptions extends CLIContext {\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 watchAdmin,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const { didInstall } = await checkRequiredDependencies({ cwd, logger }).catch((err) => {\n logger.error(err.message);\n process.exit(1);\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 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 = createStrapi({\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 const strapiInstance = await strapi.load();\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 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 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 '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\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":["timer","fs","path","generatingDuration","prettyTime","getTimer","cluster","checkRequiredDependencies","tsUtils","createBuildContext","writeStaticClientFiles","createStrapi","chokidar","strings"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACAA,OAAAA;AACF,MAA6E;AACrE,QAAA,UAAU,UAAU,QAAQ,SAAS;AAE3C,MACE,CAAC;AAAA,EACA,MAAMC,YAAA,QACJ,OAAO,OAAO,EACd,KAAK,MAAM,KAAK,EAChB,MAAM,MAAM,IAAI,GACnB;AACA;AAAA,EAAA;AAGF,QAAM,YAAY,eAAe,KAAK,IAAK,CAAA;AAC3CD,UAAM,MAAM,SAAS;AACrB,QAAM,kBAAkB,OAAO,QAAQ,qBAAqB,OAAO,EAAE,EAAE,MAAM;AAEzE,MAAA;AACF,UAAM,aAAa,MAAMC,oBAAG,QAAQ,OAAO;AAC3C,UAAM,iBAAiB,WAEpB,OAAO,CAAC,aAAa,aAAa,OAAO;AAC5C,eAAW,YAAY,gBAAgB;AAC/B,YAAAA,YAAA,QAAG,GAAGC,cAAAA,QAAK,QAAQ,SAAS,QAAQ,GAAG,EAAE,WAAW,MAAM;AAAA,IAAA;AAAA,WAE3D,KAAc;AACfC,UAAAA,sBAAqBH,QAAM,IAAI,SAAS;AAC9C,oBAAgB,OAAO,4BAA4B,GAAG,KAAKI,MAAA,WAAWD,mBAAkB,CAAC;AACzF,qBAAiB,KAAK;AACtB;AAAA,EAAA;AAGI,QA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AAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,QAEA,GAAG,eAAe,OAAO,IAAI,0BAA0B,CAAE,CAAA;AAAA,MAAA;AAAA,IAE5D,CAAA,EACA,GAAG,OAAO,CAACX,UAAS;AACnB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC,cAAA;AAAA,IACT,CAAA,EACA,GAAG,UAAU,CAACA,UAAS;AACtB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC,cAAA;AAAA,IACT,CAAA,EACA,GAAG,UAAU,CAACA,UAAS;AACtB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC,cAAA;AAAA,IAAA,CACT;AAEK,YAAA,GAAG,WAAW,OAAO,YAAY;AACvC,cAAQ,SAAS;AAAA,QACf,KAAK,QAAQ;AACJ,iBAAA;AAAA,YACL;AAAA,UACF;AACA,gBAAM,QAAQ,MAAM;AAEpB,gBAAM,eAAe,QAAQ;AAE7B,cAAI,eAAe;AACjB,0BAAc,MAAM;AAAA,UAAA;AAEtB,kBAAQ,OAAO,QAAQ;AACvB;AAAA,QAAA;AAAA,MAGA;AAAA,IACJ,CACD;AAED,mBAAe,MAAM;AAAA,EAAA;AAEzB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"develop.mjs","sources":["../../src/node/develop.ts"],"sourcesContent":["import * as tsUtils from '@strapi/typescript-utils';\nimport { strings } from '@strapi/utils';\nimport chokidar from 'chokidar';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\nimport { createStrapi } from '@strapi/core';\n\nimport type { CLIContext } from '../cli/types';\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport { createBuildContext } from './create-build-context';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\n\nimport { writeStaticClientFiles } from './staticFiles';\n\ninterface DevelopOptions extends CLIContext {\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 watchAdmin,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const { didInstall } = await checkRequiredDependencies({ cwd, logger }).catch((err) => {\n logger.error(err.message);\n process.exit(1);\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 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 = createStrapi({\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 const strapiInstance = await strapi.load();\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 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 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 '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\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":["generatingDuration","path"],"mappings":";;;;;;;;;;;AA8BA,MAAM,uBAAuB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,MAA6E;AACrE,QAAA,UAAU,UAAU,QAAQ,SAAS;AAE3C,MACE,CAAC;AAAA,EACA,MAAM,GACJ,OAAO,OAAO,EACd,KAAK,MAAM,KAAK,EAChB,MAAM,MAAM,I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QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,KAAK,OAAO;AAAA,QAC3B,QAAQ,OAAO,KAAK,eAAe,KAAK,OAAO,QAAQ,IAAI;AAAA,QAC3D;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,QAEA,GAAG,eAAe,OAAO,IAAI,0BAA0B,CAAA,CAAE;AAAA,MAC3D;AAAA,IACD,CAAA,EACA,GAAG,OAAO,CAACC,UAAS;AACnB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC;IACT,CAAA,EACA,GAAG,UAAU,CAACA,UAAS;AACtB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC;IACT,CAAA,EACA,GAAG,UAAU,CAACA,UAAS;AACtB,qBAAe,IAAI,KAAK,iBAAiBA,KAAI,EAAE;AACvC;IAAA,CACT;AAEK,YAAA,GAAG,WAAW,OAAO,YAAY;AACvC,cAAQ,SAAS;AAAA,QACf,KAAK,QAAQ;AACJ,iBAAA;AAAA,YACL;AAAA,UAAA;AAEF,gBAAM,QAAQ;AAEd,gBAAM,eAAe;AAErB,cAAI,eAAe;AACjB,0BAAc,MAAM;AAAA,UACtB;AACA,kBAAQ,OAAO,QAAQ;AACvB;AAAA,QACF;AAAA,MAGF;AAAA,IAAA,CACD;AAED,mBAAe,MAAM;AAAA,EACvB;AACF;"}
|
|
1
|
+
{"version":3,"file":"develop.mjs","sources":["../../src/node/develop.ts"],"sourcesContent":["import * as tsUtils from '@strapi/typescript-utils';\nimport { strings } from '@strapi/utils';\nimport chokidar from 'chokidar';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\nimport { createStrapi } from '@strapi/core';\n\nimport type { CLIContext } from '../cli/types';\nimport { checkRequiredDependencies } from './core/dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport { createBuildContext } from './create-build-context';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\n\nimport { writeStaticClientFiles } from './staticFiles';\n\ninterface DevelopOptions extends CLIContext {\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 watchAdmin,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const { didInstall } = await checkRequiredDependencies({ cwd, logger }).catch((err) => {\n logger.error(err.message);\n process.exit(1);\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 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 = createStrapi({\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 const strapiInstance = await strapi.load();\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 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 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 '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\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":["generatingDuration","path"],"mappings":";;;;;;;;;;;AA8BA,MAAM,uBAAuB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,MAA6E;AACrE,QAAA,UAAU,UAAU,QAAQ,SAA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