@metamask/snaps-cli 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/builders.cjs +4 -0
  3. package/dist/builders.cjs.map +1 -1
  4. package/dist/builders.d.cts +4 -0
  5. package/dist/builders.d.cts.map +1 -1
  6. package/dist/builders.d.mts +4 -0
  7. package/dist/builders.d.mts.map +1 -1
  8. package/dist/builders.mjs +4 -0
  9. package/dist/builders.mjs.map +1 -1
  10. package/dist/commands/build/build.cjs +8 -23
  11. package/dist/commands/build/build.cjs.map +1 -1
  12. package/dist/commands/build/build.d.cts +1 -0
  13. package/dist/commands/build/build.d.cts.map +1 -1
  14. package/dist/commands/build/build.d.mts +1 -0
  15. package/dist/commands/build/build.d.mts.map +1 -1
  16. package/dist/commands/build/build.mjs +9 -24
  17. package/dist/commands/build/build.mjs.map +1 -1
  18. package/dist/commands/build/implementation.cjs.map +1 -1
  19. package/dist/commands/build/implementation.d.cts.map +1 -1
  20. package/dist/commands/build/implementation.d.mts.map +1 -1
  21. package/dist/commands/build/implementation.mjs.map +1 -1
  22. package/dist/commands/build/index.cjs +1 -2
  23. package/dist/commands/build/index.cjs.map +1 -1
  24. package/dist/commands/build/index.d.cts.map +1 -1
  25. package/dist/commands/build/index.d.mts.map +1 -1
  26. package/dist/commands/build/index.mjs +1 -2
  27. package/dist/commands/build/index.mjs.map +1 -1
  28. package/dist/commands/manifest/implementation.cjs +8 -4
  29. package/dist/commands/manifest/implementation.cjs.map +1 -1
  30. package/dist/commands/manifest/implementation.d.cts +2 -1
  31. package/dist/commands/manifest/implementation.d.cts.map +1 -1
  32. package/dist/commands/manifest/implementation.d.mts +2 -1
  33. package/dist/commands/manifest/implementation.d.mts.map +1 -1
  34. package/dist/commands/manifest/implementation.mjs +8 -4
  35. package/dist/commands/manifest/implementation.mjs.map +1 -1
  36. package/dist/commands/manifest/index.cjs +5 -1
  37. package/dist/commands/manifest/index.cjs.map +1 -1
  38. package/dist/commands/manifest/index.d.cts.map +1 -1
  39. package/dist/commands/manifest/index.d.mts.map +1 -1
  40. package/dist/commands/manifest/index.mjs +5 -1
  41. package/dist/commands/manifest/index.mjs.map +1 -1
  42. package/dist/commands/manifest/manifest.cjs +20 -4
  43. package/dist/commands/manifest/manifest.cjs.map +1 -1
  44. package/dist/commands/manifest/manifest.d.cts +1 -0
  45. package/dist/commands/manifest/manifest.d.cts.map +1 -1
  46. package/dist/commands/manifest/manifest.d.mts +1 -0
  47. package/dist/commands/manifest/manifest.d.mts.map +1 -1
  48. package/dist/commands/manifest/manifest.mjs +21 -5
  49. package/dist/commands/manifest/manifest.mjs.map +1 -1
  50. package/dist/commands/watch/watch.cjs +1 -1
  51. package/dist/commands/watch/watch.cjs.map +1 -1
  52. package/dist/commands/watch/watch.mjs +1 -1
  53. package/dist/commands/watch/watch.mjs.map +1 -1
  54. package/dist/webpack/config.cjs +1 -1
  55. package/dist/webpack/config.cjs.map +1 -1
  56. package/dist/webpack/config.d.cts.map +1 -1
  57. package/dist/webpack/config.d.mts.map +1 -1
  58. package/dist/webpack/config.mjs +1 -1
  59. package/dist/webpack/config.mjs.map +1 -1
  60. package/dist/webpack/plugins.cjs +2 -2
  61. package/dist/webpack/plugins.cjs.map +1 -1
  62. package/dist/webpack/plugins.d.cts.map +1 -1
  63. package/dist/webpack/plugins.d.mts.map +1 -1
  64. package/dist/webpack/plugins.mjs +2 -2
  65. package/dist/webpack/plugins.mjs.map +1 -1
  66. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.2.0]
