@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,35 @@
1
+ import { createCommand } from "commander";
2
+ import { EOL } from "os";
3
+ import { compileStrapi, createStrapi } from "@strapi/core";
4
+ import { runAction } from "../utils/helpers.mjs";
5
+ const action = async ({ uuid, dependencies, all }) => {
6
+ const config = {
7
+ reportUUID: Boolean(all || uuid),
8
+ reportDependencies: Boolean(all || dependencies)
9
+ };
10
+ const appContext = await compileStrapi();
11
+ const app = await createStrapi(appContext).register();
12
+ let debugInfo = `Launched In: ${Date.now() - app.config.launchedAt} ms
13
+ Environment: ${app.config.environment}
14
+ OS: ${process.platform}-${process.arch}
15
+ Strapi Version: ${app.config.info.strapi}
16
+ Node/Yarn Version: ${process.env.npm_config_user_agent}
17
+ Edition: ${app.EE ? "Enterprise" : "Community"}
18
+ Database: ${app?.config?.database?.connection?.client ?? "unknown"}`;
19
+ if (config.reportUUID) {
20
+ debugInfo += `${EOL}UUID: ${app.config.uuid}`;
21
+ }
22
+ if (config.reportDependencies) {
23
+ debugInfo += `${EOL}Dependencies: ${JSON.stringify(app.config.info.dependencies, null, 2)}
24
+ Dev Dependencies: ${JSON.stringify(app.config.info.devDependencies, null, 2)}`;
25
+ }
26
+ console.log(debugInfo);
27
+ await app.destroy();
28
+ };
29
+ const command = () => {
30
+ return createCommand("report").description("Get system stats for debugging and submitting issues").option("-u, --uuid", "Include Project UUID").option("-d, --dependencies", "Include Project Dependencies").option("--all", "Include All Information").action(runAction("report", action));
31
+ };
32
+ export {
33
+ command
34
+ };
35
+ //# sourceMappingURL=report.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.mjs","sources":["../../../src/cli/commands/report.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { EOL } from 'os';\nimport { createStrapi, compileStrapi } from '@strapi/core';\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\ninterface CmdOptions {\n uuid: boolean;\n dependencies: boolean;\n all: boolean;\n}\n\nconst action = async ({ uuid, dependencies, all }: CmdOptions) => {\n const config = {\n reportUUID: Boolean(all || uuid),\n reportDependencies: Boolean(all || dependencies),\n };\n\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n let debugInfo = `Launched In: ${Date.now() - app.config.launchedAt} ms\nEnvironment: ${app.config.environment}\nOS: ${process.platform}-${process.arch}\nStrapi Version: ${app.config.info.strapi}\nNode/Yarn Version: ${process.env.npm_config_user_agent}\nEdition: ${app.EE ? 'Enterprise' : 'Community'}\nDatabase: ${app?.config?.database?.connection?.client ?? 'unknown'}`;\n\n if (config.reportUUID) {\n debugInfo += `${EOL}UUID: ${app.config.uuid}`;\n }\n\n if (config.reportDependencies) {\n debugInfo += `${EOL}Dependencies: ${JSON.stringify(app.config.info.dependencies, null, 2)}\nDev Dependencies: ${JSON.stringify(app.config.info.devDependencies, null, 2)}`;\n }\n\n console.log(debugInfo);\n\n await app.destroy();\n};\n\n/**\n * `$ strapi report`\n */\nconst command: StrapiCommand = () => {\n return createCommand('report')\n .description('Get system stats for debugging and submitting issues')\n .option('-u, --uuid', 'Include Project UUID')\n .option('-d, --dependencies', 'Include Project Dependencies')\n .option('--all', 'Include All Information')\n .action(runAction('report', action));\n};\n\nexport { command };\n"],"names":[],"mappings":";;;;AAYA,MAAM,SAAS,OAAO,EAAE,MAAM,cAAc,UAAsB;AAChE,QAAM,SAAS;AAAA,IACb,YAAY,QAAQ,OAAO,IAAI;AAAA,IAC/B,oBAAoB,QAAQ,OAAO,YAAY;AAAA,EAAA;AAG3C,QAAA,aAAa,MAAM;AACzB,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,SAAS;AAEpD,MAAI,YAAY,gBAAgB,KAAK,QAAQ,IAAI,OAAO,UAAU;AAAA,eACrD,IAAI,OAAO,WAAW;AAAA,MAC/B,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AAAA,kBACpB,IAAI,OAAO,KAAK,MAAM;AAAA,qBACnB,QAAQ,IAAI,qBAAqB;AAAA,WAC3C,IAAI,KAAK,eAAe,WAAW;AAAA,YAClC,KAAK,QAAQ,UAAU,YAAY,UAAU,SAAS;AAEhE,MAAI,OAAO,YAAY;AACrB,iBAAa,GAAG,GAAG,SAAS,IAAI,OAAO,IAAI;AAAA,EAC7C;AAEA,MAAI,OAAO,oBAAoB;AAChB,iBAAA,GAAG,GAAG,iBAAiB,KAAK,UAAU,IAAI,OAAO,KAAK,cAAc,MAAM,CAAC,CAAC;AAAA,oBACzE,KAAK,UAAU,IAAI,OAAO,KAAK,iBAAiB,MAAM,CAAC,CAAC;AAAA,EAC1E;AAEA,UAAQ,IAAI,SAAS;AAErB,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,QAAQ,EAC1B,YAAY,sDAAsD,EAClE,OAAO,cAAc,sBAAsB,EAC3C,OAAO,sBAAsB,8BAA8B,EAC3D,OAAO,SAAS,yBAAyB,EACzC,OAAO,UAAU,UAAU,MAAM,CAAC;AACvC;"}
@@ -10,8 +10,8 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
10
  const CLITable__default = /* @__PURE__ */ _interopDefault(CLITable);
11
11
  const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
