@strapi/strapi 5.0.0-rc.9 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin.d.ts CHANGED
@@ -3,4 +3,6 @@ declare const render: (mountNode: HTMLElement | null, { plugins, ...restArgs }:
3
3
  export { render as renderAdmin };
4
4
  export type { RenderAdminArgs };
5
5
  export * from '@strapi/admin/strapi-admin';
6
+ export { unstable_useDocumentLayout, unstable_useDocumentActions, unstable_useDocument, unstable_useContentManagerContext, useDocumentRBAC, } from '@strapi/content-manager/strapi-admin';
7
+ export { private_useAutoReloadOverlayBlocker, private_AutoReloadOverlayBlockerProvider, } from '@strapi/content-type-builder/strapi-admin';
6
8
  //# sourceMappingURL=admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAU1E,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,kBAiBvF,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAU1E,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,kBAiBvF,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,iCAAiC,EACjC,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,mCAAmC,EACnC,wCAAwC,GACzC,MAAM,2CAA2C,CAAC"}
package/dist/admin.js CHANGED
@@ -34,6 +34,34 @@ const render = (mountNode, { plugins, ...restArgs }) => {
34
34
  }
35
35
  });
36
36
  };
37
+ Object.defineProperty(exports, "private_AutoReloadOverlayBlockerProvider", {
38
+ enumerable: true,
39
+ get: () => contentTypeBuilder.private_AutoReloadOverlayBlockerProvider
40
+ });
41
+ Object.defineProperty(exports, "private_useAutoReloadOverlayBlocker", {
42
+ enumerable: true,
43
+ get: () => contentTypeBuilder.private_useAutoReloadOverlayBlocker
44
+ });
45
+ Object.defineProperty(exports, "unstable_useContentManagerContext", {
46
+ enumerable: true,
47
+ get: () => contentManager.unstable_useContentManagerContext
48
+ });
49
+ Object.defineProperty(exports, "unstable_useDocument", {
50
+ enumerable: true,
51
+ get: () => contentManager.unstable_useDocument
52
+ });
53
+ Object.defineProperty(exports, "unstable_useDocumentActions", {
54
+ enumerable: true,
55
+ get: () => contentManager.unstable_useDocumentActions
56
+ });
57
+ Object.defineProperty(exports, "unstable_useDocumentLayout", {
58
+ enumerable: true,
59
+ get: () => contentManager.unstable_useDocumentLayout
60
+ });
61
+ Object.defineProperty(exports, "useDocumentRBAC", {
62
+ enumerable: true,
63
+ get: () => contentManager.useDocumentRBAC
64
+ });
37
65
  exports.renderAdmin = render;
38
66
  Object.keys(strapiAdmin).forEach((k) => {
39
67
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
package/dist/admin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n"],"names":["renderAdmin","contentManager","contentTypeBuilder","email","upload","contentReleases","i18n","reviewWorkflows"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAOA,YAAAA,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmBC,wBAAA;AAAA,MACnB,wBAAwBC,4BAAA;AAAA;AAAA,MAAA,OAExBC,eAAA;AAAA,MAAA,QACAC,gBAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MAAA,MACAC,cAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;;;;;;;;;"}
1
+ {"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n\nexport {\n unstable_useDocumentLayout,\n unstable_useDocumentActions,\n unstable_useDocument,\n unstable_useContentManagerContext,\n useDocumentRBAC,\n} from '@strapi/content-manager/strapi-admin';\n\nexport {\n private_useAutoReloadOverlayBlocker,\n private_AutoReloadOverlayBlockerProvider,\n} from '@strapi/content-type-builder/strapi-admin';\n"],"names":["renderAdmin","contentManager","contentTypeBuilder","email","upload","contentReleases","i18n","reviewWorkflows"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAOA,YAAAA,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmBC,wBAAA;AAAA,MACnB,wBAAwBC,4BAAA;AAAA;AAAA,MAAA,OAExBC,eAAA;AAAA,MAAA,QACAC,gBAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MAAA,MACAC,cAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/admin.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { renderAdmin } from "@strapi/admin/strapi-admin";
2
2
  export * from "@strapi/admin/strapi-admin";
3
3
  import contentTypeBuilder from "@strapi/content-type-builder/strapi-admin";
4
+ import { private_AutoReloadOverlayBlockerProvider, private_useAutoReloadOverlayBlocker } from "@strapi/content-type-builder/strapi-admin";
4
5
  import contentManager from "@strapi/content-manager/strapi-admin";
6
+ import { unstable_useContentManagerContext, unstable_useDocument, unstable_useDocumentActions, unstable_useDocumentLayout, useDocumentRBAC } from "@strapi/content-manager/strapi-admin";
5
7
  import email from "@strapi/email/strapi-admin";
6
8
  import upload from "@strapi/upload/strapi-admin";
7
9
  import i18n from "@strapi/i18n/strapi-admin";
@@ -26,6 +28,13 @@ const render = (mountNode, { plugins, ...restArgs }) => {
26
28
  });
27
29
  };
28
30
  export {
29
- render as renderAdmin
31
+ private_AutoReloadOverlayBlockerProvider,
32
+ private_useAutoReloadOverlayBlocker,
33
+ render as renderAdmin,
34
+ unstable_useContentManagerContext,
35
+ unstable_useDocument,
36
+ unstable_useDocumentActions,
37
+ unstable_useDocumentLayout,
38
+ useDocumentRBAC
30
39
  };
31
40
  //# sourceMappingURL=admin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n"],"names":[],"mappings":";;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAO,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmB;AAAA,MACnB,wBAAwB;AAAA;AAAA,MAExB;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n\nexport {\n unstable_useDocumentLayout,\n unstable_useDocumentActions,\n unstable_useDocument,\n unstable_useContentManagerContext,\n useDocumentRBAC,\n} from '@strapi/content-manager/strapi-admin';\n\nexport {\n private_useAutoReloadOverlayBlocker,\n private_AutoReloadOverlayBlockerProvider,\n} from '@strapi/content-type-builder/strapi-admin';\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAO,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmB;AAAA,MACnB,wBAAwB;AAAA;AAAA,MAExB;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;"}
@@ -1,8 +1,7 @@
1
1
  import type { StrapiCommand } from '../../types';
2
- declare const action: (directory: string) => Promise<void>;
3
2
  /**
4
3
  *`$ strapi templates:generate <directory>`
5
4
  */
6
5
  declare const command: StrapiCommand;
7
- export { action, command };
6
+ export { command };
8
7
  //# sourceMappingURL=generate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/templates/generate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwDjD,QAAA,MAAM,MAAM,cAA8C,MAAM,kBAkC/D,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAId,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/templates/generate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAOd,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,78 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const commander = require("commander");
