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

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
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const commander = require("commander");
4
- const boxen = require("boxen");
5
- const chalk = require("chalk");
6
- const packUp = require("@strapi/pack-up");
7
- const helpers = require("../../utils/helpers.js");
8
- const pkg = require("../../utils/pkg.js");
9
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
- const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
11
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
12
- const action = async (opts, _cmd, { cwd, logger }) => {
13
- try {
14
- const pkg$1 = await pkg.loadPkg({ cwd, logger });
15
- const pkgJson = await pkg.validatePkg({ pkg: pkg$1 });
16
- if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
17
- throw new Error(
18
- "You need to have either a strapi-admin or strapi-server export in your package.json"
19
- );
20
- }
21
- const bundles = [];
22
- if (pkgJson.exports["./strapi-admin"]) {
23
- const exp = pkgJson.exports["./strapi-admin"];
24
- const bundle = {
25
- source: exp.source,
26
- import: exp.import,
27
- require: exp.require,
28
- runtime: "web"
29
- };
30
- if (exp.types) {
31
- bundle.types = exp.types;
32
- bundle.tsconfig = "./admin/tsconfig.build.json";
33
- }
34
- bundles.push(bundle);
35
- }
36
- if (pkgJson.exports["./strapi-server"]) {
37
- const exp = pkgJson.exports["./strapi-server"];
38
- const bundle = {
39
- source: exp.source,
40
- import: exp.import,
41
- require: exp.require,
42
- runtime: "node"
43
- };
44
- if (exp.types) {
45
- bundle.types = exp.types;
46
- bundle.tsconfig = "./server/tsconfig.build.json";
47
- }
48
- bundles.push(bundle);
49
- }
50
- await packUp.watch({
51
- cwd,
52
- configFile: false,
53
- config: {
54
- bundles,
55
- dist: "./dist",
56
- /**
57
- * ignore the exports map of a plugin, because we're streamlining the
58
- * process and ensuring the server package and admin package are built
59
- * with the correct runtime and their individual tsconfigs
60
- */
61
- exports: {}
62
- },
63
- ...opts
64
- });
65
- } catch (err) {
66
- logger.error(
67
- "There seems to be an unexpected error, try again with --debug for more information \n"
68
- );
69
- if (err instanceof Error && err.stack) {
70
- console.log(
71
- chalk__default.default.red(
72
- boxen__default.default(err.stack, {
73
- padding: 1,
74
- align: "left"
75
- })
76
- )
77
- );
78
- }
79
- process.exit(1);
80
- }
81
- };
82
- const command = ({ ctx }) => {
83
- return commander.createCommand("plugin:watch").description("Watch & compile your strapi plugin for local development.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => helpers.runAction("plugin:watch", action)(...args, ctx));
84
- };
85
- exports.command = command;
86
- //# sourceMappingURL=watch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watch.js","sources":["../../../../src/cli/commands/plugin/watch.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { ConfigBundle, WatchCLIOptions, watch } from '@strapi/pack-up';\n\nimport { runAction } from '../../utils/helpers';\nimport { Export, loadPkg, validatePkg } from '../../utils/pkg';\nimport type { StrapiCommand, CLIContext } from '../../types';\n\ntype ActionOptions = WatchCLIOptions;\n\nconst action = async (opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => {\n try {\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await watch({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n\n/**\n * `$ strapi plugin:watch`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('plugin:watch')\n .description('Watch & compile your strapi plugin for local development.')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .action((...args) => runAction('plugin:watch', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":["pkg","loadPkg","validatePkg","watch","chalk","boxen","createCommand","runAction"],"mappings":";;;;;;;;;;;AAWA,MAAM,SAAS,OAAO,MAAqB,MAAe,EAAE,KAAK,aAAyB;AACpF,MAAA;AACF,UAAMA,QAAM,MAAMC,IAAA,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAMC,IAAAA,YAAY,EAAEF,KAAAA,MAAK,CAAA;AAErC,QAAA,CAAC,QAAQ,QAAQ,gBAAgB,KAAK,CAAC,QAAQ,QAAQ,iBAAiB,GAAG;AAC7E,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,UAA0B,CAAA;AAE5B,QAAA,QAAQ,QAAQ,gBAAg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Y,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAASC,QAAA,UAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;;"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("fs/promises");
4
- const os = require("os");
5
- const pkgUp = require("pkg-up");
6
- const yup = require("yup");
7
- const chalk = require("chalk");
8
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule)
11
- return e;
12
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
13
- if (e) {
14
- for (const k in e) {
15
- if (k !== "default") {
16
- const d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: () => e[k]
20
- });
21
- }
22
- }
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
- const fs__default = /* @__PURE__ */ _interopDefault(fs);
28
- const os__default = /* @__PURE__ */ _interopDefault(os);
29
- const pkgUp__default = /* @__PURE__ */ _interopDefault(pkgUp);
30
- const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
31
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
32
- const packageJsonSchema = yup__namespace.object({
33
- name: yup__namespace.string().required(),
34
- exports: yup__namespace.lazy(
35
- (value) => yup__namespace.object(
36
- typeof value === "object" ? Object.entries(value).reduce((acc, [key, value2]) => {
37
- if (typeof value2 === "object") {
38
- acc[key] = yup__namespace.object({
39
- types: yup__namespace.string().optional(),
40
- source: yup__namespace.string().required(),
41
- module: yup__namespace.string().optional(),
42
- import: yup__namespace.string().required(),
43
- require: yup__namespace.string().required(),
44
- default: yup__namespace.string().required()
45
- }).noUnknown(true);
46
- } else {
47
- acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
48
- }
49
- return acc;
50
- }, {}) : void 0
51
- ).optional()
52
- )
53
- });
54
- const loadPkg = async ({ cwd, logger }) => {
55
- const pkgPath = await pkgUp__default.default({ cwd });
56
- if (!pkgPath) {
57
- throw new Error("Could not find a package.json in the current directory");
58
- }
59
- const buffer = await fs__default.default.readFile(pkgPath);
60
- const pkg = JSON.parse(buffer.toString());
61
- logger.debug("Loaded package.json:", os__default.default.EOL, pkg);
62
- return pkg;
63
- };
64
- const validatePkg = async ({ pkg }) => {
65
- try {
66
- const validatedPkg = await packageJsonSchema.validate(pkg, {
67
- strict: true
68
- });
69
- return validatedPkg;
70
- } catch (err) {
71
- if (err instanceof yup__namespace.ValidationError) {
72
- switch (err.type) {
73
- case "required":
74
- if (err.path) {
75
- throw new Error(
76
- `'${err.path}' in 'package.json' is required as type '${chalk__default.default.magenta(
77
- yup__namespace.reach(packageJsonSchema, err.path).type
78
- )}'`
79
- );
80
- }
81
- break;
82
- case "noUnknown":
83
- if (err.path && err.params && "unknown" in err.params) {
84
- throw new Error(
85
- `'${err.path}' in 'package.json' contains the unknown key ${chalk__default.default.magenta(
86
- err.params.unknown
87
- )}, for compatability only the following keys are allowed: ${chalk__default.default.magenta(
88
- "['types', 'source', 'import', 'require', 'default']"
89
- )}`
90
- );
91
- }
92
- break;
93
- default:
94
- if (err.path && err.params && "type" in err.params && "value" in err.params) {
95
- throw new Error(
96
- `'${err.path}' in 'package.json' must be of type '${chalk__default.default.magenta(
97
- err.params.type
98
- )}' (recieved '${chalk__default.default.magenta(typeof err.params.value)}')`
99
- );
100
- }
101
- }
102
- }
103
- throw err;
104
- }
105
- };
106
- exports.loadPkg = loadPkg;
107
- exports.validatePkg = validatePkg;
108
- //# sourceMappingURL=pkg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkg.js","sources":["../../../src/cli/utils/pkg.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport os from 'os';\nimport pkgUp from 'pkg-up';\nimport * as yup from 'yup';\nimport chalk from 'chalk';\nimport { Logger } from './logger';\n\ninterface Export {\n types?: string;\n source: string;\n module?: string;\n import?: string;\n require?: string;\n default: string;\n}\n\nconst packageJsonSchema = yup.object({\n name: yup.string().required(),\n exports: yup.lazy((value) =>\n yup\n .object(\n typeof value === 'object'\n ? Object.entries(value).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n acc[key] = yup\n .object({\n types: yup.string().optional(),\n source: yup.string().required(),\n module: yup.string().optional(),\n import: yup.string().required(),\n require: yup.string().required(),\n default: yup.string().required(),\n })\n .noUnknown(true);\n } else {\n acc[key] = yup\n .string()\n .matches(/^\\.\\/.*\\.json$/)\n .required();\n }\n\n return acc;\n }, {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>)\n : undefined\n )\n .optional()\n ),\n});\n\n/**\n * @description being a task to load the package.json starting from the current working directory\n * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,\n * the process will throw with an appropriate error message.\n */\nconst loadPkg = async ({ cwd, logger }: { cwd: string; logger: Logger }): Promise<object> => {\n const pkgPath = await pkgUp({ cwd });\n\n if (!pkgPath) {\n throw new Error('Could not find a package.json in the current directory');\n }\n\n const buffer = await fs.readFile(pkgPath);\n\n const pkg = JSON.parse(buffer.toString());\n\n logger.debug('Loaded package.json:', os.EOL, pkg);\n\n return pkg;\n};\n\ntype PackageJson = yup.Asserts<typeof packageJsonSchema>;\n\n/**\n * @description validate the package.json against a standardised schema using `yup`.\n * If the validation fails, the process will throw with an appropriate error message.\n */\nconst validatePkg = async ({ pkg }: { pkg: object }): Promise<PackageJson> => {\n try {\n const validatedPkg = await packageJsonSchema.validate(pkg, {\n strict: true,\n });\n\n return validatedPkg;\n } catch (err) {\n if (err instanceof yup.ValidationError) {\n switch (err.type) {\n case 'required':\n if (err.path) {\n throw new Error(\n `'${err.path}' in 'package.json' is required as type '${chalk.magenta(\n yup.reach(packageJsonSchema, err.path).type\n )}'`\n );\n }\n break;\n /**\n * This will only be thrown if there are keys in the export map\n * that we don't expect so we can therefore make some assumptions\n */\n case 'noUnknown':\n if (err.path && err.params && 'unknown' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(\n err.params.unknown\n )}, for compatability only the following keys are allowed: ${chalk.magenta(\n \"['types', 'source', 'import', 'require', 'default']\"\n )}`\n );\n }\n break;\n default:\n if (err.path && err.params && 'type' in err.params && 'value' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' must be of type '${chalk.magenta(\n err.params.type\n )}' (recieved '${chalk.magenta(typeof err.params.value)}')`\n );\n }\n }\n }\n\n throw err;\n }\n};\n\nexport type { PackageJson, Export };\nexport { loadPkg, validatePkg };\n"],"names":["yup","value","pkgUp","fs","os","chalk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,oBAAoBA,eAAI,OAAO;AAAA,EACnC,MAAMA,eAAI,OAAO,EAAE,SAAS;AAAA,EAC5B,SAASA,eAAI;AAAA,IAAK,CAAC,UACjBA,eACG;AAAA,MACC,OAAO,UAAU,WACb,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAKC,MAAK,MAAM;AAC9C,YAAA,OAAOA,WAAU,UAAU;AACzB,cAAA,GAAG,IAAID,eACR,OAAO;AAAA,YACN,OAAOA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC7B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,SAASA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC/B,SAASA,eAAI,OAAO,EAAE,SAAS;AAAA,UAAA,CAChC,EACA,UAAU,IAAI;AAAA,QAAA,OACZ;AACD,cAAA,GAAG,IAAIA,eACR,SACA,QAAQ,gBAAgB,EACxB;QACL;AAEO,eAAA;AAAA,MAAA,GACN,CAAA,CAAiE,IACpE;AAAA,MAEL,SAAS;AAAA,EACd;AACF,CAAC;AAOD,MAAM,UAAU,OAAO,EAAE,KAAK,aAA+D;A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