@strapi/strapi 5.0.0-beta.1 → 5.0.0-beta.10

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 (250) hide show
  1. package/README.md +4 -4
  2. package/dist/admin.d.ts.map +1 -1
  3. package/dist/admin.js +12 -4
  4. package/dist/admin.js.map +1 -1
  5. package/dist/admin.mjs +10 -4
  6. package/dist/admin.mjs.map +1 -1
  7. package/dist/cli/commands/admin/create-user.js +2 -2
  8. package/dist/cli/commands/admin/create-user.js.map +1 -1
  9. package/dist/cli/commands/admin/create-user.mjs +88 -0
  10. package/dist/cli/commands/admin/create-user.mjs.map +1 -0
  11. package/dist/cli/commands/admin/reset-user-password.js +2 -2
  12. package/dist/cli/commands/admin/reset-user-password.js.map +1 -1
  13. package/dist/cli/commands/admin/reset-user-password.mjs +44 -0
  14. package/dist/cli/commands/admin/reset-user-password.mjs.map +1 -0
  15. package/dist/cli/commands/build.mjs +30 -0
  16. package/dist/cli/commands/build.mjs.map +1 -0
  17. package/dist/cli/commands/components/list.js +2 -2
  18. package/dist/cli/commands/components/list.js.map +1 -1
  19. package/dist/cli/commands/components/list.mjs +24 -0
  20. package/dist/cli/commands/components/list.mjs.map +1 -0
  21. package/dist/cli/commands/configuration/dump.js +2 -2
  22. package/dist/cli/commands/configuration/dump.js.map +1 -1
  23. package/dist/cli/commands/configuration/dump.mjs +41 -0
  24. package/dist/cli/commands/configuration/dump.mjs.map +1 -0
  25. package/dist/cli/commands/configuration/restore.js +2 -2
  26. package/dist/cli/commands/configuration/restore.js.map +1 -1
  27. package/dist/cli/commands/configuration/restore.mjs +140 -0
  28. package/dist/cli/commands/configuration/restore.mjs.map +1 -0
  29. package/dist/cli/commands/console.js +2 -2
  30. package/dist/cli/commands/console.js.map +1 -1
  31. package/dist/cli/commands/console.mjs +27 -0
  32. package/dist/cli/commands/console.mjs.map +1 -0
  33. package/dist/cli/commands/content-types/list.js +2 -2
  34. package/dist/cli/commands/content-types/list.js.map +1 -1
  35. package/dist/cli/commands/content-types/list.mjs +24 -0
  36. package/dist/cli/commands/content-types/list.mjs.map +1 -0
  37. package/dist/cli/commands/controllers/list.js +2 -2
  38. package/dist/cli/commands/controllers/list.js.map +1 -1
  39. package/dist/cli/commands/controllers/list.mjs +24 -0
  40. package/dist/cli/commands/controllers/list.mjs.map +1 -0
  41. package/dist/cli/commands/develop.mjs +27 -0
  42. package/dist/cli/commands/develop.mjs.map +1 -0
  43. package/dist/cli/commands/export/action.js.map +1 -1
  44. package/dist/cli/commands/export/action.mjs +116 -0
  45. package/dist/cli/commands/export/action.mjs.map +1 -0
  46. package/dist/cli/commands/export/command.mjs +24 -0
  47. package/dist/cli/commands/export/command.mjs.map +1 -0
  48. package/dist/cli/commands/generate.mjs +13 -0
  49. package/dist/cli/commands/generate.mjs.map +1 -0
  50. package/dist/cli/commands/hooks/list.js +2 -2
  51. package/dist/cli/commands/hooks/list.js.map +1 -1
  52. package/dist/cli/commands/hooks/list.mjs +24 -0
  53. package/dist/cli/commands/hooks/list.mjs.map +1 -0
  54. package/dist/cli/commands/import/action.js.map +1 -1
  55. package/dist/cli/commands/import/action.mjs +105 -0
  56. package/dist/cli/commands/import/action.mjs.map +1 -0
  57. package/dist/cli/commands/import/command.mjs +68 -0
  58. package/dist/cli/commands/import/command.mjs.map +1 -0
  59. package/dist/cli/commands/index.d.ts.map +1 -1
  60. package/dist/cli/commands/index.js +1 -14
  61. package/dist/cli/commands/index.js.map +1 -1
  62. package/dist/cli/commands/index.mjs +58 -0
  63. package/dist/cli/commands/index.mjs.map +1 -0
  64. package/dist/cli/commands/middlewares/list.js +2 -2
  65. package/dist/cli/commands/middlewares/list.js.map +1 -1
  66. package/dist/cli/commands/middlewares/list.mjs +24 -0
  67. package/dist/cli/commands/middlewares/list.mjs.map +1 -0
  68. package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +1 -1
  69. package/dist/cli/commands/policies/list.js +2 -2
  70. package/dist/cli/commands/policies/list.js.map +1 -1
  71. package/dist/cli/commands/policies/list.mjs +24 -0
  72. package/dist/cli/commands/policies/list.mjs.map +1 -0
  73. package/dist/cli/commands/report.js +2 -2
  74. package/dist/cli/commands/report.js.map +1 -1
  75. package/dist/cli/commands/report.mjs +35 -0
  76. package/dist/cli/commands/report.mjs.map +1 -0
  77. package/dist/cli/commands/routes/list.js +2 -2
  78. package/dist/cli/commands/routes/list.js.map +1 -1
  79. package/dist/cli/commands/routes/list.mjs +28 -0
  80. package/dist/cli/commands/routes/list.mjs.map +1 -0
  81. package/dist/cli/commands/services/list.js +2 -2
  82. package/dist/cli/commands/services/list.js.map +1 -1
  83. package/dist/cli/commands/services/list.mjs +24 -0
  84. package/dist/cli/commands/services/list.mjs.map +1 -0
  85. package/dist/cli/commands/start.js +1 -1
  86. package/dist/cli/commands/start.js.map +1 -1
  87. package/dist/cli/commands/start.mjs +24 -0
  88. package/dist/cli/commands/start.mjs.map +1 -0
  89. package/dist/cli/commands/telemetry/disable.mjs +67 -0
  90. package/dist/cli/commands/telemetry/disable.mjs.map +1 -0
  91. package/dist/cli/commands/telemetry/enable.mjs +86 -0
  92. package/dist/cli/commands/telemetry/enable.mjs.map +1 -0
  93. package/dist/cli/commands/templates/generate.mjs +74 -0
  94. package/dist/cli/commands/templates/generate.mjs.map +1 -0
  95. package/dist/cli/commands/transfer/action.mjs +131 -0
  96. package/dist/cli/commands/transfer/action.mjs.map +1 -0
  97. package/dist/cli/commands/transfer/command.mjs +84 -0
  98. package/dist/cli/commands/transfer/command.mjs.map +1 -0
  99. package/dist/cli/commands/ts/generate-types.d.ts.map +1 -1
  100. package/dist/cli/commands/ts/generate-types.js +4 -5
  101. package/dist/cli/commands/ts/generate-types.js.map +1 -1
  102. package/dist/cli/commands/ts/generate-types.mjs +34 -0
  103. package/dist/cli/commands/ts/generate-types.mjs.map +1 -0
  104. package/dist/cli/commands/version.mjs +13 -0
  105. package/dist/cli/commands/version.mjs.map +1 -0
  106. package/dist/cli/index.d.ts.map +1 -1
  107. package/dist/cli/index.js +30 -0
  108. package/dist/cli/index.js.map +1 -1
  109. package/dist/cli/index.mjs +79 -0
  110. package/dist/cli/index.mjs.map +1 -0
  111. package/dist/cli/utils/commander.d.ts +2 -2
  112. package/dist/cli/utils/commander.d.ts.map +1 -1
  113. package/dist/cli/utils/commander.mjs +109 -0
  114. package/dist/cli/utils/commander.mjs.map +1 -0
  115. package/dist/cli/utils/data-transfer.d.ts +4 -4
  116. package/dist/cli/utils/data-transfer.d.ts.map +1 -1
  117. package/dist/cli/utils/data-transfer.js +32 -24
  118. package/dist/cli/utils/data-transfer.js.map +1 -1
  119. package/dist/cli/utils/data-transfer.mjs +347 -0
  120. package/dist/cli/utils/data-transfer.mjs.map +1 -0
  121. package/dist/cli/utils/helpers.d.ts +1 -1
  122. package/dist/cli/utils/helpers.d.ts.map +1 -1
  123. package/dist/cli/utils/helpers.mjs +100 -0
  124. package/dist/cli/utils/helpers.mjs.map +1 -0
  125. package/dist/cli/utils/logger.mjs +80 -0
  126. package/dist/cli/utils/logger.mjs.map +1 -0
  127. package/dist/cli/utils/pkg.d.ts.map +1 -1
  128. package/dist/cli/utils/telemetry.mjs +22 -0
  129. package/dist/cli/utils/telemetry.mjs.map +1 -0
  130. package/dist/cli/utils/tsconfig.d.ts.map +1 -1
  131. package/dist/cli/utils/tsconfig.mjs +23 -0
  132. package/dist/cli/utils/tsconfig.mjs.map +1 -0
  133. package/dist/node/build.mjs +58 -0
  134. package/dist/node/build.mjs.map +1 -0
  135. package/dist/node/core/admin-customisations.mjs +22 -0
  136. package/dist/node/core/admin-customisations.mjs.map +1 -0
  137. package/dist/node/core/aliases.d.ts +1 -1
  138. package/dist/node/core/aliases.d.ts.map +1 -1
  139. package/dist/node/core/aliases.js +8 -5
  140. package/dist/node/core/aliases.js.map +1 -1
  141. package/dist/node/core/aliases.mjs +31 -0
  142. package/dist/node/core/aliases.mjs.map +1 -0
  143. package/dist/node/core/config.d.ts.map +1 -1
  144. package/dist/node/core/config.mjs +16 -0
  145. package/dist/node/core/config.mjs.map +1 -0
  146. package/dist/node/core/dependencies.d.ts.map +1 -1
  147. package/dist/node/core/dependencies.js +5 -1
  148. package/dist/node/core/dependencies.js.map +1 -1
  149. package/dist/node/core/dependencies.mjs +155 -0
  150. package/dist/node/core/dependencies.mjs.map +1 -0
  151. package/dist/node/core/env.d.ts.map +1 -1
  152. package/dist/node/core/env.js +7 -4
  153. package/dist/node/core/env.js.map +1 -1
  154. package/dist/node/core/env.mjs +23 -0
  155. package/dist/node/core/env.mjs.map +1 -0
  156. package/dist/node/core/errors.mjs +29 -0
  157. package/dist/node/core/errors.mjs.map +1 -0
  158. package/dist/node/core/files.mjs +43 -0
  159. package/dist/node/core/files.mjs.map +1 -0
  160. package/dist/node/core/managers.mjs +17 -0
  161. package/dist/node/core/managers.mjs.map +1 -0
  162. package/dist/node/core/monorepo.mjs +20 -0
  163. package/dist/node/core/monorepo.mjs.map +1 -0
  164. package/dist/node/core/plugins.mjs +93 -0
  165. package/dist/node/core/plugins.mjs.map +1 -0
  166. package/dist/node/core/timer.mjs +27 -0
  167. package/dist/node/core/timer.mjs.map +1 -0
  168. package/dist/node/create-build-context.d.ts.map +1 -1
  169. package/dist/node/create-build-context.js +1 -1
  170. package/dist/node/create-build-context.js.map +1 -1
  171. package/dist/node/create-build-context.mjs +91 -0
  172. package/dist/node/create-build-context.mjs.map +1 -0
  173. package/dist/node/develop.js +1 -1
  174. package/dist/node/develop.js.map +1 -1
  175. package/dist/node/develop.mjs +252 -0
  176. package/dist/node/develop.mjs.map +1 -0
  177. package/dist/node/staticFiles.d.ts.map +1 -1
  178. package/dist/node/staticFiles.js +25 -3
  179. package/dist/node/staticFiles.js.map +1 -1
  180. package/dist/node/staticFiles.mjs +76 -0
  181. package/dist/node/staticFiles.mjs.map +1 -0
  182. package/dist/node/vite/build.mjs +12 -0
  183. package/dist/node/vite/build.mjs.map +1 -0
  184. package/dist/node/vite/config.mjs +99 -0
  185. package/dist/node/vite/config.mjs.map +1 -0
  186. package/dist/node/vite/plugins.mjs +43 -0
  187. package/dist/node/vite/plugins.mjs.map +1 -0
  188. package/dist/node/vite/watch.mjs +52 -0
  189. package/dist/node/vite/watch.mjs.map +1 -0
  190. package/dist/node/webpack/build.mjs +39 -0
  191. package/dist/node/webpack/build.mjs.map +1 -0
  192. package/dist/node/webpack/config.mjs +228 -0
  193. package/dist/node/webpack/config.mjs.map +1 -0
  194. package/dist/node/webpack/watch.mjs +92 -0
  195. package/dist/node/webpack/watch.mjs.map +1 -0
  196. package/package.json +33 -40
  197. package/dist/cli/commands/plugin/build.d.ts +0 -7
  198. package/dist/cli/commands/plugin/build.d.ts.map +0 -1
  199. package/dist/cli/commands/plugin/build.js +0 -88
  200. package/dist/cli/commands/plugin/build.js.map +0 -1
  201. package/dist/cli/commands/plugin/init/action.d.ts +0 -6
  202. package/dist/cli/commands/plugin/init/action.d.ts.map +0 -1
  203. package/dist/cli/commands/plugin/init/action.js +0 -414
  204. package/dist/cli/commands/plugin/init/action.js.map +0 -1
  205. package/dist/cli/commands/plugin/init/command.d.ts +0 -7
  206. package/dist/cli/commands/plugin/init/command.d.ts.map +0 -1
  207. package/dist/cli/commands/plugin/init/command.js +0 -9
  208. package/dist/cli/commands/plugin/init/command.js.map +0 -1
  209. package/dist/cli/commands/plugin/init/files/admin.d.ts +0 -5
  210. package/dist/cli/commands/plugin/init/files/admin.d.ts.map +0 -1
  211. package/dist/cli/commands/plugin/init/files/admin.js +0 -283
  212. package/dist/cli/commands/plugin/init/files/admin.js.map +0 -1
  213. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts +0 -4
  214. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts.map +0 -1
  215. package/dist/cli/commands/plugin/init/files/editorConfig.js +0 -26
  216. package/dist/cli/commands/plugin/init/files/editorConfig.js.map +0 -1
  217. package/dist/cli/commands/plugin/init/files/eslint.d.ts +0 -4
  218. package/dist/cli/commands/plugin/init/files/eslint.d.ts.map +0 -1
  219. package/dist/cli/commands/plugin/init/files/eslint.js +0 -11
  220. package/dist/cli/commands/plugin/init/files/eslint.js.map +0 -1
  221. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts +0 -4
  222. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts.map +0 -1
  223. package/dist/cli/commands/plugin/init/files/gitIgnore.js +0 -34
  224. package/dist/cli/commands/plugin/init/files/gitIgnore.js.map +0 -1
  225. package/dist/cli/commands/plugin/init/files/prettier.d.ts +0 -5
  226. package/dist/cli/commands/plugin/init/files/prettier.d.ts.map +0 -1
  227. package/dist/cli/commands/plugin/init/files/prettier.js +0 -25
  228. package/dist/cli/commands/plugin/init/files/prettier.js.map +0 -1
  229. package/dist/cli/commands/plugin/init/files/server.d.ts +0 -5
  230. package/dist/cli/commands/plugin/init/files/server.d.ts.map +0 -1
  231. package/dist/cli/commands/plugin/init/files/server.js +0 -360
  232. package/dist/cli/commands/plugin/init/files/server.js.map +0 -1
  233. package/dist/cli/commands/plugin/init/files/typescript.js +0 -66
  234. package/dist/cli/commands/plugin/init/files/typescript.js.map +0 -1
  235. package/dist/cli/commands/plugin/init/index.d.ts +0 -2
  236. package/dist/cli/commands/plugin/init/index.d.ts.map +0 -1
  237. package/dist/cli/commands/plugin/link-watch.d.ts +0 -7
  238. package/dist/cli/commands/plugin/link-watch.d.ts.map +0 -1
  239. package/dist/cli/commands/plugin/link-watch.js +0 -89
  240. package/dist/cli/commands/plugin/link-watch.js.map +0 -1
  241. package/dist/cli/commands/plugin/verify.d.ts +0 -7
  242. package/dist/cli/commands/plugin/verify.d.ts.map +0 -1
  243. package/dist/cli/commands/plugin/verify.js +0 -37
  244. package/dist/cli/commands/plugin/verify.js.map +0 -1
  245. package/dist/cli/commands/plugin/watch.d.ts +0 -7
  246. package/dist/cli/commands/plugin/watch.d.ts.map +0 -1
  247. package/dist/cli/commands/plugin/watch.js +0 -86
  248. package/dist/cli/commands/plugin/watch.js.map +0 -1
  249. package/dist/cli/utils/pkg.js +0 -108
  250. package/dist/cli/utils/pkg.js.map +0 -1