4
- const path = require("path");
5
- const fse = require("fs-extra");
6
- const chalk = require("chalk");
7
- const inquirer = require("inquirer");
8
- const helpers = require("../../utils/helpers.js");
9
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
- const fse__default = /* @__PURE__ */ _interopDefault(fse);
11
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
12
- const inquirer__default = /* @__PURE__ */ _interopDefault(inquirer);
13
- const TEMPLATE_CONTENT = ["src", "data"];
14
- async function copyContent(templatePath, rootBase) {
15
- for (const item of TEMPLATE_CONTENT) {
16
- try {
17
- const pathToCopy = path.join(process.cwd(), item);
18
- if (!await fse__default.default.pathExists(pathToCopy)) {
19
- continue;
20
- }
21
- await fse__default.default.copy(pathToCopy, path.join(templatePath, item));
22
- const currentProjectBase = path.basename(process.cwd());
23
- console.log(
24
- `${chalk__default.default.green(
25
- "success"
26
- )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
27
- );
28
- } catch (error) {
29
- if (error instanceof Error) {
30
- console.error(`${chalk__default.default.red("error")}: ${error.message}`);
31
- }
32
- }
33
- }
34
- }
35
- async function writeTemplateJson(rootPath) {
36
- try {
37
- await fse__default.default.writeJSON(path.join(rootPath, "template.json"), {});
38
- console.log(`${chalk__default.default.green("success")}: create JSON config file`);
39
- } catch (error) {
40
- if (error instanceof Error) {
41
- console.error(`${chalk__default.default.red("error")}: ${error.message}`);
42
- }
43
- }
44
- }
45
- async function templateConfigExists(rootPath) {
46
- const configExists = await fse__default.default.pathExists(path.join(rootPath, "template.json"));
47
- console.log(`checking: ${path.join(rootPath, "template.json")}. result ${configExists}`);
48
- return configExists;
49
- }
50
- const action = async function generateTemplate(directory) {
51
- const rootPath = path.resolve(directory);
52
- const templatePath = path.join(rootPath, "template");
53
- const exists = await fse__default.default.pathExists(templatePath);
54
- const rootBase = path.basename(rootPath);
55
- if (exists) {
56
- const inquiry = await inquirer__default.default.prompt({
57
- type: "confirm",
58
- name: "confirm",
59
- message: `${chalk__default.default.yellow(rootBase)} already exists. Do you want to replace it?`
60
- });
61
- if (!inquiry.confirm) {
62
- process.exit(0);
63
- }
64
- }
65
- await fse__default.default.ensureDir(templatePath);
66
- await copyContent(templatePath, rootBase);
67
- const configExists = await templateConfigExists(rootPath);
68
- if (!configExists) {
69
- await writeTemplateJson(rootPath);
70
- }
71
- console.log(`${chalk__default.default.green("success")}: generated template at ${chalk__default.default.yellow(rootPath)}`);
72
- };
73
4
  const command = () => {
74
- return commander.createCommand("templates:generate <directory>").description("Generate template from Strapi project").action(helpers.runAction("templates:generate", action));
5
+ return commander.createCommand("templates:generate <directory>").description("(deprecated) Generate template from Strapi project").action(() => {
6
+ console.warn("This command is deprecated and will be removed in the next major release.");
7
+ console.warn("You can now copy an existing app and use it as a template.");
8
+ });
75
9
  };
76
- exports.action = action;
77
10
  exports.command = command;
78
11
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sources":["../../../../src/cli/commands/templates/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { resolve, join, basename } from 'path';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\n// All directories that a template could need\nconst TEMPLATE_CONTENT = ['src', 'data'];\n\nasync function copyContent(templatePath: string, rootBase: string) {\n for (const item of TEMPLATE_CONTENT) {\n try {\n const pathToCopy = join(process.cwd(), item);\n\n if (!(await fse.pathExists(pathToCopy))) {\n continue;\n }\n\n await fse.copy(pathToCopy, join(templatePath, item));\n const currentProjectBase = basename(process.cwd());\n console.log(\n `${chalk.green(\n 'success'\n )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n */\nasync function writeTemplateJson(rootPath: string) {\n try {\n await fse.writeJSON(join(rootPath, 'template.json'), {});\n console.log(`${chalk.green('success')}: create JSON config file`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n * @returns boolean\n */\nasync function templateConfigExists(rootPath: string) {\n const configExists = await fse.pathExists(join(rootPath, 'template.json'));\n console.log(`checking: ${join(rootPath, 'template.json')}. result ${configExists}`);\n return configExists;\n}\n\nconst action = async function generateTemplate(directory: string) {\n const rootPath = resolve(directory);\n\n // Get path to template directory: <rootPath>/template\n const templatePath = join(rootPath, 'template');\n\n // Check if the template directory exists\n const exists = await fse.pathExists(templatePath);\n const rootBase = basename(rootPath);\n\n if (exists) {\n // Confirm the user wants to replace the existing template\n const inquiry = await inquirer.prompt({\n type: 'confirm',\n name: 'confirm',\n message: `${chalk.yellow(rootBase)} already exists. Do you want to replace it?`,\n });\n\n if (!inquiry.confirm) {\n process.exit(0);\n }\n }\n\n // Create or replace root directory with <roothPath>/template\n await fse.ensureDir(templatePath);\n // Copy content to /template\n await copyContent(templatePath, rootBase);\n // Create config file if it doesn't exist\n const configExists = await templateConfigExists(rootPath);\n if (!configExists) {\n await writeTemplateJson(rootPath);\n }\n\n console.log(`${chalk.green('success')}: generated template at ${chalk.yellow(rootPath)}`);\n};\n\n/**\n *`$ strapi templates:generate <directory>`\n */\nconst command: StrapiCommand = () => {\n return createCommand('templates:generate <directory>')\n .description('Generate template from Strapi project')\n .action(runAction('templates:generate', action));\n};\n\nexport { action, command };\n"],"names":["join","fse","basename","chalk","resolve","inquirer","createCommand","runAction"],"mappings":";;;;;;;;;;;;AAUA,MAAM,mBAAmB,CAAC,OAAO,MAAM;AAEvC,eAAe,YAAY,cAAsB,UAAkB;AACjE,aAAW,QAAQ,kBAAkB;AAC/B,QAAA;AACF,YAAM,aA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A,WAAWC,cAAS,QAAQ;AAElC,MAAI,QAAQ;AAEJ,UAAA,UAAU,MAAMG,kBAAA,QAAS,OAAO;AAAA,MACpC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,GAAGF,eAAM,QAAA,OAAO,QAAQ,CAAC;AAAA,IAAA,CACnC;AAEG,QAAA,CAAC,QAAQ,SAAS;AACpB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAGM,QAAAF,aAAA,QAAI,UAAU,YAAY;AAE1B,QAAA,YAAY,cAAc,QAAQ;AAElC,QAAA,eAAe,MAAM,qBAAqB,QAAQ;AACxD,MAAI,CAAC,cAAc;AACjB,UAAM,kBAAkB,QAAQ;AAAA,EAClC;AAEQ,UAAA,IAAI,GAAGE,eAAA,QAAM,MAAM,SAAS,CAAC,2BAA2BA,eAAM,QAAA,OAAO,QAAQ,CAAC,EAAE;AAC1F;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAG,wBAAc,gCAAgC,EAClD,YAAY,uCAAuC,EACnD,OAAOC,kBAAU,sBAAsB,MAAM,CAAC;AACnD;;;"}
1
+ {"version":3,"file":"generate.js","sources":["../../../../src/cli/commands/templates/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\n\n/**\n *`$ strapi templates:generate <directory>`\n */\nconst command: StrapiCommand = () => {\n return createCommand('templates:generate <directory>')\n .description('(deprecated) Generate template from Strapi project')\n .action(() => {\n console.warn('This command is deprecated and will be removed in the next major release.');\n console.warn('You can now copy an existing app and use it as a template.');\n });\n};\n\nexport { command };\n"],"names":["createCommand"],"mappings":";;;AAOA,MAAM,UAAyB,MAAM;AACnC,SAAOA,UAAAA,cAAc,gCAAgC,EAClD,YAAY,oDAAoD,EAChE,OAAO,MAAM;AACZ,YAAQ,KAAK,2EAA2E;AACxF,YAAQ,KAAK,4DAA4D;AAAA,EAAA,CAC1E;AACL;;"}
@@ -1,74 +1,11 @@
1
1
  import { createCommand } from "commander";
2
- import { resolve, join, basename } from "path";
3
- import fse from "fs-extra";
4
- import chalk from "chalk";
5
- import inquirer from "inquirer";
6
- import { runAction } from "../../utils/helpers.mjs";
7
- const TEMPLATE_CONTENT = ["src", "data"];
8
- async function copyContent(templatePath, rootBase) {
9
- for (const item of TEMPLATE_CONTENT) {
10
- try {
11
- const pathToCopy = join(process.cwd(), item);
12
- if (!await fse.pathExists(pathToCopy)) {
13
- continue;
14
- }
15
- await fse.copy(pathToCopy, join(templatePath, item));
16
- const currentProjectBase = basename(process.cwd());
17
- console.log(
18
- `${chalk.green(
19
- "success"
20
- )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
21
- );
22
- } catch (error) {
23
- if (error instanceof Error) {
24
- console.error(`${chalk.red("error")}: ${error.message}`);
25
- }
26
- }
27
- }
28
- }
29
- async function writeTemplateJson(rootPath) {
30
- try {
31
- await fse.writeJSON(join(rootPath, "template.json"), {});
32
- console.log(`${chalk.green("success")}: create JSON config file`);
33
- } catch (error) {
34
- if (error instanceof Error) {
35
- console.error(`${chalk.red("error")}: ${error.message}`);
36
- }
37
- }
38
- }
39
- async function templateConfigExists(rootPath) {
40
- const configExists = await fse.pathExists(join(rootPath, "template.json"));
41
- console.log(`checking: ${join(rootPath, "template.json")}. result ${configExists}`);
42
- return configExists;
43
- }
44
- const action = async function generateTemplate(directory) {
45
- const rootPath = resolve(directory);
46
- const templatePath = join(rootPath, "template");
47
- const exists = await fse.pathExists(templatePath);
48
- const rootBase = basename(rootPath);
49
- if (exists) {
50
- const inquiry = await inquirer.prompt({
51
- type: "confirm",
52
- name: "confirm",
53
- message: `${chalk.yellow(rootBase)} already exists. Do you want to replace it?`
54
- });
55
- if (!inquiry.confirm) {
56
- process.exit(0);
57
- }
58
- }
59
- await fse.ensureDir(templatePath);
60
- await copyContent(templatePath, rootBase);
61
- const configExists = await templateConfigExists(rootPath);
62
- if (!configExists) {
63
- await writeTemplateJson(rootPath);
64
- }
65
- console.log(`${chalk.green("success")}: generated template at ${chalk.yellow(rootPath)}`);
66
- };
67
2
  const command = () => {
68
- return createCommand("templates:generate <directory>").description("Generate template from Strapi project").action(runAction("templates:generate", action));
3
+ return createCommand("templates:generate <directory>").description("(deprecated) Generate template from Strapi project").action(() => {
4
+ console.warn("This command is deprecated and will be removed in the next major release.");
5
+ console.warn("You can now copy an existing app and use it as a template.");
6
+ });
69
7
  };
70
8
  export {
71
- action,
72
9
  command
73
10
  };
74
11
  //# sourceMappingURL=generate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.mjs","sources":["../../../../src/cli/commands/templates/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { resolve, join, basename } from 'path';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\n// All directories that a template could need\nconst TEMPLATE_CONTENT = ['src', 'data'];\n\nasync function copyContent(templatePath: string, rootBase: string) {\n for (const item of TEMPLATE_CONTENT) {\n try {\n const pathToCopy = join(process.cwd(), item);\n\n if (!(await fse.pathExists(pathToCopy))) {\n continue;\n }\n\n await fse.copy(pathToCopy, join(templatePath, item));\n const currentProjectBase = basename(process.cwd());\n console.log(\n `${chalk.green(\n 'success'\n )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n */\nasync function writeTemplateJson(rootPath: string) {\n try {\n await fse.writeJSON(join(rootPath, 'template.json'), {});\n console.log(`${chalk.green('success')}: create JSON config file`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n * @returns boolean\n */\nasync function templateConfigExists(rootPath: string) {\n const configExists = await fse.pathExists(join(rootPath, 'template.json'));\n console.log(`checking: ${join(rootPath, 'template.json')}. result ${configExists}`);\n return configExists;\n}\n\nconst action = async function generateTemplate(directory: string) {\n const rootPath = resolve(directory);\n\n // Get path to template directory: <rootPath>/template\n const templatePath = join(rootPath, 'template');\n\n // Check if the template directory exists\n const exists = await fse.pathExists(templatePath);\n const rootBase = basename(rootPath);\n\n if (exists) {\n // Confirm the user wants to replace the existing template\n const inquiry = await inquirer.prompt({\n type: 'confirm',\n name: 'confirm',\n message: `${chalk.yellow(rootBase)} already exists. Do you want to replace it?`,\n });\n\n if (!inquiry.confirm) {\n process.exit(0);\n }\n }\n\n // Create or replace root directory with <roothPath>/template\n await fse.ensureDir(templatePath);\n // Copy content to /template\n await copyContent(templatePath, rootBase);\n // Create config file if it doesn't exist\n const configExists = await templateConfigExists(rootPath);\n if (!configExists) {\n await writeTemplateJson(rootPath);\n }\n\n console.log(`${chalk.green('success')}: generated template at ${chalk.yellow(rootPath)}`);\n};\n\n/**\n *`$ strapi templates:generate <directory>`\n */\nconst command: StrapiCommand = () => {\n return createCommand('templates:generate <directory>')\n .description('Generate template from Strapi project')\n .action(runAction('templates:generate', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,mBAAmB,CAAC,OAAO,MAAM;AAEvC,eAAe,YAAY,cAAsB,UAAkB;AACjE,aAAW,QAAQ,kBAAkB;AAC/B,QAAA;AACF,YAAM,aAAa,KAAK,QAAQ,OAAO,IAAI;AAE3C,UAAI,CAAE,MAAM,IAAI,WAAW,UAAU,GAAI;AACvC;AAAA,MACF;AAEA,YAAM,IAAI,KAAK,YAAY,KAAK,cAAc,IAAI,CAAC;AACnD,YAAM,qBAAqB,SAAS,QAAQ,IAAK,CAAA;AACzC,cAAA;AAAA,QACN,GAAG,MAAM;AAAA,UACP;AAAA,QAAA,CACD,UAAU,kBAAkB,IAAI,IAAI,OAAO,QAAQ,aAAa,IAAI;AAAA,MAAA;AAAA,aAEhE,OAAO;AACd,UAAI,iBAAiB,OAAO;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AAM,OAAO,QAAQ,CAAC,EAAE;AAC1F;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,gCAAgC,EAClD,YAAY,uCAAuC,EACnD,OAAO,UAAU,sBAAsB,MAAM,CAAC;AACnD;"}
1
+ {"version":3,"file":"generate.mjs","sources":["../../../../src/cli/commands/templates/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\n\n/**\n *`$ strapi templates:generate <directory>`\n */\nconst command: StrapiCommand = () => {\n return createCommand('templates:generate <directory>')\n .description('(deprecated) Generate template from Strapi project')\n .action(() => {\n console.warn('This command is deprecated and will be removed in the next major release.');\n console.warn('You can now copy an existing app and use it as a template.');\n });\n};\n\nexport { command };\n"],"names":[],"mappings":";AAOA,MAAM,UAAyB,MAAM;AACnC,SAAO,cAAc,gCAAgC,EAClD,YAAY,oDAAoD,EAChE,OAAO,MAAM;AACZ,YAAQ,KAAK,2EAA2E;AACxF,YAAQ,KAAK,4DAA4D;AAAA,EAAA,CAC1E;AACL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../src/node/core/plugins.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC;IACb;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,KA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AG,QAAQ,GAAG,YAAY,CAAC,KAAG,QACjE,OAAO,MAAM,EAAE,UAAU,CAAC,CA2D3B,CAAC;AAsBF,QAAA,MAAM,wBAAwB,YAAa,OAAO,MAAM,EAAE,UAAU,CAAC;;UApJ7D,MAAM;IACZ;;OAEG;gBACS,MAAM;IAClB;;;OAGG;UACG,MAAM;UAON,OAAO;;;UAIP,MAAM;IACZ;;OAEG;gBACS,MAAM;IAClB;;;OAGG;;UAOG,QAAQ;IA6Lf,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC"}
@@ -72,27 +72,45 @@ const loadUserPluginsFile = async (root) => {
72
72
  }
73
73
  return {};
74
74
  };
75
- const getMapOfPluginsWithAdmin = (plugins) => Object.values(plugins).filter((plugin) => {
76
- if (!plugin) {
77
- return false;
78
- }
79
- try {
80
- const isLocalPluginWithLegacyAdminFile = plugin.path && fs__default.default.existsSync(path__default.default.join(plugin.path, "strapi-admin.js"));
81
- if (!isLocalPluginWithLegacyAdminFile) {
82
- const isModuleWithFE = require.resolve(`${plugin.modulePath}/strapi-admin`);
83
- return isModuleWithFE;
75
+ const getMapOfPluginsWithAdmin = (plugins) => {
76
+ const pluginImportPaths = {};
77
+ return Object.values(plugins).filter((plugin) => {
78
+ if (!plugin) {
79
+ return false;
84
80
  }
85
- return isLocalPluginWithLegacyAdminFile;
86
- } catch (err) {
87
- if (errors.isError(err) && "code" in err && (err.code === "MODULE_NOT_FOUND" || err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
81
+ try {
82
+ const localPluginPath = plugin.path;
83
+ if (localPluginPath) {
84
+ const packageJsonPath = path__default.default.join(localPluginPath, "package.json");
85
+ if (fs__default.default.existsSync(packageJsonPath)) {
86
+ const packageJson = JSON.parse(fs__default.default.readFileSync(packageJsonPath, "utf-8"));
87
+ const localAdminPath = packageJson?.exports?.["./strapi-admin"]?.import;
88
+ if (localAdminPath) {
89
+ pluginImportPaths[plugin.modulePath] = localAdminPath;
90
+ return true;
91
+ }
92
+ }
93
+ if (fs__default.default.existsSync(path__default.default.join(localPluginPath, "strapi-admin.js"))) {
94
+ pluginImportPaths[plugin.modulePath] = "strapi-admin";
95
+ return true;
96
+ }
97
+ }
98
+ if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {
99
+ pluginImportPaths[plugin.modulePath] = "strapi-admin";
100
+ return true;
101
+ }
88
102
  return false;
103
+ } catch (err) {
104
+ if (errors.isError(err) && "code" in err && (err.code === "MODULE_NOT_FOUND" || err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
105
+ return false;
106
+ }
107
+ throw err;
89
108
  }
90
- throw err;
91
- }
92
- }).map((plugin) => ({
93
- ...plugin,
94
- modulePath: `${plugin.modulePath}/strapi-admin`
95
- }));
109
+ }).map((plugin) => ({
110
+ ...plugin,
111
+ modulePath: `${plugin.modulePath}/${pluginImportPaths[plugin.modulePath]}`
112
+ }));
113
+ };
96
114
  exports.getEnabledPlugins = getEnabledPlugins;
97
115
  exports.getMapOfPluginsWithAdmin = getMapOfPluginsWithAdmin;
98
116
  //# sourceMappingURL=plugins.js.map
@@ -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 Object.values(plugins)\n .filter((plugin) => {\n if (!plugin) {\n return false;\n }\n\n /**\n * There are two ways a plugin should be imported, either it's local to the strapi app,\n * or it's an actual npm module that's installed and resolved via node_modules.\n *\n * We first check if the plugin is local to the strapi app, using a regular `fs.existsSync` because\n * the pathToPlugin will be relative i.e. `/Users/my-name/strapi-app/src/plugins/my-plugin`.\n *\n * If the file doesn't exist well then it's probably a node_module, so instead we use `require.resolve`\n * which will resolve the path to the module in node_modules. If it fails with the specific code `MODULE_NOT_FOUND`\n * then it doesn't have an admin part to the package.\n */\n try {\n const isLocalPluginWithLegacyAdminFile =\n plugin.path && fs.existsSync(path.join(plugin.path, 'strapi-admin.js'));\n\n if (!isLocalPluginWithLegacyAdminFile) {\n const isModuleWithFE = require.resolve(`${plugin.modulePath}/strapi-admin`);\n\n return isModuleWithFE;\n }\n\n return isLocalPluginWithLegacyAdminFile;\n } catch (err) {\n if (\n isError(err) &&\n 'code' in err &&\n (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n /**\n * the plugin does not contain FE code, so we\n * don't want to import it anyway\n */\n return false;\n }\n\n throw err;\n }\n })\n .map((plugin) => ({\n ...plugin,\n modulePath: `${plugin.modulePath}/strapi-admin`,\n }));\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":["os","getModule","camelCase","convertModulePathToSystemPath","convertSystemPathToModulePath","path","loadFile","env","fs","isError"],"mappings":";;;;;;;;;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAA;AAO5C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoCA,YAAG,QAAA,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAMC,aAAAA,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAEJ;AAEA,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAYC,2BAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MAAA;AAAA,IAEhB;AAAA,EACF;AAE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Q,GAAG,KACX,UAAU,QACT,IAAI,SAAS,sBAAsB,IAAI,SAAS,kCACjD;AAKO,aAAA;AAAA,IACT;AAEM,UAAA;AAAA,EACR;AACF,CAAC,EACA,IAAI,CAAC,YAAY;AAAA,EAChB,GAAG;AAAA,EACH,YAAY,GAAG,OAAO,UAAU;AAClC,EAAE;;;"}
1
+ {"version":3,"file":"plugins.js","sources":["../../../src/node/core/plugins.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport camelCase from 'lodash/camelCase';\nimport { env } from '@strapi/utils';\nimport { getModule, PackageJson } from './dependencies';\nimport { convertModulePathToSystemPath, convertSystemPathToModulePath, loadFile } from './files';\nimport type { BaseContext } from '../types';\nimport { isError } from './errors';\n\ninterface LocalPluginMeta {\n name: string;\n /**\n * camelCased version of the plugin name\n */\n importName: string;\n /**\n * The path to the plugin, relative to the app's root directory\n * in system format\n */\n path: string;\n /**\n * The path to the plugin, relative to the runtime directory\n * in module format (i.e. with forward slashes) because thats\n * where it should be used as an import\n */\n modulePath: string;\n type: 'local';\n}\n\ninterface ModulePluginMeta {\n name: string;\n /**\n * camelCased version of the plugin name\n */\n importName: string;\n /**\n * Modules don't have a path because we never resolve them to their node_modules\n * because we simply do not require it.\n */\n path?: never;\n /**\n * The path to the plugin, relative to the app's root directory\n * in module format (i.e. with forward slashes)\n */\n modulePath: string;\n type: 'module';\n}\n\ntype PluginMeta = LocalPluginMeta | ModulePluginMeta;\n\ninterface StrapiPlugin extends PackageJson {\n strapi: {\n description?: string;\n displayName?: string;\n kind: 'plugin';\n name?: string;\n required?: boolean;\n };\n}\n\nconst validatePackageHasStrapi = (\n pkg: PackageJson\n): pkg is PackageJson & { strapi: Record<string, unknown> } =>\n 'strapi' in pkg &&\n typeof pkg.strapi === 'object' &&\n !Array.isArray(pkg.strapi) &&\n pkg.strapi !== null;\n\nconst validatePackageIsPlugin = (pkg: PackageJson): pkg is StrapiPlugin =>\n validatePackageHasStrapi(pkg) && pkg.strapi.kind === 'plugin';\n\nconst getEnabledPlugins = async ({\n cwd,\n logger,\n runtimeDir,\n strapi,\n}: Pick<BaseContext, 'cwd' | 'logger' | 'strapi' | 'runtimeDir'>): Promise<\n Record<string, PluginMeta>\n> => {\n const plugins: Record<string, PluginMeta> = {};\n\n /**\n * This is the list of dependencies that are installed in the user's project.\n * It will include libraries like \"react\", so we need to collect the ones that\n * are plugins.\n */\n const deps = strapi.config.get('info.dependencies', {});\n\n logger.debug(\"Dependencies from user's project\", os.EOL, deps);\n\n for (const dep of Object.keys(deps)) {\n const pkg = await getModule(dep, cwd);\n\n if (pkg && validatePackageIsPlugin(pkg)) {\n const name = pkg.strapi.name || pkg.name;\n\n if (!name) {\n /**\n * Unlikely to happen, but you never know.\n */\n throw Error(\n \"You're trying to import a plugin that doesn't have a name – check the package.json of that plugin!\"\n );\n }\n\n plugins[name] = {\n name,\n importName: camelCase(name),\n type: 'module',\n modulePath: dep,\n };\n }\n }\n\n const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);\n\n logger.debug(\"User's plugins file\", os.EOL, userPluginsFile);\n\n for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)) {\n if (userPluginConfig.enabled && userPluginConfig.resolve) {\n const sysPath = convertModulePathToSystemPath(userPluginConfig.resolve);\n plugins[userPluginName] = {\n name: userPluginName,\n importName: camelCase(userPluginName),\n type: 'local',\n /**\n * User plugin paths are resolved from the entry point\n * of the app, because that's how you import them.\n */\n modulePath: convertSystemPathToModulePath(path.relative(runtimeDir, sysPath)),\n path: sysPath,\n };\n }\n }\n\n return plugins;\n};\n\nconst PLUGIN_CONFIGS = ['plugins.js', 'plugins.mjs', 'plugins.ts'];\n\ntype UserPluginConfigFile = Record<string, { enabled: boolean; resolve: string }>;\n\nconst loadUserPluginsFile = async (root: string): Promise<UserPluginConfigFile> => {\n for (const file of PLUGIN_CONFIGS) {\n const filePath = path.join(root, file);\n const configFile = await loadFile(filePath);\n\n if (configFile) {\n /**\n * Configs can be a function or they can be just an object!\n */\n return typeof configFile === 'function' ? configFile({ env }) : configFile;\n }\n }\n\n return {};\n};\n\nconst getMapOfPluginsWithAdmin = (plugins: Record<string, PluginMeta>) => {\n /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return Object.values(plugins)\n .filter((plugin) => {\n if (!plugin) {\n return false;\n }\n\n /**\n * There are two ways a plugin should be imported, either it's local to the strapi app,\n * or it's an actual npm module that's installed and resolved via node_modules.\n *\n * We first check if the plugin is local to the strapi app, using a regular `fs.existsSync` because\n * the pathToPlugin will be relative i.e. `/Users/my-name/strapi-app/src/plugins/my-plugin`.\n *\n * If the file doesn't exist well then it's probably a node_module, so instead we use `require.resolve`\n * which will resolve the path to the module in node_modules. If it fails with the specific code `MODULE_NOT_FOUND`\n * then it doesn't have an admin part to the package.\n */\n try {\n const localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\n } catch (err) {\n if (\n isError(err) &&\n 'code' in err &&\n (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n /**\n * the plugin does not contain FE code, so we\n * don't want to import it anyway\n */\n return false;\n }\n\n throw err;\n }\n })\n .map((plugin) => ({\n ...plugin,\n modulePath: `${plugin.modulePath}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":["os","getModule","camelCase","convertModulePathToSystemPath","convertSystemPathToModulePath","path","loadFile","env","fs","isError"],"mappings":";;;;;;;;;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAA;AAO5C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoCA,YAAG,QAAA,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAMC,aAAAA,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAEJ;AAEA,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAYC,2BAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MAAA;AAAA,IAEhB;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM,oBAAoB,OAAO,KAAK,IAAI,MAAM;AAExE,SAAO,MAAM,uB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gBAAgB;AACA,8BAAA,OAAO,UAAU,IAAI;AAChC,mBAAA;AAAA,UACT;AAAA,QACF;AAGA,YAAIA,YAAAA,QAAG,WAAWH,cAAA,QAAK,KAAK,iBAAiB,iBAAiB,CAAC,GAAG;AAC9C,4BAAA,OAAO,UAAU,IAAI;AAChC,iBAAA;AAAA,QACT;AAAA,MACF;AAGA,UAAI,QAAQ,QAAQ,GAAG,OAAO,UAAU,eAAe,GAAG;AACtC,0BAAA,OAAO,UAAU,IAAI;AAChC,eAAA;AAAA,MACT;AAEO,aAAA;AAAA,aACA,KAAK;AAEV,UAAAI,eAAQ,GAAG,KACX,UAAU,QACT,IAAI,SAAS,sBAAsB,IAAI,SAAS,kCACjD;AAKO,eAAA;AAAA,MACT;AAEM,YAAA;AAAA,IACR;AAAA,EAAA,CACD,EACA,IAAI,CAAC,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY,GAAG,OAAO,UAAU,IAAI,kBAAkB,OAAO,UAAU,CAAC;AAAA,EACxE,EAAA;AACN;;;"}
@@ -65,27 +65,45 @@ const loadUserPluginsFile = async (root) => {
65
65
  }
66
66
  return {};
67
67
  };
68
- const getMapOfPluginsWithAdmin = (plugins) => Object.values(plugins).filter((plugin) => {
69
- if (!plugin) {
70
- return false;
71
- }
72
- try {
73
- const isLocalPluginWithLegacyAdminFile = plugin.path && fs.existsSync(path.join(plugin.path, "strapi-admin.js"));
74
- if (!isLocalPluginWithLegacyAdminFile) {
75
- const isModuleWithFE = require.resolve(`${plugin.modulePath}/strapi-admin`);
76
- return isModuleWithFE;
68
+ const getMapOfPluginsWithAdmin = (plugins) => {
69
+ const pluginImportPaths = {};
70
+ return Object.values(plugins).filter((plugin) => {
71
+ if (!plugin) {
72
+ return false;
77
73
  }
78
- return isLocalPluginWithLegacyAdminFile;
79
- } catch (err) {
80
- if (isError(err) && "code" in err && (err.code === "MODULE_NOT_FOUND" || err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
74
+ try {
75
+ const localPluginPath = plugin.path;
76
+ if (localPluginPath) {
77
+ const packageJsonPath = path.join(localPluginPath, "package.json");
78
+ if (fs.existsSync(packageJsonPath)) {
79
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
80
+ const localAdminPath = packageJson?.exports?.["./strapi-admin"]?.import;
81
+ if (localAdminPath) {
82
+ pluginImportPaths[plugin.modulePath] = localAdminPath;
83
+ return true;
84
+ }
85
+ }
86
+ if (fs.existsSync(path.join(localPluginPath, "strapi-admin.js"))) {
87
+ pluginImportPaths[plugin.modulePath] = "strapi-admin";
88
+ return true;
89
+ }
90
+ }
91
+ if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {
92
+ pluginImportPaths[plugin.modulePath] = "strapi-admin";
93
+ return true;
94
+ }
81
95
  return false;
96
+ } catch (err) {
97
+ if (isError(err) && "code" in err && (err.code === "MODULE_NOT_FOUND" || err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
98
+ return false;
99
+ }
100
+ throw err;
82
101
  }
83
- throw err;
84
- }
85
- }).map((plugin) => ({
86
- ...plugin,
87
- modulePath: `${plugin.modulePath}/strapi-admin`
88
- }));
102
+ }).map((plugin) => ({
103
+ ...plugin,
104
+ modulePath: `${plugin.modulePath}/${pluginImportPaths[plugin.modulePath]}`
105
+ }));
106
+ };
89
107
  export {
90
108
  getEnabledPlugins,
91
109
  getMapOfPluginsWithAdmin
@@ -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 Object.values(plugins)\n .filter((plugin) => {\n if (!plugin) {\n return false;\n }\n\n /**\n * There are two ways a plugin should be imported, either it's local to the strapi app,\n * or it's an actual npm module that's installed and resolved via node_modules.\n *\n * We first check if the plugin is local to the strapi app, using a regular `fs.existsSync` because\n * the pathToPlugin will be relative i.e. `/Users/my-name/strapi-app/src/plugins/my-plugin`.\n *\n * If the file doesn't exist well then it's probably a node_module, so instead we use `require.resolve`\n * which will resolve the path to the module in node_modules. If it fails with the specific code `MODULE_NOT_FOUND`\n * then it doesn't have an admin part to the package.\n */\n try {\n const isLocalPluginWithLegacyAdminFile =\n plugin.path && fs.existsSync(path.join(plugin.path, 'strapi-admin.js'));\n\n if (!isLocalPluginWithLegacyAdminFile) {\n const isModuleWithFE = require.resolve(`${plugin.modulePath}/strapi-admin`);\n\n return isModuleWithFE;\n }\n\n return isLocalPluginWithLegacyAdminFile;\n } catch (err) {\n if (\n isError(err) &&\n 'code' in err &&\n (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n /**\n * the plugin does not contain FE code, so we\n * don't want to import it anyway\n */\n return false;\n }\n\n throw err;\n }\n })\n .map((plugin) => ({\n ...plugin,\n modulePath: `${plugin.modulePath}/strapi-admin`,\n }));\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":[],"mappings":";;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAA;AAO5C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoC,GAAG,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAM,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAEJ;AAEA,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAY,UAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MAAA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S,sBAAsB,IAAI,SAAS,kCACjD;AAKO,aAAA;AAAA,IACT;AAEM,UAAA;AAAA,EACR;AACF,CAAC,EACA,IAAI,CAAC,YAAY;AAAA,EAChB,GAAG;AAAA,EACH,YAAY,GAAG,OAAO,UAAU;AAClC,EAAE;"}
1
+ {"version":3,"file":"plugins.mjs","sources":["../../../src/node/core/plugins.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport camelCase from 'lodash/camelCase';\nimport { env } from '@strapi/utils';\nimport { getModule, PackageJson } from './dependencies';\nimport { convertModulePathToSystemPath, convertSystemPathToModulePath, loadFile } from './files';\nimport type { BaseContext } from '../types';\nimport { isError } from './errors';\n\ninterface LocalPluginMeta {\n name: string;\n /**\n * camelCased version of the plugin name\n */\n importName: string;\n /**\n * The path to the plugin, relative to the app's root directory\n * in system format\n */\n path: string;\n /**\n * The path to the plugin, relative to the runtime directory\n * in module format (i.e. with forward slashes) because thats\n * where it should be used as an import\n */\n modulePath: string;\n type: 'local';\n}\n\ninterface ModulePluginMeta {\n name: string;\n /**\n * camelCased version of the plugin name\n */\n importName: string;\n /**\n * Modules don't have a path because we never resolve them to their node_modules\n * because we simply do not require it.\n */\n path?: never;\n /**\n * The path to the plugin, relative to the app's root directory\n * in module format (i.e. with forward slashes)\n */\n modulePath: string;\n type: 'module';\n}\n\ntype PluginMeta = LocalPluginMeta | ModulePluginMeta;\n\ninterface StrapiPlugin extends PackageJson {\n strapi: {\n description?: string;\n displayName?: string;\n kind: 'plugin';\n name?: string;\n required?: boolean;\n };\n}\n\nconst validatePackageHasStrapi = (\n pkg: PackageJson\n): pkg is PackageJson & { strapi: Record<string, unknown> } =>\n 'strapi' in pkg &&\n typeof pkg.strapi === 'object' &&\n !Array.isArray(pkg.strapi) &&\n pkg.strapi !== null;\n\nconst validatePackageIsPlugin = (pkg: PackageJson): pkg is StrapiPlugin =>\n validatePackageHasStrapi(pkg) && pkg.strapi.kind === 'plugin';\n\nconst getEnabledPlugins = async ({\n cwd,\n logger,\n runtimeDir,\n strapi,\n}: Pick<BaseContext, 'cwd' | 'logger' | 'strapi' | 'runtimeDir'>): Promise<\n Record<string, PluginMeta>\n> => {\n const plugins: Record<string, PluginMeta> = {};\n\n /**\n * This is the list of dependencies that are installed in the user's project.\n * It will include libraries like \"react\", so we need to collect the ones that\n * are plugins.\n */\n const deps = strapi.config.get('info.dependencies', {});\n\n logger.debug(\"Dependencies from user's project\", os.EOL, deps);\n\n for (const dep of Object.keys(deps)) {\n const pkg = await getModule(dep, cwd);\n\n if (pkg && validatePackageIsPlugin(pkg)) {\n const name = pkg.strapi.name || pkg.name;\n\n if (!name) {\n /**\n * Unlikely to happen, but you never know.\n */\n throw Error(\n \"You're trying to import a plugin that doesn't have a name – check the package.json of that plugin!\"\n );\n }\n\n plugins[name] = {\n name,\n importName: camelCase(name),\n type: 'module',\n modulePath: dep,\n };\n }\n }\n\n const userPluginsFile = await loadUserPluginsFile(strapi.dirs.app.config);\n\n logger.debug(\"User's plugins file\", os.EOL, userPluginsFile);\n\n for (const [userPluginName, userPluginConfig] of Object.entries(userPluginsFile)) {\n if (userPluginConfig.enabled && userPluginConfig.resolve) {\n const sysPath = convertModulePathToSystemPath(userPluginConfig.resolve);\n plugins[userPluginName] = {\n name: userPluginName,\n importName: camelCase(userPluginName),\n type: 'local',\n /**\n * User plugin paths are resolved from the entry point\n * of the app, because that's how you import them.\n */\n modulePath: convertSystemPathToModulePath(path.relative(runtimeDir, sysPath)),\n path: sysPath,\n };\n }\n }\n\n return plugins;\n};\n\nconst PLUGIN_CONFIGS = ['plugins.js', 'plugins.mjs', 'plugins.ts'];\n\ntype UserPluginConfigFile = Record<string, { enabled: boolean; resolve: string }>;\n\nconst loadUserPluginsFile = async (root: string): Promise<UserPluginConfigFile> => {\n for (const file of PLUGIN_CONFIGS) {\n const filePath = path.join(root, file);\n const configFile = await loadFile(filePath);\n\n if (configFile) {\n /**\n * Configs can be a function or they can be just an object!\n */\n return typeof configFile === 'function' ? configFile({ env }) : configFile;\n }\n }\n\n return {};\n};\n\nconst getMapOfPluginsWithAdmin = (plugins: Record<string, PluginMeta>) => {\n /**\n * This variable stores the import paths for plugins.\n * The keys are the module paths of the plugins, and the values are the paths\n * to the admin part of the plugins, which is either loaded from the\n * package.json exports or from the legacy strapi-admin.js file.\n */\n const pluginImportPaths: Record<string, string> = {};\n\n return Object.values(plugins)\n .filter((plugin) => {\n if (!plugin) {\n return false;\n }\n\n /**\n * There are two ways a plugin should be imported, either it's local to the strapi app,\n * or it's an actual npm module that's installed and resolved via node_modules.\n *\n * We first check if the plugin is local to the strapi app, using a regular `fs.existsSync` because\n * the pathToPlugin will be relative i.e. `/Users/my-name/strapi-app/src/plugins/my-plugin`.\n *\n * If the file doesn't exist well then it's probably a node_module, so instead we use `require.resolve`\n * which will resolve the path to the module in node_modules. If it fails with the specific code `MODULE_NOT_FOUND`\n * then it doesn't have an admin part to the package.\n */\n try {\n const localPluginPath = plugin.path;\n if (localPluginPath) {\n // Here we are loading a locally installed plugin\n const packageJsonPath = path.join(localPluginPath, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const localAdminPath = packageJson?.exports?.['./strapi-admin']?.import;\n\n if (localAdminPath) {\n pluginImportPaths[plugin.modulePath] = localAdminPath;\n return true;\n }\n }\n\n // Check if legacy admin file exists in local plugin\n if (fs.existsSync(path.join(localPluginPath, 'strapi-admin.js'))) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n }\n\n // This plugin is a module, so we need to check if it has a strapi-admin export\n if (require.resolve(`${plugin.modulePath}/strapi-admin`)) {\n pluginImportPaths[plugin.modulePath] = 'strapi-admin';\n return true;\n }\n\n return false;\n } catch (err) {\n if (\n isError(err) &&\n 'code' in err &&\n (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n /**\n * the plugin does not contain FE code, so we\n * don't want to import it anyway\n */\n return false;\n }\n\n throw err;\n }\n })\n .map((plugin) => ({\n ...plugin,\n modulePath: `${plugin.modulePath}/${pluginImportPaths[plugin.modulePath]}`,\n }));\n};\n\nexport { getEnabledPlugins, getMapOfPluginsWithAdmin };\nexport type { PluginMeta, LocalPluginMeta, ModulePluginMeta };\n"],"names":[],"mappings":";;;;;;;;AA6DA,MAAM,2BAA2B,CAC/B,QAEA,YAAY,OACZ,OAAO,IAAI,WAAW,YACtB,CAAC,MAAM,QAAQ,IAAI,MAAM,KACzB,IAAI,WAAW;AAEjB,MAAM,0BAA0B,CAAC,QAC/B,yBAAyB,GAAG,KAAK,IAAI,OAAO,SAAS;AAEvD,MAAM,oBAAoB,OAAO;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAEK;AACH,QAAM,UAAsC,CAAA;AAO5C,QAAM,OAAO,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAEtD,SAAO,MAAM,oCAAoC,GAAG,KAAK,IAAI;AAE7D,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,MAAM,MAAM,UAAU,KAAK,GAAG;AAEhC,QAAA,OAAO,wBAAwB,GAAG,GAAG;AACvC,YAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAEpC,UAAI,CAAC,MAAM;AAIH,cAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAEJ;AAEA,cAAQ,IAAI,IAAI;AAAA,QACd;AAAA,QACA,YAAY,UAAU,IAAI;AAAA,QAC1B,MAAM;AAAA,QACN,YAAY;AAAA,MAAA;AAAA,IAEhB;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM,oBAAoB,OAAO,KAAK,IAAI,MAAM;AAExE,SAAO,MAAM,uBAAuB,GAAG,KAAK,eAAe;AAE3D,aAAW,CAAC,gBAAgB,gBAAgB,KAAK,OAAO,QAAQ,eAAe,GAAG;AAC5E,QAAA,iBAAiB,WAAW,iBAA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MACF;AAGA,UAAI,QAAQ,QAAQ,GAAG,OAAO,UAAU,eAAe,GAAG;AACtC,0BAAA,OAAO,UAAU,IAAI;AAChC,eAAA;AAAA,MACT;AAEO,aAAA;AAAA,aACA,KAAK;AAEV,UAAA,QAAQ,GAAG,KACX,UAAU,QACT,IAAI,SAAS,sBAAsB,IAAI,SAAS,kCACjD;AAKO,eAAA;AAAA,MACT;AAEM,YAAA;AAAA,IACR;AAAA,EAAA,CACD,EACA,IAAI,CAAC,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY,GAAG,OAAO,UAAU,IAAI,kBAAkB,OAAO,UAAU,CAAC;AAAA,EACxE,EAAA;AACN;"}
@@ -25,7 +25,7 @@ const buildFilesPlugin = (ctx) => {
25
25
  throw new Error("Entry file is not a chunk");
26
26
  }
27
27
  const entryFileName = entryFile.fileName;
28
- const entryPath = ["/admin".replace(/\/+$/, ""), entryFileName].join("/");
28
+ const entryPath = [ctx.basePath.replace(/\/+$/, ""), entryFileName].join("/");
29
29
  this.emitFile({
30
30
  type: "asset",
31
31
  fileName: "index.html",
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sources":["../../../src/node/vite/plugins.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport { getDocumentHTML } from '../staticFiles';\nimport type { BuildContext } from '../create-build-context';\n\nconst buildFilesPlugin = (ctx: BuildContext): Plugin => {\n const CHUNK_ID = '.strapi/client/app.js';\n\n return {\n name: 'strapi/server/build-files',\n apply: 'build',\n buildStart() {\n this.emitFile({\n type: 'chunk',\n id: CHUNK_ID,\n name: 'strapi',\n });\n },\n async generateBundle(_options, outputBundle) {\n const bundle = outputBundle;\n const entryFile = Object.values(bundle).find(\n (file) =>\n file.type === 'chunk' && file.name === 'strapi' && file.facadeModuleId?.endsWith(CHUNK_ID)\n );\n\n if (!entryFile) {\n throw new Error(`Failed to find entry file in bundle (${CHUNK_ID})`);\n }\n\n if (entryFile.type !== 'chunk') {\n throw new Error('Entry file is not a chunk');\n }\n\n const entryFileName = entryFile.fileName;\n const entryPath = ['/admin'.replace(/\\/+$/, ''), entryFileName].join('/');\n\n this.emitFile({\n type: 'asset',\n fileName: 'index.html',\n source: getDocumentHTML({\n logger: ctx.logger,\n props: {\n entryPath,\n },\n }),\n });\n },\n };\n};\n\nexport { buildFilesPlugin };\n"],"names":["getDocumentHTML"],"mappings":";;;AAKM,MAAA,mBAAmB,CAAC,QAA8B;AACtD,QAAM,WAAW;AAEV,SAAA;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AACX,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,IACA,MAAM,eAAe,UAAU,cAAc;AAC3C,YAAM,SAAS;AACf,YAAM,YAAY,OAAO,OAAO,MAAM,EAAE;AAAA,QACtC,CAAC,SACC,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,gBAAgB,SAAS,QAAQ;AAAA,MAAA;AAG7F,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,wCAAwC,QAAQ,GAAG;AAAA,MACrE;AAEI,UAAA,UAAU,SAAS,SAAS;AACxB,cAAA,IAAI,MAAM,2BAA2B;AAAA,MAC7C;AAEA,YAAM,gBAAgB,UAAU;AAC1B,YAAA,YAAY,CAAC,SAAS,QAAQ,QAAQ,EAAE,GAAG,aAAa,EAAE,KAAK,GAAG;AAExE,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQA,YAAAA,gBAAgB;AAAA,UACtB,QAAQ,IAAI;AAAA,UACZ,OAAO;AAAA,YACL;AAAA,UACF;AAAA,QAAA,CACD;AAAA,MAAA,CACF;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"plugins.js","sources":["../../../src/node/vite/plugins.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport { getDocumentHTML } from '../staticFiles';\nimport type { BuildContext } from '../create-build-context';\n\nconst buildFilesPlugin = (ctx: BuildContext): Plugin => {\n const CHUNK_ID = '.strapi/client/app.js';\n\n return {\n name: 'strapi/server/build-files',\n apply: 'build',\n buildStart() {\n this.emitFile({\n type: 'chunk',\n id: CHUNK_ID,\n name: 'strapi',\n });\n },\n async generateBundle(_options, outputBundle) {\n const bundle = outputBundle;\n const entryFile = Object.values(bundle).find(\n (file) =>\n file.type === 'chunk' && file.name === 'strapi' && file.facadeModuleId?.endsWith(CHUNK_ID)\n );\n\n if (!entryFile) {\n throw new Error(`Failed to find entry file in bundle (${CHUNK_ID})`);\n }\n\n if (entryFile.type !== 'chunk') {\n throw new Error('Entry file is not a chunk');\n }\n\n const entryFileName = entryFile.fileName;\n const entryPath = [ctx.basePath.replace(/\\/+$/, ''), entryFileName].join('/');\n\n this.emitFile({\n type: 'asset',\n fileName: 'index.html',\n source: getDocumentHTML({\n logger: ctx.logger,\n props: {\n entryPath,\n },\n }),\n });\n },\n };\n};\n\nexport { buildFilesPlugin };\n"],"names":["getDocumentHTML"],"mappings":";;;AAKM,MAAA,mBAAmB,CAAC,QAA8B;AACtD,QAAM,WAAW;AAEV,SAAA;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AACX,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,IACA,MAAM,eAAe,UAAU,cAAc;AAC3C,YAAM,SAAS;AACf,YAAM,YAAY,OAAO,OAAO,MAAM,EAAE;AAAA,QACtC,CAAC,SACC,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,gBAAgB,SAAS,QAAQ;AAAA,MAAA;AAG7F,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,wCAAwC,QAAQ,GAAG;AAAA,MACrE;AAEI,UAAA,UAAU,SAAS,SAAS;AACxB,cAAA,IAAI,MAAM,2BAA2B;AAAA,MAC7C;AAEA,YAAM,gBAAgB,UAAU;AAC1B,YAAA,YAAY,CAAC,IAAI,SAAS,QAAQ,QAAQ,EAAE,GAAG,aAAa,EAAE,KAAK,GAAG;AAE5E,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQA,YAAAA,gBAAgB;AAAA,UACtB,QAAQ,IAAI;AAAA,UACZ,OAAO;AAAA,YACL;AAAA,UACF;AAAA,QAAA,CACD;AAAA,MAAA,CACF;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
@@ -23,7 +23,7 @@ const buildFilesPlugin = (ctx) => {
23
23
  throw new Error("Entry file is not a chunk");
24
24
  }
25
25
  const entryFileName = entryFile.fileName;
26
- const entryPath = ["/admin".replace(/\/+$/, ""), entryFileName].join("/");
26
+ const entryPath = [ctx.basePath.replace(/\/+$/, ""), entryFileName].join("/");
27
27
  this.emitFile({
28
28
  type: "asset",
29
29
  fileName: "index.html",
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","sources":["../../../src/node/vite/plugins.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport { getDocumentHTML } from '../staticFiles';\nimport type { BuildContext } from '../create-build-context';\n\nconst buildFilesPlugin = (ctx: BuildContext): Plugin => {\n const CHUNK_ID = '.strapi/client/app.js';\n\n return {\n name: 'strapi/server/build-files',\n apply: 'build',\n buildStart() {\n this.emitFile({\n type: 'chunk',\n id: CHUNK_ID,\n name: 'strapi',\n });\n },\n async generateBundle(_options, outputBundle) {\n const bundle = outputBundle;\n const entryFile = Object.values(bundle).find(\n (file) =>\n file.type === 'chunk' && file.name === 'strapi' && file.facadeModuleId?.endsWith(CHUNK_ID)\n );\n\n if (!entryFile) {\n throw new Error(`Failed to find entry file in bundle (${CHUNK_ID})`);\n }\n\n if (entryFile.type !== 'chunk') {\n throw new Error('Entry file is not a chunk');\n }\n\n const entryFileName = entryFile.fileName;\n const entryPath = ['/admin'.replace(/\\/+$/, ''), entryFileName].join('/');\n\n this.emitFile({\n type: 'asset',\n fileName: 'index.html',\n source: getDocumentHTML({\n logger: ctx.logger,\n props: {\n entryPath,\n },\n }),\n });\n },\n };\n};\n\nexport { buildFilesPlugin };\n"],"names":[],"mappings":";AAKM,MAAA,mBAAmB,CAAC,QAA8B;AACtD,QAAM,WAAW;AAEV,SAAA;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AACX,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,IACA,MAAM,eAAe,UAAU,cAAc;AAC3C,YAAM,SAAS;AACf,YAAM,YAAY,OAAO,OAAO,MAAM,EAAE;AAAA,QACtC,CAAC,SACC,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,gBAAgB,SAAS,QAAQ;AAAA,MAAA;AAG7F,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,wCAAwC,QAAQ,GAAG;AAAA,MACrE;AAEI,UAAA,UAAU,SAAS,SAAS;AACxB,cAAA,IAAI,MAAM,2BAA2B;AAAA,MAC7C;AAEA,YAAM,gBAAgB,UAAU;AAC1B,YAAA,YAAY,CAAC,SAAS,QAAQ,QAAQ,EAAE,GAAG,aAAa,EAAE,KAAK,GAAG;AAExE,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,gBAAgB;AAAA,UACtB,QAAQ,IAAI;AAAA,UACZ,OAAO;AAAA,YACL;AAAA,UACF;AAAA,QAAA,CACD;AAAA,MAAA,CACF;AAAA,IACH;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"plugins.mjs","sources":["../../../src/node/vite/plugins.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport { getDocumentHTML } from '../staticFiles';\nimport type { BuildContext } from '../create-build-context';\n\nconst buildFilesPlugin = (ctx: BuildContext): Plugin => {\n const CHUNK_ID = '.strapi/client/app.js';\n\n return {\n name: 'strapi/server/build-files',\n apply: 'build',\n buildStart() {\n this.emitFile({\n type: 'chunk',\n id: CHUNK_ID,\n name: 'strapi',\n });\n },\n async generateBundle(_options, outputBundle) {\n const bundle = outputBundle;\n const entryFile = Object.values(bundle).find(\n (file) =>\n file.type === 'chunk' && file.name === 'strapi' && file.facadeModuleId?.endsWith(CHUNK_ID)\n );\n\n if (!entryFile) {\n throw new Error(`Failed to find entry file in bundle (${CHUNK_ID})`);\n }\n\n if (entryFile.type !== 'chunk') {\n throw new Error('Entry file is not a chunk');\n }\n\n const entryFileName = entryFile.fileName;\n const entryPath = [ctx.basePath.replace(/\\/+$/, ''), entryFileName].join('/');\n\n this.emitFile({\n type: 'asset',\n fileName: 'index.html',\n source: getDocumentHTML({\n logger: ctx.logger,\n props: {\n entryPath,\n },\n }),\n });\n },\n };\n};\n\nexport { buildFilesPlugin };\n"],"names":[],"mappings":";AAKM,MAAA,mBAAmB,CAAC,QAA8B;AACtD,QAAM,WAAW;AAEV,SAAA;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AACX,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,IACA,MAAM,eAAe,UAAU,cAAc;AAC3C,YAAM,SAAS;AACf,YAAM,YAAY,OAAO,OAAO,MAAM,EAAE;AAAA,QACtC,CAAC,SACC,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,gBAAgB,SAAS,QAAQ;AAAA,MAAA;AAG7F,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,wCAAwC,QAAQ,GAAG;AAAA,MACrE;AAEI,UAAA,UAAU,SAAS,SAAS;AACxB,cAAA,IAAI,MAAM,2BAA2B;AAAA,MAC7C;AAEA,YAAM,gBAAgB,UAAU;AAC1B,YAAA,YAAY,CAAC,IAAI,SAAS,QAAQ,QAAQ,EAAE,GAAG,aAAa,EAAE,KAAK,GAAG;AAE5E,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,gBAAgB;AAAA,UACtB,QAAQ,IAAI;AAAA,UACZ,OAAO;AAAA,YACL;AAAA,UACF;AAAA,QAAA,CACD;AAAA,MAAA,CACF;AAAA,IACH;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "5.0.0-rc.9",
3
+ "version": "5.0.0",
4
4
  "description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
5
5
  "keywords": [
6
6
  "strapi",
@@ -109,26 +109,25 @@
109
109
  },
110
110
  "dependencies": {
111
111
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
112
- "@strapi/admin": "5.0.0-rc.9",
113
- "@strapi/cloud-cli": "5.0.0-rc.9",
114
- "@strapi/content-manager": "5.0.0-rc.9",
115
- "@strapi/content-releases": "5.0.0-rc.9",
116
- "@strapi/content-type-builder": "5.0.0-rc.9",
117
- "@strapi/core": "5.0.0-rc.9",
118
- "@strapi/data-transfer": "5.0.0-rc.9",
119
- "@strapi/database": "5.0.0-rc.9",
120
- "@strapi/email": "5.0.0-rc.9",
121
- "@strapi/generate-new": "5.0.0-rc.9",
122
- "@strapi/generators": "5.0.0-rc.9",
123
- "@strapi/i18n": "5.0.0-rc.9",
124
- "@strapi/logger": "5.0.0-rc.9",
112
+ "@strapi/admin": "5.0.0",
113
+ "@strapi/cloud-cli": "5.0.0",
114
+ "@strapi/content-manager": "5.0.0",
115
+ "@strapi/content-releases": "5.0.0",
116
+ "@strapi/content-type-builder": "5.0.0",
117
+ "@strapi/core": "5.0.0",
118
+ "@strapi/data-transfer": "5.0.0",
119
+ "@strapi/database": "5.0.0",
120
+ "@strapi/email": "5.0.0",
121
+ "@strapi/generators": "5.0.0",
122
+ "@strapi/i18n": "5.0.0",
123
+ "@strapi/logger": "5.0.0",
125
124
  "@strapi/pack-up": "5.0.0",
126
- "@strapi/permissions": "5.0.0-rc.9",
127
- "@strapi/review-workflows": "5.0.0-rc.9",
128
- "@strapi/types": "5.0.0-rc.9",
129
- "@strapi/typescript-utils": "5.0.0-rc.9",
130
- "@strapi/upload": "5.0.0-rc.9",
131
- "@strapi/utils": "5.0.0-rc.9",
125
+ "@strapi/permissions": "5.0.0",
126
+ "@strapi/review-workflows": "5.0.0",
127
+ "@strapi/types": "5.0.0",
128
+ "@strapi/typescript-utils": "5.0.0",
129
+ "@strapi/upload": "5.0.0",
130
+ "@strapi/utils": "5.0.0",
132
131
  "@types/nodemon": "1.19.6",
133
132
  "@vitejs/plugin-react-swc": "3.6.0",
134
133
  "boxen": "5.1.2",
@@ -138,7 +137,7 @@
138
137
  "chokidar": "3.5.3",
139
138
  "ci-info": "3.8.0",
140
139
  "cli-progress": "3.12.0",
141
- "cli-table3": "0.6.2",
140
+ "cli-table3": "0.6.5",
142
141
  "commander": "8.3.0",
143
142
  "concurrently": "8.2.2",
144
143
  "copyfiles": "2.4.1",
@@ -183,10 +182,11 @@
183
182
  "@types/node": "18.19.24",
184
183
  "@types/webpack-bundle-analyzer": "4.7.0",
185
184
  "@types/webpack-hot-middleware": "2.25.9",
186
- "eslint-config-custom": "5.0.0-rc.9",
185
+ "eslint-config-custom": "5.0.0",
186
+ "jest": "29.6.0",
187
187
  "react": "18.3.1",
188
188
  "react-dom": "18.3.1",
189
- "tsconfig": "5.0.0-rc.9"
189
+ "tsconfig": "5.0.0"
190
190
  },
191
191
  "peerDependencies": {
192
192
  "react": "^17.0.0 || ^18.0.0",
@@ -198,5 +198,5 @@
198
198
  "node": ">=18.0.0 <=20.x.x",
199
199
  "npm": ">=6.0.0"
200
200
  },
201
- "gitHead": "e281ba8e37693c2fc24795be4df4f2ed516063fc"
201
+ "gitHead": "ce84fada19d58a7dfbdd553035e6558f8befcba4"
202
202
  }