11
+
12
+ ### Added
13
+
14
+ - Validate platform version against production ([#3417](https://github.com/MetaMask/snaps/pull/3417))
15
+ - Detect unused permissions ([#3335](https://github.com/MetaMask/snaps/pull/3335))
16
+
10
17
  ## [7.1.0]
11
18
 
12
19
  ### Added
@@ -362,7 +369,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
362
369
  - The version of the package no longer needs to match the version of all other
363
370
  MetaMask Snaps packages.
364
371
 
365
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@7.1.0...HEAD
372
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@7.2.0...HEAD
373
+ [7.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@7.1.0...@metamask/snaps-cli@7.2.0
366
374
  [7.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@7.0.0...@metamask/snaps-cli@7.1.0
367
375
  [7.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.7.0...@metamask/snaps-cli@7.0.0
368
376
  [6.7.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.6.1...@metamask/snaps-cli@6.7.0
package/dist/builders.cjs CHANGED
@@ -16,6 +16,10 @@ const builders = {
16
16
  type: 'string',
17
17
  normalize: true,
18
18
  },
19
+ eval: {
20
+ describe: 'Evaluate the Snap bundle',
21
+ type: 'boolean',
22
+ },
19
23
  fix: {
20
24
  describe: 'Attempt to fix snap.manifest.json',
21
25
  type: 'boolean',
@@ -1 +1 @@
1
- {"version":3,"file":"builders.cjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":";;AAEA,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE;QACP,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;KACd;IAED,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,GAAG,EAAE;QACH,QAAQ,EAAE,mCAAmC;QAC7C,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,+BAA+B;QACzC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,GAAY,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACmD,CAAC;AAEvD,kBAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\n build: {\n describe: 'Build the Snap bundle',\n type: 'boolean',\n default: true,\n },\n\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
1
+ {"version":3,"file":"builders.cjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":";;AAEA,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE;QACP,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;KACd;IAED,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE,SAAS;KAChB;IAED,GAAG,EAAE;QACH,QAAQ,EAAE,mCAAmC;QAC7C,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,+BAA+B;QACzC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,GAAY,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACmD,CAAC;AAEvD,kBAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\n build: {\n describe: 'Build the Snap bundle',\n type: 'boolean',\n default: true,\n },\n\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n eval: {\n describe: 'Evaluate the Snap bundle',\n type: 'boolean',\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
@@ -14,6 +14,10 @@ declare const builders: {
14
14
  readonly type: "string";
15
15
  readonly normalize: true;
16
16
  };
17
+ readonly eval: {
18
+ readonly describe: "Evaluate the Snap bundle";
19
+ readonly type: "boolean";
20
+ };
17
21
  readonly fix: {
18
22
  readonly describe: "Attempt to fix snap.manifest.json";
19
23
  readonly type: "boolean";
@@ -1 +1 @@
1
- {"version":3,"file":"builders.d.cts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAmCI,OAAO;;CAS6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"builders.d.cts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwCI,OAAO;;CAS6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
@@ -14,6 +14,10 @@ declare const builders: {
14
14
  readonly type: "string";
15
15
  readonly normalize: true;
16
16
  };
17
+ readonly eval: {
18
+ readonly describe: "Evaluate the Snap bundle";
19
+ readonly type: "boolean";
20
+ };
17
21
  readonly fix: {
18
22
  readonly describe: "Attempt to fix snap.manifest.json";
19
23
  readonly type: "boolean";
@@ -1 +1 @@
1
- {"version":3,"file":"builders.d.mts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAmCI,OAAO;;CAS6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"builders.d.mts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwCI,OAAO;;CAS6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
package/dist/builders.mjs CHANGED
@@ -14,6 +14,10 @@ const builders = {
14
14
  type: 'string',
15
15
  normalize: true,
16
16
  },
17
+ eval: {
18
+ describe: 'Evaluate the Snap bundle',
19
+ type: 'boolean',
20
+ },
17
21
  fix: {
18
22
  describe: 'Attempt to fix snap.manifest.json',
19
23
  type: 'boolean',
@@ -1 +1 @@
1
- {"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE;QACP,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;KACd;IAED,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,GAAG,EAAE;QACH,QAAQ,EAAE,mCAAmC;QAC7C,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,+BAA+B;QACzC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,GAAY,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACmD,CAAC;AAEvD,eAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\n build: {\n describe: 'Build the Snap bundle',\n type: 'boolean',\n default: true,\n },\n\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
1
+ {"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE;QACP,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;KACd;IAED,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE,SAAS;KAChB;IAED,GAAG,EAAE;QACH,QAAQ,EAAE,mCAAmC;QAC7C,IAAI,EAAE,SAAS;KAChB;IAED,KAAK,EAAE;QACL,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IAED,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,+BAA+B;QACzC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,GAAY,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACmD,CAAC;AAEvD,eAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\n build: {\n describe: 'Build the Snap bundle',\n type: 'boolean',\n default: true,\n },\n\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n eval: {\n describe: 'Evaluate the Snap bundle',\n type: 'boolean',\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
@@ -3,55 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildHandler = exports.steps = void 0;
4
4
  const node_1 = require("@metamask/snaps-utils/node");
5
5
  const utils_1 = require("@metamask/utils");
6
- const path_1 = require("path");
7
6
  const implementation_1 = require("./implementation.cjs");
8
7
  const utils_2 = require("./utils.cjs");
9
8
  const errors_1 = require("../../errors.cjs");
10
9
  const utils_3 = require("../../utils/index.cjs");
11
- const eval_1 = require("../eval/index.cjs");
12
10
  exports.steps = [
13
11
  {
14
12
  name: 'Checking the input file.',
15
- condition: ({ build }) => build,
13
+ condition: ({ build: enableBuild }) => enableBuild,
16
14
  task: async ({ config }) => {
17
15
  const { input } = config;
18
16
  if (!(await (0, node_1.isFile)(input))) {
19
- throw new errors_1.CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
17
+ throw new errors_1.CommandError(`Input file not found: "${input}". Make sure that the "input" field in your Snap config is correct.`);
20
18
  }
21
19
  },
22
20
  },
23
21
  {
24
- name: 'Building the snap bundle.',
25
- condition: ({ build }) => build,
26
- task: async ({ analyze, build: enableBuild, config, spinner }) => {
27
- // We don't evaluate the bundle here, because it's done in a separate
28
- // step.
22
+ name: 'Building the Snap bundle.',
23
+ condition: ({ build: enableBuild }) => enableBuild,
24
+ task: async (context) => {
25
+ const { analyze, config, spinner } = context;
29
26
  const compiler = await (0, implementation_1.build)(config, {
30
27
  analyze,
31
- evaluate: false,
28
+ evaluate: config.evaluate,
32
29
  spinner,
33
30
  });
34
31
  if (analyze) {
35
32
  return {
36
- analyze,
37
- build: enableBuild,
38
- config,
39
- spinner,
33
+ ...context,
40
34
  port: await (0, utils_2.getBundleAnalyzerPort)(compiler),
41
35
  };
42
36
  }
43
37
  return undefined;
44
38
  },
45
39
  },
46
- {
47
- name: 'Evaluating the snap bundle.',
48
- condition: ({ build, config }) => build && config.evaluate,
49
- task: async ({ config, spinner }) => {
50
- const path = (0, path_1.resolve)(process.cwd(), config.output.path, config.output.filename);
51
- await (0, eval_1.evaluate)(path);
52
- (0, utils_3.info)(`Snap bundle evaluated successfully.`, spinner);
53
- },
54
- },
55
40
  {
56
41
  name: 'Running analyser.',
57
42
  condition: ({ analyze }) => analyze,
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,2CAAyC;AACzC,+BAA8C;AAE9C,yDAAyC;AACzC,uCAAgD;AAEhD,6CAA4C;AAE5C,iDAA0D;AAC1D,4CAAmC;AAStB,QAAA,KAAK,GAAwB;IACxC;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK;QAC/B,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK;QAC/B,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAC/D,qEAAqE;YACrE,QAAQ;YACR,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAK,EAAC,MAAM,EAAE;gBACnC,OAAO;gBACP,QAAQ,EAAE,KAAK;gBAC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AK,EAAE,IAAI;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AATD,oCASC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\nimport { resolve as pathResolve } from 'path';\n\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\n\nexport type BuildContext = {\n analyze: boolean;\n build: boolean;\n config: ProcessedConfig;\n port?: number;\n};\n\nexport const steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n condition: ({ build }) => build,\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the snap bundle.',\n condition: ({ build }) => build,\n task: async ({ analyze, build: enableBuild, config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n const compiler = await build(config, {\n analyze,\n evaluate: false,\n spinner,\n });\n\n if (analyze) {\n return {\n analyze,\n build: enableBuild,\n config,\n spinner,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n condition: ({ build, config }) => build && config.evaluate,\n task: async ({ config, spinner }) => {\n const path = pathResolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n },\n },\n {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n analyze,\n });\n}\n"]}
1
+ {"version":3,"file":"build.cjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,2CAAyC;AAEzC,yDAAyC;AACzC,uCAAgD;AAEhD,6CAA4C;AAE5C,iDAAoD;AAUvC,QAAA,KAAK,GAAwB;IACxC;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;QAClD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;QAClD,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACtB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAE7C,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAK,EAAC,MAAM,EAAE;gBACnC,OAAO;gBACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO;aACR,CAAC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;oBACL,GAAG,OAAO;oBACV,IAAI,EAAE,MAAM,IAAA,6BAAqB,EAAC,QAAQ,CAAC;iBAC5C,CAAC;YACJ,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO;QACnC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAChC,IAAA,cAAM,EAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YACrC,IAAA,eAAO,EAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACO,CAAC;AAEX;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAO,GAAG,KAAK;IAEf,OAAO,MAAM,IAAA,oBAAY,EAAC,aAAK,EAAE;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AATD,oCASC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\n\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps } from '../../utils';\n\nexport type BuildContext = {\n analyze: boolean;\n build: boolean;\n config: ProcessedConfig;\n exports?: string[];\n port?: number;\n};\n\nexport const steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n condition: ({ build: enableBuild }) => enableBuild,\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your Snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the Snap bundle.',\n condition: ({ build: enableBuild }) => enableBuild,\n task: async (context) => {\n const { analyze, config, spinner } = context;\n\n const compiler = await build(config, {\n analyze,\n evaluate: config.evaluate,\n spinner,\n });\n\n if (analyze) {\n return {\n ...context,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\n },\n },\n {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n analyze,\n });\n}\n"]}
@@ -4,6 +4,7 @@ export type BuildContext = {
4
4
  analyze: boolean;
5
5
  build: boolean;
6
6
  config: ProcessedConfig;
7
+ exports?: string[];
7
8
  port?: number;
8
9
  };
9
10
  export declare const steps: Steps<BuildContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.cts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAAoB;AAIzC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CAgE5B,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
1
+ {"version":3,"file":"build.d.cts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAAoB;AAGzC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CA8C5B,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -4,6 +4,7 @@ export type BuildContext = {
4
4
  analyze: boolean;
5
5
  build: boolean;
6
6
  config: ProcessedConfig;
7
+ exports?: string[];
7
8
  port?: number;
8
9
  };
9
10
  export declare const steps: Steps<BuildContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.mts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAAoB;AAIzC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CAgE5B,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
1
+ {"version":3,"file":"build.d.mts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAAoB;AAGzC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CA8C5B,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -1,54 +1,39 @@
1
1
  import { isFile } from "@metamask/snaps-utils/node";
2
2
  import { assert } from "@metamask/utils";
3
- import { resolve as pathResolve } from "path";
4
3
  import { build } from "./implementation.mjs";
5
4
  import { getBundleAnalyzerPort } from "./utils.mjs";
6
5
  import { CommandError } from "../../errors.mjs";
7
- import { success, executeSteps, info } from "../../utils/index.mjs";
8
- import { evaluate } from "../eval/index.mjs";
6
+ import { success, executeSteps } from "../../utils/index.mjs";
9
7
  export const steps = [
10
8
  {
11
9
  name: 'Checking the input file.',
12
- condition: ({ build }) => build,
10
+ condition: ({ build: enableBuild }) => enableBuild,
13
11
  task: async ({ config }) => {
14
12
  const { input } = config;
15
13
  if (!(await isFile(input))) {
16
- throw new CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
14
+ throw new CommandError(`Input file not found: "${input}". Make sure that the "input" field in your Snap config is correct.`);
17
15
  }
18
16
  },
19
17
  },
20
18
  {
21
- name: 'Building the snap bundle.',
22
- condition: ({ build }) => build,
23
- task: async ({ analyze, build: enableBuild, config, spinner }) => {
24
- // We don't evaluate the bundle here, because it's done in a separate
25
- // step.
19
+ name: 'Building the Snap bundle.',
20
+ condition: ({ build: enableBuild }) => enableBuild,
21
+ task: async (context) => {
22
+ const { analyze, config, spinner } = context;
26
23
  const compiler = await build(config, {
27
24
  analyze,
28
- evaluate: false,
25
+ evaluate: config.evaluate,
29
26
  spinner,
30
27
  });
31
28
  if (analyze) {
32
29
  return {
33
- analyze,
34
- build: enableBuild,
35
- config,
36
- spinner,
30
+ ...context,
37
31
  port: await getBundleAnalyzerPort(compiler),
38
32
  };
39
33
  }
40
34
  return undefined;
41
35
  },
42
36
  },
43
- {
44
- name: 'Evaluating the snap bundle.',
45
- condition: ({ build, config }) => build && config.evaluate,
46
- task: async ({ config, spinner }) => {
47
- const path = pathResolve(process.cwd(), config.output.path, config.output.filename);
48
- await evaluate(path);
49
- info(`Snap bundle evaluated successfully.`, spinner);
50
- },
51
- },
52
37
  {
53
38
  name: 'Running analyser.',
54
39
  condition: ({ analyze }) => analyze,
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AACpD,OAAO,EAAE,MAAM,EAAE,wBAAwB;AACzC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,aAAa;AAE9C,OAAO,EAAE,KAAK,EAAE,6BAAyB;AACzC,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAAoB;AAC1D,OAAO,EAAE,QAAQ,EAAE,0BAAgB;AASnC,MAAM,CAAC,MAAM,KAAK,GAAwB;IACxC;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK;QAC/B,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,C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AAE,CAAC,OAAO;QACnC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAChC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YACrC,OAAO,CAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACO,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAO,GAAG,KAAK;IAEf,OAAO,MAAM,YAAY,CAAC,KAAK,EAAE;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\nimport { resolve as pathResolve } from 'path';\n\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\n\nexport type BuildContext = {\n analyze: boolean;\n build: boolean;\n config: ProcessedConfig;\n port?: number;\n};\n\nexport const steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n condition: ({ build }) => build,\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the snap bundle.',\n condition: ({ build }) => build,\n task: async ({ analyze, build: enableBuild, config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n const compiler = await build(config, {\n analyze,\n evaluate: false,\n spinner,\n });\n\n if (analyze) {\n return {\n analyze,\n build: enableBuild,\n config,\n spinner,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n condition: ({ build, config }) => build && config.evaluate,\n task: async ({ config, spinner }) => {\n const path = pathResolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n },\n },\n {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n analyze,\n });\n}\n"]}
1
+ {"version":3,"file":"build.mjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AACpD,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAEzC,OAAO,EAAE,KAAK,EAAE,6BAAyB;AACzC,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,8BAAoB;AAUpD,MAAM,CAAC,MAAM,KAAK,GAAwB;IACxC;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;QAClD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;QAClD,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACtB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAE7C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE;gBACnC,OAAO;gBACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO;aACR,CAAC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;oBACL,GAAG,OAAO;oBACV,IAAI,EAAE,MAAM,qBAAqB,CAAC,QAAQ,CAAC;iBAC5C,CAAC;YACJ,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO;QACnC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAChC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YACrC,OAAO,CAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACO,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAO,GAAG,KAAK;IAEf,OAAO,MAAM,YAAY,CAAC,KAAK,EAAE;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\n\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps } from '../../utils';\n\nexport type BuildContext = {\n analyze: boolean;\n build: boolean;\n config: ProcessedConfig;\n exports?: string[];\n port?: number;\n};\n\nexport const steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n condition: ({ build: enableBuild }) => enableBuild,\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your Snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the Snap bundle.',\n condition: ({ build: enableBuild }) => enableBuild,\n task: async (context) => {\n const { analyze, config, spinner } = context;\n\n const compiler = await build(config, {\n analyze,\n evaluate: config.evaluate,\n spinner,\n });\n\n if (analyze) {\n return {\n ...context,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\n },\n },\n {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n analyze,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":";;;AAIA,qDAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,KAAK,CACzB,MAAuB,EACvB,OAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC5B,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,UAAU,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,sBAsBC","sourcesContent":["import type { Compiler } from 'webpack';\n\nimport type { ProcessedConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(\n config: ProcessedConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, options);\n return await new Promise<Compiler>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve(compiler);\n });\n });\n });\n}\n"]}
1
+ {"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":";;;AAIA,qDAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,KAAK,CAAC,MAAuB,EAAE,OAAwB;IAC3E,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC5B,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,UAAU,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,sBAmBC","sourcesContent":["import type { Compiler } from 'webpack';\n\nimport type { ProcessedConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(config: ProcessedConfig, options?: WebpackOptions) {\n const compiler = await getCompiler(config, options);\n return await new Promise<Compiler>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve(compiler);\n });\n });\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,cAAc,qBAoBzB"}
1
+ {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBAmB5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,cAAc,qBAoBzB"}
1
+ {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBAmB5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,gCAAsB;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,MAAuB,EACvB,OAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC5B,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,UAAU,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Compiler } from 'webpack';\n\nimport type { ProcessedConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(\n config: ProcessedConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, options);\n return await new Promise<Compiler>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve(compiler);\n });\n });\n });\n}\n"]}
1
+ {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,gCAAsB;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,MAAuB,EAAE,OAAwB;IAC3E,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC5B,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,UAAU,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Compiler } from 'webpack';\n\nimport type { ProcessedConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(config: ProcessedConfig, options?: WebpackOptions) {\n const compiler = await getCompiler(config, options);\n return await new Promise<Compiler>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve(compiler);\n });\n });\n });\n}\n"]}
@@ -24,8 +24,7 @@ const command = {
24
24
  command: ['build', 'b'],
25
25
  desc: 'Build snap from source',
26
26
  builder: (yarg) => {
27
- yarg
28
- .option('analyze', builders_1.default.analyze);
27
+ yarg.option('analyze', builders_1.default.analyze);
29
28
  },
30
29
  handler: async (argv) => (0, build_1.buildHandler)(argv.context.config, argv.analyze),
31
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,uCAAuC;AACvC,kEAAsC;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI;aACD,MAAM,CAAC,SAAS,EAAE,kBAAQ,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;CAClD,CAAC;AAEF,uDAAiC;AACjC,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { buildHandler } from './build';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('analyze', builders.analyze)\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(argv.context.config, argv.analyze),\n};\n\nexport * from './implementation';\nexport { steps } from './build';\nexport default command;\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,uCAAuC;AACvC,kEAAsC;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;CAClD,CAAC;AAEF,uDAAiC;AACjC,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { buildHandler } from './build';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg.option('analyze', builders.analyze);\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(argv.context.config, argv.analyze),\n};\n\nexport * from './implementation';\nexport { steps } from './build';\nexport default command;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAIJ,SAAS;CAEhC,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAEhC,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAIJ,SAAS;CAEhC,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAEhC,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC"}
@@ -4,8 +4,7 @@ const command = {
4
4
  command: ['build', 'b'],
5
5
  desc: 'Build snap from source',
6
6
  builder: (yarg) => {
7
- yarg
8
- .option('analyze', builders.analyze);
7
+ yarg.option('analyze', builders.analyze);
9
8
  },
10
9
  handler: async (argv) => buildHandler(argv.context.config, argv.analyze),
11
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI;aACD,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;CAClD,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { buildHandler } from './build';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('analyze', builders.analyze)\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(argv.context.config, argv.analyze),\n};\n\nexport * from './implementation';\nexport { steps } from './build';\nexport default command;\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;CAClD,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { buildHandler } from './build';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg.option('analyze', builders.analyze);\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(argv.context.config, argv.analyze),\n};\n\nexport * from './implementation';\nexport { steps } from './build';\nexport default command;\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.manifest = void 0;
4
+ const snaps_rpc_methods_1 = require("@metamask/snaps-rpc-methods");
4
5
  const node_1 = require("@metamask/snaps-utils/node");
5
6
  const snaps_webpack_plugin_1 = require("@metamask/snaps-webpack-plugin");
6
7
  const utils_1 = require("@metamask/utils");
@@ -15,11 +16,14 @@ const utils_2 = require("../../utils/index.cjs");
15
16
  *
16
17
  * @param path - The path to the manifest file.
17
18
  * @param write - Whether to write the manifest to disk if it is invalid.
19
+ * @param exports - The exports to check in the manifest.
18
20
  * @param spinner - An optional spinner to use for logging.
19
21
  * @returns Whether the manifest is valid.
20
22
  */
21
- async function manifest(path, write, spinner) {
23
+ async function manifest(path, write, exports, spinner) {
22
24
  const { reports, updated } = await (0, node_1.checkManifest)((0, path_1.dirname)(path), {
25
+ exports,
26
+ handlerEndowments: snaps_rpc_methods_1.handlerEndowments,
23
27
  updateAndWriteManifest: write,
24
28
  writeFileFn: snaps_webpack_plugin_1.writeManifest,
25
29
  });
@@ -40,7 +44,7 @@ async function manifest(path, write, spinner) {
40
44
  }
41
45
  if (errors.length > 0) {
42
46
  const formattedErrors = errors.join('\n');
43
- let message = `The snap manifest file is invalid.\n\n${formattedErrors}`;
47
+ let message = `The Snap manifest file is invalid.\n\n${formattedErrors}`;
44
48
  if (!write) {
45
49
  message +=
46
50
  '\n\nRun the command with the `--fix` flag to attempt to fix the manifest.';
@@ -49,11 +53,11 @@ async function manifest(path, write, spinner) {
49
53
  }
50
54
  if (write && updated) {
51
55
  const formattedFixed = fixed.join('\n');
52
- (0, utils_2.info)(`The snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
56
+ (0, utils_2.info)(`The Snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
53
57
  }
54
58
  if (warnings.length > 0) {
55
59
  const formattedWarnings = warnings.join('\n');
56
- (0, utils_2.warn)(`The snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
60
+ (0, utils_2.warn)(`The Snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
57
61
  }
58
62
  if (errors.length > 0) {
59
63
  spinner?.stop();
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.cjs","sourceRoot":"","sources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AAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,yCAAyC,eAAe,EAAE,CAAC;QACzE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,2EAA2E,CAAC;QAChF,CAAC;QAED,IAAA,aAAK,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAA,YAAI,EACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAA,YAAI,EACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA5DD,4BA4DC","sourcesContent":["import { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAChE,qDAAmE;AACnE,yEAA+D;AAC/D,2CAAyC;AACzC,iCAA2C;AAE3C,+BAA+B;AAE/B,iDAAgD;AAEhD;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ,KAAc,EACd,OAAkB,EAClB,OAAa;IAEb,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,oBAAa,EAAC,IA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AC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAA,YAAI,EACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAA,YAAI,EACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA/DD,4BA+DC","sourcesContent":["import { handlerEndowments } from '@metamask/snaps-rpc-methods';\nimport { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param exports - The exports to check in the manifest.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n exports?: string[],\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n exports,\n handlerEndowments,\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The Snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The Snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The Snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
@@ -7,8 +7,9 @@ import type { Ora } from "ora/index.js";
7
7
  *
8
8
  * @param path - The path to the manifest file.
9
9
  * @param write - Whether to write the manifest to disk if it is invalid.
10
+ * @param exports - The exports to check in the manifest.
10
11
  * @param spinner - An optional spinner to use for logging.
11
12
  * @returns Whether the manifest is valid.
12
13
  */
13
- export declare function manifest(path: string, write: boolean, spinner?: Ora): Promise<boolean>;
14
+ export declare function manifest(path: string, write: boolean, exports?: string[], spinner?: Ora): Promise<boolean>;
14
15
  //# sourceMappingURL=implementation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CAwDlB"}
1
+ {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
@@ -7,8 +7,9 @@ import type { Ora } from "ora/index.js";
7
7
  *
8
8
  * @param path - The path to the manifest file.
9
9
  * @param write - Whether to write the manifest to disk if it is invalid.
10
+ * @param exports - The exports to check in the manifest.
10
11
  * @param spinner - An optional spinner to use for logging.
11
12
  * @returns Whether the manifest is valid.
12
13
  */
13
- export declare function manifest(path: string, write: boolean, spinner?: Ora): Promise<boolean>;
14
+ export declare function manifest(path: string, write: boolean, exports?: string[], spinner?: Ora): Promise<boolean>;
14
15
  //# sourceMappingURL=implementation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CAwDlB"}
1
+ {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
@@ -1,3 +1,4 @@
1
+ import { handlerEndowments } from "@metamask/snaps-rpc-methods";
1
2
  import { checkManifest, indent } from "@metamask/snaps-utils/node";
2
3
  import { writeManifest } from "@metamask/snaps-webpack-plugin";
3
4
  import { assert } from "@metamask/utils";
@@ -13,11 +14,14 @@ import { error, info, warn } from "../../utils/index.mjs";
13
14
  *
14
15
  * @param path - The path to the manifest file.
15
16
  * @param write - Whether to write the manifest to disk if it is invalid.
17
+ * @param exports - The exports to check in the manifest.
16
18
  * @param spinner - An optional spinner to use for logging.
17
19
  * @returns Whether the manifest is valid.
18
20
  */
19
- export async function manifest(path, write, spinner) {
21
+ export async function manifest(path, write, exports, spinner) {
20
22
  const { reports, updated } = await checkManifest(dirname(path), {
23
+ exports,
24
+ handlerEndowments,
21
25
  updateAndWriteManifest: write,
22
26
  writeFileFn: writeManifest,
23
27
  });
@@ -38,7 +42,7 @@ export async function manifest(path, write, spinner) {
38
42
  }
39
43
  if (errors.length > 0) {
40
44
  const formattedErrors = errors.join('\n');
41
- let message = `The snap manifest file is invalid.\n\n${formattedErrors}`;
45
+ let message = `The Snap manifest file is invalid.\n\n${formattedErrors}`;
42
46
  if (!write) {
43
47
  message +=
44
48
  '\n\nRun the command with the `--fix` flag to attempt to fix the manifest.';
@@ -47,11 +51,11 @@ export async function manifest(path, write, spinner) {
47
51
  }
48
52
  if (write && updated) {
49
53
  const formattedFixed = fixed.join('\n');
50
- info(`The snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
54
+ info(`The Snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
51
55
  }
52
56
  if (warnings.length > 0) {
53
57
  const formattedWarnings = warnings.join('\n');
54
- warn(`The snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
58
+ warn(`The Snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
55
59
  }
56
60
  if (errors.length > 0) {
57
61
  spinner?.stop();
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mCAAmC;AACnE,OAAO,EAAE,aAAa,EAAE,uCAAuC;AAC/D,OAAO,EAAE,MAAM,EAAE,wBAAwB;;;AAGzC,OAAO,EAAE,OAAO,EAAE,aAAa;AAE/B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,8BAAoB;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ,KAAc,EACd,OAAa;IAEb,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC9D,sBAAsB,EAAE,KAAK;QAC7B,WAAW,EAAE,aAAa;KAC3B,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,yCAAyC,eAAe,EAAE,CAAC;QACzE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,2EAA2E,CAAC;QAChF,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,CACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oCAAoC;AAChE,OAAO,EAAE,aA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AE,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,yCAAyC,eAAe,EAAE,CAAC;QACzE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,2EAA2E,CAAC;QAChF,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,CACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { handlerEndowments } from '@metamask/snaps-rpc-methods';\nimport { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param exports - The exports to check in the manifest.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n exports?: string[],\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n exports,\n handlerEndowments,\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The Snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The Snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The Snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
@@ -24,8 +24,12 @@ const command = {
24
24
  desc: 'Validate the snap.manifest.json file',
25
25
  builder: (yarg) => {
26
26
  yarg.option('fix', builders_1.default.fix);
27
+ yarg.option('eval', builders_1.default.eval);
27
28
  },
28
- handler: async (argv) => (0, manifest_1.manifestHandler)(argv.context.config, { fix: argv.fix }),
29
+ handler: async (argv) => (0, manifest_1.manifestHandler)(argv.context.config, {
30
+ fix: argv.fix,
31
+ eval: argv.eval ?? argv.context.config.evaluate,
32
+ }),
29
33
  };
30
34
  __exportStar(require("./implementation.cjs"), exports);
31
35
  exports.default = command;