@strapi/strapi 5.48.0 → 5.49.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.
Files changed (129) hide show
  1. package/README.md +9 -9
  2. package/dist/admin.js +17 -7
  3. package/dist/admin.js.map +1 -1
  4. package/dist/node/core/plugins.d.ts.map +1 -1
  5. package/dist/node/create-build-context.d.ts +0 -4
  6. package/dist/node/create-build-context.d.ts.map +1 -1
  7. package/dist/node/vite/config.d.ts.map +1 -1
  8. package/dist/node/vite/resolve-development-config.test.d.ts +2 -0
  9. package/dist/node/vite/resolve-development-config.test.d.ts.map +1 -0
  10. package/dist/node/vite/watch.d.ts.map +1 -1
  11. package/dist/node/webpack/config.d.ts.map +1 -1
  12. package/dist/package.json.js +1 -1
  13. package/dist/package.json.mjs +1 -1
  14. package/dist/src/cli/commands/admin/active-user.js +6 -2
  15. package/dist/src/cli/commands/admin/active-user.js.map +1 -1
  16. package/dist/src/cli/commands/admin/block-user.js +6 -2
  17. package/dist/src/cli/commands/admin/block-user.js.map +1 -1
  18. package/dist/src/cli/commands/admin/create-user.js +5 -1
  19. package/dist/src/cli/commands/admin/create-user.js.map +1 -1
  20. package/dist/src/cli/commands/admin/delete-user.js +6 -2
  21. package/dist/src/cli/commands/admin/delete-user.js.map +1 -1
  22. package/dist/src/cli/commands/admin/list-users.js +16 -11
  23. package/dist/src/cli/commands/admin/list-users.js.map +1 -1
  24. package/dist/src/cli/commands/admin/reset-user-password.js +6 -2
  25. package/dist/src/cli/commands/admin/reset-user-password.js.map +1 -1
  26. package/dist/src/cli/commands/components/list.js +7 -2
  27. package/dist/src/cli/commands/components/list.js.map +1 -1
  28. package/dist/src/cli/commands/configuration/dump.js +5 -1
  29. package/dist/src/cli/commands/configuration/dump.js.map +1 -1
  30. package/dist/src/cli/commands/configuration/restore.js +8 -3
  31. package/dist/src/cli/commands/configuration/restore.js.map +1 -1
  32. package/dist/src/cli/commands/console.js +5 -1
  33. package/dist/src/cli/commands/console.js.map +1 -1
  34. package/dist/src/cli/commands/content-types/list.js +7 -2
  35. package/dist/src/cli/commands/content-types/list.js.map +1 -1
  36. package/dist/src/cli/commands/controllers/list.js +7 -2
  37. package/dist/src/cli/commands/controllers/list.js.map +1 -1
  38. package/dist/src/cli/commands/develop.js +5 -1
  39. package/dist/src/cli/commands/develop.js.map +1 -1
  40. package/dist/src/cli/commands/export/action.js +11 -5
  41. package/dist/src/cli/commands/export/action.js.map +1 -1
  42. package/dist/src/cli/commands/hooks/list.js +7 -2
  43. package/dist/src/cli/commands/hooks/list.js.map +1 -1
  44. package/dist/src/cli/commands/import/action.js +7 -2
  45. package/dist/src/cli/commands/import/action.js.map +1 -1
  46. package/dist/src/cli/commands/import/command.js +6 -2
  47. package/dist/src/cli/commands/import/command.js.map +1 -1
  48. package/dist/src/cli/commands/middlewares/list.js +7 -2
  49. package/dist/src/cli/commands/middlewares/list.js.map +1 -1
  50. package/dist/src/cli/commands/openapi/generate.js +17 -11
  51. package/dist/src/cli/commands/openapi/generate.js.map +1 -1
  52. package/dist/src/cli/commands/policies/list.js +7 -2
  53. package/dist/src/cli/commands/policies/list.js.map +1 -1
  54. package/dist/src/cli/commands/routes/list.js +8 -3
  55. package/dist/src/cli/commands/routes/list.js.map +1 -1
  56. package/dist/src/cli/commands/services/list.js +7 -2
  57. package/dist/src/cli/commands/services/list.js.map +1 -1
  58. package/dist/src/cli/commands/start.js +8 -3
  59. package/dist/src/cli/commands/start.js.map +1 -1
  60. package/dist/src/cli/commands/telemetry/disable.js +14 -9
  61. package/dist/src/cli/commands/telemetry/disable.js.map +1 -1
  62. package/dist/src/cli/commands/telemetry/enable.js +14 -9
  63. package/dist/src/cli/commands/telemetry/enable.js.map +1 -1
  64. package/dist/src/cli/commands/transfer/action.js +5 -1
  65. package/dist/src/cli/commands/transfer/action.js.map +1 -1
  66. package/dist/src/cli/commands/ts/generate-types.js +5 -1
  67. package/dist/src/cli/commands/ts/generate-types.js.map +1 -1
  68. package/dist/src/cli/utils/commander.js +5 -1
  69. package/dist/src/cli/utils/commander.js.map +1 -1
  70. package/dist/src/cli/utils/data-transfer.js +28 -21
  71. package/dist/src/cli/utils/data-transfer.js.map +1 -1
  72. package/dist/src/cli/utils/helpers.js +7 -3
  73. package/dist/src/cli/utils/helpers.js.map +1 -1
  74. package/dist/src/cli/utils/logger.js +15 -10
  75. package/dist/src/cli/utils/logger.js.map +1 -1
  76. package/dist/src/cli/utils/tsconfig.js +9 -4
  77. package/dist/src/cli/utils/tsconfig.js.map +1 -1
  78. package/dist/src/node/build.js +3 -2
  79. package/dist/src/node/build.js.map +1 -1
  80. package/dist/src/node/core/admin-customisations.js +6 -2
  81. package/dist/src/node/core/admin-customisations.js.map +1 -1
  82. package/dist/src/node/core/aliases.js +5 -1
  83. package/dist/src/node/core/aliases.js.map +1 -1
  84. package/dist/src/node/core/config.js +5 -1
  85. package/dist/src/node/core/config.js.map +1 -1
  86. package/dist/src/node/core/dependencies.js +33 -22
  87. package/dist/src/node/core/dependencies.js.map +1 -1
  88. package/dist/src/node/core/ensure-admin-dependencies.js +5 -1
  89. package/dist/src/node/core/ensure-admin-dependencies.js.map +1 -1
  90. package/dist/src/node/core/env.js +7 -2
  91. package/dist/src/node/core/env.js.map +1 -1
  92. package/dist/src/node/core/errors.js +9 -3
  93. package/dist/src/node/core/errors.js.map +1 -1
  94. package/dist/src/node/core/files.js +6 -2
  95. package/dist/src/node/core/files.js.map +1 -1
  96. package/dist/src/node/core/linked-packages.js +5 -1
  97. package/dist/src/node/core/linked-packages.js.map +1 -1
  98. package/dist/src/node/core/monorepo.js +8 -3
  99. package/dist/src/node/core/monorepo.js.map +1 -1
  100. package/dist/src/node/core/plugins.js +35 -12
  101. package/dist/src/node/core/plugins.js.map +1 -1
  102. package/dist/src/node/core/plugins.mjs +19 -3
  103. package/dist/src/node/core/plugins.mjs.map +1 -1
  104. package/dist/src/node/core/resolve-module.js +8 -3
  105. package/dist/src/node/core/resolve-module.js.map +1 -1
  106. package/dist/src/node/create-build-context.js +16 -9
  107. package/dist/src/node/create-build-context.js.map +1 -1
  108. package/dist/src/node/create-build-context.mjs.map +1 -1
  109. package/dist/src/node/develop.js +14 -8
  110. package/dist/src/node/develop.js.map +1 -1
  111. package/dist/src/node/staticFiles.js +11 -5
  112. package/dist/src/node/staticFiles.js.map +1 -1
  113. package/dist/src/node/vite/config.js +23 -5
  114. package/dist/src/node/vite/config.js.map +1 -1
  115. package/dist/src/node/vite/config.mjs +18 -4
  116. package/dist/src/node/vite/config.mjs.map +1 -1
  117. package/dist/src/node/vite/watch.js +7 -62
  118. package/dist/src/node/vite/watch.js.map +1 -1
  119. package/dist/src/node/vite/watch.mjs +2 -62
  120. package/dist/src/node/vite/watch.mjs.map +1 -1
  121. package/dist/src/node/webpack/build.js +5 -1
  122. package/dist/src/node/webpack/build.js.map +1 -1
  123. package/dist/src/node/webpack/config.js +19 -9
  124. package/dist/src/node/webpack/config.js.map +1 -1
  125. package/dist/src/node/webpack/config.mjs +2 -1
  126. package/dist/src/node/webpack/config.mjs.map +1 -1
  127. package/dist/src/node/webpack/watch.js +11 -4
  128. package/dist/src/node/webpack/watch.js.map +1 -1
  129. package/package.json +26 -26