@@ -0,0 +1,84 @@
1
+ import inquirer from "inquirer";
2
+ import { createCommand, Option } from "commander";
3
+ import { parseURL, forceOption, getCommanderConfirmMessage } from "../../utils/commander.mjs";
4
+ import { ifOptions, exitWith, assertUrlHasProtocol } from "../../utils/helpers.mjs";
5
+ import { excludeOption, onlyOption, throttleOption, validateExcludeOnly } from "../../utils/data-transfer.mjs";
6
+ import action from "./action.mjs";
7
+ const command = () => {
8
+ return createCommand("transfer").description("Transfer data from one source to another").allowExcessArguments(false).addOption(
9
+ new Option(
10
+ "--from <sourceURL>",
11
+ `URL of the remote Strapi instance to get data from`
12
+ ).argParser(parseURL)
13
+ ).addOption(new Option("--from-token <token>", `Transfer token for the remote Strapi source`)).addOption(
14
+ new Option(
15
+ "--to <destinationURL>",
16
+ `URL of the remote Strapi instance to send data to`
17
+ ).argParser(parseURL)
18
+ ).addOption(
19
+ new Option("--to-token <token>", `Transfer token for the remote Strapi destination`)
20
+ ).addOption(forceOption).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook("preAction", validateExcludeOnly).hook(
21
+ "preAction",
22
+ ifOptions(
23
+ (opts) => !(opts.from || opts.to) || opts.from && opts.to,
24
+ async () => exitWith(
25
+ 1,
26
+ "Exactly one remote source (from) or destination (to) option must be provided"
27
+ )
28
+ )
29
+ ).hook(
30
+ "preAction",
31
+ ifOptions(
32
+ (opts) => opts.from,
33
+ async (thisCommand) => {
34
+ assertUrlHasProtocol(thisCommand.opts().from, ["https:", "http:"]);
35
+ if (!thisCommand.opts().fromToken) {
36
+ const answers = await inquirer.prompt([
37
+ {
38
+ type: "password",
39
+ message: "Please enter your transfer token for the remote Strapi source",
40
+ name: "fromToken"
41
+ }
42
+ ]);
43
+ if (!answers.fromToken?.length) {
44
+ exitWith(1, "No token provided for remote source, aborting transfer.");
45
+ }
46
+ thisCommand.opts().fromToken = answers.fromToken;
47
+ }
48
+ await getCommanderConfirmMessage(
49
+ "The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?",
50
+ { failMessage: "Transfer process aborted" }
51
+ )(thisCommand);
52
+ }
53
+ )
54
+ ).hook(
55
+ "preAction",
56
+ ifOptions(
57
+ (opts) => opts.to,
58
+ async (thisCommand) => {
59
+ assertUrlHasProtocol(thisCommand.opts().to, ["https:", "http:"]);
60
+ if (!thisCommand.opts().toToken) {
61
+ const answers = await inquirer.prompt([
62
+ {
63
+ type: "password",
64
+ message: "Please enter your transfer token for the remote Strapi destination",
65
+ name: "toToken"
66
+ }
67
+ ]);
68
+ if (!answers.toToken?.length) {
69
+ exitWith(1, "No token provided for remote destination, aborting transfer.");
70
+ }
71
+ thisCommand.opts().toToken = answers.toToken;
72
+ }
73
+ await getCommanderConfirmMessage(
74
+ "The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?",
75
+ { failMessage: "Transfer process aborted" }
76
+ )(thisCommand);
77
+ }
78
+ )
79
+ ).action(action);
80
+ };
81
+ export {
82
+ command as default
83
+ };
84
+ //# sourceMappingURL=command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.mjs","sources":["../../../../src/cli/commands/transfer/command.ts"],"sourcesContent":["import inquirer from 'inquirer';\nimport { createCommand, Option } from 'commander';\nimport { getCommanderConfirmMessage, forceOption, parseURL } from '../../utils/commander';\nimport { exitWith, assertUrlHasProtocol, ifOptions } from '../../utils/helpers';\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\n\nimport action from './action';\n\n/**\n * `$ strapi transfer`\n */\nconst command = () => {\n return (\n createCommand('transfer')\n .description('Transfer data from one source to another')\n .allowExcessArguments(false)\n .addOption(\n new Option(\n '--from <sourceURL>',\n `URL of the remote Strapi instance to get data from`\n ).argParser(parseURL)\n )\n .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))\n .addOption(\n new Option(\n '--to <destinationURL>',\n `URL of the remote Strapi instance to send data to`\n ).argParser(parseURL)\n )\n .addOption(\n new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)\n )\n .addOption(forceOption)\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook(\n 'preAction',\n ifOptions(\n (opts) => !(opts.from || opts.to) || (opts.from && opts.to),\n async () =>\n exitWith(\n 1,\n 'Exactly one remote source (from) or destination (to) option must be provided'\n )\n )\n )\n // If --from is used, validate the URL and token\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.from,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);\n if (!thisCommand.opts().fromToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi source',\n name: 'fromToken',\n },\n ]);\n if (!answers.fromToken?.length) {\n exitWith(1, 'No token provided for remote source, aborting transfer.');\n }\n thisCommand.opts().fromToken = answers.fromToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n // If --to is used, validate the URL, token, and confirm restore\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.to,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);\n if (!thisCommand.opts().toToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi destination',\n name: 'toToken',\n },\n ]);\n if (!answers.toToken?.length) {\n exitWith(1, 'No token provided for remote destination, aborting transfer.');\n }\n thisCommand.opts().toToken = answers.toToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n .action(action)\n );\n};\n\nexport default command;\n"],"names":[],"mappings":";;;;;;AAgBA,MAAM,UAAU,MAAM;AAElB,SAAA,cAAc,UAAU,EACrB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BAAqB,YAAY,KAAK,EAAE,IAAI,CAAC,UAAU,OAAO,CAAC;AAC/D,YAAI,CAAC,YAAY,KAAK,EAAE,SAAS;AACzB,gBAAA,UAAU,MAAM,SAAS,OAAO;AAAA,YACpC;AAAA,cACE,MAAM;AAAA,cACN,SAAS;AAAA,cACT,MAAM;AAAA,YACR;AAAA,UAAA,CACD;AACG,cAAA,CAAC,QAAQ,SAAS,QAAQ;AAC5B,qBAAS,GAAG,8DAA8D;AAAA,UAC5E;AACY,sBAAA,KAAO,EAAA,UAAU,QAAQ;AAAA,QACvC;AAEM,cAAA;AAAA,UACJ;AAAA,UACA,EAAE,aAAa,2BAA2B;AAAA,UAC1C,WAAW;AAAA,MACf;AAAA,IACF;AAAA,EAAA,EAED,OAAO,MAAM;AAEpB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ts/generate-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,MAAM,uCAA8C,UAAU,kBAsBnE,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAWd,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ts/generate-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,MAAM,uCAA8C,UAAU,kBAqBnE,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAUd,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
@@ -11,23 +11,22 @@ const action = async ({ debug, silent, verbose, outDir }) => {
11
11
  console.error("Flags conflict: both silent and debug mode are enabled, exiting...");
12
12
  process.exit(1);
13
13
  }