12
12
  const action = async () => {
13
- const appContext = await core.strapiFactory.compile();
14
- const app = await core.strapiFactory(appContext).load();
13
+ const appContext = await core.compileStrapi();
14
+ const app = await core.createStrapi(appContext).load();
15
15
  const list = app.server.mount().listRoutes();
16
16
  const infoTable = new CLITable__default.default({
17
17
  head: [chalk__default.default.blue("Method"), chalk__default.default.blue("Path")],
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sources":["../../../../src/cli/commands/routes/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { toUpper } from 'lodash/fp';\n\nimport { strapiFactory } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await strapiFactory.compile();\n const app = await strapiFactory(appContext).load();\n\n const list = app.server.mount().listRoutes();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Method'), chalk.blue('Path')],\n colWidths: [20],\n });\n\n list\n .filter((route) => route.methods.length)\n .forEach((route) => {\n infoTable.push([route.methods.map(toUpper).join('|'), route.path]);\n });\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi routes:list``\n */\nconst command: StrapiCommand = () => {\n return createCommand('routes:list')\n .description('List all the application routes')\n .action(runAction('routes:list', action));\n};\n\nexport { action, command };\n"],"names":["strapiFactory","CLITable","chalk","toUpper","createCommand","runAction"],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,mBAAc;AACvC,QAAM,MAAM,MAAMA,KAAAA,cAAc,UAAU,EAAE,KAAK;AAEjD,QAAM,OAAO,IAAI,OAAO,QAAQ,WAAW;AAErC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAM,QAAA,KAAK,QAAQ,GAAGA,uBAAM,KAAK,MAAM,CAAC;AAAA,IAC/C,WAAW,CAAC,EAAE;AAAA,EAAA,CACf;AAGE,OAAA,OAAO,CAAC,UAAU,MAAM,QAAQ,MAAM,EACtC,QAAQ,CAAC,UAAU;AAClB,cAAU,KAAK,CAAC,MAAM,QAAQ,IAAIC,GAAAA,OAAO,EAAE,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC;AAAA,EAAA,CAClE;AAEK,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,aAAa,EAC/B,YAAY,iCAAiC,EAC7C,OAAOC,kBAAU,eAAe,MAAM,CAAC;AAC5C;;;"}
1
+ {"version":3,"file":"list.js","sources":["../../../../src/cli/commands/routes/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { toUpper } from 'lodash/fp';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n const list = app.server.mount().listRoutes();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Method'), chalk.blue('Path')],\n colWidths: [20],\n });\n\n list\n .filter((route) => route.methods.length)\n .forEach((route) => {\n infoTable.push([route.methods.map(toUpper).join('|'), route.path]);\n });\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi routes:list``\n */\nconst command: StrapiCommand = () => {\n return createCommand('routes:list')\n .description('List all the application routes')\n .action(runAction('routes:list', action));\n};\n\nexport { action, command };\n"],"names":["compileStrapi","createStrapi","CLITable","chalk","toUpper","createCommand","runAction"],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,KAAAA;AACzB,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,KAAK;AAEhD,QAAM,OAAO,IAAI,OAAO,QAAQ,WAAW;AAErC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAM,QAAA,KAAK,QAAQ,GAAGA,uBAAM,KAAK,MAAM,CAAC;AAAA,IAC/C,WAAW,CAAC,EAAE;AAAA,EAAA,CACf;AAGE,OAAA,OAAO,CAAC,UAAU,MAAM,QAAQ,MAAM,EACtC,QAAQ,CAAC,UAAU;AAClB,cAAU,KAAK,CAAC,MAAM,QAAQ,IAAIC,GAAAA,OAAO,EAAE,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC;AAAA,EAAA,CAClE;AAEK,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,aAAa,EAC/B,YAAY,iCAAiC,EAC7C,OAAOC,kBAAU,eAAe,MAAM,CAAC;AAC5C;;;"}
@@ -0,0 +1,28 @@
1
+ import { createCommand } from "commander";
2
+ import CLITable from "cli-table3";
3
+ import chalk from "chalk";
4
+ import { toUpper } from "lodash/fp";
5
+ import { compileStrapi, createStrapi } from "@strapi/core";
6
+ import { runAction } from "../../utils/helpers.mjs";
7
+ const action = async () => {
8
+ const appContext = await compileStrapi();
9
+ const app = await createStrapi(appContext).load();
10
+ const list = app.server.mount().listRoutes();
11
+ const infoTable = new CLITable({
12
+ head: [chalk.blue("Method"), chalk.blue("Path")],
13
+ colWidths: [20]
14
+ });
15
+ list.filter((route) => route.methods.length).forEach((route) => {
16
+ infoTable.push([route.methods.map(toUpper).join("|"), route.path]);
17
+ });
18
+ console.log(infoTable.toString());
19
+ await app.destroy();
20
+ };
21
+ const command = () => {
22
+ return createCommand("routes:list").description("List all the application routes").action(runAction("routes:list", action));
23
+ };
24
+ export {
25
+ action,
26
+ command
27
+ };
28
+ //# sourceMappingURL=list.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.mjs","sources":["../../../../src/cli/commands/routes/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { toUpper } from 'lodash/fp';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n const list = app.server.mount().listRoutes();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Method'), chalk.blue('Path')],\n colWidths: [20],\n });\n\n list\n .filter((route) => route.methods.length)\n .forEach((route) => {\n infoTable.push([route.methods.map(toUpper).join('|'), route.path]);\n });\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi routes:list``\n */\nconst command: StrapiCommand = () => {\n return createCommand('routes:list')\n .description('List all the application routes')\n .action(runAction('routes:list', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAM;AACzB,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,KAAK;AAEhD,QAAM,OAAO,IAAI,OAAO,QAAQ,WAAW;AAErC,QAAA,YAAY,IAAI,SAAS;AAAA,IAC7B,MAAM,CAAC,MAAM,KAAK,QAAQ,GAAG,MAAM,KAAK,MAAM,CAAC;AAAA,IAC/C,WAAW,CAAC,EAAE;AAAA,EAAA,CACf;AAGE,OAAA,OAAO,CAAC,UAAU,MAAM,QAAQ,MAAM,EACtC,QAAQ,CAAC,UAAU;AAClB,cAAU,KAAK,CAAC,MAAM,QAAQ,IAAI,OAAO,EAAE,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC;AAAA,EAAA,CAClE;AAEK,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,aAAa,EAC/B,YAAY,iCAAiC,EAC7C,OAAO,UAAU,eAAe,MAAM,CAAC;AAC5C;"}
@@ -9,8 +9,8 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
9
  const CLITable__default = /* @__PURE__ */ _interopDefault(CLITable);
10
10
  const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
11
11
  const action = async () => {
12
- const appContext = await core.strapiFactory.compile();
13
- const app = await core.strapiFactory(appContext).register();
12
+ const appContext = await core.compileStrapi();
13
+ const app = await core.createStrapi(appContext).register();
14
14
  const list = app.get("services").keys();
15
15
  const infoTable = new CLITable__default.default({
16
16
  head: [chalk__default.default.blue("Name")]
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sources":["../../../../src/cli/commands/services/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { strapiFactory } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await strapiFactory.compile();\n const app = await strapiFactory(appContext).register();\n\n const list = app.get('services').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi services:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('services:list')\n .description('List all the application services')\n .action(runAction('services:list', action));\n};\n\nexport { action, command };\n"],"names":["strapiFactory","CLITable","chalk","createCommand","runAction"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,mBAAc;AACvC,QAAM,MAAM,MAAMA,KAAAA,cAAc,UAAU,EAAE,SAAS;AAErD,QAAM,OAAO,IAAI,IAAI,UAAU,EAAE,KAAK;AAEhC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAAA,QAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAiB,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAE7C,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,eAAe,EACjC,YAAY,mCAAmC,EAC/C,OAAOC,kBAAU,iBAAiB,MAAM,CAAC;AAC9C;;;"}
1
+ {"version":3,"file":"list.js","sources":["../../../../src/cli/commands/services/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('services').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi services:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('services:list')\n .description('List all the application services')\n .action(runAction('services:list', action));\n};\n\nexport { action, command };\n"],"names":["compileStrapi","createStrapi","CLITable","chalk","createCommand","runAction"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,KAAAA;AACzB,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,SAAS;AAEpD,QAAM,OAAO,IAAI,IAAI,UAAU,EAAE,KAAK;AAEhC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAAA,QAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAiB,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAE7C,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,eAAe,EACjC,YAAY,mCAAmC,EAC/C,OAAOC,kBAAU,iBAAiB,MAAM,CAAC;AAC9C;;;"}
@@ -0,0 +1,24 @@
1
+ import { createCommand } from "commander";
2
+ import CLITable from "cli-table3";
3
+ import chalk from "chalk";
4
+ import { compileStrapi, createStrapi } from "@strapi/core";
5
+ import { runAction } from "../../utils/helpers.mjs";
6
+ const action = async () => {
7
+ const appContext = await compileStrapi();
8
+ const app = await createStrapi(appContext).register();
9
+ const list = app.get("services").keys();
10
+ const infoTable = new CLITable({
11
+ head: [chalk.blue("Name")]
12
+ });
13
+ list.forEach((name) => infoTable.push([name]));
14
+ console.log(infoTable.toString());
15
+ await app.destroy();
16
+ };
17
+ const command = () => {
18
+ return createCommand("services:list").description("List all the application services").action(runAction("services:list", action));
19
+ };
20
+ export {
21
+ action,
22
+ command
23
+ };
24
+ //# sourceMappingURL=list.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.mjs","sources":["../../../../src/cli/commands/services/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('services').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi services:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('services:list')\n .description('List all the application services')\n .action(runAction('services:list', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAM;AACzB,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,SAAS;AAEpD,QAAM,OAAO,IAAI,IAAI,UAAU,EAAE,KAAK;AAEhC,QAAA,YAAY,IAAI,SAAS;AAAA,IAC7B,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAiB,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAE7C,UAAA,IAAI,UAAU,SAAU,CAAA;AAEhC,QAAM,IAAI;AACZ;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,eAAe,EACjC,YAAY,mCAAmC,EAC/C,OAAO,UAAU,iBAAiB,MAAM,CAAC;AAC9C;"}
@@ -18,7 +18,7 @@ const action = async () => {
18
18
  throw new Error(
19
19
  `${outDir} directory not found. Please run the build command before starting your application`
20
20
  );
21
- core.strapiFactory({ appDir, distDir }).start();
21
+ core.createStrapi({ appDir, distDir }).start();
22
22
  };
23
23
  const command = () => {
24
24
  return commander.createCommand("start").description("Start your Strapi application").action(helpers.runAction("start", action));
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sources":["../../../src/cli/commands/start.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport fs from 'fs';\nimport tsUtils from '@strapi/typescript-utils';\nimport { strapiFactory } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n const appDir = process.cwd();\n\n const isTSProject = await tsUtils.isUsingTypeScript(appDir);\n\n const outDir = await tsUtils.resolveOutDir(appDir);\n const distDir = isTSProject ? outDir : appDir;\n\n const buildDirExists = fs.existsSync(outDir);\n if (isTSProject && !buildDirExists)\n throw new Error(\n `${outDir} directory not found. Please run the build command before starting your application`\n );\n\n strapiFactory({ appDir, distDir }).start();\n};\n\n/**\n * `$ strapi start`\n */\nconst command: StrapiCommand = () => {\n return createCommand('start')\n .description('Start your Strapi application')\n .action(runAction('start', action));\n};\n\nexport { command };\n"],"names":["tsUtils","fs","strapiFactory","createCommand","runAction"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,SAAS,QAAQ;AAEvB,QAAM,cAAc,MAAMA,iBAAAA,QAAQ,kBAAkB,MAAM;AAE1D,QAAM,SAAS,MAAMA,iBAAAA,QAAQ,cAAc,MAAM;AAC3C,QAAA,UAAU,cAAc,SAAS;AAEjC,QAAA,iBAAiBC,YAAAA,QAAG,WAAW,MAAM;AAC3C,MAAI,eAAe,CAAC;AAClB,UAAM,IAAI;AAAA,MACR,GAAG,MAAM;AAAA,IAAA;AAGbC,OAAAA,cAAc,EAAE,QAAQ,QAAQ,CAAC,EAAE,MAAM;AAC3C;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,OAAO,EACzB,YAAY,+BAA+B,EAC3C,OAAOC,kBAAU,SAAS,MAAM,CAAC;AACtC;;"}
1
+ {"version":3,"file":"start.js","sources":["../../../src/cli/commands/start.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport fs from 'fs';\nimport tsUtils from '@strapi/typescript-utils';\nimport { createStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n const appDir = process.cwd();\n\n const isTSProject = await tsUtils.isUsingTypeScript(appDir);\n\n const outDir = await tsUtils.resolveOutDir(appDir);\n const distDir = isTSProject ? outDir : appDir;\n\n const buildDirExists = fs.existsSync(outDir);\n if (isTSProject && !buildDirExists)\n throw new Error(\n `${outDir} directory not found. Please run the build command before starting your application`\n );\n\n createStrapi({ appDir, distDir }).start();\n};\n\n/**\n * `$ strapi start`\n */\nconst command: StrapiCommand = () => {\n return createCommand('start')\n .description('Start your Strapi application')\n .action(runAction('start', action));\n};\n\nexport { command };\n"],"names":["tsUtils","fs","createStrapi","createCommand","runAction"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,SAAS,QAAQ;AAEvB,QAAM,cAAc,MAAMA,iBAAAA,QAAQ,kBAAkB,MAAM;AAE1D,QAAM,SAAS,MAAMA,iBAAAA,QAAQ,cAAc,MAAM;AAC3C,QAAA,UAAU,cAAc,SAAS;AAEjC,QAAA,iBAAiBC,YAAAA,QAAG,WAAW,MAAM;AAC3C,MAAI,eAAe,CAAC;AAClB,UAAM,IAAI;AAAA,MACR,GAAG,MAAM;AAAA,IAAA;AAGbC,OAAAA,aAAa,EAAE,QAAQ,QAAQ,CAAC,EAAE,MAAM;AAC1C;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,wBAAc,OAAO,EACzB,YAAY,+BAA+B,EAC3C,OAAOC,kBAAU,SAAS,MAAM,CAAC;AACtC;;"}
@@ -0,0 +1,24 @@
1
+ import { createCommand } from "commander";
2
+ import fs from "fs";
3
+ import tsUtils__default from "@strapi/typescript-utils";
4
+ import { createStrapi } from "@strapi/core";
5
+ import { runAction } from "../utils/helpers.mjs";
6
+ const action = async () => {
7
+ const appDir = process.cwd();
8
+ const isTSProject = await tsUtils__default.isUsingTypeScript(appDir);
9
+ const outDir = await tsUtils__default.resolveOutDir(appDir);
10
+ const distDir = isTSProject ? outDir : appDir;
11
+ const buildDirExists = fs.existsSync(outDir);
12
+ if (isTSProject && !buildDirExists)
13
+ throw new Error(
14
+ `${outDir} directory not found. Please run the build command before starting your application`
15
+ );
16
+ createStrapi({ appDir, distDir }).start();
17
+ };
18
+ const command = () => {
19
+ return createCommand("start").description("Start your Strapi application").action(runAction("start", action));
20
+ };
21
+ export {
22
+ command
23
+ };
24
+ //# sourceMappingURL=start.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.mjs","sources":["../../../src/cli/commands/start.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport fs from 'fs';\nimport tsUtils from '@strapi/typescript-utils';\nimport { createStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n const appDir = process.cwd();\n\n const isTSProject = await tsUtils.isUsingTypeScript(appDir);\n\n const outDir = await tsUtils.resolveOutDir(appDir);\n const distDir = isTSProject ? outDir : appDir;\n\n const buildDirExists = fs.existsSync(outDir);\n if (isTSProject && !buildDirExists)\n throw new Error(\n `${outDir} directory not found. Please run the build command before starting your application`\n );\n\n createStrapi({ appDir, distDir }).start();\n};\n\n/**\n * `$ strapi start`\n */\nconst command: StrapiCommand = () => {\n return createCommand('start')\n .description('Start your Strapi application')\n .action(runAction('start', action));\n};\n\nexport { command };\n"],"names":["tsUtils"],"mappings":";;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,SAAS,QAAQ;AAEvB,QAAM,cAAc,MAAMA,iBAAQ,kBAAkB,MAAM;AAE1D,QAAM,SAAS,MAAMA,iBAAQ,cAAc,MAAM;AAC3C,QAAA,UAAU,cAAc,SAAS;AAEjC,QAAA,iBAAiB,GAAG,WAAW,MAAM;AAC3C,MAAI,eAAe,CAAC;AAClB,UAAM,IAAI;AAAA,MACR,GAAG,MAAM;AAAA,IAAA;AAGb,eAAa,EAAE,QAAQ,QAAQ,CAAC,EAAE,MAAM;AAC1C;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,OAAO,EACzB,YAAY,+BAA+B,EAC3C,OAAO,UAAU,SAAS,MAAM,CAAC;AACtC;"}
@@ -0,0 +1,67 @@
1
+ import { resolve } from "path";
2
+ import fse from "fs-extra";
3
+ import chalk from "chalk";
4
+ import { createCommand } from "commander";
5
+ import { runAction } from "../../utils/helpers.mjs";
6
+ import { sendEvent } from "../../utils/telemetry.mjs";
7
+ const readPackageJSON = async (path) => {
8
+ try {
9
+ const packageObj = await fse.readJson(path);
10
+ const uuid = packageObj.strapi ? packageObj.strapi.uuid : null;
11
+ return { uuid, packageObj };
12
+ } catch (err) {
13
+ if (err instanceof Error) {
14
+ console.error(`${chalk.red("Error")}: ${err.message}`);
15
+ }
16
+ }
17
+ };
18
+ const writePackageJSON = async (path, file, spacing) => {
19
+ try {
20
+ await fse.writeJson(path, file, { spaces: spacing });
21
+ return true;
22
+ } catch (err) {
23
+ if (err instanceof Error) {
24
+ console.error(`${chalk.red("Error")}: ${err.message}`);
25
+ }
26
+ }
27
+ };
28
+ const action = async () => {
29
+ const packageJSONPath = resolve(process.cwd(), "package.json");
30
+ const exists = await fse.pathExists(packageJSONPath);
31
+ if (!exists) {
32
+ console.log(`${chalk.yellow("Warning")}: could not find package.json`);
33
+ process.exit(0);
34
+ }
35
+ const { uuid, packageObj } = await readPackageJSON(packageJSONPath) ?? {};
36
+ if (packageObj.strapi && packageObj.strapi.telemetryDisabled || !uuid) {
37
+ console.log(`${chalk.yellow("Warning:")} telemetry is already disabled`);
38
+ process.exit(0);
39
+ }
40
+ const updatedPackageJSON = {
41
+ ...packageObj,
42
+ strapi: {
43
+ ...packageObj.strapi,
44
+ telemetryDisabled: true
45
+ }
46
+ };
47
+ const write = await writePackageJSON(packageJSONPath, updatedPackageJSON, 2);
48
+ if (!write) {
49
+ console.log(
50
+ `${chalk.yellow(
51
+ "Warning"
52
+ )}: There has been an error, please set "telemetryDisabled": true in the "strapi" object of your package.json manually.`
53
+ );
54
+ process.exit(0);
55
+ }
56
+ await sendEvent("didOptOutTelemetry", uuid);
57
+ console.log(`${chalk.green("Successfully opted out of Strapi telemetry")}`);
58
+ process.exit(0);
59
+ };
60
+ const command = () => {
61
+ return createCommand("telemetry:disable").description("Disable anonymous telemetry and metadata sending to Strapi analytics").action(runAction("telemetry:disable", action));
62
+ };
63
+ export {
64
+ action,
65
+ command
66
+ };
67
+ //# sourceMappingURL=disable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disable.mjs","sources":["../../../../src/cli/commands/telemetry/disable.ts"],"sourcesContent":["import { resolve } from 'path';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\nimport { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport { sendEvent } from '../../utils/telemetry';\n\nconst readPackageJSON = async (path: string) => {\n try {\n const packageObj = await fse.readJson(path);\n const uuid = packageObj.strapi ? packageObj.strapi.uuid : null;\n\n return { uuid, packageObj };\n } catch (err) {\n if (err instanceof Error) {\n console.error(`${chalk.red('Error')}: ${err.message}`);\n }\n }\n};\n\nconst writePackageJSON = async (path: string, file: object, spacing: number) => {\n try {\n await fse.writeJson(path, file, { spaces: spacing });\n return true;\n } catch (err) {\n if (err instanceof Error) {\n console.error(`${chalk.red('Error')}: ${err.message}`);\n }\n }\n};\n\nconst action = async () => {\n const packageJSONPath = resolve(process.cwd(), 'package.json');\n const exists = await fse.pathExists(packageJSONPath);\n\n if (!exists) {\n console.log(`${chalk.yellow('Warning')}: could not find package.json`);\n process.exit(0);\n }\n\n const { uuid, packageObj } = (await readPackageJSON(packageJSONPath)) ?? {};\n\n if ((packageObj.strapi && packageObj.strapi.telemetryDisabled) || !uuid) {\n console.log(`${chalk.yellow('Warning:')} telemetry is already disabled`);\n process.exit(0);\n }\n\n const updatedPackageJSON = {\n ...packageObj,\n strapi: {\n ...packageObj.strapi,\n telemetryDisabled: true,\n },\n };\n\n const write = await writePackageJSON(packageJSONPath, updatedPackageJSON, 2);\n\n if (!write) {\n console.log(\n `${chalk.yellow(\n 'Warning'\n )}: There has been an error, please set \"telemetryDisabled\": true in the \"strapi\" object of your package.json manually.`\n );\n process.exit(0);\n }\n\n await sendEvent('didOptOutTelemetry', uuid);\n console.log(`${chalk.green('Successfully opted out of Strapi telemetry')}`);\n process.exit(0);\n};\n\n/**\n * `$ strapi telemetry:disable`\n */\nconst command: StrapiCommand = () => {\n return createCommand('telemetry:disable')\n .description('Disable anonymous telemetry and metadata sending to Strapi analytics')\n .action(runAction('telemetry:disable', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;;AASA,MAAM,kBAAkB,OAAO,SAAiB;AAC1C,MAAA;AACF,UAAM,aAAa,MAAM,IAAI,SAAS,IAAI;AAC1C,UAAM,OAAO,WAAW,SAAS,WAAW,OAAO,OAAO;AAEnD,WAAA,EAAE,MAAM;WACR,KAAK;AACZ,QAAI,eAAe,OAAO;AAChB,cAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAAA,IACvD;AAAA,EACF;AACF;AAEA,MAAM,mBAAmB,OAAO,MAAc,MAAc,YAAoB;AAC1E,MAAA;AACF,UAAM,IAAI,UAAU,MAAM,MAAM,EAAE,QAAQ,SAAS;AAC5C,WAAA;AAAA,WACA,KAAK;AACZ,QAAI,eAAe,OAAO;AAChB,cAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAAA,IACvD;AAAA,EACF;AACF;AAEA,MAAM,SAAS,YAAY;AACzB,QAAM,kBAAkB,QAAQ,QAAQ,OAAO,cAAc;AAC7D,QAAM,SAAS,MAAM,IAAI,WAAW,eAAe;AAEnD,MAAI,CAAC,QAAQ;AACX,YAAQ,IAAI,GAAG,MAAM,OAAO,SAAS,CAAC,+BAA+B;AACrE,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEM,QAAA,EAAE,MAAM,WAAW,IAAK,MAAM,gBAAgB,eAAe,KAAM;AAEzE,MAAK,WAAW,UAAU,WAAW,OAAO,qBAAsB,CAAC,MAAM;AACvE,YAAQ,IAAI,GAAG,MAAM,OAAO,UAAU,CAAC,gCAAgC;AACvE,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,qBAAqB;AAAA,IACzB,GAAG;AAAA,IACH,QAAQ;AAAA,MACN,GAAG,WAAW;AAAA,MACd,mBAAmB;AAAA,IACrB;AAAA,EAAA;AAGF,QAAM,QAAQ,MAAM,iBAAiB,iBAAiB,oBAAoB,CAAC;AAE3E,MAAI,CAAC,OAAO;AACF,YAAA;AAAA,MACN,GAAG,MAAM;AAAA,QACP;AAAA,MACD,CAAA;AAAA,IAAA;AAEH,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEM,QAAA,UAAU,sBAAsB,IAAI;AAC1C,UAAQ,IAAI,GAAG,MAAM,MAAM,4CAA4C,CAAC,EAAE;AAC1E,UAAQ,KAAK,CAAC;AAChB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,mBAAmB,EACrC,YAAY,sEAAsE,EAClF,OAAO,UAAU,qBAAqB,MAAM,CAAC;AAClD;"}
@@ -0,0 +1,86 @@
1
+ import { resolve } from "path";
2
+ import { randomUUID } from "crypto";
3
+ import fse from "fs-extra";
4
+ import chalk from "chalk";
5
+ import { createCommand } from "commander";
6
+ import { runAction } from "../../utils/helpers.mjs";
7
+ import { sendEvent } from "../../utils/telemetry.mjs";
8
+ const readPackageJSON = async (path) => {
9
+ try {
10
+ const packageObj = await fse.readJson(path);
11
+ return packageObj;
12
+ } catch (err) {
13
+ if (err instanceof Error) {
14
+ console.error(`${chalk.red("Error")}: ${err.message}`);
15
+ } else {
16
+ throw err;
17
+ }
18
+ }
19
+ };
20
+ const writePackageJSON = async (path, file, spacing) => {
21
+ try {
22
+ await fse.writeJson(path, file, { spaces: spacing });
23
+ return true;
24
+ } catch (err) {
25
+ if (err instanceof Error) {
26
+ console.error(`${chalk.red("Error")}: ${err.message}`);
27
+ console.log(
28
+ `${chalk.yellow(
29
+ "Warning"
30
+ )}: There has been an error, please set "telemetryDisabled": false in the "strapi" object of your package.json manually.`
31
+ );
32
+ return false;
33
+ }
34
+ throw err;
35
+ }
36
+ };
37
+ const generateNewPackageJSON = (packageObj) => {
38
+ if (!packageObj.strapi) {
39
+ return {
40
+ ...packageObj,
41
+ strapi: {
42
+ uuid: randomUUID(),
43
+ telemetryDisabled: false
44
+ }
45
+ };
46
+ }
47
+ return {
48
+ ...packageObj,
49
+ strapi: {
50
+ ...packageObj.strapi,
51
+ uuid: packageObj.strapi.uuid ? packageObj.strapi.uuid : randomUUID(),
52
+ telemetryDisabled: false
53
+ }
54
+ };
55
+ };
56
+ const action = async () => {
57
+ const packageJSONPath = resolve(process.cwd(), "package.json");
58
+ const exists = await fse.pathExists(packageJSONPath);
59
+ if (!exists) {
60
+ console.log(`${chalk.yellow("Warning")}: could not find package.json`);
61
+ process.exit(0);
62
+ }
63
+ const packageObj = await readPackageJSON(packageJSONPath);
64
+ if (packageObj.strapi && packageObj.strapi.uuid) {
65
+ if (packageObj.strapi.telemetryDisabled === false) {
66
+ console.log(`${chalk.yellow("Warning:")} telemetry is already enabled`);
67
+ process.exit(0);
68
+ }
69
+ }
70
+ const updatedPackageJSON = generateNewPackageJSON(packageObj);
71
+ const write = await writePackageJSON(packageJSONPath, updatedPackageJSON, 2);
72
+ if (!write) {
73
+ process.exit(0);
74
+ }
75
+ await sendEvent("didOptInTelemetry", updatedPackageJSON.strapi.uuid);
76
+ console.log(`${chalk.green("Successfully opted into and enabled Strapi telemetry")}`);
77
+ process.exit(0);
78
+ };
79
+ const command = () => {
80
+ return createCommand("telemetry:enable").description("Enable anonymous telemetry and metadata sending to Strapi analytics").action(runAction("telemetry:enable", action));
81
+ };
82
+ export {
83
+ action,
84
+ command
85
+ };
86
+ //# sourceMappingURL=enable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable.mjs","sources":["../../../../src/cli/commands/telemetry/enable.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { randomUUID } from 'crypto';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\nimport { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport { sendEvent } from '../../utils/telemetry';\n\ntype PackageJson = {\n strapi?: {\n uuid?: string;\n telemetryDisabled?: boolean;\n };\n};\n\nconst readPackageJSON = async (path: string) => {\n try {\n const packageObj = await fse.readJson(path);\n return packageObj;\n } catch (err) {\n if (err instanceof Error) {\n console.error(`${chalk.red('Error')}: ${err.message}`);\n } else {\n throw err;\n }\n }\n};\n\nconst writePackageJSON = async (path: string, file: object, spacing: number) => {\n try {\n await fse.writeJson(path, file, { spaces: spacing });\n return true;\n } catch (err) {\n if (err instanceof Error) {\n console.error(`${chalk.red('Error')}: ${err.message}`);\n console.log(\n `${chalk.yellow(\n 'Warning'\n )}: There has been an error, please set \"telemetryDisabled\": false in the \"strapi\" object of your package.json manually.`\n );\n\n return false;\n }\n\n throw err;\n }\n};\n\nconst generateNewPackageJSON = (packageObj: PackageJson) => {\n if (!packageObj.strapi) {\n return {\n ...packageObj,\n strapi: {\n uuid: randomUUID(),\n telemetryDisabled: false,\n },\n };\n }\n return {\n ...packageObj,\n strapi: {\n ...packageObj.strapi,\n uuid: packageObj.strapi.uuid ? packageObj.strapi.uuid : randomUUID(),\n telemetryDisabled: false,\n },\n };\n};\n\nconst action = async () => {\n const packageJSONPath = resolve(process.cwd(), 'package.json');\n const exists = await fse.pathExists(packageJSONPath);\n\n if (!exists) {\n console.log(`${chalk.yellow('Warning')}: could not find package.json`);\n process.exit(0);\n }\n\n const packageObj = await readPackageJSON(packageJSONPath);\n\n if (packageObj.strapi && packageObj.strapi.uuid) {\n if (packageObj.strapi.telemetryDisabled === false) {\n console.log(`${chalk.yellow('Warning:')} telemetry is already enabled`);\n process.exit(0);\n }\n }\n\n const updatedPackageJSON = generateNewPackageJSON(packageObj);\n\n const write = await writePackageJSON(packageJSONPath, updatedPackageJSON, 2);\n\n if (!write) {\n process.exit(0);\n }\n\n await sendEvent('didOptInTelemetry', updatedPackageJSON.strapi.uuid);\n console.log(`${chalk.green('Successfully opted into and enabled Strapi telemetry')}`);\n process.exit(0);\n};\n\n/**\n * `$ strapi telemetry:enable`\n */\nconst command: StrapiCommand = () => {\n return createCommand('telemetry:enable')\n .description('Enable anonymous telemetry and metadata sending to Strapi analytics')\n .action(runAction('telemetry:enable', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;;;AAiBA,MAAM,kBAAkB,OAAO,SAAiB;AAC1C,MAAA;AACF,UAAM,aAAa,MAAM,IAAI,SAAS,IAAI;AACnC,WAAA;AAAA,WACA,KAAK;AACZ,QAAI,eAAe,OAAO;AAChB,cAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAAA,IAAA,OAChD;AACC,YAAA;AAAA,IACR;AAAA,EACF;AACF;AAEA,MAAM,mBAAmB,OAAO,MAAc,MAAc,YAAoB;AAC1E,MAAA;AACF,UAAM,IAAI,UAAU,MAAM,MAAM,EAAE,QAAQ,SAAS;AAC5C,WAAA;AAAA,WACA,KAAK;AACZ,QAAI,eAAe,OAAO;AAChB,cAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAC7C,cAAA;AAAA,QACN,GAAG,MAAM;AAAA,UACP;AAAA,QACD,CAAA;AAAA,MAAA;AAGI,aAAA;AAAA,IACT;AAEM,UAAA;AAAA,EACR;AACF;AAEA,MAAM,yBAAyB,CAAC,eAA4B;AACtD,MAAA,CAAC,WAAW,QAAQ;AACf,WAAA;AAAA,MACL,GAAG;AAAA,MACH,QAAQ;AAAA,QACN,MAAM,WAAW;AAAA,QACjB,mBAAmB;AAAA,MACrB;AAAA,IAAA;AAAA,EAEJ;AACO,SAAA;AAAA,IACL,GAAG;AAAA,IACH,QAAQ;AAAA,MACN,GAAG,WAAW;AAAA,MACd,MAAM,WAAW,OAAO,OAAO,WAAW,OAAO,OAAO,WAAW;AAAA,MACnE,mBAAmB;AAAA,IACrB;AAAA,EAAA;AAEJ;AAEA,MAAM,SAAS,YAAY;AACzB,QAAM,kBAAkB,QAAQ,QAAQ,OAAO,cAAc;AAC7D,QAAM,SAAS,MAAM,IAAI,WAAW,eAAe;AAEnD,MAAI,CAAC,QAAQ;AACX,YAAQ,IAAI,GAAG,MAAM,OAAO,SAAS,CAAC,+BAA+B;AACrE,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEM,QAAA,aAAa,MAAM,gBAAgB,eAAe;AAExD,MAAI,WAAW,UAAU,WAAW,OAAO,MAAM;AAC3C,QAAA,WAAW,OAAO,sBAAsB,OAAO;AACjD,cAAQ,IAAI,GAAG,MAAM,OAAO,UAAU,CAAC,+BAA+B;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEM,QAAA,qBAAqB,uBAAuB,UAAU;AAE5D,QAAM,QAAQ,MAAM,iBAAiB,iBAAiB,oBAAoB,CAAC;AAE3E,MAAI,CAAC,OAAO;AACV,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,UAAU,qBAAqB,mBAAmB,OAAO,IAAI;AACnE,UAAQ,IAAI,GAAG,MAAM,MAAM,sDAAsD,CAAC,EAAE;AACpF,UAAQ,KAAK,CAAC;AAChB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,kBAAkB,EACpC,YAAY,qEAAqE,EACjF,OAAO,UAAU,oBAAoB,MAAM,CAAC;AACjD;"}
@@ -0,0 +1,74 @@
1
+ import { createCommand } from "commander";
2
+ import { resolve, join, basename } from "path";
3
+ import fse from "fs-extra";
4
+ import chalk from "chalk";
5
+ import inquirer from "inquirer";
6
+ import { runAction } from "../../utils/helpers.mjs";
7
+ const TEMPLATE_CONTENT = ["src", "data"];
8
+ async function copyContent(templatePath, rootBase) {
9
+ for (const item of TEMPLATE_CONTENT) {
10
+ try {
11
+ const pathToCopy = join(process.cwd(), item);
12
+ if (!await fse.pathExists(pathToCopy)) {
13
+ continue;
14
+ }
15
+ await fse.copy(pathToCopy, join(templatePath, item));
16
+ const currentProjectBase = basename(process.cwd());
17
+ console.log(
18
+ `${chalk.green(
19
+ "success"
20
+ )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
21
+ );
22
+ } catch (error) {
23
+ if (error instanceof Error) {
24
+ console.error(`${chalk.red("error")}: ${error.message}`);
25
+ }
26
+ }
27
+ }
28
+ }
29
+ async function writeTemplateJson(rootPath) {
30
+ try {
31
+ await fse.writeJSON(join(rootPath, "template.json"), {});
32
+ console.log(`${chalk.green("success")}: create JSON config file`);
33
+ } catch (error) {
34
+ if (error instanceof Error) {
35
+ console.error(`${chalk.red("error")}: ${error.message}`);
36
+ }
37
+ }
38
+ }
39
+ async function templateConfigExists(rootPath) {
40
+ const configExists = await fse.pathExists(join(rootPath, "template.json"));
41
+ console.log(`checking: ${join(rootPath, "template.json")}. result ${configExists}`);
42
+ return configExists;
43
+ }
44
+ const action = async function generateTemplate(directory) {
45
+ const rootPath = resolve(directory);
46
+ const templatePath = join(rootPath, "template");
47
+ const exists = await fse.pathExists(templatePath);
48
+ const rootBase = basename(rootPath);
49
+ if (exists) {
50
+ const inquiry = await inquirer.prompt({
51
+ type: "confirm",
52
+ name: "confirm",
53
+ message: `${chalk.yellow(rootBase)} already exists. Do you want to replace it?`
54
+ });
55
+ if (!inquiry.confirm) {
56
+ process.exit(0);
57
+ }
58
+ }
59
+ await fse.ensureDir(templatePath);
60
+ await copyContent(templatePath, rootBase);
61
+ const configExists = await templateConfigExists(rootPath);
62
+ if (!configExists) {
63
+ await writeTemplateJson(rootPath);
64
+ }
65
+ console.log(`${chalk.green("success")}: generated template at ${chalk.yellow(rootPath)}`);
66
+ };
67
+ const command = () => {
68
+ return createCommand("templates:generate <directory>").description("Generate template from Strapi project").action(runAction("templates:generate", action));
69
+ };
70
+ export {
71
+ action,
72
+ command
73
+ };
74
+ //# sourceMappingURL=generate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.mjs","sources":["../../../../src/cli/commands/templates/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { resolve, join, basename } from 'path';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\n// All directories that a template could need\nconst TEMPLATE_CONTENT = ['src', 'data'];\n\nasync function copyContent(templatePath: string, rootBase: string) {\n for (const item of TEMPLATE_CONTENT) {\n try {\n const pathToCopy = join(process.cwd(), item);\n\n if (!(await fse.pathExists(pathToCopy))) {\n continue;\n }\n\n await fse.copy(pathToCopy, join(templatePath, item));\n const currentProjectBase = basename(process.cwd());\n console.log(\n `${chalk.green(\n 'success'\n )}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n */\nasync function writeTemplateJson(rootPath: string) {\n try {\n await fse.writeJSON(join(rootPath, 'template.json'), {});\n console.log(`${chalk.green('success')}: create JSON config file`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`${chalk.red('error')}: ${error.message}`);\n }\n }\n}\n\n/**\n *\n * @param {string} rootPath Absolute path to the root directory\n * @returns boolean\n */\nasync function templateConfigExists(rootPath: string) {\n const configExists = await fse.pathExists(join(rootPath, 'template.json'));\n console.log(`checking: ${join(rootPath, 'template.json')}. result ${configExists}`);\n return configExists;\n}\n\nconst action = async function generateTemplate(directory: string) {\n const rootPath = resolve(directory);\n\n // Get path to template directory: <rootPath>/template\n const templatePath = join(rootPath, 'template');\n\n // Check if the template directory exists\n const exists = await fse.pathExists(templatePath);\n const rootBase = basename(rootPath);\n\n if (exists) {\n // Confirm the user wants to replace the existing template\n const inquiry = await inquirer.prompt({\n type: 'confirm',\n name: 'confirm',\n message: `${chalk.yellow(rootBase)} already exists. Do you want to replace it?`,\n });\n\n if (!inquiry.confirm) {\n process.exit(0);\n }\n }\n\n // Create or replace root directory with <roothPath>/template\n await fse.ensureDir(templatePath);\n // Copy content to /template\n await copyContent(templatePath, rootBase);\n // Create config file if it doesn't exist\n const configExists = await templateConfigExists(rootPath);\n if (!configExists) {\n await writeTemplateJson(rootPath);\n }\n\n console.log(`${chalk.green('success')}: generated template at ${chalk.yellow(rootPath)}`);\n};\n\n/**\n *`$ strapi templates:generate <directory>`\n */\nconst command: StrapiCommand = () => {\n return createCommand('templates:generate <directory>')\n .description('Generate template from Strapi project')\n .action(runAction('templates:generate', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,mBAAmB,CAAC,OAAO,MAAM;AAEvC,eAAe,YAAY,cAAsB,UAAkB;AACjE,aAAW,QAAQ,kBAAkB;AAC/B,QAAA;AACF,YAAM,aAAa,KAAK,QAAQ,OAAO,IAAI;AAE3C,UAAI,CAAE,MAAM,IAAI,WAAW,UAAU,GAAI;AACvC;AAAA,MACF;AAEA,YAAM,IAAI,KAAK,YAAY,KAAK,cAAc,IAAI,CAAC;AACnD,YAAM,qBAAqB,SAAS,QAAQ,IAAK,CAAA;AACzC,cAAA;AAAA,QACN,GAAG,MAAM;AAAA,UACP;AAAA,QAAA,CACD,UAAU,kBAAkB,IAAI,IAAI,OAAO,QAAQ,aAAa,IAAI;AAAA,MAAA;AAAA,aAEhE,OAAO;AACd,UAAI,iBAAiB,OAAO;AAClB,gBAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,MAAM,OAAO,EAAE;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF;AAMA,eAAe,kBAAkB,UAAkB;AAC7C,MAAA;AACF,UAAM,IAAI,UAAU,KAAK,UAAU,eAAe,GAAG,CAAA,CAAE;AACvD,YAAQ,IAAI,GAAG,MAAM,MAAM,SAAS,CAAC,2BAA2B;AAAA,WACzD,OAAO;AACd,QAAI,iBAAiB,OAAO;AAClB,cAAA,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,MAAM,OAAO,EAAE;AAAA,IACzD;AAAA,EACF;AACF;AAOA,eAAe,qBAAqB,UAAkB;AACpD,QAAM,eAAe,MAAM,IAAI,WAAW,KAAK,UAAU,eAAe,CAAC;AACjE,UAAA,IAAI,aAAa,KAAK,UAAU,eAAe,CAAC,YAAY,YAAY,EAAE;AAC3E,SAAA;AACT;AAEM,MAAA,SAAS,eAAe,iBAAiB,WAAmB;AAC1D,QAAA,WAAW,QAAQ,SAAS;AAG5B,QAAA,eAAe,KAAK,UAAU,UAAU;AAG9C,QAAM,SAAS,MAAM,IAAI,WAAW,YAAY;AAC1C,QAAA,WAAW,SAAS,QAAQ;AAElC,MAAI,QAAQ;AAEJ,UAAA,UAAU,MAAM,SAAS,OAAO;AAAA,MACpC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,GAAG,MAAM,OAAO,QAAQ,CAAC;AAAA,IAAA,CACnC;AAEG,QAAA,CAAC,QAAQ,SAAS;AACpB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAGM,QAAA,IAAI,UAAU,YAAY;AAE1B,QAAA,YAAY,cAAc,QAAQ;AAElC,QAAA,eAAe,MAAM,qBAAqB,QAAQ;AACxD,MAAI,CAAC,cAAc;AACjB,UAAM,kBAAkB,QAAQ;AAAA,EAClC;AAEQ,UAAA,IAAI,GAAG,MAAM,MAAM,SAAS,CAAC,2BAA2B,MAAM,OAAO,QAAQ,CAAC,EAAE;AAC1F;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,gCAAgC,EAClD,YAAY,uCAAuC,EACnD,OAAO,UAAU,sBAAsB,MAAM,CAAC;AACnD;"}
@@ -0,0 +1,131 @@
1
+ import { isObject } from "lodash/fp";
2
+ import { engine, strapi } from "@strapi/data-transfer";
3
+ import { createStrapiInstance, parseRestoreFromOptions, DEFAULT_IGNORED_CONTENT_TYPES, formatDiagnostic, getDiffHandler, getAssetsBackupHandler, getTransferTelemetryPayload, setSignalHandler, abortTransfer, buildTransferTable, exitMessageText, loadersFactory } from "../../utils/data-transfer.mjs";
4
+ import { exitWith } from "../../utils/helpers.mjs";
5
+ const { createTransferEngine } = engine;
6
+ const {
7
+ providers: {
8
+ createRemoteStrapiDestinationProvider,
9
+ createLocalStrapiSourceProvider,
10
+ createLocalStrapiDestinationProvider,
11
+ createRemoteStrapiSourceProvider
12
+ }
13
+ } = strapi;
14
+ const action = async (opts) => {
15
+ if (!isObject(opts)) {
16
+ exitWith(1, "Could not parse command arguments");
17
+ }
18
+ if (!(opts.from || opts.to) || opts.from && opts.to) {
19
+ exitWith(1, "Exactly one source (from) or destination (to) option must be provided");
20
+ }
21
+ const strapi2 = await createStrapiInstance();
22
+ let source;
23
+ let destination;
24
+ if (!opts.from) {
25
+ source = createLocalStrapiSourceProvider({
26
+ getStrapi: () => strapi2
27
+ });
28
+ } else {
29
+ if (!opts.fromToken) {
30
+ exitWith(1, "Missing token for remote destination");
31
+ }
32
+ source = createRemoteStrapiSourceProvider({
33
+ getStrapi: () => strapi2,
34
+ url: opts.from,
35
+ auth: {
36
+ type: "token",
37
+ token: opts.fromToken
38
+ }
39
+ });
40
+ }
41
+ if (!opts.to) {
42
+ destination = createLocalStrapiDestinationProvider({
43
+ getStrapi: () => strapi2,
44
+ strategy: "restore",
45
+ restore: parseRestoreFromOptions(opts)
46
+ });
47
+ } else {
48
+ if (!opts.toToken) {
49
+ exitWith(1, "Missing token for remote destination");
50
+ }
51
+ destination = createRemoteStrapiDestinationProvider({
52
+ url: opts.to,
53
+ auth: {
54
+ type: "token",
55
+ token: opts.toToken
56
+ },
57
+ strategy: "restore",
58
+ restore: parseRestoreFromOptions(opts)
59
+ });
60
+ }
61
+ if (!source || !destination) {
62
+ exitWith(1, "Could not create providers");
63
+ }
64
+ const engine2 = createTransferEngine(source, destination, {
65
+ versionStrategy: "exact",
66
+ schemaStrategy: "strict",
67
+ exclude: opts.exclude,
68
+ only: opts.only,
69
+ throttle: opts.throttle,
70
+ transforms: {
71
+ links: [
72
+ {
73
+ filter(link) {
74
+ return !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) && !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type);
75
+ }
76
+ }
77
+ ],
78
+ entities: [
79
+ {
80
+ filter(entity) {
81
+ return !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);
82
+ }
83
+ }
84
+ ]
85
+ }
86
+ });
87
+ engine2.diagnostics.onDiagnostic(formatDiagnostic("transfer"));
88
+ const progress = engine2.progress.stream;
89
+ const { updateLoader } = loadersFactory();
90
+ engine2.onSchemaDiff(getDiffHandler(engine2, { force: opts.force, action: "transfer" }));
91
+ engine2.addErrorHandler(
92
+ "ASSETS_DIRECTORY_ERR",
93
+ getAssetsBackupHandler(engine2, { force: opts.force, action: "transfer" })
94
+ );
95
+ progress.on(`stage::start`, ({ stage, data }) => {
96
+ updateLoader(stage, data).start();
97
+ });
98
+ progress.on("stage::finish", ({ stage, data }) => {
99
+ updateLoader(stage, data).succeed();
100
+ });
101
+ progress.on("stage::progress", ({ stage, data }) => {
102
+ updateLoader(stage, data);
103
+ });
104
+ progress.on("stage::error", ({ stage, data }) => {
105
+ updateLoader(stage, data).fail();
106
+ });
107
+ progress.on("transfer::start", async () => {
108
+ console.log(`Starting transfer...`);
109
+ await strapi2.telemetry.send("didDEITSProcessStart", getTransferTelemetryPayload(engine2));
110
+ });
111
+ let results;
112
+ try {
113
+ setSignalHandler(() => abortTransfer({ engine: engine2, strapi: strapi2 }));
114
+ results = await engine2.transfer();
115
+ await strapi2.telemetry.send("didDEITSProcessFinish", getTransferTelemetryPayload(engine2));
116
+ try {
117
+ const table = buildTransferTable(results.engine);
118
+ console.log(table?.toString());
119
+ } catch (e) {
120
+ console.error("There was an error displaying the results of the transfer.");
121
+ }
122
+ exitWith(0, exitMessageText("transfer"));
123
+ } catch (e) {
124
+ await strapi2.telemetry.send("didDEITSProcessFail", getTransferTelemetryPayload(engine2));
125
+ exitWith(1, exitMessageText("transfer", true));
126
+ }
127
+ };
128
+ export {
129
+ action as default
130
+ };
131
+ //# sourceMappingURL=action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.mjs","sources":["../../../../src/cli/commands/transfer/action.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { engine as engineDataTransfer, strapi as strapiDataTransfer } from '@strapi/data-transfer';\n\nimport {\n buildTransferTable,\n createStrapiInstance,\n DEFAULT_IGNORED_CONTENT_TYPES,\n formatDiagnostic,\n loadersFactory,\n exitMessageText,\n abortTransfer,\n getTransferTelemetryPayload,\n setSignalHandler,\n getDiffHandler,\n getAssetsBackupHandler,\n parseRestoreFromOptions,\n} from '../../utils/data-transfer';\nimport { exitWith } from '../../utils/helpers';\n\nconst { createTransferEngine } = engineDataTransfer;\nconst {\n providers: {\n createRemoteStrapiDestinationProvider,\n createLocalStrapiSourceProvider,\n createLocalStrapiDestinationProvider,\n createRemoteStrapiSourceProvider,\n },\n} = strapiDataTransfer;\n\ninterface CmdOptions {\n from?: URL;\n fromToken: string;\n to: URL;\n toToken: string;\n only?: (keyof engineDataTransfer.TransferGroupFilter)[];\n exclude?: (keyof engineDataTransfer.TransferGroupFilter)[];\n throttle?: number;\n force?: boolean;\n}\n/**\n * Transfer command.\n *\n * Transfers data between local Strapi and remote Strapi instances\n */\nexport default async (opts: CmdOptions) => {\n // Validate inputs from Commander\n if (!isObject(opts)) {\n exitWith(1, 'Could not parse command arguments');\n }\n\n if (!(opts.from || opts.to) || (opts.from && opts.to)) {\n exitWith(1, 'Exactly one source (from) or destination (to) option must be provided');\n }\n\n const strapi = await createStrapiInstance();\n let source;\n let destination;\n\n // if no URL provided, use local Strapi\n if (!opts.from) {\n source = createLocalStrapiSourceProvider({\n getStrapi: () => strapi,\n });\n }\n // if URL provided, set up a remote source provider\n else {\n if (!opts.fromToken) {\n exitWith(1, 'Missing token for remote destination');\n }\n\n source = createRemoteStrapiSourceProvider({\n getStrapi: () => strapi,\n url: opts.from,\n auth: {\n type: 'token',\n token: opts.fromToken,\n },\n });\n }\n\n // if no URL provided, use local Strapi\n if (!opts.to) {\n destination = createLocalStrapiDestinationProvider({\n getStrapi: () => strapi,\n strategy: 'restore',\n restore: parseRestoreFromOptions(opts),\n });\n }\n // if URL provided, set up a remote destination provider\n else {\n if (!opts.toToken) {\n exitWith(1, 'Missing token for remote destination');\n }\n\n destination = createRemoteStrapiDestinationProvider({\n url: opts.to,\n auth: {\n type: 'token',\n token: opts.toToken,\n },\n strategy: 'restore',\n restore: parseRestoreFromOptions(opts),\n });\n }\n\n if (!source || !destination) {\n exitWith(1, 'Could not create providers');\n }\n\n const engine = createTransferEngine(source, destination, {\n versionStrategy: 'exact',\n schemaStrategy: 'strict',\n exclude: opts.exclude,\n only: opts.only,\n throttle: opts.throttle,\n transforms: {\n links: [\n {\n filter(link) {\n return (\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) &&\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type)\n );\n },\n },\n ],\n entities: [\n {\n filter(entity) {\n return !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);\n },\n },\n ],\n },\n });\n\n engine.diagnostics.onDiagnostic(formatDiagnostic('transfer'));\n\n const progress = engine.progress.stream;\n\n const { updateLoader } = loadersFactory();\n\n engine.onSchemaDiff(getDiffHandler(engine, { force: opts.force, action: 'transfer' }));\n\n engine.addErrorHandler(\n 'ASSETS_DIRECTORY_ERR',\n getAssetsBackupHandler(engine, { force: opts.force, action: 'transfer' })\n );\n\n progress.on(`stage::start`, ({ stage, data }) => {\n updateLoader(stage, data).start();\n });\n\n progress.on('stage::finish', ({ stage, data }) => {\n updateLoader(stage, data).succeed();\n });\n\n progress.on('stage::progress', ({ stage, data }) => {\n updateLoader(stage, data);\n });\n\n progress.on('stage::error', ({ stage, data }) => {\n updateLoader(stage, data).fail();\n });\n\n progress.on('transfer::start', async () => {\n console.log(`Starting transfer...`);\n\n await strapi.telemetry.send('didDEITSProcessStart', getTransferTelemetryPayload(engine));\n });\n\n let results: Awaited<ReturnType<typeof engine.transfer>>;\n try {\n // Abort transfer if user interrupts process\n setSignalHandler(() => abortTransfer({ engine, strapi }));\n\n results = await engine.transfer();\n\n // Note: we need to await telemetry or else the process ends before it is sent\n await strapi.telemetry.send('didDEITSProcessFinish', getTransferTelemetryPayload(engine));\n\n try {\n const table = buildTransferTable(results.engine);\n console.log(table?.toString());\n } catch (e) {\n console.error('There was an error displaying the results of the transfer.');\n }\n\n exitWith(0, exitMessageText('transfer'));\n } catch (e) {\n await strapi.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine));\n exitWith(1, exitMessageText('transfer', true));\n }\n};\n"],"names":["engineDataTransfer","strapiDataTransfer","strapi","engine"],"mappings":";;;;AAmBA,MAAM,EAAE,qBAAyB,IAAAA;AACjC,MAAM;AAAA,EACJ,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,IAAIC;AAiBJ,MAAe,SAAA,OAAO,SAAqB;AAErC,MAAA,CAAC,SAAS,IAAI,GAAG;AACnB,aAAS,GAAG,mCAAmC;AAAA,EACjD;AAEI,MAAA,EAAE,KAAK,QAAQ,KAAK,OAAQ,KAAK,QAAQ,KAAK,IAAK;AACrD,aAAS,GAAG,uEAAuE;AAAA,EACrF;AAEM,QAAAC,UAAS,MAAM;AACjB,MAAA;AACA,MAAA;AAGA,MAAA,CAAC,KAAK,MAAM;AACd,aAAS,gCAAgC;AAAA,MACvC,WAAW,MAAMA;AAAA,IAAA,CAClB;AAAA,EAAA,OAGE;AACC,QAAA,CAAC,KAAK,WAAW;AACnB,eAAS,GAAG,sCAAsC;AAAA,IACpD;AAEA,aAAS,iCAAiC;AAAA,MACxC,WAAW,MAAMA;AAAA,MACjB,KAAK,KAAK;AAAA,MACV,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,OAAO,KAAK;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EACH;AAGI,MAAA,CAAC,KAAK,IAAI;AACZ,kBAAc,qCAAqC;AAAA,MACjD,WAAW,MAAMA;AAAA,MACjB,UAAU;AAAA,MACV,SAAS,wBAAwB,IAAI;AAAA,IAAA,CACtC;AAAA,EAAA,OAGE;AACC,QAAA,CAAC,KAAK,SAAS;AACjB,eAAS,GAAG,sCAAsC;AAAA,IACpD;AAEA,kBAAc,sCAAsC;AAAA,MAClD,KAAK,KAAK;AAAA,MACV,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,OAAO,KAAK;AAAA,MACd;AAAA,MACA,UAAU;AAAA,MACV,SAAS,wBAAwB,IAAI;AAAA,IAAA,CACtC;AAAA,EACH;AAEI,MAAA,CAAC,UAAU,CAAC,aAAa;AAC3B,aAAS,GAAG,4BAA4B;AAAA,EAC1C;AAEM,QAAAC,UAAS,qBAAqB,QAAQ,aAAa;AAAA,IACvD,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,MAAM,KAAK;AAAA,IACX,UAAU,KAAK;AAAA,IACf,YAAY;AAAA,MACV,OAAO;AAAA,QACL;AAAA,UACE,OAAO,MAAM;AACX,mBACE,CAAC,8BAA8B,SAAS,KAAK,KAAK,IAAI,KACtD,CAAC,8BAA8B,SAAS,KAAK,MAAM,IAAI;AAAA,UAE3D;AAAA,QACF;AAAA,MACF;AAAA,MACA,UAAU;AAAA,QACR;AAAA,UACE,OAAO,QAAQ;AACb,mBAAO,CAAC,8BAA8B,SAAS,OAAO,IAAI;AAAA,UAC5D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EAAA,CACD;AAED,EAAAA,QAAO,YAAY,aAAa,iBAAiB,UAAU,CAAC;AAEtD,QAAA,WAAWA,QAAO,SAAS;AAE3B,QAAA,EAAE,iBAAiB;AAElB,EAAAA,QAAA,aAAa,eAAeA,SAAQ,EAAE,OAAO,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC;AAE9E,EAAAA,QAAA;AAAA,IACL;AAAA,IACA,uBAAuBA,SAAQ,EAAE,OAAO,KAAK,OAAO,QAAQ,YAAY;AAAA,EAAA;AAG1E,WAAS,GAAG,gBAAgB,CAAC,EAAE,OAAO,WAAW;AAClC,iBAAA,OAAO,IAAI,EAAE,MAAM;AAAA,EAAA,CACjC;AAED,WAAS,GAAG,iBAAiB,CAAC,EAAE,OAAO,WAAW;AACnC,iBAAA,OAAO,IAAI,EAAE,QAAQ;AAAA,EAAA,CACnC;AAED,WAAS,GAAG,mBAAmB,CAAC,EAAE,OAAO,WAAW;AAClD,iBAAa,OAAO,IAAI;AAAA,EAAA,CACzB;AAED,WAAS,GAAG,gBAAgB,CAAC,EAAE,OAAO,WAAW;AAClC,iBAAA,OAAO,IAAI,EAAE,KAAK;AAAA,EAAA,CAChC;AAEQ,WAAA,GAAG,mBAAmB,YAAY;AACzC,YAAQ,IAAI,sBAAsB;AAElC,UAAMD,QAAO,UAAU,KAAK,wBAAwB,4BAA4BC,OAAM,CAAC;AAAA,EAAA,CACxF;AAEG,MAAA;AACA,MAAA;AAEF,qBAAiB,MAAM,cAAc,EAAE,QAAAA,SAAQ,QAAAD,QAAA,CAAQ,CAAC;AAE9C,cAAA,MAAMC,QAAO;AAGvB,UAAMD,QAAO,UAAU,KAAK,yBAAyB,4BAA4BC,OAAM,CAAC;AAEpF,QAAA;AACI,YAAA,QAAQ,mBAAmB,QAAQ,MAAM;AACvC,cAAA,IAAI,OAAO,SAAU,CAAA;AAAA,aACtB,GAAG;AACV,cAAQ,MAAM,4DAA4D;AAAA,IAC5E;AAES,aAAA,GAAG,gBAAgB,UAAU,CAAC;AAAA,WAChC,GAAG;AACV,UAAMD,QAAO,UAAU,KAAK,uBAAuB,4BAA4BC,OAAM,CAAC;AACtF,aAAS,GAAG,gBAAgB,YAAY,IAAI,CAAC;AAAA,EAC/C;AACF;"}