@strapi/strapi 5.0.0-beta.8 → 5.0.0-beta.9

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 (95) hide show
  1. package/dist/cli/commands/index.d.ts.map +1 -1
  2. package/dist/cli/commands/index.js +1 -14
  3. package/dist/cli/commands/index.js.map +1 -1
  4. package/dist/cli/commands/index.mjs +1 -14
  5. package/dist/cli/commands/index.mjs.map +1 -1
  6. package/dist/cli/index.d.ts.map +1 -1
  7. package/dist/cli/index.js +30 -0
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/cli/index.mjs +30 -0
  10. package/dist/cli/index.mjs.map +1 -1
  11. package/package.json +23 -23
  12. package/dist/cli/commands/plugin/build.d.ts +0 -7
  13. package/dist/cli/commands/plugin/build.d.ts.map +0 -1
  14. package/dist/cli/commands/plugin/build.js +0 -88
  15. package/dist/cli/commands/plugin/build.js.map +0 -1
  16. package/dist/cli/commands/plugin/build.mjs +0 -85
  17. package/dist/cli/commands/plugin/build.mjs.map +0 -1
  18. package/dist/cli/commands/plugin/init/action.d.ts +0 -6
  19. package/dist/cli/commands/plugin/init/action.d.ts.map +0 -1
  20. package/dist/cli/commands/plugin/init/action.js +0 -413
  21. package/dist/cli/commands/plugin/init/action.js.map +0 -1
  22. package/dist/cli/commands/plugin/init/action.mjs +0 -408
  23. package/dist/cli/commands/plugin/init/action.mjs.map +0 -1
  24. package/dist/cli/commands/plugin/init/command.d.ts +0 -7
  25. package/dist/cli/commands/plugin/init/command.d.ts.map +0 -1
  26. package/dist/cli/commands/plugin/init/command.js +0 -9
  27. package/dist/cli/commands/plugin/init/command.js.map +0 -1
  28. package/dist/cli/commands/plugin/init/command.mjs +0 -10
  29. package/dist/cli/commands/plugin/init/command.mjs.map +0 -1
  30. package/dist/cli/commands/plugin/init/files/admin.d.ts +0 -5
  31. package/dist/cli/commands/plugin/init/files/admin.d.ts.map +0 -1
  32. package/dist/cli/commands/plugin/init/files/admin.js +0 -283
  33. package/dist/cli/commands/plugin/init/files/admin.js.map +0 -1
  34. package/dist/cli/commands/plugin/init/files/admin.mjs +0 -283
  35. package/dist/cli/commands/plugin/init/files/admin.mjs.map +0 -1
  36. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts +0 -4
  37. package/dist/cli/commands/plugin/init/files/editorConfig.d.ts.map +0 -1
  38. package/dist/cli/commands/plugin/init/files/editorConfig.js +0 -26
  39. package/dist/cli/commands/plugin/init/files/editorConfig.js.map +0 -1
  40. package/dist/cli/commands/plugin/init/files/editorConfig.mjs +0 -26
  41. package/dist/cli/commands/plugin/init/files/editorConfig.mjs.map +0 -1
  42. package/dist/cli/commands/plugin/init/files/eslint.d.ts +0 -4
  43. package/dist/cli/commands/plugin/init/files/eslint.d.ts.map +0 -1
  44. package/dist/cli/commands/plugin/init/files/eslint.js +0 -11
  45. package/dist/cli/commands/plugin/init/files/eslint.js.map +0 -1
  46. package/dist/cli/commands/plugin/init/files/eslint.mjs +0 -11
  47. package/dist/cli/commands/plugin/init/files/eslint.mjs.map +0 -1
  48. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts +0 -4
  49. package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts.map +0 -1
  50. package/dist/cli/commands/plugin/init/files/gitIgnore.js +0 -34
  51. package/dist/cli/commands/plugin/init/files/gitIgnore.js.map +0 -1
  52. package/dist/cli/commands/plugin/init/files/gitIgnore.mjs +0 -34
  53. package/dist/cli/commands/plugin/init/files/gitIgnore.mjs.map +0 -1
  54. package/dist/cli/commands/plugin/init/files/prettier.d.ts +0 -5
  55. package/dist/cli/commands/plugin/init/files/prettier.d.ts.map +0 -1
  56. package/dist/cli/commands/plugin/init/files/prettier.js +0 -25
  57. package/dist/cli/commands/plugin/init/files/prettier.js.map +0 -1
  58. package/dist/cli/commands/plugin/init/files/prettier.mjs +0 -25
  59. package/dist/cli/commands/plugin/init/files/prettier.mjs.map +0 -1
  60. package/dist/cli/commands/plugin/init/files/server.d.ts +0 -5
  61. package/dist/cli/commands/plugin/init/files/server.d.ts.map +0 -1
  62. package/dist/cli/commands/plugin/init/files/server.js +0 -360
  63. package/dist/cli/commands/plugin/init/files/server.js.map +0 -1
  64. package/dist/cli/commands/plugin/init/files/server.mjs +0 -360
  65. package/dist/cli/commands/plugin/init/files/server.mjs.map +0 -1
  66. package/dist/cli/commands/plugin/init/files/typescript.d.ts +0 -9
  67. package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +0 -1
  68. package/dist/cli/commands/plugin/init/files/typescript.js +0 -66
  69. package/dist/cli/commands/plugin/init/files/typescript.js.map +0 -1
  70. package/dist/cli/commands/plugin/init/files/typescript.mjs +0 -66
  71. package/dist/cli/commands/plugin/init/files/typescript.mjs.map +0 -1
  72. package/dist/cli/commands/plugin/init/index.d.ts +0 -2
  73. package/dist/cli/commands/plugin/init/index.d.ts.map +0 -1
  74. package/dist/cli/commands/plugin/link-watch.d.ts +0 -7
  75. package/dist/cli/commands/plugin/link-watch.d.ts.map +0 -1
  76. package/dist/cli/commands/plugin/link-watch.js +0 -89
  77. package/dist/cli/commands/plugin/link-watch.js.map +0 -1
  78. package/dist/cli/commands/plugin/link-watch.mjs +0 -82
  79. package/dist/cli/commands/plugin/link-watch.mjs.map +0 -1
  80. package/dist/cli/commands/plugin/verify.d.ts +0 -7
  81. package/dist/cli/commands/plugin/verify.d.ts.map +0 -1
  82. package/dist/cli/commands/plugin/verify.js +0 -37
  83. package/dist/cli/commands/plugin/verify.js.map +0 -1
  84. package/dist/cli/commands/plugin/verify.mjs +0 -34
  85. package/dist/cli/commands/plugin/verify.mjs.map +0 -1
  86. package/dist/cli/commands/plugin/watch.d.ts +0 -7
  87. package/dist/cli/commands/plugin/watch.d.ts.map +0 -1
  88. package/dist/cli/commands/plugin/watch.js +0 -86
  89. package/dist/cli/commands/plugin/watch.js.map +0 -1
  90. package/dist/cli/commands/plugin/watch.mjs +0 -83
  91. package/dist/cli/commands/plugin/watch.mjs.map +0 -1
  92. package/dist/cli/utils/pkg.js +0 -111
  93. package/dist/cli/utils/pkg.js.map +0 -1
  94. package/dist/cli/utils/pkg.mjs +0 -87
  95. package/dist/cli/utils/pkg.mjs.map +0 -1