14
- const appContext = await core.strapiFactory.compile({ ignoreDiagnostics: true });
15
- const app = await core.strapiFactory(appContext).register();
14
+ const appContext = await core.compileStrapi({ ignoreDiagnostics: true });
15
+ const app = await core.createStrapi(appContext).register();
16
16
  await tsUtils__default.default.generators.generate({
17
17
  strapi: app,
18
18
  pwd: appContext.appDir,
19
19
  rootDir: outDir ?? void 0,
20
20
  logger: {
21
21
  silent,
22
- // TODO V5: verbose is deprecated and should be removed
23
- debug: debug || verbose
22
+ debug
24
23
  },
25
24
  artifacts: { contentTypes: true, components: true }
26
25
  });
27
26
  await app.destroy();
28
27
  };
29
28
  const command = () => {
30
- return commander.createCommand("ts:generate-types").description(`Generate TypeScript typings for your schemas`).option("--verbose", `[DEPRECATED] The verbose option has been replaced by debug`, false).option("-d, --debug", `Run the generation with debug messages`, false).option("-s, --silent", `Run the generation silently, without any output`, false).option(
29
+ return commander.createCommand("ts:generate-types").description(`Generate TypeScript typings for your schemas`).option("-d, --debug", `Run the generation with debug messages`, false).option("-s, --silent", `Run the generation silently, without any output`, false).option(
31
30
  "-o, --out-dir <outDir>",
32
31
  "Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types."
33
32
  ).action(helpers.runAction("ts:generate-types", action));
@@ -1 +1 @@
1
- {"version":3,"file":"generate-types.js","sources":["../../../../src/cli/commands/ts/generate-types.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport tsUtils from '@strapi/typescript-utils';\nimport { strapiFactory } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ninterface CmdOptions {\n debug?: boolean;\n silent?: boolean;\n verbose?: boolean;\n outDir?: string;\n}\n\nconst action = async ({ debug, silent, verbose, outDir }: CmdOptions) => {\n if ((debug || verbose) && silent) {\n console.error('Flags conflict: both silent and debug mode are enabled, exiting...');\n process.exit(1);\n }\n\n const appContext = await strapiFactory.compile({ ignoreDiagnostics: true });\n const app = await strapiFactory(appContext).register();\n\n await tsUtils.generators.generate({\n strapi: app,\n pwd: appContext.appDir,\n rootDir: outDir ?? undefined,\n logger: {\n silent,\n // TODO V5: verbose is deprecated and should be removed\n debug: debug || verbose,\n },\n artifacts: { contentTypes: true, components: true },\n });\n\n await app.destroy();\n};\n\n/**\n * `$ strapi ts:generate-types`\n */\nconst command: StrapiCommand = () => {\n return createCommand('ts:generate-types')\n .description(`Generate TypeScript typings for your schemas`)\n .option('--verbose', `[DEPRECATED] The verbose option has been replaced by debug`, false)\n .option('-d, --debug', `Run the generation with debug messages`, false)\n .option('-s, --silent', `Run the generation silently, without any output`, false)\n .option(\n '-o, --out-dir <outDir>',\n 'Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types.'\n )\n .action(runAction('ts:generate-types', action));\n};\n\nexport { action, command };\n"],"names":["strapiFactory","tsUtils","createCommand","runAction"],"mappings":";;;;;;;;AAcA,MAAM,SAAS,OAAO,EAAE,OAAO,QAAQ,SAAS,aAAyB;AAClE,OAAA,SAAS,YAAY,QAAQ;AAChC,YAAQ,MAAM,oEAAoE;AAClF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,aAAa,MAAMA,mBAAc,QAAQ,EAAE,mBAAmB,MAAM;AAC1E,QAAM,MAAM,MAAMA,KAAAA,cAAc,UAAU,EAAE,SAAS;AAE/C,QAAAC,iBAAA,QAAQ,WAAW,SAAS;AAAA,IAChC,QAAQ;AAAA,IACR,KAAK,WAAW;AAAA,IAChB,SAAS,UAAU;AAAA,IACnB,QAAQ;AAAA,MACN;AAAA;AAAA,MAEA,OAAO,SAAS;AAAA,IAClB;AAAA,IACA,WAAW,EAAE,cAAc,MAAM,YAAY,KAAK;AAAA,EAAA,CACnD;AAED,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,mBAAmB,EACrC,YAAY,8CAA8C,EAC1D,OAAO,aAAa,8DAA8D,KAAK,EACvF,OAAO,eAAe,0CAA0C,KAAK,EACrE,OAAO,gBAAgB,mDAAmD,KAAK,EAC/E;AAAA,IACC;AAAA,IACA;AAAA,EAED,EAAA,OAAOC,QAAU,UAAA,qBAAqB,MAAM,CAAC;AAClD;;;"}
1
+ {"version":3,"file":"generate-types.js","sources":["../../../../src/cli/commands/ts/generate-types.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport tsUtils from '@strapi/typescript-utils';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ninterface CmdOptions {\n debug?: boolean;\n silent?: boolean;\n verbose?: boolean;\n outDir?: string;\n}\n\nconst action = async ({ debug, silent, verbose, outDir }: CmdOptions) => {\n if ((debug || verbose) && silent) {\n console.error('Flags conflict: both silent and debug mode are enabled, exiting...');\n process.exit(1);\n }\n\n const appContext = await compileStrapi({ ignoreDiagnostics: true });\n const app = await createStrapi(appContext).register();\n\n await tsUtils.generators.generate({\n strapi: app,\n pwd: appContext.appDir,\n rootDir: outDir ?? undefined,\n logger: {\n silent,\n debug,\n },\n artifacts: { contentTypes: true, components: true },\n });\n\n await app.destroy();\n};\n\n/**\n * `$ strapi ts:generate-types`\n */\nconst command: StrapiCommand = () => {\n return createCommand('ts:generate-types')\n .description(`Generate TypeScript typings for your schemas`)\n .option('-d, --debug', `Run the generation with debug messages`, false)\n .option('-s, --silent', `Run the generation silently, without any output`, false)\n .option(\n '-o, --out-dir <outDir>',\n 'Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types.'\n )\n .action(runAction('ts:generate-types', action));\n};\n\nexport { action, command };\n"],"names":["compileStrapi","createStrapi","tsUtils","createCommand","runAction"],"mappings":";;;;;;;;AAcA,MAAM,SAAS,OAAO,EAAE,OAAO,QAAQ,SAAS,aAAyB;AAClE,OAAA,SAAS,YAAY,QAAQ;AAChC,YAAQ,MAAM,oEAAoE;AAClF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,aAAa,MAAMA,KAAA,cAAc,EAAE,mBAAmB,KAAM,CAAA;AAClE,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,SAAS;AAE9C,QAAAC,iBAAA,QAAQ,WAAW,SAAS;AAAA,IAChC,QAAQ;AAAA,IACR,KAAK,WAAW;AAAA,IAChB,SAAS,UAAU;AAAA,IACnB,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,IACA,WAAW,EAAE,cAAc,MAAM,YAAY,KAAK;AAAA,EAAA,CACnD;AAED,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AACnC,SAAOC,UAAAA,cAAc,mBAAmB,EACrC,YAAY,8CAA8C,EAC1D,OAAO,eAAe,0CAA0C,KAAK,EACrE,OAAO,gBAAgB,mDAAmD,KAAK,EAC/E;AAAA,IACC;AAAA,IACA;AAAA,EAED,EAAA,OAAOC,QAAU,UAAA,qBAAqB,MAAM,CAAC;AAClD;;;"}
@@ -0,0 +1,34 @@
1
+ import { createCommand } from "commander";
2
+ import tsUtils__default from "@strapi/typescript-utils";
3
+ import { compileStrapi, createStrapi } from "@strapi/core";
4
+ import { runAction } from "../../utils/helpers.mjs";
5
+ const action = async ({ debug, silent, verbose, outDir }) => {
6
+ if ((debug || verbose) && silent) {
7
+ console.error("Flags conflict: both silent and debug mode are enabled, exiting...");
8
+ process.exit(1);
9
+ }
10
+ const appContext = await compileStrapi({ ignoreDiagnostics: true });
11
+ const app = await createStrapi(appContext).register();
12
+ await tsUtils__default.generators.generate({
13
+ strapi: app,
14
+ pwd: appContext.appDir,
15
+ rootDir: outDir ?? void 0,
16
+ logger: {
17
+ silent,
18
+ debug
19
+ },
20
+ artifacts: { contentTypes: true, components: true }
21
+ });
22
+ await app.destroy();
23
+ };
24
+ const command = () => {
25
+ return createCommand("ts:generate-types").description(`Generate TypeScript typings for your schemas`).option("-d, --debug", `Run the generation with debug messages`, false).option("-s, --silent", `Run the generation silently, without any output`, false).option(
26
+ "-o, --out-dir <outDir>",
27
+ "Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types."
28
+ ).action(runAction("ts:generate-types", action));
29
+ };
30
+ export {
31
+ action,
32
+ command
33
+ };
34
+ //# sourceMappingURL=generate-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-types.mjs","sources":["../../../../src/cli/commands/ts/generate-types.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport tsUtils from '@strapi/typescript-utils';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ninterface CmdOptions {\n debug?: boolean;\n silent?: boolean;\n verbose?: boolean;\n outDir?: string;\n}\n\nconst action = async ({ debug, silent, verbose, outDir }: CmdOptions) => {\n if ((debug || verbose) && silent) {\n console.error('Flags conflict: both silent and debug mode are enabled, exiting...');\n process.exit(1);\n }\n\n const appContext = await compileStrapi({ ignoreDiagnostics: true });\n const app = await createStrapi(appContext).register();\n\n await tsUtils.generators.generate({\n strapi: app,\n pwd: appContext.appDir,\n rootDir: outDir ?? undefined,\n logger: {\n silent,\n debug,\n },\n artifacts: { contentTypes: true, components: true },\n });\n\n await app.destroy();\n};\n\n/**\n * `$ strapi ts:generate-types`\n */\nconst command: StrapiCommand = () => {\n return createCommand('ts:generate-types')\n .description(`Generate TypeScript typings for your schemas`)\n .option('-d, --debug', `Run the generation with debug messages`, false)\n .option('-s, --silent', `Run the generation silently, without any output`, false)\n .option(\n '-o, --out-dir <outDir>',\n 'Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types.'\n )\n .action(runAction('ts:generate-types', action));\n};\n\nexport { action, command };\n"],"names":["tsUtils"],"mappings":";;;;AAcA,MAAM,SAAS,OAAO,EAAE,OAAO,QAAQ,SAAS,aAAyB;AAClE,OAAA,SAAS,YAAY,QAAQ;AAChC,YAAQ,MAAM,oEAAoE;AAClF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,aAAa,MAAM,cAAc,EAAE,mBAAmB,KAAM,CAAA;AAClE,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,SAAS;AAE9C,QAAAA,iBAAQ,WAAW,SAAS;AAAA,IAChC,QAAQ;AAAA,IACR,KAAK,WAAW;AAAA,IAChB,SAAS,UAAU;AAAA,IACnB,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,IACA,WAAW,EAAE,cAAc,MAAM,YAAY,KAAK;AAAA,EAAA,CACnD;AAED,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AACnC,SAAO,cAAc,mBAAmB,EACrC,YAAY,8CAA8C,EAC1D,OAAO,eAAe,0CAA0C,KAAK,EACrE,OAAO,gBAAgB,mDAAmD,KAAK,EAC/E;AAAA,IACC;AAAA,IACA;AAAA,EAED,EAAA,OAAO,UAAU,qBAAqB,MAAM,CAAC;AAClD;"}
@@ -0,0 +1,13 @@
1
+ import { createCommand } from "commander";
2
+ const command = () => {
3
+ return createCommand("version").description("Output the version of Strapi").action(() => {
4
+ const { version } = require("../../../package.json");
5
+ process.stdout.write(`${version}
6
+ `);
7
+ process.exit(0);
8
+ });
9
+ };
10
+ export {
11
+ command
12
+ };
13
+ //# sourceMappingURL=version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.mjs","sources":["../../../src/cli/commands/version.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport type { StrapiCommand } from '../types';\n\n/**\n * `$ strapi version`\n */\n\nconst command: StrapiCommand = () => {\n // load the Strapi package.json to get version and other information\n return createCommand('version')\n .description('Output the version of Strapi')\n .action(() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { version } = require('../../../package.json');\n\n process.stdout.write(`${version}\\n`);\n process.exit(0);\n });\n};\n\nexport { command };\n"],"names":[],"mappings":";AAOA,MAAM,UAAyB,MAAM;AAEnC,SAAO,cAAc,SAAS,EAC3B,YAAY,8BAA8B,EAC1C,OAAO,MAAM;AAEZ,UAAM,EAAE,QAAA,IAAY,QAAQ,uBAAuB;AAE3C,YAAA,OAAO,MAAM,GAAG,OAAO;AAAA,CAAI;AACnC,YAAQ,KAAK,CAAC;AAAA,EAAA,CACf;AACL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,QAAA,MAAM,SAAS,SAAgB,MAAM,EAAE,wCAiDtC,CAAC;AAEF,QAAA,MAAM,MAAM,uDAGX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,QAAA,MAAM,SAAS,SAAgB,MAAM,EAAE,wCAqFtC,CAAC;AAEF,QAAA,MAAM,MAAM,uDAGX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC"}
package/dist/cli/index.js CHANGED
@@ -38,6 +38,36 @@ const createCLI = async (argv, command = new commander.Command()) => {
38
38
  console.error(`Failed to load command`, e);
39
39
  }
40
40
  });