@@ -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';\nimport { errors } from '@strapi/utils';\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 if (err instanceof errors.YupValidationError) {\n const message = [];\n const size = err.details.errors.length;\n\n for (const error of err.details.errors) {\n // No need to repeat the error message as it's the same as the err.message\n if (size === 1) {\n message.push(` value: ${error.value}`);\n continue;\n }\n\n message.push(\n [` [${error.name}]`, ` message: ${error.message}`, ` value: ${error.value}`].join(\n '\\n'\n )\n );\n }\n\n console.log(\n chalk.red(\n boxen(['Details:', message.join('\\n\\n')].join('\\n'), {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n\n process.exit(1);\n};\n\nexport { handleUnexpectedError, isError };\n"],"names":["isError","err","Error","handleUnexpectedError","console","error","chalk","red","os","EOL","stack","log","boxen","padding","align","errors","YupValidationError","message","size","details","length","push","value","name","join","process","exit"],"mappings":";;;;;;;AAKA,MAAMA,OAAAA,GAAU,CAACC,GAAAA,GAA+BA,GAAAA,YAAeC;AAE/D;;;;;IAMA,MAAMC,wBAAwB,CAACF,GAAAA,GAAAA;IAC7BG,OAAAA,CAAQC,KAAK,CACXC,KAAAA,CAAMC,GAAG,CACP,CAAC,QAAQ,CAAC,EACV,oFAAA,EACAC,EAAAA,CAAGC,GAAG,CAAA,CAAA;AAIV,IAAA,IAAIT,OAAAA,CAAQC,GAAAA,CAAAA,IAAQA,GAAAA,CAAIS,KAAK,EAAE;;QAE7BN,OAAAA,CAAQO,GAAG,CACTL,KAAAA,CAAMC,GAAG,CACPK,KAAAA,CAAMX,GAAAA,CAAIS,KAAK,EAAE;YACfG,OAAAA,EAAS,CAAA;YACTC,KAAAA,EAAO;AACT,SAAA,CAAA,CAAA,CAAA;AAGN,IAAA;IAEA,IAAIb,GAAAA,YAAec,YAAAA,CAAOC,kBAAkB,EAAE;AAC5C,QAAA,MAAMC,UAAU,EAAE;AAClB,QAAA,MAAMC,OAAOjB,GAAAA,CAAIkB,OAAO,CAACJ,MAAM,CAACK,MAAM;AAEtC,QAAA,KAAK,MAAMf,KAAAA,IAASJ,GAAAA,CAAIkB,OAAO,CAACJ,MAAM,CAAE;;AAEtC,YAAA,IAAIG,SAAS,CAAA,EAAG;AACdD,gBAAAA,OAAAA,CAAQI,IAAI,CAAC,CAAC,SAAS,EAAEhB,KAAAA,CAAMiB,KAAK,CAAA,CAAE,CAAA;AACtC,gBAAA;AACF,YAAA;AAEAL,YAAAA,OAAAA,CAAQI,IAAI,CACV;AAAC,gBAAA,CAAC,GAAG,EAAEhB,KAAAA,CAAMkB,IAAI,CAAC,CAAC,CAAC;AAAE,gBAAA,CAAC,aAAa,EAAElB,KAAAA,CAAMY,OAAO,CAAA,CAAE;AAAE,gBAAA,CAAC,aAAa,EAAEZ,KAAAA,CAAMiB,KAAK,CAAA;AAAG,aAAA,CAACE,IAAI,CACxF,IAAA,CAAA,CAAA;AAGN,QAAA;AAEApB,QAAAA,OAAAA,CAAQO,GAAG,CACTL,KAAAA,CAAMC,GAAG,CACPK,KAAAA,CAAM;AAAC,YAAA,UAAA;AAAYK,YAAAA,OAAAA,CAAQO,IAAI,CAAC,MAAA;SAAQ,CAACA,IAAI,CAAC,IAAA,CAAA,EAAO;YACnDX,OAAAA,EAAS,CAAA;YACTC,KAAAA,EAAO;AACT,SAAA,CAAA,CAAA,CAAA;AAGN,IAAA;AAEAW,IAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;;;;;"}
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';\nimport { errors } from '@strapi/utils';\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 if (err instanceof errors.YupValidationError) {\n const message = [];\n const size = err.details.errors.length;\n\n for (const error of err.details.errors) {\n // No need to repeat the error message as it's the same as the err.message\n if (size === 1) {\n message.push(` value: ${error.value}`);\n continue;\n }\n\n message.push(\n [` [${error.name}]`, ` message: ${error.message}`, ` value: ${error.value}`].join(\n '\\n'\n )\n );\n }\n\n console.log(\n chalk.red(\n boxen(['Details:', message.join('\\n\\n')].join('\\n'), {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n\n process.exit(1);\n};\n\nexport { handleUnexpectedError, isError };\n"],"names":["isError","err","Error","handleUnexpectedError","console","error","chalk","red","os","EOL","stack","log","boxen","padding","align","errors","YupValidationError","message","size","details","length","push","value","name","join","process","exit"],"mappings":";;;;;;;;;;;;;AAKA,MAAMA,OAAAA,GAAU,CAACC,GAAAA,GAA+BA,GAAAA,YAAeC;AAE/D;;;;;IAMA,MAAMC,wBAAwB,CAACF,GAAAA,GAAAA;IAC7BG,OAAAA,CAAQC,KAAK,CACXC,sBAAAA,CAAMC,GAAG,CACP,CAAC,QAAQ,CAAC,EACV,oFAAA,EACAC,mBAAAA,CAAGC,GAAG,CAAA,CAAA;AAIV,IAAA,IAAIT,OAAAA,CAAQC,GAAAA,CAAAA,IAAQA,GAAAA,CAAIS,KAAK,EAAE;;QAE7BN,OAAAA,CAAQO,GAAG,CACTL,sBAAAA,CAAMC,GAAG,CACPK,sBAAAA,CAAMX,GAAAA,CAAIS,KAAK,EAAE;YACfG,OAAAA,EAAS,CAAA;YACTC,KAAAA,EAAO;AACT,SAAA,CAAA,CAAA,CAAA;AAGN,IAAA;IAEA,IAAIb,GAAAA,YAAec,YAAAA,CAAOC,kBAAkB,EAAE;AAC5C,QAAA,MAAMC,UAAU,EAAE;AAClB,QAAA,MAAMC,OAAOjB,GAAAA,CAAIkB,OAAO,CAACJ,MAAM,CAACK,MAAM;AAEtC,QAAA,KAAK,MAAMf,KAAAA,IAASJ,GAAAA,CAAIkB,OAAO,CAACJ,MAAM,CAAE;;AAEtC,YAAA,IAAIG,SAAS,CAAA,EAAG;AACdD,gBAAAA,OAAAA,CAAQI,IAAI,CAAC,CAAC,SAAS,EAAEhB,KAAAA,CAAMiB,KAAK,CAAA,CAAE,CAAA;AACtC,gBAAA;AACF,YAAA;AAEAL,YAAAA,OAAAA,CAAQI,IAAI,CACV;AAAC,gBAAA,CAAC,GAAG,EAAEhB,KAAAA,CAAMkB,IAAI,CAAC,CAAC,CAAC;AAAE,gBAAA,CAAC,aAAa,EAAElB,KAAAA,CAAMY,OAAO,CAAA,CAAE;AAAE,gBAAA,CAAC,aAAa,EAAEZ,KAAAA,CAAMiB,KAAK,CAAA;AAAG,aAAA,CAACE,IAAI,CACxF,IAAA,CAAA,CAAA;AAGN,QAAA;AAEApB,QAAAA,OAAAA,CAAQO,GAAG,CACTL,sBAAAA,CAAMC,GAAG,CACPK,sBAAAA,CAAM;AAAC,YAAA,UAAA;AAAYK,YAAAA,OAAAA,CAAQO,IAAI,CAAC,MAAA;SAAQ,CAACA,IAAI,CAAC,IAAA,CAAA,EAAO;YACnDX,OAAAA,EAAS,CAAA;YACTC,KAAAA,EAAO;AACT,SAAA,CAAA,CAAA,CAAA;AAGN,IAAA;AAEAW,IAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;;;;;"}
@@ -4,6 +4,10 @@ var path = require('node:path');
4
4
  var fs = require('node:fs/promises');
5
5
  var node = require('esbuild-register/dist/node');
6
6
 
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var path__default = /*#__PURE__*/_interopDefault(path);
10
+
7
11
  /**
8
12
  * @internal
9
13
  */ const pathExists = async (path)=>{
@@ -44,7 +48,7 @@ var node = require('esbuild-register/dist/node');
44
48
  * is identical to the module path separator.
45
49
  */ const convertSystemPathToModulePath = (sysPath)=>{
46
50
  if (process.platform === 'win32') {
47
- return sysPath.split(path.sep).join(path.posix.sep);
51
+ return sysPath.split(path__default.default.sep).join(path__default.default.posix.sep);
48
52
  }
49
53
  return sysPath;
50
54
  };
@@ -56,7 +60,7 @@ var node = require('esbuild-register/dist/node');
56
60
  * have it relative to the runtime directory.
57
61
  */ const convertModulePathToSystemPath = (modulePath)=>{
58
62
  if (process.platform === 'win32') {
59
- return modulePath.split(path.posix.sep).join(path.sep);
63
+ return modulePath.split(path__default.default.posix.sep).join(path__default.default.sep);
60
64
  }
61
65
  return modulePath;
62
66
  };
@@ -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":["pathExists","path","access","error","loadFile","esbuildOptions","extensions","unregister","register","mod","require","file","default","undefined","convertSystemPathToModulePath","sysPath","process","platform","split","sep","join","posix","convertModulePathToSystemPath","modulePath"],"mappings":";;;;;;AAIA;;IAGA,MAAMA,aAAa,OAAOC,IAAAA,GAAAA;IACxB,IAAI;AACF,QAAA,MAAMC,SAAAA,CAAOD,IAAAA,CAAAA;QACb,OAAO,IAAA;AACT,IAAA,CAAA,CAAE,OAAOE,KAAAA,EAAO;QACd,OAAO,KAAA;AACT,IAAA;AACF;AAEA;;IAGA,MAAMC,WAAW,OAAOH,IAAAA,GAAAA;IACtB,IAAI,MAAMD,WAAWC,IAAAA,CAAAA,EAAO;AAC1B,QAAA,MAAMI,cAAAA,GAAiD;YACrDC,UAAAA,EAAY;AAAC,gBAAA,KAAA;AAAO,gBAAA,MAAA;AAAQ,gBAAA;AAAM;AACpC,SAAA;AAEA,QAAA,MAAM,EAAEC,UAAU,EAAE,GAAGC,aAAAA,CAASH,cAAAA,CAAAA;;AAGhC,QAAA,MAAMI,MAAMC,OAAAA,CAAQT,IAAAA,CAAAA;AAEpBM,QAAAA,UAAAA,EAAAA;AAEA;;AAEC,QACD,MAAMI,IAAAA,GAAOF,GAAAA,EAAKG,OAAAA,IAAWH,GAAAA,IAAOI,SAAAA;QAEpC,OAAOF,IAAAA;AACT,IAAA;IAEA,OAAOE,SAAAA;AACT;AAEA;;;;;;IAOA,MAAMC,gCAAgC,CAACC,OAAAA,GAAAA;IACrC,IAAIC,OAAAA,CAAQC,QAAQ,KAAK,OAAA,EAAS;QAChC,OAAOF,OAAAA,CAAQG,KAAK,CAACjB,IAAAA,CAAKkB,GAAG,CAAA,CAAEC,IAAI,CAACnB,IAAAA,CAAKoB,KAAK,CAACF,GAAG,CAAA;AACpD,IAAA;IAEA,OAAOJ,OAAAA;AACT;AAEA;;;;;;IAOA,MAAMO,gCAAgC,CAACC,UAAAA,GAAAA;IACrC,IAAIP,OAAAA,CAAQC,QAAQ,KAAK,OAAA,EAAS;QAChC,OAAOM,UAAAA,CAAWL,KAAK,CAACjB,IAAAA,CAAKoB,KAAK,CAACF,GAAG,CAAA,CAAEC,IAAI,CAACnB,IAAAA,CAAKkB,GAAG,CAAA;AACvD,IAAA;IAEA,OAAOI,UAAAA;AACT;;;;;;;"}
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":["pathExists","path","access","error","loadFile","esbuildOptions","extensions","unregister","register","mod","require","file","default","undefined","convertSystemPathToModulePath","sysPath","process","platform","split","sep","join","posix","convertModulePathToSystemPath","modulePath"],"mappings":";;;;;;;;;;AAIA;;IAGA,MAAMA,aAAa,OAAOC,IAAAA,GAAAA;IACxB,IAAI;AACF,QAAA,MAAMC,SAAAA,CAAOD,IAAAA,CAAAA;QACb,OAAO,IAAA;AACT,IAAA,CAAA,CAAE,OAAOE,KAAAA,EAAO;QACd,OAAO,KAAA;AACT,IAAA;AACF;AAEA;;IAGA,MAAMC,WAAW,OAAOH,IAAAA,GAAAA;IACtB,IAAI,MAAMD,WAAWC,IAAAA,CAAAA,EAAO;AAC1B,QAAA,MAAMI,cAAAA,GAAiD;YACrDC,UAAAA,EAAY;AAAC,gBAAA,KAAA;AAAO,gBAAA,MAAA;AAAQ,gBAAA;AAAM;AACpC,SAAA;AAEA,QAAA,MAAM,EAAEC,UAAU,EAAE,GAAGC,aAAAA,CAASH,cAAAA,CAAAA;;AAGhC,QAAA,MAAMI,MAAMC,OAAAA,CAAQT,IAAAA,CAAAA;AAEpBM,QAAAA,UAAAA,EAAAA;AAEA;;AAEC,QACD,MAAMI,IAAAA,GAAOF,GAAAA,EAAKG,OAAAA,IAAWH,GAAAA,IAAOI,SAAAA;QAEpC,OAAOF,IAAAA;AACT,IAAA;IAEA,OAAOE,SAAAA;AACT;AAEA;;;;;;IAOA,MAAMC,gCAAgC,CAACC,OAAAA,GAAAA;IACrC,IAAIC,OAAAA,CAAQC,QAAQ,KAAK,OAAA,EAAS;QAChC,OAAOF,OAAAA,CAAQG,KAAK,CAACjB,qBAAAA,CAAKkB,GAAG,CAAA,CAAEC,IAAI,CAACnB,qBAAAA,CAAKoB,KAAK,CAACF,GAAG,CAAA;AACpD,IAAA;IAEA,OAAOJ,OAAAA;AACT;AAEA;;;;;;IAOA,MAAMO,gCAAgC,CAACC,UAAAA,GAAAA;IACrC,IAAIP,OAAAA,CAAQC,QAAQ,KAAK,OAAA,EAAS;QAChC,OAAOM,UAAAA,CAAWL,KAAK,CAACjB,qBAAAA,CAAKoB,KAAK,CAACF,GAAG,CAAA,CAAEC,IAAI,CAACnB,qBAAAA,CAAKkB,GAAG,CAAA;AACvD,IAAA;IAEA,OAAOI,UAAAA;AACT;;;;;;;"}
@@ -3,6 +3,10 @@
3
3
  var path = require('node:path');
4
4
  var resolveModule = require('./resolve-module.js');
5
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+
6
10
  const DESIGN_SYSTEM_MODULE = '@strapi/design-system';
7
11
  /**
8
12
  * Detect if a package is locally linked (portal:, file:, yarn link) rather than installed in node_modules.
@@ -11,7 +15,7 @@ const DESIGN_SYSTEM_MODULE = '@strapi/design-system';
11
15
  * @internal
12
16
  */ const isPackageLinked = (mod)=>{
13
17
  const pkgRoot = resolveModule.getModulePath(mod);
14
- const pathSegments = pkgRoot.split(path.sep);
18
+ const pathSegments = pkgRoot.split(path__default.default.sep);
15
19
  return !pathSegments.includes('node_modules');
16
20
  };
17
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"linked-packages.js","sources":["../../../../src/node/core/linked-packages.ts"],"sourcesContent":["import path from 'node:path';\nimport { getModulePath } from './resolve-module';\n\nconst DESIGN_SYSTEM_MODULE = '@strapi/design-system';\n\n/**\n * Detect if a package is locally linked (portal:, file:, yarn link) rather than installed in node_modules.\n * When linked, the resolved path is outside node_modules.\n *\n * @internal\n */\nexport const isPackageLinked = (mod: string): boolean => {\n const pkgRoot = getModulePath(mod);\n const pathSegments = pkgRoot.split(path.sep);\n return !pathSegments.includes('node_modules');\n};\n\n/**\n * Detects if @strapi/design-system is linked (portal:, file:, or yarn link).\n * Returns the package root path when linked, null otherwise.\n * Uses the heuristic: linked packages resolve outside node_modules.\n */\nexport const getLinkedDesignSystemPath = (): string | null => {\n try {\n const pkgRoot = getModulePath(DESIGN_SYSTEM_MODULE);\n return isPackageLinked(DESIGN_SYSTEM_MODULE) ? pkgRoot : null;\n } catch {\n return null;\n }\n};\n\nexport const isDesignSystemLinked = (): boolean => getLinkedDesignSystemPath() !== null;\n"],"names":["DESIGN_SYSTEM_MODULE","isPackageLinked","mod","pkgRoot","getModulePath","pathSegments","split","path","sep","includes","getLinkedDesignSystemPath","isDesignSystemLinked"],"mappings":";;;;;AAGA,MAAMA,oBAAAA,GAAuB,uBAAA;AAE7B;;;;;IAMO,MAAMC,eAAAA,GAAkB,CAACC,GAAAA,GAAAA;AAC9B,IAAA,MAAMC,UAAUC,2BAAAA,CAAcF,GAAAA,CAAAA;AAC9B,IAAA,MAAMG,YAAAA,GAAeF,OAAAA,CAAQG,KAAK,CAACC,KAAKC,GAAG,CAAA;IAC3C,OAAO,CAACH,YAAAA,CAAaI,QAAQ,CAAC,cAAA,CAAA;AAChC;AAEA;;;;UAKaC,yBAAAA,GAA4B,IAAA;IACvC,IAAI;AACF,QAAA,MAAMP,UAAUC,2BAAAA,CAAcJ,oBAAAA,CAAAA;QAC9B,OAAOC,eAAAA,CAAgBD,wBAAwBG,OAAAA,GAAU,IAAA;AAC3D,IAAA,CAAA,CAAE,OAAM;QACN,OAAO,IAAA;AACT,IAAA;AACF;AAEO,MAAMQ,oBAAAA,GAAuB,IAAeD,yBAAAA,EAAAA,KAAgC;;;;;;"}
1
+ {"version":3,"file":"linked-packages.js","sources":["../../../../src/node/core/linked-packages.ts"],"sourcesContent":["import path from 'node:path';\nimport { getModulePath } from './resolve-module';\n\nconst DESIGN_SYSTEM_MODULE = '@strapi/design-system';\n\n/**\n * Detect if a package is locally linked (portal:, file:, yarn link) rather than installed in node_modules.\n * When linked, the resolved path is outside node_modules.\n *\n * @internal\n */\nexport const isPackageLinked = (mod: string): boolean => {\n const pkgRoot = getModulePath(mod);\n const pathSegments = pkgRoot.split(path.sep);\n return !pathSegments.includes('node_modules');\n};\n\n/**\n * Detects if @strapi/design-system is linked (portal:, file:, or yarn link).\n * Returns the package root path when linked, null otherwise.\n * Uses the heuristic: linked packages resolve outside node_modules.\n */\nexport const getLinkedDesignSystemPath = (): string | null => {\n try {\n const pkgRoot = getModulePath(DESIGN_SYSTEM_MODULE);\n return isPackageLinked(DESIGN_SYSTEM_MODULE) ? pkgRoot : null;\n } catch {\n return null;\n }\n};\n\nexport const isDesignSystemLinked = (): boolean => getLinkedDesignSystemPath() !== null;\n"],"names":["DESIGN_SYSTEM_MODULE","isPackageLinked","mod","pkgRoot","getModulePath","pathSegments","split","path","sep","includes","getLinkedDesignSystemPath","isDesignSystemLinked"],"mappings":";;;;;;;;;AAGA,MAAMA,oBAAAA,GAAuB,uBAAA;AAE7B;;;;;IAMO,MAAMC,eAAAA,GAAkB,CAACC,GAAAA,GAAAA;AAC9B,IAAA,MAAMC,UAAUC,2BAAAA,CAAcF,GAAAA,CAAAA;AAC9B,IAAA,MAAMG,YAAAA,GAAeF,OAAAA,CAAQG,KAAK,CAACC,sBAAKC,GAAG,CAAA;IAC3C,OAAO,CAACH,YAAAA,CAAaI,QAAQ,CAAC,cAAA,CAAA;AAChC;AAEA;;;;UAKaC,yBAAAA,GAA4B,IAAA;IACvC,IAAI;AACF,QAAA,MAAMP,UAAUC,2BAAAA,CAAcJ,oBAAAA,CAAAA;QAC9B,OAAOC,eAAAA,CAAgBD,wBAAwBG,OAAAA,GAAU,IAAA;AAC3D,IAAA,CAAA,CAAE,OAAM;QACN,OAAO,IAAA;AACT,IAAA;AACF;AAEO,MAAMQ,oBAAAA,GAAuB,IAAeD,yBAAAA,EAAAA,KAAgC;;;;;;"}
@@ -3,6 +3,11 @@
3
3
  var path = require('path');
4
4
  var readPkgUp = require('read-pkg-up');
5
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+ var readPkgUp__default = /*#__PURE__*/_interopDefault(readPkgUp);
10
+
6
11
  /**
7
12
  * Load information about the strapi CMS monorepo (if applicable)
8
13
  *
@@ -10,7 +15,7 @@ var readPkgUp = require('read-pkg-up');
10
15
  */ async function loadStrapiMonorepo(cwd) {
11
16
  let p = cwd;
12
17
  while(p !== '/'){
13
- const readResult = await readPkgUp({
18
+ const readResult = await readPkgUp__default.default({
14
19
  cwd: p
15
20
  });
16
21
  if (!readResult) {
@@ -18,10 +23,10 @@ var readPkgUp = require('read-pkg-up');
18
23
  }
19
24
  if (readResult.packageJson.isStrapiMonorepo) {
20
25
  return {
21
- path: path.dirname(readResult.path)
26
+ path: path__default.default.dirname(readResult.path)
22
27
  };
23
28
  }
24
- p = path.dirname(path.dirname(readResult.path));
29
+ p = path__default.default.dirname(path__default.default.dirname(readResult.path));
25
30
  }
26
31
  return undefined;
27
32
  }
@@ -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":["loadStrapiMonorepo","cwd","p","readResult","readPkgUp","undefined","packageJson","isStrapiMonorepo","path","dirname"],"mappings":";;;;;AAOA;;;;IAKA,eAAeA,mBAAmBC,GAAW,EAAA;AAC3C,IAAA,IAAIC,CAAAA,GAAID,GAAAA;AAER,IAAA,MAAOC,MAAM,GAAA,CAAK;QAChB,MAAMC,UAAAA,GAAa,MAAMC,SAAAA,CAAU;YAAEH,GAAAA,EAAKC;AAAE,SAAA,CAAA;AAE5C,QAAA,IAAI,CAACC,UAAAA,EAAY;YACf,OAAOE,SAAAA;AACT,QAAA;AAEA,QAAA,IAAIF,UAAAA,CAAWG,WAAW,CAACC,gBAAgB,EAAE;YAC3C,OAAO;AAAEC,gBAAAA,IAAAA,EAAMA,IAAAA,CAAKC,OAAO,CAACN,UAAAA,CAAWK,IAAI;AAAE,aAAA;AAC/C,QAAA;AAEAN,QAAAA,CAAAA,GAAIM,KAAKC,OAAO,CAACD,KAAKC,OAAO,CAACN,WAAWK,IAAI,CAAA,CAAA;AAC/C,IAAA;IAEA,OAAOH,SAAAA;AACT;;;;"}
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":["loadStrapiMonorepo","cwd","p","readResult","readPkgUp","undefined","packageJson","isStrapiMonorepo","path","dirname"],"mappings":";;;;;;;;;;AAOA;;;;IAKA,eAAeA,mBAAmBC,GAAW,EAAA;AAC3C,IAAA,IAAIC,CAAAA,GAAID,GAAAA;AAER,IAAA,MAAOC,MAAM,GAAA,CAAK;QAChB,MAAMC,UAAAA,GAAa,MAAMC,0BAAAA,CAAU;YAAEH,GAAAA,EAAKC;AAAE,SAAA,CAAA;AAE5C,QAAA,IAAI,CAACC,UAAAA,EAAY;YACf,OAAOE,SAAAA;AACT,QAAA;AAEA,QAAA,IAAIF,UAAAA,CAAWG,WAAW,CAACC,gBAAgB,EAAE;YAC3C,OAAO;AAAEC,gBAAAA,IAAAA,EAAMA,qBAAAA,CAAKC,OAAO,CAACN,UAAAA,CAAWK,IAAI;AAAE,aAAA;AAC/C,QAAA;AAEAN,QAAAA,CAAAA,GAAIM,sBAAKC,OAAO,CAACD,sBAAKC,OAAO,CAACN,WAAWK,IAAI,CAAA,CAAA;AAC/C,IAAA;IAEA,OAAOH,SAAAA;AACT;;;;"}
@@ -9,8 +9,21 @@ var dependencies = require('./dependencies.js');
9
9
  var files = require('./files.js');
10
10
  var errors = require('./errors.js');
11
11
 
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var os__default = /*#__PURE__*/_interopDefault(os);
15
+ var path__default = /*#__PURE__*/_interopDefault(path);
16
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
+ var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
18
+
12
19
  const validatePackageHasStrapi = (pkg)=>'strapi' in pkg && typeof pkg.strapi === 'object' && !Array.isArray(pkg.strapi) && pkg.strapi !== null;
13
20
  const validatePackageIsPlugin = (pkg)=>validatePackageHasStrapi(pkg) && pkg.strapi.kind === 'plugin';
21
+ const isPluginConfigEnabled = (config)=>{
22
+ if (typeof config === 'boolean') {
23
+ return config;
24
+ }
25
+ return config.enabled !== false;
26
+ };
14
27
  const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
15
28
  const plugins = {};
16
29
  /**
@@ -18,7 +31,9 @@ const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
18
31
  * It will include libraries like "react", so we need to collect the ones that
19
32
  * are plugins.
20
33
  */ const deps = strapi.config.get('info.dependencies', {});
21
- logger.debug("Dependencies from user's project", os.EOL, deps);
34
+ logger.debug("Dependencies from user's project", os__default.default.EOL, deps);
35
+ const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);
36
+ logger.debug("User's plugins file", os__default.default.EOL, userPluginsFile);
22
37
  for (const dep of Object.keys(deps)){
23
38
  const pkg = await dependencies.getModule(dep, cwd);
24
39
  if (pkg && validatePackageIsPlugin(pkg)) {
@@ -28,27 +43,35 @@ const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
28
43
  * Unlikely to happen, but you never know.
29
44
  */ throw Error("You're trying to import a plugin that doesn't have a name – check the package.json of that plugin!");
30
45
  }
46
+ const userPluginConfig = userPluginsFile[name];
47
+ if (userPluginConfig !== undefined && !isPluginConfigEnabled(userPluginConfig)) {
48
+ continue;
49
+ }
31
50
  plugins[name] = {
32
51
  name,
33
- importName: camelCase(name),
52
+ importName: camelCase__default.default(name),
34
53
  type: 'module',
35
54
  modulePath: dep
36
55
  };
37
56
  }
38
57
  }
39
- const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);
40
- logger.debug("User's plugins file", os.EOL, userPluginsFile);
41
58
  for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)){
42
- if (userPluginConfig.enabled && userPluginConfig.resolve) {
59
+ /**
60
+ * Local plugins must be explicitly enabled to be registered, matching the
61
+ * server-side loader (`@strapi/core` get-enabled-plugins), which drops a
62
+ * `{ resolve }` declaration without a truthy `enabled`. Treating an omitted
63
+ * `enabled` as enabled here would bundle the plugin into the admin while the
64
+ * server leaves it unloaded.
65
+ */ if (typeof userPluginConfig === 'object' && userPluginConfig.enabled && userPluginConfig.resolve) {
43
66
  const sysPath = files.convertModulePathToSystemPath(userPluginConfig.resolve);
44
67
  plugins[userPluginName] = {
45
68
  name: userPluginName,
46
- importName: camelCase(userPluginName),
69
+ importName: camelCase__default.default(userPluginName),
47
70
  type: 'local',
48
71
  /**
49
72
  * User plugin paths are resolved from the entry point
50
73
  * of the app, because that's how you import them.
51
- */ modulePath: files.convertSystemPathToModulePath(path.relative(runtimeDir, sysPath)),
74
+ */ modulePath: files.convertSystemPathToModulePath(path__default.default.relative(runtimeDir, sysPath)),
52
75
  path: sysPath
53
76
  };
54
77
  }
@@ -62,7 +85,7 @@ const PLUGIN_CONFIGS = [
62
85
  ];
63
86
  const loadUserPluginsFile = async (root)=>{
64
87
  for (const file of PLUGIN_CONFIGS){
65
- const filePath = path.join(root, file);
88
+ const filePath = path__default.default.join(root, file);
66
89
  const configFile = await files.loadFile(filePath);
67
90
  if (configFile) {
68
91
  /**
@@ -99,9 +122,9 @@ const getMapOfPluginsWithAdmin = (plugins)=>{
99
122
  const localPluginPath = plugin.path;
100
123
  if (localPluginPath) {
101
124
  // Here we are loading a locally installed plugin
102
- const packageJsonPath = path.join(localPluginPath, 'package.json');
103
- if (fs.existsSync(packageJsonPath)) {
104
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
125
+ const packageJsonPath = path__default.default.join(localPluginPath, 'package.json');
126
+ if (fs__default.default.existsSync(packageJsonPath)) {
127
+ const packageJson = JSON.parse(fs__default.default.readFileSync(packageJsonPath, 'utf-8'));
105
128
  const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;
106
129
  if (localAdminPath) {
107
130
  pluginImportPaths[plugin.modulePath] = localAdminPath;
@@ -109,7 +132,7 @@ const getMapOfPluginsWithAdmin = (plugins)=>{
109
132
  }
110
133
  }
111
134
  // Check if legacy admin file exists in local plugin
112
- if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {
135
+ if (fs__default.default.existsSync(path__default.default.join(localPluginPath, 'strapi-admin.js'))) {
113
136
  pluginImportPaths[plugin.modulePath] = 'strapi-admin';
114
137
  return true;
115
138
  }
@@ -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":["validatePackageHasStrapi","pkg","strapi","Array","isArray","validatePackageIsPlugin","kind","getEnabledPlugins","cwd","logger","runtimeDir","plugins","deps","config","get","debug","os","EOL","dep","Object","keys","getModule","name","Error","importName","camelCase","type","modulePath","userPluginsFile","loadUserPluginsFile","dirs","app","userPluginName","userPluginConfig","entries","enabled","resolve","sysPath","convertModulePathToSystemPath","convertSystemPathToModulePath","path","relative","PLUGIN_CONFIGS","root","file","filePath","join","configFile","loadFile","env","getMapOfPluginsWithAdmin","pluginImportPaths","values","filter","plugin","localPluginPath","packageJsonPath","fs","existsSync","packageJson","JSON","parse","readFileSync","localAdminPath","exports","import","require","err","isError","code","map"],"mappings":";;;;;;;;;;;AA6DA,MAAMA,2BAA2B,CAC/BC,GAAAA,GAEA,YAAYA,GAAAA,IACZ,OAAOA,IAAIC,MAAM,KAAK,YACtB,CAACC,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAIC,MAAM,CAAA,IACzBD,GAAAA,CAAIC,MAAM,KAAK,IAAA;AAEjB,MAAMG,uBAAAA,GAA0B,CAACJ,GAAAA,GAC/BD,wBAAAA,CAAyBC,QAAQA,GAAAA,CAAIC,MAAM,CAACI,IAAI,KAAK,QAAA;AAEvD,MAAMC,iBAAAA,GAAoB,OAAO,EAC/BC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVR,MAAM,EACwD,GAAA;AAG9D,IAAA,MAAMS,UAAsC,EAAC;AAE7C;;;;MAKA,MAAMC,OAAOV,MAAAA,CAAOW,MAAM,CAACC,GAAG,CAAC,qBAAqB,EAAC,CAAA;AAErDL,IAAAA,MAAAA,CAAOM,KAAK,CAAC,kCAAA,EAAoCC,EAAAA,CAAGC,GAAG,EAAEL,IAAAA,CAAAA;AAEzD,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACR,IAAAA,CAAAA,CAAO;QACnC,MAAMX,GAAAA,GAAM,MAAMoB,sBAAAA,CAAUH,GAAAA,EAAKV,GAAAA,CAAAA;QAEjC,IAAIP,GAAAA,IAAOI,wBAAwBJ,GAAAA,CAAAA,EAAM;AACvC,YAAA,MAAMqB,OAAOrB,GAAAA,CAAIC,MAAM,CAACoB,IAAI,IAAIrB,IAAIqB,IAAI;AAExC,YAAA,IAAI,CAACA,IAAAA,EAAM;AACT;;AAEC,YACD,MAAMC,KAAAA,CACJ,oGAA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AClB,KAAKM,IAAI,CAACS,iBAAiB,iBAAA,CAAA,CAAA,EAAqB;AAChEJ,oBAAAA,iBAAiB,CAACG,MAAAA,CAAO3B,UAAU,CAAC,GAAG,cAAA;oBACvC,OAAO,IAAA;AACT,gBAAA;AACF,YAAA;;YAGA,IAAIuC,OAAAA,CAAQ9B,OAAO,CAAC,CAAA,EAAGkB,OAAO3B,UAAU,CAAC,aAAa,CAAC,CAAA,EAAG;AACxDwB,gBAAAA,iBAAiB,CAACG,MAAAA,CAAO3B,UAAU,CAAC,GAAG,cAAA;gBACvC,OAAO,IAAA;AACT,YAAA;YAEA,OAAO,KAAA;AACT,QAAA,CAAA,CAAE,OAAOwC,GAAAA,EAAK;AACZ,YAAA,IACEC,cAAAA,CAAQD,GAAAA,CAAAA,IACR,MAAA,IAAUA,GAAAA,KACTA,GAAAA,CAAIE,IAAI,KAAK,kBAAA,IAAsBF,GAAAA,CAAIE,IAAI,KAAK,+BAA8B,CAAA,EAC/E;AACA;;;AAGC,cACD,OAAO,KAAA;AACT,YAAA;YAEA,MAAMF,GAAAA;AACR,QAAA;AACF,IAAA,CAAA,CAAA,CACCG,GAAG,CAAC,CAAChB,MAAAA,IAAY;AAChB,YAAA,GAAGA,MAAM;YACT3B,UAAAA,EAAY,CAAA,EAAG2B,MAAAA,CAAO3B,UAAU,CAAC,CAAC,EAAEwB,iBAAiB,CAACG,MAAAA,CAAO3B,UAAU,CAAC,CAAA;SAC1E,CAAA,CAAA;AACJ;;;;;"}
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\ntype UserPluginConfig = boolean | { enabled?: boolean; resolve?: string };\n\nconst isPluginConfigEnabled = (config: UserPluginConfig): boolean => {\n if (typeof config === 'boolean') {\n return config;\n }\n\n return config.enabled !== false;\n};\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 const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);\n\n logger.debug(\"User's plugins file\", os.EOL, userPluginsFile);\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 const userPluginConfig = userPluginsFile[name];\n\n if (userPluginConfig !== undefined && !isPluginConfigEnabled(userPluginConfig)) {\n continue;\n }\n\n plugins[name] = {\n name,\n importName: camelCase(name),\n type: 'module',\n modulePath: dep,\n };\n }\n }\n\n for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)) {\n /**\n * Local plugins must be explicitly enabled to be registered, matching the\n * server-side loader (`@strapi/core` get-enabled-plugins), which drops a\n * `{ resolve }` declaration without a truthy `enabled`. Treating an omitted\n * `enabled` as enabled here would bundle the plugin into the admin while the\n * server leaves it unloaded.\n */\n if (\n typeof userPluginConfig === 'object' &&\n userPluginConfig.enabled &&\n userPluginConfig.resolve\n ) {\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, UserPluginConfig>;\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":["validatePackageHasStrapi","pkg","strapi","Array","isArray","validatePackageIsPlugin","kind","isPluginConfigEnabled","config","enabled","getEnabledPlugins","cwd","logger","runtimeDir","plugins","deps","get","debug","os","EOL","userPluginsFile","loadUserPluginsFile","dirs","app","dep","Object","keys","getModule","name","Error","userPluginConfig","undefined","importName","camelCase","type","modulePath","userPluginName","entries","resolve","sysPath","convertModulePathToSystemPath","convertSystemPathToModulePath","path","relative","PLUGIN_CONFIGS","root","file","filePath","join","configFile","loadFile","env","getMapOfPluginsWithAdmin","pluginImportPaths","values","filter","plugin","localPluginPath","packageJsonPath","fs","existsSync","packageJson","JSON","parse","readFileSync","localAdminPath","exports","import","require","err","isError","code","map"],"mappings":";;;;;;;;;;;;;;;;;;AA6DA,MAAMA,2BAA2B,CAC/BC,GAAAA,GAEA,YAAYA,GAAAA,IACZ,OAAOA,IAAIC,MAAM,KAAK,YACtB,CAACC,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAIC,MAAM,CAAA,IACzBD,GAAAA,CAAIC,MAAM,KAAK,IAAA;AAEjB,MAAMG,uBAAAA,GAA0B,CAACJ,GAAAA,GAC/BD,wBAAAA,CAAyBC,QAAQA,GAAAA,CAAIC,MAAM,CAACI,IAAI,KAAK,QAAA;AAIvD,MAAMC,wBAAwB,CAACC,MAAAA,GAAAA;IAC7B,IAAI,OAAOA,WAAW,SAAA,EAAW;QAC/B,OAAOA,MAAAA;AACT,IAAA;IAEA,OAAOA,MAAAA,CAAOC,OAAO,KAAK,KAAA;AAC5B,CAAA;AAEA,MAAMC,iBAAAA,GAAoB,OAAO,EAC/BC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVX,MAAM,EACwD,GAAA;AAG9D,IAAA,MAAMY,UAAsC,EAAC;AAE7C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AAOkC,GAAAA,EAAK;AACZ,YAAA,IACEC,cAAAA,CAAQD,GAAAA,CAAAA,IACR,MAAA,IAAUA,GAAAA,KACTA,GAAAA,CAAIE,IAAI,KAAK,kBAAA,IAAsBF,GAAAA,CAAIE,IAAI,KAAK,+BAA8B,CAAA,EAC/E;AACA;;;AAGC,cACD,OAAO,KAAA;AACT,YAAA;YAEA,MAAMF,GAAAA;AACR,QAAA;AACF,IAAA,CAAA,CAAA,CACCG,GAAG,CAAC,CAAChB,MAAAA,IAAY;AAChB,YAAA,GAAGA,MAAM;YACTrB,UAAAA,EAAY,CAAA,EAAGqB,MAAAA,CAAOrB,UAAU,CAAC,CAAC,EAAEkB,iBAAiB,CAACG,MAAAA,CAAOrB,UAAU,CAAC,CAAA;SAC1E,CAAA,CAAA;AACJ;;;;;"}
@@ -9,6 +9,12 @@ import { isError } from './errors.mjs';
9
9
 
10
10
  const validatePackageHasStrapi = (pkg)=>'strapi' in pkg && typeof pkg.strapi === 'object' && !Array.isArray(pkg.strapi) && pkg.strapi !== null;
11
11
  const validatePackageIsPlugin = (pkg)=>validatePackageHasStrapi(pkg) && pkg.strapi.kind === 'plugin';
12
+ const isPluginConfigEnabled = (config)=>{
13
+ if (typeof config === 'boolean') {
14
+ return config;
15
+ }
16
+ return config.enabled !== false;
17
+ };
12
18
  const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
13
19
  const plugins = {};
14
20
  /**
@@ -17,6 +23,8 @@ const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
17
23
  * are plugins.
18
24
  */ const deps = strapi.config.get('info.dependencies', {});
19
25
  logger.debug("Dependencies from user's project", os.EOL, deps);
26
+ const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);
27
+ logger.debug("User's plugins file", os.EOL, userPluginsFile);
20
28
  for (const dep of Object.keys(deps)){
21
29
  const pkg = await getModule(dep, cwd);
22
30
  if (pkg && validatePackageIsPlugin(pkg)) {
@@ -26,6 +34,10 @@ const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
26
34
  * Unlikely to happen, but you never know.
27
35
  */ throw Error("You're trying to import a plugin that doesn't have a name – check the package.json of that plugin!");
28
36
  }
37
+ const userPluginConfig = userPluginsFile[name];
38
+ if (userPluginConfig !== undefined && !isPluginConfigEnabled(userPluginConfig)) {
39
+ continue;
40
+ }
29
41
  plugins[name] = {
30
42
  name,
31
43
  importName: camelCase(name),
@@ -34,10 +46,14 @@ const getEnabledPlugins = async ({ cwd, logger, runtimeDir, strapi })=>{
34
46
  };
35
47
  }
36
48
  }
37
- const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);
38
- logger.debug("User's plugins file", os.EOL, userPluginsFile);
39
49
  for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)){
40
- if (userPluginConfig.enabled && userPluginConfig.resolve) {
50
+ /**
51
+ * Local plugins must be explicitly enabled to be registered, matching the
52
+ * server-side loader (`@strapi/core` get-enabled-plugins), which drops a
53
+ * `{ resolve }` declaration without a truthy `enabled`. Treating an omitted
54
+ * `enabled` as enabled here would bundle the plugin into the admin while the
55
+ * server leaves it unloaded.
56
+ */ if (typeof userPluginConfig === 'object' && userPluginConfig.enabled && userPluginConfig.resolve) {
41
57
  const sysPath = convertModulePathToSystemPath(userPluginConfig.resolve);
42
58
  plugins[userPluginName] = {
43
59
  name: userPluginName,
@@ -1 +1 @@
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":["validatePackageHasStrapi","pkg","strapi","Array","isArray","validatePackageIsPlugin","kind","getEnabledPlugins","cwd","logger","runtimeDir","plugins","deps","config","get","debug","os","EOL","dep","Object","keys","getModule","name","Error","importName","camelCase","type","modulePath","userPluginsFile","loadUserPluginsFile","dirs","app","userPluginName","userPluginConfig","entries","enabled","resolve","sysPath","convertModulePathToSystemPath","convertSystemPathToModulePath","path","relative","PLUGIN_CONFIGS","root","file","filePath","join","configFile","loadFile","env","getMapOfPluginsWithAdmin","pluginImportPaths","values","filter","plugin","localPluginPath","packageJsonPath","fs","existsSync","packageJson","JSON","parse","readFileSync","localAdminPath","exports","import","require","err","isError","code","map"],"mappings":";;;;;;;;;AA6DA,MAAMA,2BAA2B,CAC/BC,GAAAA,GAEA,YAAYA,GAAAA,IACZ,OAAOA,IAAIC,MAAM,KAAK,YACtB,CAACC,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAIC,MAAM,CAAA,IACzBD,GAAAA,CAAIC,MAAM,KAAK,IAAA;AAEjB,MAAMG,uBAAAA,GAA0B,CAACJ,GAAAA,GAC/BD,wBAAAA,CAAyBC,QAAQA,GAAAA,CAAIC,MAAM,CAACI,IAAI,KAAK,QAAA;AAEvD,MAAMC,iBAAAA,GAAoB,OAAO,EAC/BC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVR,MAAM,EACwD,GAAA;AAG9D,IAAA,MAAMS,UAAsC,EAAC;AAE7C;;;;MAKA,MAAMC,OAAOV,MAAAA,CAAOW,MAAM,CAACC,GAAG,CAAC,qBAAqB,EAAC,CAAA;AAErDL,IAAAA,MAAAA,CAAOM,KAAK,CAAC,kCAAA,EAAoCC,EAAAA,CAAGC,GAAG,EAAEL,IAAAA,CAAAA;AAEzD,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACR,IAAAA,CAAAA,CAAO;QACnC,MAAMX,GAAAA,GAAM,MAAMoB,SAAAA,CAAUH,GAAAA,EAAKV,GAAAA,CAAAA;QAEjC,IAAIP,GAAAA,IAAOI,wBAAwBJ,GAAAA,CAAAA,EAAM;AACvC,YAAA,MAAMqB,OAAOrB,GAAAA,CAAIC,MAAM,CAACoB,IAAI,IAAIrB,IAAIqB,IAAI;AAExC,YAAA,IAAI,CAACA,IAAAA,EAAM;AACT;;AAEC,YACD,MAAMC,KAAAA,CACJ,oGAAA,CAAA;AAEJ,YAAA;YAEAZ,OAAO,CAACW,KAAK,GAAG;AACdA,gBAAAA,IAAAA;AACAE,gBAAAA,U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AAAA,CAAO3B,UAAU,CAAC,GAAG,cAAA;oBACvC,OAAO,IAAA;AACT,gBAAA;AACF,YAAA;;YAGA,IAAIuC,OAAAA,CAAQ9B,OAAO,CAAC,CAAA,EAAGkB,OAAO3B,UAAU,CAAC,aAAa,CAAC,CAAA,EAAG;AACxDwB,gBAAAA,iBAAiB,CAACG,MAAAA,CAAO3B,UAAU,CAAC,GAAG,cAAA;gBACvC,OAAO,IAAA;AACT,YAAA;YAEA,OAAO,KAAA;AACT,QAAA,CAAA,CAAE,OAAOwC,GAAAA,EAAK;AACZ,YAAA,IACEC,OAAAA,CAAQD,GAAAA,CAAAA,IACR,MAAA,IAAUA,GAAAA,KACTA,GAAAA,CAAIE,IAAI,KAAK,kBAAA,IAAsBF,GAAAA,CAAIE,IAAI,KAAK,+BAA8B,CAAA,EAC/E;AACA;;;AAGC,cACD,OAAO,KAAA;AACT,YAAA;YAEA,MAAMF,GAAAA;AACR,QAAA;AACF,IAAA,CAAA,CAAA,CACCG,GAAG,CAAC,CAAChB,MAAAA,IAAY;AAChB,YAAA,GAAGA,MAAM;YACT3B,UAAAA,EAAY,CAAA,EAAG2B,MAAAA,CAAO3B,UAAU,CAAC,CAAC,EAAEwB,iBAAiB,CAACG,MAAAA,CAAO3B,UAAU,CAAC,CAAA;SAC1E,CAAA,CAAA;AACJ;;;;"}
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\ntype UserPluginConfig = boolean | { enabled?: boolean; resolve?: string };\n\nconst isPluginConfigEnabled = (config: UserPluginConfig): boolean => {\n if (typeof config === 'boolean') {\n return config;\n }\n\n return config.enabled !== false;\n};\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 const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);\n\n logger.debug(\"User's plugins file\", os.EOL, userPluginsFile);\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 const userPluginConfig = userPluginsFile[name];\n\n if (userPluginConfig !== undefined && !isPluginConfigEnabled(userPluginConfig)) {\n continue;\n }\n\n plugins[name] = {\n name,\n importName: camelCase(name),\n type: 'module',\n modulePath: dep,\n };\n }\n }\n\n for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)) {\n /**\n * Local plugins must be explicitly enabled to be registered, matching the\n * server-side loader (`@strapi/core` get-enabled-plugins), which drops a\n * `{ resolve }` declaration without a truthy `enabled`. Treating an omitted\n * `enabled` as enabled here would bundle the plugin into the admin while the\n * server leaves it unloaded.\n */\n if (\n typeof userPluginConfig === 'object' &&\n userPluginConfig.enabled &&\n userPluginConfig.resolve\n ) {\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, UserPluginConfig>;\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":["validatePackageHasStrapi","pkg","strapi","Array","isArray","validatePackageIsPlugin","kind","isPluginConfigEnabled","config","enabled","getEnabledPlugins","cwd","logger","runtimeDir","plugins","deps","get","debug","os","EOL","userPluginsFile","loadUserPluginsFile","dirs","app","dep","Object","keys","getModule","name","Error","userPluginConfig","undefined","importName","camelCase","type","modulePath","userPluginName","entries","resolve","sysPath","convertModulePathToSystemPath","convertSystemPathToModulePath","path","relative","PLUGIN_CONFIGS","root","file","filePath","join","configFile","loadFile","env","getMapOfPluginsWithAdmin","pluginImportPaths","values","filter","plugin","localPluginPath","packageJsonPath","fs","existsSync","packageJson","JSON","parse","readFileSync","localAdminPath","exports","import","require","err","isError","code","map"],"mappings":";;;;;;;;;AA6DA,MAAMA,2BAA2B,CAC/BC,GAAAA,GAEA,YAAYA,GAAAA,IACZ,OAAOA,IAAIC,MAAM,KAAK,YACtB,CAACC,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAIC,MAAM,CAAA,IACzBD,GAAAA,CAAIC,MAAM,KAAK,IAAA;AAEjB,MAAMG,uBAAAA,GAA0B,CAACJ,GAAAA,GAC/BD,wBAAAA,CAAyBC,QAAQA,GAAAA,CAAIC,MAAM,CAACI,IAAI,KAAK,QAAA;AAIvD,MAAMC,wBAAwB,CAACC,MAAAA,GAAAA;IAC7B,IAAI,OAAOA,WAAW,SAAA,EAAW;QAC/B,OAAOA,MAAAA;AACT,IAAA;IAEA,OAAOA,MAAAA,CAAOC,OAAO,KAAK,KAAA;AAC5B,CAAA;AAEA,MAAMC,iBAAAA,GAAoB,OAAO,EAC/BC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVX,MAAM,EACwD,GAAA;AAG9D,IAAA,MAAMY,UAAsC,EAAC;AAE7C;;;;MAKA,MAAMC,OAAOb,MAAAA,CAAOM,MAAM,CAACQ,GAAG,CAAC,qBAAqB,EAAC,CAAA;AAErDJ,IAAAA,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AI,KAAK,kBAAA,IAAsBF,GAAAA,CAAIE,IAAI,KAAK,+BAA8B,CAAA,EAC/E;AACA;;;AAGC,cACD,OAAO,KAAA;AACT,YAAA;YAEA,MAAMF,GAAAA;AACR,QAAA;AACF,IAAA,CAAA,CAAA,CACCG,GAAG,CAAC,CAAChB,MAAAA,IAAY;AAChB,YAAA,GAAGA,MAAM;YACTrB,UAAAA,EAAY,CAAA,EAAGqB,MAAAA,CAAOrB,UAAU,CAAC,CAAC,EAAEkB,iBAAiB,CAACG,MAAAA,CAAOrB,UAAU,CAAC,CAAA;SAC1E,CAAA,CAAA;AACJ;;;;"}
@@ -3,6 +3,11 @@
3
3
  var path = require('node:path');
4
4
  var readPkgUp = require('read-pkg-up');
5
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+ var readPkgUp__default = /*#__PURE__*/_interopDefault(readPkgUp);
10
+
6
11
  /**
7
12
  * Resolve module to package root for use in aliases.
8
13
  * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.
@@ -10,10 +15,10 @@ var readPkgUp = require('read-pkg-up');
10
15
  * @internal
11
16
  */ const getModulePath = (mod)=>{
12
17
  const modulePath = require.resolve(mod);
13
- const pkg = readPkgUp.sync({
14
- cwd: path.dirname(modulePath)
18
+ const pkg = readPkgUp__default.default.sync({
19
+ cwd: path__default.default.dirname(modulePath)
15
20
  });
16
- return pkg ? path.dirname(pkg.path) : modulePath;
21
+ return pkg ? path__default.default.dirname(pkg.path) : modulePath;
17
22
  };
18
23
 
19
24
  exports.getModulePath = getModulePath;
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-module.js","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath = require.resolve(mod);\n const pkg = readPkgUp.sync({ cwd: path.dirname(modulePath) });\n return pkg ? path.dirname(pkg.path) : modulePath;\n};\n"],"names":["getModulePath","mod","modulePath","require","resolve","pkg","readPkgUp","sync","cwd","path","dirname"],"mappings":";;;;;AAGA;;;;;IAMO,MAAMA,aAAAA,GAAgB,CAACC,GAAAA,GAAAA;IAC5B,MAAMC,UAAAA,GAAaC,OAAAA,CAAQC,OAAO,CAACH,GAAAA,CAAAA;IACnC,MAAMI,GAAAA,GAAMC,SAAAA,CAAUC,IAAI,CAAC;QAAEC,GAAAA,EAAKC,IAAAA,CAAKC,OAAO,CAACR,UAAAA;AAAY,KAAA,CAAA;AAC3D,IAAA,OAAOG,MAAMI,IAAAA,CAAKC,OAAO,CAACL,GAAAA,CAAII,IAAI,CAAA,GAAIP,UAAAA;AACxC;;;;"}
1
+ {"version":3,"file":"resolve-module.js","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath = require.resolve(mod);\n const pkg = readPkgUp.sync({ cwd: path.dirname(modulePath) });\n return pkg ? path.dirname(pkg.path) : modulePath;\n};\n"],"names":["getModulePath","mod","modulePath","require","resolve","pkg","readPkgUp","sync","cwd","path","dirname"],"mappings":";;;;;;;;;;AAGA;;;;;IAMO,MAAMA,aAAAA,GAAgB,CAACC,GAAAA,GAAAA;IAC5B,MAAMC,UAAAA,GAAaC,OAAAA,CAAQC,OAAO,CAACH,GAAAA,CAAAA;IACnC,MAAMI,GAAAA,GAAMC,0BAAAA,CAAUC,IAAI,CAAC;QAAEC,GAAAA,EAAKC,qBAAAA,CAAKC,OAAO,CAACR,UAAAA;AAAY,KAAA,CAAA;AAC3D,IAAA,OAAOG,MAAMI,qBAAAA,CAAKC,OAAO,CAACL,GAAAA,CAAII,IAAI,CAAA,GAAIP,UAAAA;AACxC;;;;"}
@@ -9,6 +9,13 @@ var env = require('./core/env.js');
9
9
  var plugins = require('./core/plugins.js');
10
10
  var adminCustomisations = require('./core/admin-customisations.js');
11
11
 
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var os__default = /*#__PURE__*/_interopDefault(os);
15
+ var path__default = /*#__PURE__*/_interopDefault(path);
16
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
+ var browserslist__default = /*#__PURE__*/_interopDefault(browserslist);
18
+
12
19
  const DEFAULT_BROWSERSLIST = [
13
20
  'last 3 major versions',
14
21
  'Firefox ESR',
@@ -50,15 +57,15 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
50
57
  logger.debug([
51
58
  'Including the following ENV variables as part of the JS bundle:',
52
59
  ...envKeys.map((key)=>` - ${key}`)
53
- ].join(os.EOL));
60
+ ].join(os__default.default.EOL));
54
61
  }
55
- const distPath = path.join(strapiInstance.dirs.dist.root, 'build');
56
- const distDir = path.relative(cwd, distPath);
62
+ const distPath = path__default.default.join(strapiInstance.dirs.dist.root, 'build');
63
+ const distDir = path__default.default.relative(cwd, distPath);
57
64
  /**
58
65
  * If the distPath already exists, clean it
59
66
  */ try {
60
67
  logger.debug(`Cleaning dist folder: ${distPath}`);
61
- await fs.rm(distPath, {
68
+ await fs__default.default.rm(distPath, {
62
69
  recursive: true,
63
70
  force: true
64
71
  });
@@ -67,18 +74,18 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
67
74
  // do nothing, it will fail if the folder does not exist
68
75
  logger.debug('There was no dist folder to clean');
69
76
  }
70
- const runtimeDir = path.join(cwd, '.strapi', 'client');
71
- const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));
77
+ const runtimeDir = path__default.default.join(cwd, '.strapi', 'client');
78
+ const entry = path__default.default.relative(cwd, path__default.default.join(runtimeDir, 'app.js'));
72
79
  const plugins$1 = await plugins.getEnabledPlugins({
73
80
  cwd,
74
81
  logger,
75
82
  runtimeDir,
76
83
  strapi: strapiInstance
77
84
  });
78
- logger.debug('Enabled plugins', os.EOL, plugins$1);
85
+ logger.debug('Enabled plugins', os__default.default.EOL, plugins$1);
79
86
  const pluginsWithFront = plugins.getMapOfPluginsWithAdmin(plugins$1);
80
- logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);
81
- const target = browserslist.loadConfig({
87
+ logger.debug('Enabled plugins with FE', os__default.default.EOL, pluginsWithFront);
88
+ const target = browserslist__default.default.loadConfig({
82
89
  path: cwd
83
90
  }) ?? DEFAULT_BROWSERSLIST;
84
91
  const customisations = await adminCustomisations.loadUserAppFile({
@@ -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 type { 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 serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\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 adminPath,\n basePath: adminPublicPath,\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":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;AAkDA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,iBAAAA,CAAa;;QAEXC,MAAAA,EAAQP,GAAAA;QACRQ,OAAAA,EAASN,QAAAA,EAAUO,MAAAA,CAAOL,OAAAA,CAAQM,MAAAA,IAAU,EAAA;;QAE5CC,UAAAA,EAAY,IAAA;QACZC,eAAAA,EAAiB;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAAA,GAAoBR,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAAA,GAAmBV,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAAA,GAAYX,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,YAAA,CAAA;;IAGpD,MAAMG,UAAAA,GAAa,IAAIC,GAAAA,CAAIH,gBAAAA,CAAAA,CAAkBI,MAAM,KAAK,IAAID,GAAAA,CAAIL,iBAAAA,CAAAA,CAAmBM,MAAM;AAEzF,IAAA,MAAMC,eAAAA,GAAkB,IAAIF,GAAAA,CAAIH,gBAAAA,CAAAA,CA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E,IAAA,MAAMW,WAAW/D,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAC,UAAA,EAAYuD,SAAAA,CAAAA;AAEvD,IAAA,MAAM,EAAEC,OAAAA,GAAU,MAAM,EAAE,GAAGC,aAAa,GAAGnE,OAAAA;AAE7C,IAAA,MAAMoE,YAAAA,GAAe;AACnBjE,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;QACAyD,QAAAA,EAAUrD,eAAAA;AACVkD,QAAAA,OAAAA;AACAJ,QAAAA,cAAAA;AACAlE,QAAAA,GAAAA;AACAQ,QAAAA,OAAAA;AACAyC,QAAAA,QAAAA;AACAS,QAAAA,KAAAA;AACA/B,aAAAA,KAAAA;AACAyC,QAAAA,QAAAA;AACAnE,QAAAA,MAAAA;QACAG,OAAAA,EAASmE,WAAAA;QACTZ,OAAAA,EAASE,gBAAAA;AACTJ,QAAAA,UAAAA;QACAtD,MAAAA,EAAQE,cAAAA;AACR0D,QAAAA,MAAAA;AACA7D,QAAAA;AACF,KAAA;IAEA,OAAOsE,YAAAA;AACT;;;;"}
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 type { Core, Modules } from '@strapi/types';\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}\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 serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\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 adminPath,\n basePath: adminPublicPath,\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":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;;;;;;;;AA+CA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,iBAAAA,CAAa;;QAEXC,MAAAA,EAAQP,GAAAA;QACRQ,OAAAA,EAASN,QAAAA,EAAUO,MAAAA,CAAOL,OAAAA,CAAQM,MAAAA,IAAU,EAAA;;QAE5CC,UAAAA,EAAY,IAAA;QACZC,eAAAA,EAAiB;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAAA,GAAoBR,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAAA,GAAmBV,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAAA,GAAYX,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,YAAA,CAAA;;IAGpD,MAAMG,UAAAA,GAAa,IAAIC,GAAAA,CAAIH,gBAAAA,CA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