@strapi/strapi 5.0.0-beta.8 → 5.0.0-rc.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 (127) hide show
  1. package/LICENSE +18 -3
  2. package/README.md +4 -4
  3. package/dist/cli/commands/build.d.ts.map +1 -1
  4. package/dist/cli/commands/build.js +0 -6
  5. package/dist/cli/commands/build.js.map +1 -1
  6. package/dist/cli/commands/build.mjs +0 -6
  7. package/dist/cli/commands/build.mjs.map +1 -1
  8. package/dist/cli/commands/index.d.ts.map +1 -1
  9. package/dist/cli/commands/index.js +4 -12
  10. package/dist/cli/commands/index.js.map +1 -1
  11. package/dist/cli/commands/index.mjs +4 -12
  12. package/dist/cli/commands/index.mjs.map +1 -1
  13. package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +1 -1
  14. package/dist/cli/index.d.ts.map +1 -1
  15. package/dist/cli/index.js +32 -2
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/cli/index.mjs +32 -2
  18. package/dist/cli/index.mjs.map +1 -1
  19. package/dist/cli/types.d.ts +1 -1
  20. package/dist/cli/types.d.ts.map +1 -1
  21. package/dist/cli/utils/logger.d.ts +4 -1
  22. package/dist/cli/utils/logger.d.ts.map +1 -1
  23. package/dist/cli/utils/logger.js +68 -13
  24. package/dist/cli/utils/logger.js.map +1 -1
  25. package/dist/cli/utils/logger.mjs +49 -13
  26. package/dist/cli/utils/logger.mjs.map +1 -1
  27. package/dist/node/core/aliases.d.ts.map +1 -1
  28. package/dist/node/core/aliases.js +1 -0
  29. package/dist/node/core/aliases.js.map +1 -1
  30. package/dist/node/core/aliases.mjs +1 -0
  31. package/dist/node/core/aliases.mjs.map +1 -1
  32. package/dist/node/core/dependencies.d.ts.map +1 -1
  33. package/dist/node/core/dependencies.js +4 -0
  34. package/dist/node/core/dependencies.js.map +1 -1
  35. package/dist/node/core/dependencies.mjs +4 -0
  36. package/dist/node/core/dependencies.mjs.map +1 -1
  37. package/dist/node/create-build-context.js +1 -1
  38. package/dist/node/create-build-context.js.map +1 -1
  39. package/dist/node/create-build-context.mjs +1 -1
  40. package/dist/node/create-build-context.mjs.map +1 -1
  41. package/dist/node/vite/config.js +1 -1
  42. package/dist/node/vite/config.js.map +1 -1
  43. package/dist/node/vite/config.mjs +1 -1
  44. package/dist/node/vite/config.mjs.map +1 -1
  45. package/package.json +26 -23
  46. package/dist/cli/commands/plugin/build.d.ts +0 -7
  47. package/dist/cli/commands/plugin/build.d.ts.map +0 -1
  48. package/dist/cli/commands/plugin/build.js +0 -88
  49. package/dist/cli/commands/plugin/build.js.map +0 -1
  50. package/dist/cli/commands/plugin/build.mjs +0 -85
  51. package/dist/cli/commands/plugin/build.mjs.map +0 -1
  52. package/dist/cli/commands/plugin/init/action.d.ts +0 -6
  53. package/dist/cli/commands/plugin/init/action.d.ts.map +0 -1
  54. package/dist/cli/commands/plugin/init/action.js +0 -413
  55. package/dist/cli/commands/plugin/init/action.js.map +0 -1
  56. package/dist/cli/commands/plugin/init/action.mjs +0 -408
  57. package/dist/cli/commands/plugin/init/action.mjs.map +0 -1
  58. package/dist/cli/commands/plugin/init/command.d.ts +0 -7
  59. package/dist/cli/commands/plugin/init/command.d.ts.map +0 -1
  60. package/dist/cli/commands/plugin/init/command.js +0 -9
  61. package/dist/cli/commands/plugin/init/command.js.map +0 -1
  62. package/dist/cli/commands/plugin/init/command.mjs +0 -10
  63. package/dist/cli/commands/plugin/init/command.mjs.map +0 -1
  64. package/dist/cli/commands/plugin/init/files/admin.d.ts +0 -5
  65. package/dist/cli/commands/plugin/init/files/admin.d.ts.map +0 -1
  66. package/dist/cli/commands/plugin/init/files/admin.js +0 -283
  67. package/dist/cli/commands/plugin/init/files/admin.js.map +0 -1
  68. package/dist/cli/commands/plugin/init/files/admin.mjs +0 -283
  69. package/dist/cli/commands/plugin/init/files/admin.mjs.map +0 -1
  70. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts +0 -4
  71. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts.map +0 -1
  72. package/dist/cli/commands/plugin/init/files/editorConfig.js +0 -26
  73. package/dist/cli/commands/plugin/init/files/editorConfig.js.map +0 -1
  74. package/dist/cli/commands/plugin/init/files/editorConfig.mjs +0 -26
  75. package/dist/cli/commands/plugin/init/files/editorConfig.mjs.map +0 -1
  76. package/dist/cli/commands/plugin/init/files/eslint.d.ts +0 -4
  77. package/dist/cli/commands/plugin/init/files/eslint.d.ts.map +0 -1
  78. package/dist/cli/commands/plugin/init/files/eslint.js +0 -11
  79. package/dist/cli/commands/plugin/init/files/eslint.js.map +0 -1
  80. package/dist/cli/commands/plugin/init/files/eslint.mjs +0 -11
  81. package/dist/cli/commands/plugin/init/files/eslint.mjs.map +0 -1
  82. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts +0 -4
  83. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts.map +0 -1
  84. package/dist/cli/commands/plugin/init/files/gitIgnore.js +0 -34
  85. package/dist/cli/commands/plugin/init/files/gitIgnore.js.map +0 -1
  86. package/dist/cli/commands/plugin/init/files/gitIgnore.mjs +0 -34
  87. package/dist/cli/commands/plugin/init/files/gitIgnore.mjs.map +0 -1
  88. package/dist/cli/commands/plugin/init/files/prettier.d.ts +0 -5
  89. package/dist/cli/commands/plugin/init/files/prettier.d.ts.map +0 -1
  90. package/dist/cli/commands/plugin/init/files/prettier.js +0 -25
  91. package/dist/cli/commands/plugin/init/files/prettier.js.map +0 -1
  92. package/dist/cli/commands/plugin/init/files/prettier.mjs +0 -25
  93. package/dist/cli/commands/plugin/init/files/prettier.mjs.map +0 -1
  94. package/dist/cli/commands/plugin/init/files/server.d.ts +0 -5
  95. package/dist/cli/commands/plugin/init/files/server.d.ts.map +0 -1
  96. package/dist/cli/commands/plugin/init/files/server.js +0 -360
  97. package/dist/cli/commands/plugin/init/files/server.js.map +0 -1
  98. package/dist/cli/commands/plugin/init/files/server.mjs +0 -360
  99. package/dist/cli/commands/plugin/init/files/server.mjs.map +0 -1
  100. package/dist/cli/commands/plugin/init/files/typescript.js +0 -66
  101. package/dist/cli/commands/plugin/init/files/typescript.js.map +0 -1
  102. package/dist/cli/commands/plugin/init/files/typescript.mjs +0 -66
  103. package/dist/cli/commands/plugin/init/files/typescript.mjs.map +0 -1
  104. package/dist/cli/commands/plugin/init/index.d.ts +0 -2
  105. package/dist/cli/commands/plugin/init/index.d.ts.map +0 -1
  106. package/dist/cli/commands/plugin/link-watch.d.ts +0 -7
  107. package/dist/cli/commands/plugin/link-watch.d.ts.map +0 -1
  108. package/dist/cli/commands/plugin/link-watch.js +0 -89
  109. package/dist/cli/commands/plugin/link-watch.js.map +0 -1
  110. package/dist/cli/commands/plugin/link-watch.mjs +0 -82
  111. package/dist/cli/commands/plugin/link-watch.mjs.map +0 -1
  112. package/dist/cli/commands/plugin/verify.d.ts +0 -7
  113. package/dist/cli/commands/plugin/verify.d.ts.map +0 -1
  114. package/dist/cli/commands/plugin/verify.js +0 -37
  115. package/dist/cli/commands/plugin/verify.js.map +0 -1
  116. package/dist/cli/commands/plugin/verify.mjs +0 -34
  117. package/dist/cli/commands/plugin/verify.mjs.map +0 -1
  118. package/dist/cli/commands/plugin/watch.d.ts +0 -7
  119. package/dist/cli/commands/plugin/watch.d.ts.map +0 -1
  120. package/dist/cli/commands/plugin/watch.js +0 -86
  121. package/dist/cli/commands/plugin/watch.js.map +0 -1
  122. package/dist/cli/commands/plugin/watch.mjs +0 -83
  123. package/dist/cli/commands/plugin/watch.mjs.map +0 -1
  124. package/dist/cli/utils/pkg.js +0 -111
  125. package/dist/cli/utils/pkg.js.map +0 -1
  126. package/dist/cli/utils/pkg.mjs +0 -87
  127. package/dist/cli/utils/pkg.mjs.map +0 -1
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const commander = require("commander");
4
- const boxen = require("boxen");
5
- const chalk = require("chalk");
6
- const packUp = require("@strapi/pack-up");
7
- const commander$1 = require("../../utils/commander.js");
8
- const helpers = require("../../utils/helpers.js");
9
- const pkg = require("../../utils/pkg.js");
10
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
11
- const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
12
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
13
- const action = async ({ force, ...opts }, _cmd, { logger, cwd }) => {
14
- try {
15
- process.env.NODE_ENV = "production";
16
- const pkg$1 = await pkg.loadPkg({ cwd, logger });
17
- const pkgJson = await pkg.validatePkg({ pkg: pkg$1 });
18
- if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
19
- throw new Error(
20
- "You need to have either a strapi-admin or strapi-server export in your package.json"
21
- );
22
- }
23
- const bundles = [];
24
- if (pkgJson.exports["./strapi-admin"]) {
25
- const exp = pkgJson.exports["./strapi-admin"];
26
- const bundle = {
27
- source: exp.source,
28
- import: exp.import,
29
- require: exp.require,
30
- runtime: "web"
31
- };
32
- if (exp.types) {
33
- bundle.types = exp.types;
34
- bundle.tsconfig = "./admin/tsconfig.build.json";
35
- }
36
- bundles.push(bundle);
37
- }
38
- if (pkgJson.exports["./strapi-server"]) {
39
- const exp = pkgJson.exports["./strapi-server"];
40
- const bundle = {
41
- source: exp.source,
42
- import: exp.import,
43
- require: exp.require,
44
- runtime: "node"
45
- };
46
- if (exp.types) {
47
- bundle.types = exp.types;
48
- bundle.tsconfig = "./server/tsconfig.build.json";
49
- }
50
- bundles.push(bundle);
51
- }
52
- await packUp.build({
53
- cwd,
54
- configFile: false,
55
- config: {
56
- bundles,
57
- dist: "./dist",
58
- /**
59
- * ignore the exports map of a plugin, because we're streamlining the
60
- * process and ensuring the server package and admin package are built
61
- * with the correct runtime and their individual tsconfigs
62
- */
63
- exports: {}
64
- },
65
- ...opts
66
- });
67
- } catch (err) {
68
- logger.error(
69
- "There seems to be an unexpected error, try again with --debug for more information \n"
70
- );
71
- if (err instanceof Error && err.stack) {
72
- console.log(
73
- chalk__default.default.red(
74
- boxen__default.default(err.stack, {
75
- padding: 1,
76
- align: "left"
77
- })
78
- )
79
- );
80
- }
81
- process.exit(1);
82
- }
83
- };
84
- const command = ({ ctx }) => {
85
- return commander.createCommand("plugin:build").description("Bundle your strapi plugin for publishing.").addOption(commander$1.forceOption).option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).option("--sourcemap", "produce sourcemaps", false).option("--minify", "minify the output", false).action((...args) => helpers.runAction("plugin:build", action)(...args, ctx));
86
- };
87
- exports.command = command;
88
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.js","sources":["../../../../src/cli/commands/plugin/build.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { BuildCLIOptions, ConfigBundle, build } from '@strapi/pack-up';\n\nimport { forceOption } from '../../utils/commander';\nimport { runAction } from '../../utils/helpers';\nimport { Export, loadPkg, validatePkg } from '../../utils/pkg';\nimport type { CLIContext, StrapiCommand } from '../../types';\n\ninterface ActionOptions extends BuildCLIOptions {\n force?: boolean;\n}\n\nconst action = async (\n { force, ...opts }: ActionOptions,\n _cmd: unknown,\n { logger, cwd }: CLIContext\n) => {\n try {\n /**\n * ALWAYS set production for using plugin build CLI.\n */\n process.env.NODE_ENV = 'production';\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await build({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n\n/**\n * `$ strapi plugin:build`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('plugin:build')\n .description('Bundle your strapi plugin for publishing.')\n .addOption(forceOption)\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--sourcemap', 'produce sourcemaps', false)\n .option('--minify', 'minify the output', false)\n .action((...args) => runAction('plugin:build', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":["pkg","loadPkg","validatePkg","build","chalk","boxen","createCommand","forceOption","runAction"],"mappings":";;;;;;;;;;;;AAcA,MAAM,SAAS,OACb,EAAE,OAAO,GAAG,KAAK,GACjB,MACA,EAAE,QAAQ,UACP;AACC,MAAA;AAIF,YAAQ,IAAI,WAAW;AAEvB,UAAMA,QAAM,MAAMC,IAAA,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAMC,IAAAA,YAAY,EAAEF,KAAAA,MAAK,CAAA;AAErC,QAAA,CAAC,QAAQ,QAAQ,gBAAgB,KAAK,CAAC,QAAQ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AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,UAAU;AAC1C,SAAOC,UAAAA,cAAc,cAAc,EAChC,YAAY,2CAA2C,EACvD,UAAUC,uBAAW,EACrB,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,eAAe,sBAAsB,KAAK,EACjD,OAAO,YAAY,qBAAqB,KAAK,EAC7C,OAAO,IAAI,SAASC,kBAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;;"}
@@ -1,85 +0,0 @@
1
- import { createCommand } from "commander";
2
- import boxen from "boxen";
3
- import chalk from "chalk";
4
- import { build } from "@strapi/pack-up";
5
- import { forceOption } from "../../utils/commander.mjs";
6
- import { runAction } from "../../utils/helpers.mjs";
7
- import { loadPkg, validatePkg } from "../../utils/pkg.mjs";
8
- const action = async ({ force, ...opts }, _cmd, { logger, cwd }) => {
9
- try {
10
- process.env.NODE_ENV = "production";
11
- const pkg = await loadPkg({ cwd, logger });
12
- const pkgJson = await validatePkg({ pkg });
13
- if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
14
- throw new Error(
15
- "You need to have either a strapi-admin or strapi-server export in your package.json"
16
- );
17
- }
18
- const bundles = [];
19
- if (pkgJson.exports["./strapi-admin"]) {
20
- const exp = pkgJson.exports["./strapi-admin"];
21
- const bundle = {
22
- source: exp.source,
23
- import: exp.import,
24
- require: exp.require,
25
- runtime: "web"
26
- };
27
- if (exp.types) {
28
- bundle.types = exp.types;
29
- bundle.tsconfig = "./admin/tsconfig.build.json";
30
- }
31
- bundles.push(bundle);
32
- }
33
- if (pkgJson.exports["./strapi-server"]) {
34
- const exp = pkgJson.exports["./strapi-server"];
35
- const bundle = {
36
- source: exp.source,
37
- import: exp.import,
38
- require: exp.require,
39
- runtime: "node"
40
- };
41
- if (exp.types) {
42
- bundle.types = exp.types;
43
- bundle.tsconfig = "./server/tsconfig.build.json";
44
- }
45
- bundles.push(bundle);
46
- }
47
- await build({
48
- cwd,
49
- configFile: false,
50
- config: {
51
- bundles,
52
- dist: "./dist",
53
- /**
54
- * ignore the exports map of a plugin, because we're streamlining the
55
- * process and ensuring the server package and admin package are built
56
- * with the correct runtime and their individual tsconfigs
57
- */
58
- exports: {}
59
- },
60
- ...opts
61
- });
62
- } catch (err) {
63
- logger.error(
64
- "There seems to be an unexpected error, try again with --debug for more information \n"
65
- );
66
- if (err instanceof Error && err.stack) {
67
- console.log(
68
- chalk.red(
69
- boxen(err.stack, {
70
- padding: 1,
71
- align: "left"
72
- })
73
- )
74
- );
75
- }
76
- process.exit(1);
77
- }
78
- };
79
- const command = ({ ctx }) => {
80
- return createCommand("plugin:build").description("Bundle your strapi plugin for publishing.").addOption(forceOption).option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).option("--sourcemap", "produce sourcemaps", false).option("--minify", "minify the output", false).action((...args) => runAction("plugin:build", action)(...args, ctx));
81
- };
82
- export {
83
- command
84
- };
85
- //# sourceMappingURL=build.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.mjs","sources":["../../../../src/cli/commands/plugin/build.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { BuildCLIOptions, ConfigBundle, build } from '@strapi/pack-up';\n\nimport { forceOption } from '../../utils/commander';\nimport { runAction } from '../../utils/helpers';\nimport { Export, loadPkg, validatePkg } from '../../utils/pkg';\nimport type { CLIContext, StrapiCommand } from '../../types';\n\ninterface ActionOptions extends BuildCLIOptions {\n force?: boolean;\n}\n\nconst action = async (\n { force, ...opts }: ActionOptions,\n _cmd: unknown,\n { logger, cwd }: CLIContext\n) => {\n try {\n /**\n * ALWAYS set production for using plugin build CLI.\n */\n process.env.NODE_ENV = 'production';\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await build({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n\n/**\n * `$ strapi plugin:build`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('plugin:build')\n .description('Bundle your strapi plugin for publishing.')\n .addOption(forceOption)\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--sourcemap', 'produce sourcemaps', false)\n .option('--minify', 'minify the output', false)\n .action((...args) => runAction('plugin:build', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":[],"mappings":";;;;;;;AAcA,MAAM,SAAS,OACb,EAAE,OAAO,GAAG,KAAK,GACj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AA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACN,MAAM;AAAA,UACJ,MAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,UAAU;AAC1C,SAAO,cAAc,cAAc,EAChC,YAAY,2CAA2C,EACvD,UAAU,WAAW,EACrB,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,eAAe,sBAAsB,KAAK,EACjD,OAAO,YAAY,qBAAqB,KAAK,EAC7C,OAAO,IAAI,SAAS,UAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;"}
@@ -1,6 +0,0 @@
1
- import { InitOptions } from '@strapi/pack-up';
2
- import { CLIContext } from '../../../types';
3
- type ActionOptions = Pick<InitOptions, 'silent' | 'debug'>;
4
- declare const _default: (packagePath: string, { silent, debug }: ActionOptions, { logger, cwd }: CLIContext) => Promise<void>;
5
- export default _default;
6
- //# sourceMappingURL=action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/plugin/init/action.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAMZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,KAAK,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;sCAG5C,MAAM,qBACA,aAAa,mBACf,UAAU;AAH7B,wBAkCE"}
@@ -1,413 +0,0 @@
1
- "use strict";
2
- const path = require("node:path");
3
- const boxen = require("boxen");
4
- const chalk = require("chalk");
5
- const getLatestVersion = require("get-latest-version");
6
- const gitUrlParse = require("git-url-parse");
7
- const packUp = require("@strapi/pack-up");
8
- const outdent = require("outdent");
9
- const gitIgnore = require("./files/gitIgnore.js");
10
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
11
- const path__default = /* @__PURE__ */ _interopDefault(path);
12
- const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
13
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
14
- const getLatestVersion__default = /* @__PURE__ */ _interopDefault(getLatestVersion);
15
- const gitUrlParse__default = /* @__PURE__ */ _interopDefault(gitUrlParse);
16
- const action = async (packagePath, { silent, debug }, { logger, cwd }) => {
17
- try {
18
- await packUp.init({
19
- path: packagePath,
20
- cwd,
21
- silent,
22
- debug,
23
- template: PLUGIN_TEMPLATE
24
- });
25
- logger.info("Don't forget to enable your plugin in your configuration files.");
26
- } catch (err) {
27
- logger.error(
28
- "There seems to be an unexpected error, try again with --debug for more information \n"
29
- );
30
- if (err instanceof Error && err.stack) {
31
- logger.log(
32
- chalk__default.default.red(
33
- boxen__default.default(err.stack, {
34
- padding: 1,
35
- align: "left"
36
- })
37
- )
38
- );
39
- }
40
- process.exit(1);
41
- }
42
- };
43
- const PACKAGE_NAME_REGEXP = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i;
44
- const PLUGIN_TEMPLATE = packUp.defineTemplate(async ({ logger, gitConfig, packagePath }) => {
45
- let repo;
46
- const [packageFolder] = packagePath.split(path__default.default.sep).slice(-1);
47
- return {
48
- prompts: [
49
- packUp.definePackageOption({
50
- name: "repo",
51
- type: "text",
52
- message: "git url",
53
- validate(v) {
54
- if (!v) {
55
- return true;
56
- }
57
- try {
58
- const result = gitUrlParse__default.default(v);
59
- repo = { source: result.source, owner: result.owner, name: result.name };
60
- return true;
61
- } catch (err) {
62
- return "invalid git url";
63
- }
64
- }
65
- }),
66
- packUp.definePackageOption({
67
- name: "pkgName",
68
- type: "text",
69
- message: "plugin name",
70
- initial: () => repo?.name ?? "",
71
- validate(v) {
72
- if (!v) {
73
- return "package name is required";
74
- }
75
- const match = PACKAGE_NAME_REGEXP.exec(v);
76
- if (!match) {
77
- return "invalid package name";
78
- }
79
- return true;
80
- }
81
- }),
82
- packUp.definePackageOption({
83
- name: "displayName",
84
- type: "text",
85
- message: "plugin display name"
86
- }),
87
- packUp.definePackageOption({
88
- name: "description",
89
- type: "text",
90
- message: "plugin description"
91
- }),
92
- packUp.definePackageOption({
93
- name: "authorName",
94
- type: "text",
95
- message: "plugin author name",
96
- initial: gitConfig?.user?.name
97
- }),
98
- packUp.definePackageOption({
99
- name: "authorEmail",
100
- type: "text",
101
- message: "plugin author email",
102
- initial: gitConfig?.user?.email
103
- }),
104
- packUp.definePackageOption({
105
- name: "license",
106
- type: "text",
107
- message: "plugin license",
108
- initial: "MIT",
109
- validate(v) {
110
- if (!v) {
111
- return "license is required";
112
- }
113
- return true;
114
- }
115
- }),
116
- packUp.definePackageOption({
117
- name: "client-code",
118
- type: "confirm",
119
- message: "register with the admin panel?",
120
- initial: true
121
- }),
122
- packUp.definePackageOption({
123
- name: "server-code",
124
- type: "confirm",
125
- message: "register with the server?",
126
- initial: true
127
- }),
128
- packUp.definePackageFeature({
129
- name: "editorconfig",
130
- initial: true,
131
- optional: true
132
- }),
133
- packUp.definePackageFeature({
134
- name: "eslint",
135
- initial: true,
136
- optional: true
137
- }),
138
- packUp.definePackageFeature({
139
- name: "prettier",
140
- initial: true,
141
- optional: true
142
- }),
143
- packUp.definePackageFeature({
144
- name: "typescript",
145
- initial: true,
146
- optional: true
147
- })
148
- ],
149
- async getFiles(answers) {
150
- const author = [];
151
- const files = [];
152
- const pkgJson = {
153
- version: "0.0.0",
154
- keywords: [],
155
- type: "commonjs",
156
- exports: {
157
- "./package.json": "./package.json"
158
- },
159
- files: ["dist"],
160
- scripts: {
161
- build: "strapi plugin:build",
162
- watch: "strapi plugin:watch",
163
- "watch:link": "strapi plugin:watch:link",
164
- verify: "strapi plugin:verify"
165
- },
166
- dependencies: {},
167
- devDependencies: {
168
- /**
169
- * We set * as a default version, but further down
170
- * we try to resolve each package to their latest
171
- * version, failing that we leave the fallback of *.
172
- */
173
- "@strapi/strapi": "*",
174
- prettier: "*"
175
- },
176
- peerDependencies: {
177
- "@strapi/strapi": "^4.0.0"
178
- },
179
- strapi: {
180
- kind: "plugin"
181
- }
182
- };
183
- if (Array.isArray(answers)) {
184
- for (const ans of answers) {
185
- const { name, answer } = ans;
186
- switch (name) {
187
- case "pkgName": {
188
- pkgJson.name = String(answer);
189
- pkgJson.strapi.name = String(answer);
190
- break;
191
- }
192
- case "description": {
193
- pkgJson.description = String(answer) ?? void 0;
194
- pkgJson.strapi.description = String(answer) ?? void 0;
195
- break;
196
- }
197
- case "displayName": {
198
- pkgJson.strapi.displayName = String(answer) ?? void 0;
199
- break;
200
- }
201
- case "authorName": {
202
- author.push(String(answer));
203
- break;
204
- }
205
- case "authorEmail": {
206
- if (answer) {
207
- author.push(`<${answer}>`);
208
- }
209
- break;
210
- }
211
- case "license": {
212
- pkgJson.license = String(answer);
213
- break;
214
- }
215
- case "client-code": {
216
- if (answer) {
217
- pkgJson.exports["./strapi-admin"] = {
218
- source: "./admin/src/index.js",
219
- import: "./dist/admin/index.mjs",
220
- require: "./dist/admin/index.js",
221
- default: "./dist/admin/index.js"
222
- };
223
- pkgJson.dependencies = {
224
- ...pkgJson.dependencies,
225
- "@strapi/design-system": "*",
226
- "@strapi/icons": "*"
227
- };
228
- pkgJson.devDependencies = {
229
- ...pkgJson.devDependencies,
230
- react: "*",
231
- "react-dom": "*",
232
- "react-router-dom": "*",
233
- "styled-components": "*"
234
- };
235
- pkgJson.peerDependencies = {
236
- ...pkgJson.peerDependencies,
237
- react: "^17.0.0 || ^18.0.0",
238
- "react-dom": "^17.0.0 || ^18.0.0",
239
- "react-router-dom": "^6.0.0",
240
- "styled-components": "^6.0.0"
241
- };
242
- }
243
- break;
244
- }
245
- case "server-code": {
246
- if (answer) {
247
- pkgJson.exports["./strapi-server"] = {
248
- source: "./server/src/index.js",
249
- import: "./dist/server/index.mjs",
250
- require: "./dist/server/index.js",
251
- default: "./dist/server/index.js"
252
- };
253
- pkgJson.files.push("./strapi-server.js");
254
- files.push({
255
- name: "strapi-server.js",
256
- contents: outdent.outdent`
257
- 'use strict';
258
-
259
- module.exports = require('./dist/server');
260
- `
261
- });
262
- }
263
- break;
264
- }
265
- case "typescript": {
266
- const isTypescript = Boolean(answer);
267
- if (isTypescript) {
268
- if (isRecord(pkgJson.exports["./strapi-admin"])) {
269
- pkgJson.exports["./strapi-admin"].source = "./admin/src/index.ts";
270
- pkgJson.exports["./strapi-admin"] = {
271
- types: "./dist/admin/src/index.d.ts",
272
- ...pkgJson.exports["./strapi-admin"]
273
- };
274
- pkgJson.scripts = {
275
- ...pkgJson.scripts,
276
- "test:ts:front": "run -T tsc -p admin/tsconfig.json"
277
- };
278
- pkgJson.devDependencies = {
279
- ...pkgJson.devDependencies,
280
- "@types/react": "*",
281
- "@types/react-dom": "*"
282
- };
283
- const { adminTsconfigFiles } = await Promise.resolve().then(() => require("./files/typescript.js"));
284
- files.push(adminTsconfigFiles.tsconfigBuildFile, adminTsconfigFiles.tsconfigFile);
285
- }
286
- if (isRecord(pkgJson.exports["./strapi-server"])) {
287
- pkgJson.exports["./strapi-server"].source = "./server/src/index.ts";
288
- pkgJson.exports["./strapi-server"] = {
289
- types: "./dist/server/src/index.d.ts",
290
- ...pkgJson.exports["./strapi-server"]
291
- };
292
- pkgJson.scripts = {
293
- ...pkgJson.scripts,
294
- "test:ts:back": "run -T tsc -p server/tsconfig.json"
295
- };
296
- const { serverTsconfigFiles } = await Promise.resolve().then(() => require("./files/typescript.js"));
297
- files.push(
298
- serverTsconfigFiles.tsconfigBuildFile,
299
- serverTsconfigFiles.tsconfigFile
300
- );
301
- }
302
- pkgJson.devDependencies = {
303
- ...pkgJson.devDependencies,
304
- "@strapi/typescript-utils": "*",
305
- typescript: "*"
306
- };
307
- }
308
- if (isRecord(pkgJson.exports["./strapi-admin"])) {
309
- files.push({
310
- name: isTypescript ? "admin/src/pluginId.ts" : "admin/src/pluginId.js",
311
- contents: outdent.outdent`
312
- export const PLUGIN_ID = '${pkgJson.name.replace(/^strapi-plugin-/i, "")}';
313
- `
314
- });
315
- if (isTypescript) {
316
- const { adminTypescriptFiles } = await Promise.resolve().then(() => require("./files/admin.js"));
317
- files.push(...adminTypescriptFiles);
318
- } else {
319
- const { adminJavascriptFiles } = await Promise.resolve().then(() => require("./files/admin.js"));
320
- files.push(...adminJavascriptFiles);
321
- }
322
- }
323
- if (isRecord(pkgJson.exports["./strapi-server"])) {
324
- if (isTypescript) {
325
- const { serverTypescriptFiles } = await Promise.resolve().then(() => require("./files/server.js"));
326
- files.push(...serverTypescriptFiles(packageFolder));
327
- } else {
328
- const { serverJavascriptFiles } = await Promise.resolve().then(() => require("./files/server.js"));
329
- files.push(...serverJavascriptFiles(packageFolder));
330
- }
331
- }
332
- break;
333
- }
334
- case "eslint": {
335
- if (answer) {
336
- const { eslintIgnoreFile } = await Promise.resolve().then(() => require("./files/eslint.js"));
337
- files.push(eslintIgnoreFile);
338
- }
339
- break;
340
- }
341
- case "prettier": {
342
- if (answer) {
343
- const { prettierFile, prettierIgnoreFile } = await Promise.resolve().then(() => require("./files/prettier.js"));
344
- files.push(prettierFile, prettierIgnoreFile);
345
- }
346
- break;
347
- }
348
- case "editorconfig": {
349
- if (answer) {
350
- const { editorConfigFile } = await Promise.resolve().then(() => require("./files/editorConfig.js"));
351
- files.push(editorConfigFile);
352
- }
353
- break;
354
- }
355
- }
356
- }
357
- }
358
- if (repo) {
359
- pkgJson.repository = {
360
- type: "git",
361
- url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`
362
- };
363
- pkgJson.bugs = {
364
- url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`
365
- };
366
- pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`;
367
- }
368
- pkgJson.author = author.filter(Boolean).join(" ") ?? void 0;
369
- try {
370
- pkgJson.devDependencies = await resolveLatestVerisonOfDeps(pkgJson.devDependencies);
371
- pkgJson.dependencies = await resolveLatestVerisonOfDeps(pkgJson.dependencies);
372
- pkgJson.peerDependencies = await resolveLatestVerisonOfDeps(pkgJson.peerDependencies);
373
- } catch (err) {
374
- if (err instanceof Error) {
375
- logger.error(err.message);
376
- } else {
377
- logger.error(err);
378
- }
379
- }
380
- files.push({
381
- name: "package.json",
382
- contents: outdent.outdent`
383
- ${JSON.stringify(pkgJson, null, 2)}
384
- `
385
- });
386
- files.push({
387
- name: "README.md",
388
- contents: outdent.outdent`
389
- # ${pkgJson.name}
390
-
391
- ${pkgJson.description ?? ""}
392
- `
393
- });
394
- files.push(gitIgnore.gitIgnoreFile);
395
- return files;
396
- }
397
- };
398
- });
399
- const isRecord = (value) => Boolean(value) && !Array.isArray(value) && typeof value === "object";
400
- const resolveLatestVerisonOfDeps = async (deps) => {
401
- const latestDeps = {};
402
- for (const [name, version] of Object.entries(deps)) {
403
- try {
404
- const latestVersion = await getLatestVersion__default.default(name, version);
405
- latestDeps[name] = latestVersion ? `^${latestVersion}` : "*";
406
- } catch (err) {
407
- latestDeps[name] = "*";
408
- }
409
- }
410
- return latestDeps;
411
- };
412
- module.exports = action;
413
- //# sourceMappingURL=action.js.map