41
+ const deprecatedCommands = [
42
+ { name: "plugin:init", message: "Please use `npx @strapi/sdk-plugin init` instead." },
43
+ {
44
+ name: "plugin:verify",
45
+ message: "After migrating your plugin to v5, use `strapi-plugin verify`"
46
+ },
47
+ {
48
+ name: "plugin:watch",
49
+ message: "After migrating your plugin to v5, use `strapi-plugin watch`"
50
+ },
51
+ {
52
+ name: "plugin:watch:link",
53
+ message: "After migrating your plugin to v5, use `strapi-plugin watch:link`"
54
+ },
55
+ {
56
+ name: "plugin:build",
57
+ message: "After migrating your plugin to v5, use `strapi-plugin build`"
58
+ }
59
+ ];
60
+ deprecatedCommands.forEach(({ name, message }) => {
61
+ const deprecated = new commander.Command(name).command(name).description("(deprecated)").action(() => {
62
+ console.warn(
63
+ `The command ${name} has been deprecated. See the Strapi 5 migration guide for more information.`
64
+ );
65
+ if (message) {
66
+ console.warn(message);
67
+ }
68
+ });
69
+ command.addCommand(deprecated, { hidden: true });
70
+ });
41
71
  return command;
42
72
  };
43
73
  const runCLI = async (argv = process.argv, command = new commander.Command()) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/cli/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { commands as strapiCommands } from './commands';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\n\nconst createCLI = async (argv: string[], command = new Command()) => {\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n command.version(\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('../../package.json').version,\n '-v, --version',\n 'Output the version number'\n );\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n const tsconfig = loadTsConfig({\n cwd,\n path: 'tsconfig.json',\n logger,\n });\n\n const ctx = {\n cwd,\n logger,\n tsconfig,\n } satisfies CLIContext;\n\n // Load all commands\n strapiCommands.forEach((commandFactory) => {\n try {\n const subCommand = commandFactory({ command, argv, ctx });\n\n // Add this command to the Commander command object\n if (subCommand) {\n command.addCommand(subCommand);\n }\n } catch (e) {\n console.error(`Failed to load command`, e);\n }\n });\n\n return command;\n};\n\nconst runCLI = async (argv = process.argv, command = new Command()) => {\n const commands = await createCLI(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runCLI, createCLI };\n"],"names":["Command","logger","createLogger","tsconfig","loadTsConfig","strapiCommands"],"mappings":";;;;;;AAQA,MAAM,YAAY,OAAO,MAAgB,UAAU,IAAIA,wBAAc;AAEnE,UAAQ,yBAAyB,KAAK,EAAE,mBAAmB,IAAI;AAGvD,UAAA,WAAW,cAAc,0BAA0B;AACnD,UAAA,eAAe,kBAAkB,0BAA0B;AAE3D,UAAA;AAAA;AAAA,IAEN,QAAQ,oBAAoB,EAAE;AAAA,IAC9B;AAAA,IACA;AAAA,EAAA;AAGI,QAAA,MAAM,QAAQ;AAEd,QAAA,WAAW,KAAK,SAAS,SAAS;AAClC,QAAA,YAAY,KAAK,SAAS,UAAU;AAEpC,QAAAC,WAASC,oBAAa,EAAE,OAAO,UAAU,QAAQ,WAAW,WAAW,MAAA,CAAO;AAEpF,QAAMC,aAAWC,SAAAA,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM;AAAA,IAAA,QACNH;AAAAA,EAAA,CACD;AAED,QAAM,MAAM;AAAA,IACV;AAAA,IAAA,QACAA;AAAAA,IAAA,UACAE;AAAAA,EAAA;AAIaE,iBAAA,QAAQ,CAAC,mBAAmB;AACrC,QAAA;AACF,YAAM,aAAa,eAAe,EAAE,SAAS,MAAM,KAAK;AAGxD,UAAI,YAAY;AACd,gBAAQ,WAAW,UAAU;AAAA,MAC/B;AAAA,aACO,GAAG;AACF,cAAA,MAAM,0BAA0B,CAAC;AAAA,IAC3C;AAAA,EAAA,CACD;AAEM,SAAA;AACT;AAEM,MAAA,SAAS,OAAO,OAAO,QAAQ,MAAM,UAAU,IAAIL,UAAAA,cAAc;AACrE,QAAM,WAAW,MAAM,UAAU,MAAM,OAAO;AACxC,QAAA,SAAS,WAAW,IAAI;AAChC;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/cli/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { commands as strapiCommands } from './commands';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\n\nconst createCLI = async (argv: string[], command = new Command()) => {\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n command.version(\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('../../package.json').version,\n '-v, --version',\n 'Output the version number'\n );\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n const tsconfig = loadTsConfig({\n cwd,\n path: 'tsconfig.json',\n logger,\n });\n\n const ctx = {\n cwd,\n logger,\n tsconfig,\n } satisfies CLIContext;\n\n // Load all commands\n strapiCommands.forEach((commandFactory) => {\n try {\n const subCommand = commandFactory({ command, argv, ctx });\n\n // Add this command to the Commander command object\n if (subCommand) {\n command.addCommand(subCommand);\n }\n } catch (e) {\n console.error(`Failed to load command`, e);\n }\n });\n\n // TODO v6: remove these deprecation notices\n const deprecatedCommands = [\n { name: 'plugin:init', message: 'Please use `npx @strapi/sdk-plugin init` instead.' },\n {\n name: 'plugin:verify',\n message: 'After migrating your plugin to v5, use `strapi-plugin verify`',\n },\n {\n name: 'plugin:watch',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch`',\n },\n {\n name: 'plugin:watch:link',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch:link`',\n },\n {\n name: 'plugin:build',\n message: 'After migrating your plugin to v5, use `strapi-plugin build`',\n },\n ];\n\n // Add hidden commands for deprecatedCommands that output a warning that the command has been removed.\n deprecatedCommands.forEach(({ name, message }) => {\n const deprecated = new Command(name)\n .command(name)\n .description('(deprecated)')\n .action(() => {\n console.warn(\n `The command ${name} has been deprecated. See the Strapi 5 migration guide for more information.`\n );\n if (message) {\n console.warn(message);\n }\n });\n command.addCommand(deprecated, { hidden: true });\n });\n return command;\n};\n\nconst runCLI = async (argv = process.argv, command = new Command()) => {\n const commands = await createCLI(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runCLI, createCLI };\n"],"names":["Command","logger","createLogger","tsconfig","loadTsConfig","strapiCommands"],"mappings":";;;;;;AAQA,MAAM,YAAY,OAAO,MAAgB,UAAU,IAAIA,wBAAc;AAEnE,UAAQ,yBAAyB,KAAK,EAAE,mBAAmB,IAAI;AAGvD,UAAA,WAAW,cAAc,0BAA0B;AACnD,UAAA,eAAe,kBAAkB,0BAA0B;AAE3D,UAAA;AAAA;AAAA,IAEN,QAAQ,oBAAoB,EAAE;AAAA,IAC9B;AAAA,IACA;AAAA,EAAA;AAGI,QAAA,MAAM,QAAQ;AAEd,QAAA,WAAW,KAAK,SAAS,SAAS;AAClC,QAAA,YAAY,KAAK,SAAS,UAAU;AAEpC,QAAAC,WAASC,oBAAa,EAAE,OAAO,UAAU,QAAQ,WAAW,WAAW,MAAA,CAAO;AAEpF,QAAMC,aAAWC,SAAAA,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM;AAAA,IAAA,QACNH;AAAAA,EAAA,CACD;AAED,QAAM,MAAM;AAAA,IACV;AAAA,IAAA,QACAA;AAAAA,IAAA,UACAE;AAAAA,EAAA;AAIaE,iBAAA,QAAQ,CAAC,mBAAmB;AACrC,QAAA;AACF,YAAM,aAAa,eAAe,EAAE,SAAS,MAAM,KAAK;AAGxD,UAAI,YAAY;AACd,gBAAQ,WAAW,UAAU;AAAA,MAC/B;AAAA,aACO,GAAG;AACF,cAAA,MAAM,0BAA0B,CAAC;AAAA,IAC3C;AAAA,EAAA,CACD;AAGD,QAAM,qBAAqB;AAAA,IACzB,EAAE,MAAM,eAAe,SAAS,oDAAoD;AAAA,IACpF;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EAAA;AAIF,qBAAmB,QAAQ,CAAC,EAAE,MAAM,cAAc;AAChD,UAAM,aAAa,IAAIL,kBAAQ,IAAI,EAChC,QAAQ,IAAI,EACZ,YAAY,cAAc,EAC1B,OAAO,MAAM;AACJ,cAAA;AAAA,QACN,eAAe,IAAI;AAAA,MAAA;AAErB,UAAI,SAAS;AACX,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IAAA,CACD;AACH,YAAQ,WAAW,YAAY,EAAE,QAAQ,KAAM,CAAA;AAAA,EAAA,CAChD;AACM,SAAA;AACT;AAEM,MAAA,SAAS,OAAO,OAAO,QAAQ,MAAM,UAAU,IAAIA,UAAAA,cAAc;AACrE,QAAM,WAAW,MAAM,UAAU,MAAM,OAAO;AACxC,QAAA,SAAS,WAAW,IAAI;AAChC;;;"}
@@ -0,0 +1,79 @@
1
+ import { Command } from "commander";
2
+ import { commands } from "./commands/index.mjs";
3
+ import { createLogger } from "./utils/logger.mjs";
4
+ import { loadTsConfig } from "./utils/tsconfig.mjs";
5
+ const createCLI = async (argv, command = new Command()) => {
6
+ command.storeOptionsAsProperties(false).allowUnknownOption(true);
7
+ command.helpOption("-h, --help", "Display help for command");
8
+ command.addHelpCommand("help [command]", "Display help for command");
9
+ command.version(
10
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
11
+ require("../../package.json").version,
12
+ "-v, --version",
13
+ "Output the version number"
14
+ );
15
+ const cwd = process.cwd();
16
+ const hasDebug = argv.includes("--debug");
17
+ const hasSilent = argv.includes("--silent");
18
+ const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });
19
+ const tsconfig = loadTsConfig({
20
+ cwd,
21
+ path: "tsconfig.json",
22
+ logger
23
+ });
24
+ const ctx = {
25
+ cwd,
26
+ logger,
27
+ tsconfig
28
+ };
29
+ commands.forEach((commandFactory) => {
30
+ try {
31
+ const subCommand = commandFactory({ command, argv, ctx });
32
+ if (subCommand) {
33
+ command.addCommand(subCommand);
34
+ }
35
+ } catch (e) {
36
+ console.error(`Failed to load command`, e);
37
+ }
38
+ });
39
+ const deprecatedCommands = [
40
+ { name: "plugin:init", message: "Please use `npx @strapi/sdk-plugin init` instead." },
41
+ {
42
+ name: "plugin:verify",
43
+ message: "After migrating your plugin to v5, use `strapi-plugin verify`"
44
+ },
45
+ {
46
+ name: "plugin:watch",
47
+ message: "After migrating your plugin to v5, use `strapi-plugin watch`"
48
+ },
49
+ {
50
+ name: "plugin:watch:link",
51
+ message: "After migrating your plugin to v5, use `strapi-plugin watch:link`"
52
+ },
53
+ {
54
+ name: "plugin:build",
55
+ message: "After migrating your plugin to v5, use `strapi-plugin build`"
56
+ }
57
+ ];
58
+ deprecatedCommands.forEach(({ name, message }) => {
59
+ const deprecated = new Command(name).command(name).description("(deprecated)").action(() => {
60
+ console.warn(
61
+ `The command ${name} has been deprecated. See the Strapi 5 migration guide for more information.`
62
+ );
63
+ if (message) {
64
+ console.warn(message);
65
+ }
66
+ });
67
+ command.addCommand(deprecated, { hidden: true });
68
+ });
69
+ return command;
70
+ };
71
+ const runCLI = async (argv = process.argv, command = new Command()) => {
72
+ const commands2 = await createCLI(argv, command);
73
+ await commands2.parseAsync(argv);
74
+ };
75
+ export {
76
+ createCLI,
77
+ runCLI
78
+ };
79
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../src/cli/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { commands as strapiCommands } from './commands';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\n\nconst createCLI = async (argv: string[], command = new Command()) => {\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n command.version(\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('../../package.json').version,\n '-v, --version',\n 'Output the version number'\n );\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n const tsconfig = loadTsConfig({\n cwd,\n path: 'tsconfig.json',\n logger,\n });\n\n const ctx = {\n cwd,\n logger,\n tsconfig,\n } satisfies CLIContext;\n\n // Load all commands\n strapiCommands.forEach((commandFactory) => {\n try {\n const subCommand = commandFactory({ command, argv, ctx });\n\n // Add this command to the Commander command object\n if (subCommand) {\n command.addCommand(subCommand);\n }\n } catch (e) {\n console.error(`Failed to load command`, e);\n }\n });\n\n // TODO v6: remove these deprecation notices\n const deprecatedCommands = [\n { name: 'plugin:init', message: 'Please use `npx @strapi/sdk-plugin init` instead.' },\n {\n name: 'plugin:verify',\n message: 'After migrating your plugin to v5, use `strapi-plugin verify`',\n },\n {\n name: 'plugin:watch',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch`',\n },\n {\n name: 'plugin:watch:link',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch:link`',\n },\n {\n name: 'plugin:build',\n message: 'After migrating your plugin to v5, use `strapi-plugin build`',\n },\n ];\n\n // Add hidden commands for deprecatedCommands that output a warning that the command has been removed.\n deprecatedCommands.forEach(({ name, message }) => {\n const deprecated = new Command(name)\n .command(name)\n .description('(deprecated)')\n .action(() => {\n console.warn(\n `The command ${name} has been deprecated. See the Strapi 5 migration guide for more information.`\n );\n if (message) {\n console.warn(message);\n }\n });\n command.addCommand(deprecated, { hidden: true });\n });\n return command;\n};\n\nconst runCLI = async (argv = process.argv, command = new Command()) => {\n const commands = await createCLI(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runCLI, createCLI };\n"],"names":["strapiCommands","commands"],"mappings":";;;;AAQA,MAAM,YAAY,OAAO,MAAgB,UAAU,IAAI,cAAc;AAEnE,UAAQ,yBAAyB,KAAK,EAAE,mBAAmB,IAAI;AAGvD,UAAA,WAAW,cAAc,0BAA0B;AACnD,UAAA,eAAe,kBAAkB,0BAA0B;AAE3D,UAAA;AAAA;AAAA,IAEN,QAAQ,oBAAoB,EAAE;AAAA,IAC9B;AAAA,IACA;AAAA,EAAA;AAGI,QAAA,MAAM,QAAQ;AAEd,QAAA,WAAW,KAAK,SAAS,SAAS;AAClC,QAAA,YAAY,KAAK,SAAS,UAAU;AAEpC,QAAA,SAAS,aAAa,EAAE,OAAO,UAAU,QAAQ,WAAW,WAAW,MAAA,CAAO;AAEpF,QAAM,WAAW,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM;AAAA,IACN;AAAA,EAAA,CACD;AAED,QAAM,MAAM;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAIaA,WAAA,QAAQ,CAAC,mBAAmB;AACrC,QAAA;AACF,YAAM,aAAa,eAAe,EAAE,SAAS,MAAM,KAAK;AAGxD,UAAI,YAAY;AACd,gBAAQ,WAAW,UAAU;AAAA,MAC/B;AAAA,aACO,GAAG;AACF,cAAA,MAAM,0BAA0B,CAAC;AAAA,IAC3C;AAAA,EAAA,CACD;AAGD,QAAM,qBAAqB;AAAA,IACzB,EAAE,MAAM,eAAe,SAAS,oDAAoD;AAAA,IACpF;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EAAA;AAIF,qBAAmB,QAAQ,CAAC,EAAE,MAAM,cAAc;AAChD,UAAM,aAAa,IAAI,QAAQ,IAAI,EAChC,QAAQ,IAAI,EACZ,YAAY,cAAc,EAC1B,OAAO,MAAM;AACJ,cAAA;AAAA,QACN,eAAe,IAAI;AAAA,MAAA;AAErB,UAAI,SAAS;AACX,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IAAA,CACD;AACH,YAAQ,WAAW,YAAY,EAAE,QAAQ,KAAM,CAAA;AAAA,EAAA,CAChD;AACM,SAAA;AACT;AAEM,MAAA,SAAS,OAAO,OAAO,QAAQ,MAAM,UAAU,IAAI,cAAc;AACrE,QAAMC,YAAW,MAAM,UAAU,MAAM,OAAO;AACxC,QAAAA,UAAS,WAAW,IAAI;AAChC;"}
@@ -26,10 +26,10 @@ declare const promptEncryptionKey: (thisCommand: Command) => Promise<void>;
26
26
  * hook: require a confirmation message to be accepted unless forceOption (-f,--force) is used
27
27
  */
28
28
  declare const getCommanderConfirmMessage: (message: string, { failMessage }?: {
29
- failMessage?: string | undefined;
29
+ failMessage?: string;
30
30
  }) => (command: Command) => Promise<void>;
31
31
  declare const confirmMessage: (message: string, { force }?: {
32
- force?: boolean | undefined;
32
+ force?: boolean;
33
33
  }) => Promise<any>;
34
34
  declare const forceOption: Option;
35
35
  export { getParseListWithChoices, parseList, parseURL, parseInteger, promptEncryptionKey, getCommanderConfirmMessage, confirmMessage, forceOption, };
@@ -1 +1 @@
1
- {"version":3,"file":"commander.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/commander.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAA8B,MAAM,EAAE,MAAM,WAAW,CAAC;AAKxE;;GAEG;AACH,QAAA,MAAM,SAAS,UAAW,MAAM,aAQ/B,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,uBAAuB,YAAa,MAAM,EAAE,oCACjC,MAAM,aAYtB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,YAAY,UAAW,MAAM,WAOlC,CAAC;AAEF;;GAEG;AAC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Z,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACd,WAAW,GACZ,CAAC"}
@@ -0,0 +1,109 @@
1
+ import inquirer from "inquirer";
2
+ import { Option, InvalidOptionArgumentError } from "commander";
3
+ import chalk from "chalk";
4
+ import { isNaN } from "lodash/fp";
5
+ import { exitWith } from "./helpers.mjs";
6
+ const parseList = (value) => {
7
+ try {
8
+ return value.split(",").map((item) => item.trim());
9
+ } catch (e) {
10
+ exitWith(1, `Unrecognized input: ${value}`);
11
+ }
12
+ return [];
13
+ };
14
+ const getParseListWithChoices = (choices, errorMessage = "Invalid options:") => {
15
+ return (value) => {
16
+ const list = parseList(value);
17
+ const invalid = list.filter((item) => {
18
+ return !choices.includes(item);
19
+ });
20
+ if (invalid.length > 0) {
21
+ exitWith(1, `${errorMessage}: ${invalid.join(",")}`);
22
+ }
23
+ return list;
24
+ };
25
+ };
26
+ const parseInteger = (value) => {
27
+ const parsedValue = parseInt(value, 10);
28
+ if (isNaN(parsedValue)) {
29
+ throw new InvalidOptionArgumentError(`Not an integer: ${value}`);
30
+ }
31
+ return parsedValue;
32
+ };
33
+ const parseURL = (value) => {
34
+ try {
35
+ const url = new URL(value);
36
+ if (!url.host) {
37
+ throw new InvalidOptionArgumentError(`Could not parse url ${value}`);
38
+ }
39
+ return url;
40
+ } catch (e) {
41
+ throw new InvalidOptionArgumentError(`Could not parse url ${value}`);
42
+ }
43
+ };
44
+ const promptEncryptionKey = async (thisCommand) => {
45
+ const opts = thisCommand.opts();
46
+ if (!opts.encrypt && opts.key) {
47
+ return exitWith(1, "Key may not be present unless encryption is used");
48
+ }
49
+ if (opts.encrypt && !(opts.key && opts.key.length > 0)) {
50
+ try {
51
+ const answers = await inquirer.prompt([
52
+ {
53
+ type: "password",
54
+ message: "Please enter an encryption key",
55
+ name: "key",
56
+ validate(key) {
57
+ if (key.length > 0)
58
+ return true;
59
+ return "Key must be present when using the encrypt option";
60
+ }
61
+ }
62
+ ]);
63
+ opts.key = answers.key;
64
+ } catch (e) {
65
+ return exitWith(1, "Failed to get encryption key");
66
+ }
67
+ if (!opts.key) {
68
+ return exitWith(1, "Failed to get encryption key");
69
+ }
70
+ }
71
+ };
72
+ const getCommanderConfirmMessage = (message, { failMessage } = {}) => {
73
+ return async (command) => {
74
+ const confirmed = await confirmMessage(message, { force: command.opts().force });
75
+ if (!confirmed) {
76
+ exitWith(1, failMessage);
77
+ }
78
+ };
79
+ };
80
+ const confirmMessage = async (message, { force } = {}) => {
81
+ if (force === true) {
82
+ console.log(`${chalk.green("?")} ${chalk.bold(message)} ${chalk.cyan("Yes")}`);
83
+ return true;
84
+ }
85
+ const answers = await inquirer.prompt([
86
+ {
87
+ type: "confirm",
88
+ message,
89
+ name: `confirm`,
90
+ default: false
91
+ }
92
+ ]);
93
+ return answers.confirm;
94
+ };
95
+ const forceOption = new Option(
96
+ "--force",
97
+ `Automatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively.`
98
+ );
99
+ export {
100
+ confirmMessage,
101
+ forceOption,
102
+ getCommanderConfirmMessage,
103
+ getParseListWithChoices,
104
+ parseInteger,
105
+ parseList,
106
+ parseURL,
107
+ promptEncryptionKey
108
+ };
109
+ //# sourceMappingURL=commander.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commander.mjs","sources":["../../../src/cli/utils/commander.ts"],"sourcesContent":["/**\n * This file includes hooks to use for commander.hook and argParsers for commander.argParser\n */\n\nimport inquirer from 'inquirer';\nimport { Command, InvalidOptionArgumentError, Option } from 'commander';\nimport chalk from 'chalk';\nimport { isNaN } from 'lodash/fp';\nimport { exitWith } from './helpers';\n\n/**\n * argParser: Parse a comma-delimited string as an array\n */\nconst parseList = (value: string) => {\n try {\n return value.split(',').map((item) => item.trim()); // trim shouldn't be necessary but might help catch unexpected whitespace characters\n } catch (e) {\n exitWith(1, `Unrecognized input: ${value}`);\n }\n\n return [];\n};\n\n/**\n * Returns an argParser that returns a list\n */\nconst getParseListWithChoices = (choices: string[], errorMessage = 'Invalid options:') => {\n return (value: string) => {\n const list = parseList(value);\n const invalid = list.filter((item) => {\n return !choices.includes(item);\n });\n\n if (invalid.length > 0) {\n exitWith(1, `${errorMessage}: ${invalid.join(',')}`);\n }\n\n return list;\n };\n};\n\n/**\n * argParser: Parse a string as an integer\n */\nconst parseInteger = (value: string) => {\n // parseInt takes a string and a radix\n const parsedValue = parseInt(value, 10);\n if (isNaN(parsedValue)) {\n throw new InvalidOptionArgumentError(`Not an integer: ${value}`);\n }\n return parsedValue;\n};\n\n/**\n * argParser: Parse a string as a URL object\n */\nconst parseURL = (value: string) => {\n try {\n const url = new URL(value);\n if (!url.host) {\n throw new InvalidOptionArgumentError(`Could not parse url ${value}`);\n }\n\n return url;\n } catch (e) {\n throw new InvalidOptionArgumentError(`Could not parse url ${value}`);\n }\n};\n\n/**\n * hook: if encrypt==true and key not provided, prompt for it\n */\nconst promptEncryptionKey = async (thisCommand: Command) => {\n const opts = thisCommand.opts();\n\n if (!opts.encrypt && opts.key) {\n return exitWith(1, 'Key may not be present unless encryption is used');\n }\n\n // if encrypt==true but we have no key, prompt for it\n if (opts.encrypt && !(opts.key && opts.key.length > 0)) {\n try {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter an encryption key',\n name: 'key',\n validate(key) {\n if (key.length > 0) return true;\n\n return 'Key must be present when using the encrypt option';\n },\n },\n ]);\n opts.key = answers.key;\n } catch (e) {\n return exitWith(1, 'Failed to get encryption key');\n }\n if (!opts.key) {\n return exitWith(1, 'Failed to get encryption key');\n }\n }\n};\n\n/**\n * hook: require a confirmation message to be accepted unless forceOption (-f,--force) is used\n */\nconst getCommanderConfirmMessage = (\n message: string,\n { failMessage }: { failMessage?: string } = {}\n) => {\n return async (command: Command) => {\n const confirmed = await confirmMessage(message, { force: command.opts().force });\n if (!confirmed) {\n exitWith(1, failMessage);\n }\n };\n};\n\nconst confirmMessage = async (message: string, { force }: { force?: boolean } = {}) => {\n // if we have a force option, respond yes\n if (force === true) {\n // attempt to mimic the inquirer prompt exactly\n console.log(`${chalk.green('?')} ${chalk.bold(message)} ${chalk.cyan('Yes')}`);\n return true;\n }\n\n const answers = await inquirer.prompt([\n {\n type: 'confirm',\n message,\n name: `confirm`,\n default: false,\n },\n ]);\n\n return answers.confirm;\n};\n\nconst forceOption = new Option(\n '--force',\n `Automatically answer \"yes\" to all prompts, including potentially destructive requests, and run non-interactively.`\n);\n\nexport {\n getParseListWithChoices,\n parseList,\n parseURL,\n parseInteger,\n promptEncryptionKey,\n getCommanderConfirmMessage,\n confirmMessage,\n forceOption,\n};\n"],"names":[],"mappings":";;;;;AAaM,MAAA,YAAY,CAAC,UAAkB;AAC/B,MAAA;AACK,WAAA,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,KAAK,KAAA,CAAM;AAAA,WAC1C,GAAG;AACD,aAAA,GAAG,uBAAuB,KAAK,EAAE;AAAA,EAC5C;AAEA,SAAO;AACT;AAKA,MAAM,0BAA0B,CAAC,SAAmB,eAAe,uBAAuB;AACxF,SAAO,CAAC,UAAkB;AAClB,UAAA,OAAO,UAAU,KAAK;AAC5B,UAAM,UAAU,KAAK,OAAO,CAAC,SAAS;AAC7B,aAAA,CAAC,QAAQ,SAAS,IAAI;AAAA,IAAA,CAC9B;AAEG,QAAA,QAAQ,SAAS,GAAG;AACb,eAAA,GAAG,GAAG,YAAY,KAAK,QAAQ,KAAK,GAAG,CAAC,EAAE;AAAA,IACrD;AAEO,WAAA;AAAA,EAAA;AAEX;AAKM,MAAA,eAAe,CAAC,UAAkB;AAEhC,QAAA,cAAc,SAAS,OAAO,EAAE;AAClC,MAAA,MAAM,WAAW,GAAG;AACtB,UAAM,IAAI,2BAA2B,mBAAmB,KAAK,EAAE;AAAA,EACjE;AACO,SAAA;AACT;AAKM,MAAA,WAAW,CAAC,UAAkB;AAC9B,MAAA;AACI,UAAA,MAAM,IAAI,IAAI,KAAK;AACrB,QAAA,CAAC,IAAI,MAAM;AACb,YAAM,IAAI,2BAA2B,uBAA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,OAAO;AAAA,IACpC;AAAA,MACE,MAAM;AAAA,MACN;AAAA,MACA,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EAAA,CACD;AAED,SAAO,QAAQ;AACjB;AAEA,MAAM,cAAc,IAAI;AAAA,EACtB;AAAA,EACA;AACF;"}
@@ -10,12 +10,12 @@ declare const buildTransferTable: (resultData: ResultData) => Table.Table | unde
10
10
  declare const DEFAULT_IGNORED_CONTENT_TYPES: string[];
11
11
  declare const abortTransfer: ({ engine, strapi, }: {
12
12
  engine: engineDataTransfer.TransferEngine;
13
- strapi: Core.LoadedStrapi;
13
+ strapi: Core.Strapi;
14
14
  }) => Promise<boolean>;
15
15
  declare const setSignalHandler: (handler: (...args: unknown[]) => void, signals?: string[]) => Promise<void>;
16
16
  declare const createStrapiInstance: (opts?: {
17
17
  logLevel?: string;
18
- }) => Promise<Core.Strapi & Required<Core.Strapi>>;
18
+ }) => Promise<Core.Strapi>;
19
19
  declare const throttleOption: Option;