@@ -1,82 +0,0 @@
1
- import boxen from "boxen";
2
- import chalk from "chalk";
3
- import concurrently from "concurrently";
4
- import fs from "node:fs/promises";
5
- import path from "node:path";
6
- import nodemon from "nodemon";
7
- import { outdent } from "outdent";
8
- import { runAction } from "../../utils/helpers.mjs";
9
- import { loadPkg, validatePkg } from "../../utils/pkg.mjs";
10
- const action = async (_opts, _cmd, { cwd, logger }) => {
11
- try {
12
- const outDir = "./dist";
13
- const extensions = "ts,js,png,svg,gif,jpeg,css";
14
- nodemon({
15
- watch: [outDir],
16
- ext: extensions,
17
- exec: "yalc push --changed"
18
- });
19
- const folder = path.join(cwd, outDir);
20
- if (!await pathExists(folder)) {
21
- await fs.mkdir(folder);
22
- }
23
- const pkg = await loadPkg({ cwd, logger });
24
- const pkgJson = await validatePkg({ pkg });
25
- concurrently(["npm run watch"]);
26
- nodemon.on("start", () => {
27
- logger.info(
28
- outdent`
29
- Watching ${outDir} for changes to files with extensions: ${extensions}
30
-
31
- To use this package in Strapi, in a separate shell run:
32
- cd /path/to/strapi/project
33
-
34
- Then run one of the commands below based on the package manager used in that project:
35
-
36
- ## yarn
37
- ${chalk.greenBright(`yarn dlx yalc add --link ${pkgJson.name} && yarn install`)}
38
-
39
- ## npm
40
- ${chalk.greenBright(
41
- `npx yalc add ${pkgJson.name} && npx yalc link ${pkgJson.name} && npm install`
42
- )}
43
- `.trimStart()
44
- );
45
- }).on("quit", () => {
46
- process.exit();
47
- }).on("restart", (files) => {
48
- logger.info("Found changes in files:", chalk.magentaBright(files));
49
- logger.info("Pushing new yalc package...");
50
- });
51
- } catch (err) {
52
- logger.error(
53
- "There seems to be an unexpected error, try again with --debug for more information \n"
54
- );
55
- if (err instanceof Error && err.stack) {
56
- console.log(
57
- chalk.red(
58
- boxen(err.stack, {
59
- padding: 1,
60
- align: "left"
61
- })
62
- )
63
- );
64
- }
65
- process.exit(1);
66
- }
67
- };
68
- const pathExists = async (path2) => {
69
- try {
70
- await fs.access(path2);
71
- return true;
72
- } catch (error) {
73
- return false;
74
- }
75
- };
76
- const command = ({ command: command2, ctx }) => {
77
- command2.command("plugin:watch:link").description("Recompiles your plugin automatically on changes and runs yalc push --publish").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => runAction("plugin:watch:link", action)(...args, ctx));
78
- };
79
- export {
80
- command
81
- };
82
- //# sourceMappingURL=link-watch.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"link-watch.mjs","sources":["../../../../src/cli/commands/plugin/link-watch.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport concurrently from 'concurrently';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport nodemon from 'nodemon';\nimport { outdent } from 'outdent';\n\nimport { runAction } from '../../utils/helpers';\nimport type { CLIContext, StrapiCommand } from '../../types';\nimport { loadPkg, validatePkg } from '../../utils/pkg';\n\ninterface ActionOptions {}\n\nconst action = async (_opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => {\n try {\n const outDir = './dist';\n const extensions = 'ts,js,png,svg,gif,jpeg,css';\n\n nodemon({\n watch: [outDir],\n ext: extensions,\n exec: 'yalc push --changed',\n });\n\n const folder = path.join(cwd, outDir);\n\n if (!(await pathExists(folder))) {\n await fs.mkdir(folder);\n }\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n concurrently(['npm run watch']);\n\n nodemon\n .on('start', () => {\n logger.info(\n outdent`\n Watching ${outDir} for changes to files with extensions: ${extensions}\n\n To use this package in Strapi, in a separate shell run:\n cd /path/to/strapi/project\n\n Then run one of the commands below based on the package manager used in that project:\n\n ## yarn\n ${chalk.greenBright(`yarn dlx yalc add --link ${pkgJson.name} && yarn install`)}\n\n ## npm\n ${chalk.greenBright(\n `npx yalc add ${pkgJson.name} && npx yalc link ${pkgJson.name} && npm install`\n )}\n `.trimStart()\n );\n })\n .on('quit', () => {\n process.exit();\n })\n .on('restart', (files) => {\n logger.info('Found changes in files:', chalk.magentaBright(files));\n logger.info('Pushing new yalc package...');\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 * @internal\n */\nconst pathExists = async (path: string) => {\n try {\n await fs.access(path);\n return true;\n } catch (error) {\n return false;\n }\n};\n\n/**\n * `$ strapi plugin:watch:link`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:watch:link')\n .description('Recompiles your plugin automatically on changes and runs yalc push --publish')\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:link', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":["path","command"],"mappings":";;;;;;;;;AAcA,MAAM,SAAS,OAAO,OAAsB,MAAe,EAAE,KAAK,aAAyB;AACrF,MAAA;AACF,UAAM,SAAS;AACf,UAAM,aAAa;AAEX,YAAA;AAAA,MACN,OAAO,CAAC,MAAM;AAAA,MACd,KAAK;AAAA,MACL,MAAM;AAAA,IAAA,CACP;AAED,UAAM,SAAS,KAAK,KAAK,KAAK,MAAM;AAEpC,QAAI,CAAE,MAAM,WAAW,MAAM,GAAI;AACzB,YAAA,GAAG,MAAM,MAAM;AAAA,IACvB;AAEA,UAAM,MAAM,MAAM,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAM,YAAY,EAAE,IAAK,CAAA;AAE5B,iBAAA,CAAC,eAAe,CAAC;AAG3B,YAAA,GAAG,SAAS,MAAM;AACV,aAAA;AAAA,QACL;AAAA,mBACS,MAAM,0CAA0C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQnE,MAAM,YAAY,4BAA4B,QAAQ,IAAI,kBAAkB,CAAC;AAAA;AAAA;AAAA,UAG7E,MAAM;AAAA,UACN,gBAAgB,QAAQ,IAAI,qBAAqB,QAAQ,IAAI;AAAA,QAAA,CAC9D;AAAA,QACD,UAAU;AAAA,MAAA;AAAA,IACV,CACD,EACA,GAAG,QAAQ,MAAM;AAChB,cAAQ,KAAK;AAAA,IACd,CAAA,EACA,GAAG,WAAW,CAAC,UAAU;AACxB,aAAO,KAAK,2BAA2B,MAAM,cAAc,KAAK,CAAC;AACjE,aAAO,KAAK,6BAA6B;AAAA,IAAA,CAC1C;AAAA,WACI,KAAK;AACL,WAAA;AAAA,MACL;AAAA,IAAA;AAEE,QAAA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACN,MAAM;AAAA,UACJ,MAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAKA,MAAM,aAAa,OAAOA,UAAiB;AACrC,MAAA;AACI,UAAA,GAAG,OAAOA,KAAI;AACb,WAAA;AAAA,WACA,OAAO;AACP,WAAA;AAAA,EACT;AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,SAAAC,UAAS,UAAU;AACnDA,WACG,QAAQ,mBAAmB,EAC3B,YAAY,8EAA8E,EAC1F,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAAS,UAAU,qBAAqB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AAC7E;"}
@@ -1,7 +0,0 @@
1
- import type { StrapiCommand } from '../../types';
2
- /**
3
- * `$ strapi plugin:verify`
4
- */
5
- declare const command: StrapiCommand;
6
- export { command };
7
- //# sourceMappingURL=verify.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/plugin/verify.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,aAAa,CAAC;AA4B7D;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAOd,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const boxen = require("boxen");
4
- const chalk = require("chalk");
5
- const packUp = require("@strapi/pack-up");
6
- const helpers = require("../../utils/helpers.js");
7
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
8
- const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
9
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
10
- const action = async (opts, _cmd, { cwd, logger }) => {
11
- try {
12
- await packUp.check({
13
- cwd,
14
- ...opts
15
- });
16
- } catch (err) {
17
- logger.error(
18
- "There seems to be an unexpected error, try again with --debug for more information \n"
19
- );
20
- if (err instanceof Error && err.stack) {
21
- console.log(
22
- chalk__default.default.red(
23
- boxen__default.default(err.stack, {
24
- padding: 1,
25
- align: "left"
26
- })
27
- )
28
- );
29
- }
30
- process.exit(1);
31
- }
32
- };
33
- const command = ({ command: command2, ctx }) => {
34
- command2.command("plugin:verify").description("Verify the output of your plugin before publishing it.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => helpers.runAction("plugin:verify", action)(...args, ctx));
35
- };
36
- exports.command = command;
37
- //# sourceMappingURL=verify.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify.js","sources":["../../../../src/cli/commands/plugin/verify.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { CheckOptions, check } from '@strapi/pack-up';\n\nimport { runAction } from '../../utils/helpers';\nimport type { StrapiCommand, CLIContext } from '../../types';\n\ntype ActionOptions = CheckOptions;\n\nconst action = async (opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => {\n try {\n await check({\n cwd,\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:verify`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:verify')\n .description('Verify the output of your plugin before publishing it.')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .action((...args) => runAction('plugin:verify', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":["check","chalk","boxen","command","runAction"],"mappings":";;;;;;;;;AASA,MAAM,SAAS,OAAO,MAAqB,MAAe,EAAE,KAAK,aAAyB;AACpF,MAAA;AACF,UAAMA,aAAM;AAAA,MACV;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,WACM,KAAK;AACL,WAAA;AAAA,MACL;AAAA,IAAA;AAEE,QAAA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACNC,eAAAA,QAAM;AAAA,UACJC,eAAA,QAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,SAAAC,UAAS,UAAU;AACnDA,WACG,QAAQ,eAAe,EACvB,YAAY,wDAAwD,EACpE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAASC,QAAAA,UAAU,iBAAiB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACzE;;"}
@@ -1,34 +0,0 @@
1
- import boxen from "boxen";
2
- import chalk from "chalk";
3
- import { check } from "@strapi/pack-up";
4
- import { runAction } from "../../utils/helpers.mjs";
5
- const action = async (opts, _cmd, { cwd, logger }) => {
6
- try {
7
- await check({
8
- cwd,
9
- ...opts
10
- });
11
- } catch (err) {
12
- logger.error(
13
- "There seems to be an unexpected error, try again with --debug for more information \n"
14
- );
15
- if (err instanceof Error && err.stack) {
16
- console.log(
17
- chalk.red(
18
- boxen(err.stack, {
19
- padding: 1,
20
- align: "left"
21
- })
22
- )
23
- );
24
- }
25
- process.exit(1);
26
- }
27
- };
28
- const command = ({ command: command2, ctx }) => {
29
- command2.command("plugin:verify").description("Verify the output of your plugin before publishing it.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => runAction("plugin:verify", action)(...args, ctx));
30
- };
31
- export {
32
- command
33
- };
34
- //# sourceMappingURL=verify.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify.mjs","sources":["../../../../src/cli/commands/plugin/verify.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { CheckOptions, check } from '@strapi/pack-up';\n\nimport { runAction } from '../../utils/helpers';\nimport type { StrapiCommand, CLIContext } from '../../types';\n\ntype ActionOptions = CheckOptions;\n\nconst action = async (opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => {\n try {\n await check({\n cwd,\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:verify`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:verify')\n .description('Verify the output of your plugin before publishing it.')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .action((...args) => runAction('plugin:verify', action)(...args, ctx));\n};\n\nexport { command };\n"],"names":["command"],"mappings":";;;;AASA,MAAM,SAAS,OAAO,MAAqB,MAAe,EAAE,KAAK,aAAyB;AACpF,MAAA;AACF,UAAM,MAAM;AAAA,MACV;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,WACM,KAAK;AACL,WAAA;AAAA,MACL;AAAA,IAAA;AAEE,QAAA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACN,MAAM;AAAA,UACJ,MAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,SAAAA,UAAS,UAAU;AACnDA,WACG,QAAQ,eAAe,EACvB,YAAY,wDAAwD,EACpE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAAS,UAAU,iBAAiB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACzE;"}
@@ -1,7 +0,0 @@
1
- import type { StrapiCommand } from '../../types';
2
- /**
3
- * `$ strapi plugin:watch`
4
- */
5
- declare const command: StrapiCommand;
6
- export { command };
7
- //# sourceMappingURL=watch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/plugin/watch.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,aAAa,CAAC;AAwF7D;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAMd,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -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,gBAAgB,GAAG;AAC/B,YAAA,MAAM,QAAQ,QAAQ,gBAAgB;AAE5C,YAAM,SAAuB;AAAA,QAC3B,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,SAAS;AAAA,MAAA;AAGX,UAAI,I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ch } from "@strapi/pack-up";
5
- import { runAction } from "../../utils/helpers.mjs";
6
- import { loadPkg, validatePkg } from "../../utils/pkg.mjs";
7
- const action = async (opts, _cmd, { cwd, logger }) => {
8
- try {
9
- const pkg = await loadPkg({ cwd, logger });
10
- const pkgJson = await validatePkg({ pkg });
11
- if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
12
- throw new Error(
13
- "You need to have either a strapi-admin or strapi-server export in your package.json"
14
- );
15
- }
16
- const bundles = [];
17
- if (pkgJson.exports["./strapi-admin"]) {
18
- const exp = pkgJson.exports["./strapi-admin"];
19
- const bundle = {
20
- source: exp.source,
21
- import: exp.import,
22
- require: exp.require,
23
- runtime: "web"
24
- };
25
- if (exp.types) {
26
- bundle.types = exp.types;
27
- bundle.tsconfig = "./admin/tsconfig.build.json";
28
- }
29
- bundles.push(bundle);
30
- }
31
- if (pkgJson.exports["./strapi-server"]) {
32
- const exp = pkgJson.exports["./strapi-server"];
33
- const bundle = {
34
- source: exp.source,
35
- import: exp.import,
36
- require: exp.require,
37
- runtime: "node"
38
- };
39
- if (exp.types) {
40
- bundle.types = exp.types;
41
- bundle.tsconfig = "./server/tsconfig.build.json";
42
- }
43
- bundles.push(bundle);
44
- }
45
- await watch({
46
- cwd,
47
- configFile: false,
48
- config: {
49
- bundles,
50
- dist: "./dist",
51
- /**
52
- * ignore the exports map of a plugin, because we're streamlining the
53
- * process and ensuring the server package and admin package are built
54
- * with the correct runtime and their individual tsconfigs
55
- */
56
- exports: {}
57
- },
58
- ...opts
59
- });
60
- } catch (err) {
61
- logger.error(
62
- "There seems to be an unexpected error, try again with --debug for more information \n"
63
- );
64
- if (err instanceof Error && err.stack) {
65
- console.log(
66
- chalk.red(
67
- boxen(err.stack, {
68
- padding: 1,
69
- align: "left"
70
- })
71
- )
72
- );
73
- }
74
- process.exit(1);
75
- }
76
- };
77
- const command = ({ ctx }) => {
78
- return 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) => runAction("plugin:watch", action)(...args, ctx));
79
- };
80
- export {
81
- command
82
- };
83
- //# sourceMappingURL=watch.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watch.mjs","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":[],"mappings":";;;;;;AAWA,MAAM,SAAS,OAAO,MAAqB,MAAe,EAAE,KAAK,aAAyB;AACpF,MAAA;AACF,UAAM,MAAM,MAAM,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAM,YAAY,EAAE,IAAK,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,gBAAgB,GAAG;AAC/B,YAAA,MAAM,QAAQ,QAAQ,gBAAgB;AAE5C,YAAM,SAAuB;AAAA,QAC3B,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,SAAS;AAAA,MAAA;AAGX,UAAI,IAAI,OAAO;AACb,eAAO,QAAQ,IAAI;AAEnB,eAAO,WAAW;AAAA,MACpB;AAEA,cAAQ,KAAK,MAAM;AAAA,IACrB;AAEI,QAAA,QAAQ,QAAQ,iBAAiB,GAAG;AAChC,YAAA,MAAM,QAAQ,QAAQ,iBAAiB;AAE7C,YAAM,SAAuB;AAAA,QAC3B,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,SAAS;AAAA,MAAA;AAGX,UAAI,IAAI,OAAO;AACb,eAAO,QAAQ,IAAI;AAEnB,eAAO,WAAW;AAAA,MACpB;AAEA,cAAQ,KAAK,MAAM;AAAA,IACrB;AAEA,UAAM,MAAM;AAAA,MACV;AAAA,MACA,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN;AAAA,QACA,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMN,SAAS,CAAC;AAAA,MACZ;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,WACM,KAAK;AACL,WAAA;AAAA,MACL;AAAA,IAAA;AAEE,QAAA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACN,MAAM;AAAA,UACJ,MAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAKA,MAAM,UAAyB,CAAC,EAAE,UAAU;AACnC,SAAA,cAAc,cAAc,EAChC,YAAY,2DAA2D,EACvE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAAS,UAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;"}
@@ -1,111 +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(
37
- (acc, [key, value2]) => {
38
- if (typeof value2 === "object") {
39
- acc[key] = yup__namespace.object({
40
- types: yup__namespace.string().optional(),
41
- source: yup__namespace.string().required(),
42
- module: yup__namespace.string().optional(),
43
- import: yup__namespace.string().required(),
44
- require: yup__namespace.string().required(),
45
- default: yup__namespace.string().required()
46
- }).noUnknown(true);
47
- } else {
48
- acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
49
- }
50
- return acc;
51
- },
52
- {}
53
- ) : void 0
54
- ).optional()
55
- )
56
- });
57
- const loadPkg = async ({ cwd, logger }) => {
58
- const pkgPath = await pkgUp__default.default({ cwd });
59
- if (!pkgPath) {
60
- throw new Error("Could not find a package.json in the current directory");
61
- }
62
- const buffer = await fs__default.default.readFile(pkgPath);
63
- const pkg = JSON.parse(buffer.toString());
64
- logger.debug("Loaded package.json:", os__default.default.EOL, pkg);
65
- return pkg;
66
- };
67
- const validatePkg = async ({ pkg }) => {
68
- try {
69
- const validatedPkg = await packageJsonSchema.validate(pkg, {
70
- strict: true
71
- });
72
- return validatedPkg;
73
- } catch (err) {
74
- if (err instanceof yup__namespace.ValidationError) {
75
- switch (err.type) {
76
- case "required":
77
- if (err.path) {
78
- throw new Error(
79
- `'${err.path}' in 'package.json' is required as type '${chalk__default.default.magenta(
80
- yup__namespace.reach(packageJsonSchema, err.path).type
81
- )}'`
82
- );
83
- }
84
- break;
85
- case "noUnknown":
86
- if (err.path && err.params && "unknown" in err.params) {
87
- throw new Error(
88
- `'${err.path}' in 'package.json' contains the unknown key ${chalk__default.default.magenta(
89
- err.params.unknown
90
- )}, for compatability only the following keys are allowed: ${chalk__default.default.magenta(
91
- "['types', 'source', 'import', 'require', 'default']"
92
- )}`
93
- );
94
- }
95
- break;
96
- default:
97
- if (err.path && err.params && "type" in err.params && "value" in err.params) {
98
- throw new Error(
99
- `'${err.path}' in 'package.json' must be of type '${chalk__default.default.magenta(
100
- err.params.type
101
- )}' (recieved '${chalk__default.default.magenta(typeof err.params.value)}')`
102
- );
103
- }
104
- }
105
- }
106
- throw err;
107
- }
108
- };
109
- exports.loadPkg = loadPkg;
110
- exports.validatePkg = validatePkg;
111
- //# 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(\n (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 },\n {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>\n )\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","chal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AM,kBAAkB,SAAS,KAAK;AAAA,MACzD,QAAQ;AAAA,IAAA,CACT;AAEM,WAAA;AAAA,WACA,KAAK;AACR,QAAA,eAAeJ,eAAI,iBAAiB;AACtC,cAAQ,IAAI,MAAM;AAAA,QAChB,KAAK;AACH,cAAI,IAAI,MAAM;AACZ,kBAAM,IAAI;AAAA,cACR,IAAI,IAAI,IAAI,4CAA4CK,eAAM,QAAA;AAAA,gBAC5DL,eAAI,MAAM,mBAAmB,IAAI,IAAI,EAAE;AAAA,cACxC,CAAA;AAAA,YAAA;AAAA,UAEL;AACA;AAAA,QAKF,KAAK;AACH,cAAI,IAAI,QAAQ,IAAI,UAAU,aAAa,IAAI,QAAQ;AACrD,kBAAM,IAAI;AAAA,cACR,IAAI,IAAI,IAAI,gDAAgDK,eAAM,QAAA;AAAA,gBAChE,IAAI,OAAO;AAAA,cAAA,CACZ,4DAA4DA,eAAAA,QAAM;AAAA,gBACjE;AAAA,cAAA,CACD;AAAA,YAAA;AAAA,UAEL;AACA;AAAA,QACF;AACM,cAAA,IAAI,QAAQ,IAAI,UAAU,UAAU,IAAI,UAAU,WAAW,IAAI,QAAQ;AAC3E,kBAAM,IAAI;AAAA,cACR,IAAI,IAAI,IAAI,wCAAwCA,eAAM,QAAA;AAAA,gBACxD,IAAI,OAAO;AAAA,cAAA,CACZ,gBAAgBA,eAAM,QAAA,QAAQ,OAAO,IAAI,OAAO,KAAK,CAAC;AAAA,YAAA;AAAA,UAE3D;AAAA,MACJ;AAAA,IACF;AAEM,UAAA;AAAA,EACR;AACF;;;"}
@@ -1,87 +0,0 @@
1
- import fs from "fs/promises";
2
- import os from "os";
3
- import pkgUp from "pkg-up";
4
- import * as yup from "yup";
5
- import chalk from "chalk";
6
- const packageJsonSchema = yup.object({
7
- name: yup.string().required(),
8
- exports: yup.lazy(
9
- (value) => yup.object(
10
- typeof value === "object" ? Object.entries(value).reduce(
11
- (acc, [key, value2]) => {
12
- if (typeof value2 === "object") {
13
- acc[key] = yup.object({
14
- types: yup.string().optional(),
15
- source: yup.string().required(),
16
- module: yup.string().optional(),
17
- import: yup.string().required(),
18
- require: yup.string().required(),
19
- default: yup.string().required()
20
- }).noUnknown(true);
21
- } else {
22
- acc[key] = yup.string().matches(/^\.\/.*\.json$/).required();
23
- }
24
- return acc;
25
- },
26
- {}
27
- ) : void 0
28
- ).optional()
29
- )
30
- });
31
- const loadPkg = async ({ cwd, logger }) => {
32
- const pkgPath = await pkgUp({ cwd });
33
- if (!pkgPath) {
34
- throw new Error("Could not find a package.json in the current directory");
35
- }
36
- const buffer = await fs.readFile(pkgPath);
37
- const pkg = JSON.parse(buffer.toString());
38
- logger.debug("Loaded package.json:", os.EOL, pkg);
39
- return pkg;
40
- };
41
- const validatePkg = async ({ pkg }) => {
42
- try {
43
- const validatedPkg = await packageJsonSchema.validate(pkg, {
44
- strict: true
45
- });
46
- return validatedPkg;
47
- } catch (err) {
48
- if (err instanceof yup.ValidationError) {
49
- switch (err.type) {
50
- case "required":
51
- if (err.path) {
52
- throw new Error(
53
- `'${err.path}' in 'package.json' is required as type '${chalk.magenta(
54
- yup.reach(packageJsonSchema, err.path).type
55
- )}'`
56
- );
57
- }
58
- break;
59
- case "noUnknown":
60
- if (err.path && err.params && "unknown" in err.params) {
61
- throw new Error(
62
- `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(
63
- err.params.unknown
64
- )}, for compatability only the following keys are allowed: ${chalk.magenta(
65
- "['types', 'source', 'import', 'require', 'default']"
66
- )}`
67
- );
68
- }
69
- break;
70
- default:
71
- if (err.path && err.params && "type" in err.params && "value" in err.params) {
72
- throw new Error(
73
- `'${err.path}' in 'package.json' must be of type '${chalk.magenta(
74
- err.params.type
75
- )}' (recieved '${chalk.magenta(typeof err.params.value)}')`
76
- );
77
- }
78
- }
79
- }
80
- throw err;
81
- }
82
- };
83
- export {
84
- loadPkg,
85
- validatePkg
86
- };
87
- //# sourceMappingURL=pkg.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkg.mjs","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(\n (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 },\n {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>\n )\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":["value"],"mappings":";;;;;AAgBA,MAAM,oBAAoB,IAAI,OAAO;AAAA,EACnC,MAAM,IAAI,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,IAAI;AAAA,IAAK,CAAC,UACjB,IACG;AAAA,MACC,OAAO,UAAU,WACb,OAAO,QAAQ,KAAK,EAAE;AAAA,QACpB,CAAC,KAAK,CAAC,KAAKA,MAAK,MAAM;AACjB,cAAA,OAAOA,WAAU,UAAU;AACzB,gBAAA,GAAG,IAAI,IACR,OAAO;AAAA,cACN,OAAO,IAAI,OAAO,EAAE,SAAS;AAAA,cAC7B,QAAQ,IAAI,OAAO,EAAE,SAAS;AAAA,cAC9B,QAAQ,IAAI,OAAO,EAAE,SAAS;AAAA,cAC9B,QAAQ,IAAI,OAAO,EAAE,SAAS;AAAA,cAC9B,SAAS,IAAI,OAAO,EAAE,SAAS;AAAA,cAC/B,SAAS,IAAI,OAAO,EAAE,SAAS;AAAA,YAAA,CAChC,EACA,UAAU,IAAI;AAAA,UAAA,OACZ;AACD,gBAAA,GAAG,IAAI,IACR,SACA,QAAQ,gBAAgB,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