20
20
  declare const excludeOption: Option;
21
21
  declare const onlyOption: Option;
@@ -50,11 +50,11 @@ declare const getTransferTelemetryPayload: (engine: engineDataTransfer.TransferE
50
50
  * Get a transfer engine schema diff handler that confirms with the user before bypassing a schema check
51
51
  */
52
52
  declare const getDiffHandler: (engine: engineDataTransfer.TransferEngine, { force, action, }: {
53
- force?: boolean | undefined;
53
+ force?: boolean;
54
54
  action: string;
55
55
  }) => (context: engineDataTransfer.SchemaDiffHandlerContext, next: (ctx: engineDataTransfer.SchemaDiffHandlerContext) => void) => Promise<void>;
56
56
  declare const getAssetsBackupHandler: (engine: engineDataTransfer.TransferEngine, { force, action, }: {
57
- force?: boolean | undefined;
57
+ force?: boolean;
58
58
  action: string;
59
59
  }) => (context: engineDataTransfer.ErrorHandlerContext, next: (ctx: engineDataTransfer.ErrorHandlerContext) => void) => Promise<void>;
60
60
  declare const shouldSkipStage: (opts: Partial<engineDataTransfer.ITransferEngineOptions>, dataKind: engineDataTransfer.TransferFilterPreset) => bool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