@metamask/snaps-cli 8.3.0 → 8.4.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 (88) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/dist/builders.cjs +11 -0
  3. package/dist/builders.cjs.map +1 -1
  4. package/dist/builders.d.cts +11 -0
  5. package/dist/builders.d.cts.map +1 -1
  6. package/dist/builders.d.mts +11 -0
  7. package/dist/builders.d.mts.map +1 -1
  8. package/dist/builders.mjs +11 -0
  9. package/dist/builders.mjs.map +1 -1
  10. package/dist/commands/build/build.cjs +15 -7
  11. package/dist/commands/build/build.cjs.map +1 -1
  12. package/dist/commands/build/build.d.cts +19 -3
  13. package/dist/commands/build/build.d.cts.map +1 -1
  14. package/dist/commands/build/build.d.mts +19 -3
  15. package/dist/commands/build/build.d.mts.map +1 -1
  16. package/dist/commands/build/build.mjs +15 -7
  17. package/dist/commands/build/build.mjs.map +1 -1
  18. package/dist/commands/build/index.cjs +15 -2
  19. package/dist/commands/build/index.cjs.map +1 -1
  20. package/dist/commands/build/index.d.cts.map +1 -1
  21. package/dist/commands/build/index.d.mts.map +1 -1
  22. package/dist/commands/build/index.mjs +15 -2
  23. package/dist/commands/build/index.mjs.map +1 -1
  24. package/dist/commands/manifest/implementation.cjs +1 -2
  25. package/dist/commands/manifest/implementation.cjs.map +1 -1
  26. package/dist/commands/manifest/implementation.d.cts.map +1 -1
  27. package/dist/commands/manifest/implementation.d.mts.map +1 -1
  28. package/dist/commands/manifest/implementation.mjs +1 -2
  29. package/dist/commands/manifest/implementation.mjs.map +1 -1
  30. package/dist/commands/sandbox/sandbox.cjs +4 -1
  31. package/dist/commands/sandbox/sandbox.cjs.map +1 -1
  32. package/dist/commands/sandbox/sandbox.d.cts.map +1 -1
  33. package/dist/commands/sandbox/sandbox.d.mts.map +1 -1
  34. package/dist/commands/sandbox/sandbox.mjs +4 -1
  35. package/dist/commands/sandbox/sandbox.mjs.map +1 -1
  36. package/dist/commands/watch/index.cjs +7 -4
  37. package/dist/commands/watch/index.cjs.map +1 -1
  38. package/dist/commands/watch/index.d.cts.map +1 -1
  39. package/dist/commands/watch/index.d.mts.map +1 -1
  40. package/dist/commands/watch/index.mjs +7 -4
  41. package/dist/commands/watch/index.mjs.map +1 -1
  42. package/dist/config.cjs +5 -0
  43. package/dist/config.cjs.map +1 -1
  44. package/dist/config.d.cts +71 -22
  45. package/dist/config.d.cts.map +1 -1
  46. package/dist/config.d.mts +71 -22
  47. package/dist/config.d.mts.map +1 -1
  48. package/dist/config.mjs +5 -0
  49. package/dist/config.mjs.map +1 -1
  50. package/dist/utils/cli.cjs +44 -4
  51. package/dist/utils/cli.cjs.map +1 -1
  52. package/dist/utils/cli.d.cts +9 -0
  53. package/dist/utils/cli.d.cts.map +1 -1
  54. package/dist/utils/cli.d.mts +9 -0
  55. package/dist/utils/cli.d.mts.map +1 -1
  56. package/dist/utils/cli.mjs +20 -1
  57. package/dist/utils/cli.mjs.map +1 -1
  58. package/dist/webpack/config.cjs +7 -1
  59. package/dist/webpack/config.cjs.map +1 -1
  60. package/dist/webpack/config.d.cts +16 -4
  61. package/dist/webpack/config.d.cts.map +1 -1
  62. package/dist/webpack/config.d.mts +16 -4
  63. package/dist/webpack/config.d.mts.map +1 -1
  64. package/dist/webpack/config.mjs +8 -2
  65. package/dist/webpack/config.mjs.map +1 -1
  66. package/dist/webpack/plugins.cjs +90 -2
  67. package/dist/webpack/plugins.cjs.map +1 -1
  68. package/dist/webpack/plugins.d.cts +36 -2
  69. package/dist/webpack/plugins.d.cts.map +1 -1
  70. package/dist/webpack/plugins.d.mts +36 -2
  71. package/dist/webpack/plugins.d.mts.map +1 -1
  72. package/dist/webpack/plugins.mjs +90 -3
  73. package/dist/webpack/plugins.mjs.map +1 -1
  74. package/dist/webpack/server.cjs +14 -3
  75. package/dist/webpack/server.cjs.map +1 -1
  76. package/dist/webpack/server.d.cts.map +1 -1
  77. package/dist/webpack/server.d.mts.map +1 -1
  78. package/dist/webpack/server.mjs +16 -5
  79. package/dist/webpack/server.mjs.map +1 -1
  80. package/dist/webpack/utils.cjs +29 -1
  81. package/dist/webpack/utils.cjs.map +1 -1
  82. package/dist/webpack/utils.d.cts +9 -1
  83. package/dist/webpack/utils.d.cts.map +1 -1
  84. package/dist/webpack/utils.d.mts +9 -1
  85. package/dist/webpack/utils.d.mts.map +1 -1
  86. package/dist/webpack/utils.mjs +27 -0
  87. package/dist/webpack/utils.mjs.map +1 -1
  88. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [8.4.0]
11
+
12
+ ### Added
13
+
14
+ - Add `--manifest` option for custom manifests ([#3793](https://github.com/MetaMask/snaps/pull/3793), [#3811](https://github.com/MetaMask/snaps/pull/3811))
15
+ - This is currently only supported for the `watch` command, and `build`
16
+ command for preinstalled Snaps (when used with the `--preinstalled` flag).
17
+ - Allow manifest to extend another manifest ([#3802](https://github.com/MetaMask/snaps/pull/3802))
18
+ - For example, you could have a `snap.manifest.json` file with common fields,
19
+ and a `snap.manifest.dev.json` file that extends it with
20
+ development-specific fields:
21
+ ```json5
22
+ // snap.manifest.json
23
+ {
24
+ "version": "1.0.0",
25
+ "proposedName": "My Snap",
26
+ "initialPermissions": {
27
+ "endowment:network-access": {}
28
+ }
29
+ }
30
+ ```
31
+ and
32
+ ```json5
33
+ // snap.manifest.dev.json
34
+ {
35
+ "extends": "./snap.manifest.json",
36
+ "proposedName": "My Snap (development)",
37
+ "initialConnections": {
38
+ "https://localhost:8000": {}
39
+ }
40
+ }
41
+ ```
42
+ When running `mm-snap watch --manifest snap.manifest.dev.json`, the
43
+ resulting manifest will combine the fields from both files.
44
+ - Add `--preinstalled` flag to build command to create preinstalled Snap bundle ([#3805](https://github.com/MetaMask/snaps/pull/3805))
45
+
10
46
  ## [8.3.0]
11
47
 
12
48
  ### Added
@@ -407,7 +443,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
407
443
  - The version of the package no longer needs to match the version of all other
408
444
  MetaMask Snaps packages.
409
445
 
410
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.3.0...HEAD
446
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.4.0...HEAD
447
+ [8.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.3.0...@metamask/snaps-cli@8.4.0
411
448
  [8.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.2.0...@metamask/snaps-cli@8.3.0
412
449
  [8.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.1.1...@metamask/snaps-cli@8.2.0
413
450
  [8.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@8.1.0...@metamask/snaps-cli@8.1.1
package/dist/builders.cjs CHANGED
@@ -30,6 +30,12 @@ const builders = {
30
30
  type: 'string',
31
31
  normalize: true,
32
32
  },
33
+ manifest: {
34
+ alias: 'm',
35
+ describe: 'Path to snap.manifest.json file',
36
+ type: 'string',
37
+ normalize: true,
38
+ },
33
39
  port: {
34
40
  alias: 'p',
35
41
  describe: 'Local server port for testing',
@@ -42,6 +48,11 @@ const builders = {
42
48
  return port;
43
49
  },
44
50
  },
51
+ preinstalled: {
52
+ describe: 'Build the Snap as a preinstalled Snap',
53
+ type: 'boolean',
54
+ default: false,
55
+ },
45
56
  };
46
57
  exports.default = builders;
47
58
  //# sourceMappingURL=builders.cjs.map
@@ -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,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"]}
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,QAAQ,EAAE;QACR,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,iCAAiC;QAC3C,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;IAED,YAAY,EAAE;QACZ,QAAQ,EAAE,uCAAuC;QACjD,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;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 manifest: {\n alias: 'm',\n describe: 'Path to snap.manifest.json file',\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\n preinstalled: {\n describe: 'Build the Snap as a preinstalled Snap',\n type: 'boolean',\n default: false,\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
@@ -28,12 +28,23 @@ declare const builders: {
28
28
  readonly type: "string";
29
29
  readonly normalize: true;
30
30
  };
31
+ readonly manifest: {
32
+ readonly alias: "m";
33
+ readonly describe: "Path to snap.manifest.json file";
34
+ readonly type: "string";
35
+ readonly normalize: true;
36
+ };
31
37
  readonly port: {
32
38
  readonly alias: "p";
33
39
  readonly describe: "Local server port for testing";
34
40
  readonly type: "number";
35
41
  readonly coerce: (arg: unknown) => number;
36
42
  };
43
+ readonly preinstalled: {
44
+ readonly describe: "Build the Snap as a preinstalled Snap";
45
+ readonly type: "boolean";
46
+ readonly default: false;
47
+ };
37
48
  };
38
49
  export default builders;
39
50
  //# sourceMappingURL=builders.d.cts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"builders.d.cts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA+CI,OAAO;;;;;;;CAe6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
@@ -28,12 +28,23 @@ declare const builders: {
28
28
  readonly type: "string";
29
29
  readonly normalize: true;
30
30
  };
31
+ readonly manifest: {
32
+ readonly alias: "m";
33
+ readonly describe: "Path to snap.manifest.json file";
34
+ readonly type: "string";
35
+ readonly normalize: true;
36
+ };
31
37
  readonly port: {
32
38
  readonly alias: "p";
33
39
  readonly describe: "Local server port for testing";
34
40
  readonly type: "number";
35
41
  readonly coerce: (arg: unknown) => number;
36
42
  };
43
+ readonly preinstalled: {
44
+ readonly describe: "Build the Snap as a preinstalled Snap";
45
+ readonly type: "boolean";
46
+ readonly default: false;
47
+ };
37
48
  };
38
49
  export default builders;
39
50
  //# sourceMappingURL=builders.d.mts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"builders.d.mts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA+CI,OAAO;;;;;;;CAe6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
package/dist/builders.mjs CHANGED
@@ -28,6 +28,12 @@ const builders = {
28
28
  type: 'string',
29
29
  normalize: true,
30
30
  },
31
+ manifest: {
32
+ alias: 'm',
33
+ describe: 'Path to snap.manifest.json file',
34
+ type: 'string',
35
+ normalize: true,
36
+ },
31
37
  port: {
32
38
  alias: 'p',
33
39
  describe: 'Local server port for testing',
@@ -40,6 +46,11 @@ const builders = {
40
46
  return port;
41
47
  },
42
48
  },
49
+ preinstalled: {
50
+ describe: 'Build the Snap as a preinstalled Snap',
51
+ type: 'boolean',
52
+ default: false,
53
+ },
43
54
  };
44
55
  export default builders;
45
56
  //# sourceMappingURL=builders.mjs.map
@@ -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,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"]}
1
+ {"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;IACf,OAA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","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 manifest: {\n alias: 'm',\n describe: 'Path to snap.manifest.json file',\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\n preinstalled: {\n describe: 'Build the Snap as a preinstalled Snap',\n type: 'boolean',\n default: false,\n },\n} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
@@ -22,13 +22,15 @@ exports.steps = [
22
22
  name: 'Building the Snap bundle.',
23
23
  condition: ({ build: enableBuild }) => enableBuild,
24
24
  task: async (context) => {
25
- const { analyze, config, spinner } = context;
25
+ const { options, config, spinner } = context;
26
26
  const compiler = await (0, implementation_1.build)(config, {
27
- analyze,
27
+ analyze: options.analyze,
28
28
  evaluate: config.evaluate,
29
+ preinstalled: options.preinstalled,
30
+ preinstalledOptions: config.preinstalled,
29
31
  spinner,
30
32
  });
31
- if (analyze) {
33
+ if (options.analyze) {
32
34
  return {
33
35
  ...context,
34
36
  port: await (0, utils_2.getBundleAnalyzerPort)(compiler),
@@ -39,7 +41,7 @@ exports.steps = [
39
41
  },
40
42
  {
41
43
  name: 'Running analyser.',
42
- condition: ({ analyze }) => analyze,
44
+ condition: ({ options }) => options.analyze === true,
43
45
  task: async ({ spinner, port }) => {
44
46
  (0, utils_1.assert)(port, 'Port is not defined.');
45
47
  (0, utils_3.success)(`Bundle analyzer running at http://localhost:${port}.`, spinner);
@@ -54,14 +56,20 @@ exports.steps = [
54
56
  * This creates the destination directory if it doesn't exist.
55
57
  *
56
58
  * @param config - The config object.
57
- * @param analyze - Whether to analyze the bundle.
59
+ * @param options - The build options.
60
+ * @param options.analyze - Whether to analyze the bundle.
61
+ * @param options.preinstalled - Whether to build the Snap as a preinstalled
62
+ * Snap.
58
63
  * @returns Nothing.
59
64
  */
60
- async function buildHandler(config, analyze = false) {
65
+ async function buildHandler(config, options = {
66
+ analyze: false,
67
+ preinstalled: false,
68
+ }) {
61
69
  return await (0, utils_3.executeSteps)(exports.steps, {
62
70
  build: true,
63
71
  config,
64
- analyze,
72
+ options,
65
73
  });
66
74
  }
67
75
  exports.buildHandler = buildHandler;
@@ -1 +1 @@
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"]}
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;AAyBvC,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;YACz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AAI,EAAE,CAAC;QACjB,CAAC;KACF;CACO,CAAC;AAEX;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,UAAwB;IACtB,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;CACpB;IAED,OAAO,MAAM,IAAA,oBAAY,EAAC,aAAK,EAAE;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAZD,oCAYC","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 build: boolean;\n config: ProcessedConfig;\n exports?: string[];\n options: BuildOptions;\n port?: number;\n};\n\n/**\n * The options for {@link buildHandler}.\n */\nexport type BuildOptions = {\n /**\n * Whether to analyze the bundle.\n */\n analyze?: boolean;\n\n /**\n * Whether to build the Snap as a preinstalled Snap.\n */\n preinstalled?: boolean;\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 { options, config, spinner } = context;\n\n const compiler = await build(config, {\n analyze: options.analyze,\n evaluate: config.evaluate,\n preinstalled: options.preinstalled,\n preinstalledOptions: config.preinstalled,\n spinner,\n });\n\n if (options.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: ({ options }) => options.analyze === true,\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 options - The build options.\n * @param options.analyze - Whether to analyze the bundle.\n * @param options.preinstalled - Whether to build the Snap as a preinstalled\n * Snap.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n options: BuildOptions = {\n analyze: false,\n preinstalled: false,\n },\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n options,\n });\n}\n"]}
@@ -1,12 +1,25 @@
1
1
  import type { ProcessedConfig } from "../../config.cjs";
2
2
  import type { Steps } from "../../utils/index.cjs";
3
3
  export type BuildContext = {
4
- analyze: boolean;
5
4
  build: boolean;
6
5
  config: ProcessedConfig;
7
6
  exports?: string[];
7
+ options: BuildOptions;
8
8
  port?: number;
9
9
  };
10
+ /**
11
+ * The options for {@link buildHandler}.
12
+ */
13
+ export type BuildOptions = {
14
+ /**
15
+ * Whether to analyze the bundle.
16
+ */
17
+ analyze?: boolean;
18
+ /**
19
+ * Whether to build the Snap as a preinstalled Snap.
20
+ */
21
+ preinstalled?: boolean;
22
+ };
10
23
  export declare const steps: Steps<BuildContext>;
11
24
  /**
12
25
  * Build all files in the given source directory to the given destination
@@ -15,8 +28,11 @@ export declare const steps: Steps<BuildContext>;
15
28
  * This creates the destination directory if it doesn't exist.
16
29
  *
17
30
  * @param config - The config object.
18
- * @param analyze - Whether to analyze the bundle.
31
+ * @param options - The build options.
32
+ * @param options.analyze - Whether to analyze the bundle.
33
+ * @param options.preinstalled - Whether to build the Snap as a preinstalled
34
+ * Snap.
19
35
  * @returns Nothing.
20
36
  */
21
- export declare function buildHandler(config: ProcessedConfig, analyze?: boolean): Promise<void>;
37
+ export declare function buildHandler(config: ProcessedConfig, options?: BuildOptions): Promise<void>;
22
38
  //# sourceMappingURL=build.d.cts.map
@@ -1 +1 @@
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"}
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,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CAgD5B,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,YAGR,GACA,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -1,12 +1,25 @@
1
1
  import type { ProcessedConfig } from "../../config.mjs";
2
2
  import type { Steps } from "../../utils/index.mjs";
3
3
  export type BuildContext = {
4
- analyze: boolean;
5
4
  build: boolean;
6
5
  config: ProcessedConfig;
7
6
  exports?: string[];
7
+ options: BuildOptions;
8
8
  port?: number;
9
9
  };
10
+ /**
11
+ * The options for {@link buildHandler}.
12
+ */
13
+ export type BuildOptions = {
14
+ /**
15
+ * Whether to analyze the bundle.
16
+ */
17
+ analyze?: boolean;
18
+ /**
19
+ * Whether to build the Snap as a preinstalled Snap.
20
+ */
21
+ preinstalled?: boolean;
22
+ };
10
23
  export declare const steps: Steps<BuildContext>;
11
24
  /**
12
25
  * Build all files in the given source directory to the given destination
@@ -15,8 +28,11 @@ export declare const steps: Steps<BuildContext>;
15
28
  * This creates the destination directory if it doesn't exist.
16
29
  *
17
30
  * @param config - The config object.
18
- * @param analyze - Whether to analyze the bundle.
31
+ * @param options - The build options.
32
+ * @param options.analyze - Whether to analyze the bundle.
33
+ * @param options.preinstalled - Whether to build the Snap as a preinstalled
34
+ * Snap.
19
35
  * @returns Nothing.
20
36
  */
21
- export declare function buildHandler(config: ProcessedConfig, analyze?: boolean): Promise<void>;
37
+ export declare function buildHandler(config: ProcessedConfig, options?: BuildOptions): Promise<void>;
22
38
  //# sourceMappingURL=build.d.mts.map
@@ -1 +1 @@
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
+ {"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,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,YAAY,CAgD5B,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,YAGR,GACA,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -19,13 +19,15 @@ export const steps = [
19
19
  name: 'Building the Snap bundle.',
20
20
  condition: ({ build: enableBuild }) => enableBuild,
21
21
  task: async (context) => {
22
- const { analyze, config, spinner } = context;
22
+ const { options, config, spinner } = context;
23
23
  const compiler = await build(config, {
24
- analyze,
24
+ analyze: options.analyze,
25
25
  evaluate: config.evaluate,
26
+ preinstalled: options.preinstalled,
27
+ preinstalledOptions: config.preinstalled,
26
28
  spinner,
27
29
  });
28
- if (analyze) {
30
+ if (options.analyze) {
29
31
  return {
30
32
  ...context,
31
33
  port: await getBundleAnalyzerPort(compiler),
@@ -36,7 +38,7 @@ export const steps = [
36
38
  },
37
39
  {
38
40
  name: 'Running analyser.',
39
- condition: ({ analyze }) => analyze,
41
+ condition: ({ options }) => options.analyze === true,
40
42
  task: async ({ spinner, port }) => {
41
43
  assert(port, 'Port is not defined.');
42
44
  success(`Bundle analyzer running at http://localhost:${port}.`, spinner);
@@ -51,14 +53,20 @@ export const steps = [
51
53
  * This creates the destination directory if it doesn't exist.
52
54
  *
53
55
  * @param config - The config object.
54
- * @param analyze - Whether to analyze the bundle.
56
+ * @param options - The build options.
57
+ * @param options.analyze - Whether to analyze the bundle.
58
+ * @param options.preinstalled - Whether to build the Snap as a preinstalled
59
+ * Snap.
55
60
  * @returns Nothing.
56
61
  */
57
- export async function buildHandler(config, analyze = false) {
62
+ export async function buildHandler(config, options = {
63
+ analyze: false,
64
+ preinstalled: false,
65
+ }) {
58
66
  return await executeSteps(steps, {
59
67
  build: true,
60
68
  config,
61
- analyze,
69
+ options,
62
70
  });
63
71
  }
64
72
  //# sourceMappingURL=build.mjs.map
@@ -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;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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,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
+ {"version":3,"file":"build.mjs","sourceRoot":"","sources":["../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BACL,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,CAAC,OAAO,KAAK,IAAI;QACpD,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;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,UAAwB;IACtB,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;CACpB;IAED,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 build: boolean;\n config: ProcessedConfig;\n exports?: string[];\n options: BuildOptions;\n port?: number;\n};\n\n/**\n * The options for {@link buildHandler}.\n */\nexport type BuildOptions = {\n /**\n * Whether to analyze the bundle.\n */\n analyze?: boolean;\n\n /**\n * Whether to build the Snap as a preinstalled Snap.\n */\n preinstalled?: boolean;\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 { options, config, spinner } = context;\n\n const compiler = await build(config, {\n analyze: options.analyze,\n evaluate: config.evaluate,\n preinstalled: options.preinstalled,\n preinstalledOptions: config.preinstalled,\n spinner,\n });\n\n if (options.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: ({ options }) => options.analyze === true,\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 options - The build options.\n * @param options.analyze - Whether to analyze the bundle.\n * @param options.preinstalled - Whether to build the Snap as a preinstalled\n * Snap.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n options: BuildOptions = {\n analyze: false,\n preinstalled: false,\n },\n): Promise<void> {\n return await executeSteps(steps, {\n build: true,\n config,\n options,\n });\n}\n"]}
@@ -20,13 +20,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.steps = void 0;
21
21
  const build_1 = require("./build.cjs");
22
22
  const builders_1 = __importDefault(require("../../builders.cjs"));
23
+ const utils_1 = require("../../utils/index.cjs");
23
24
  const command = {
24
25
  command: ['build', 'b'],
25
26
  desc: 'Build snap from source',
26
27
  builder: (yarg) => {
27
- yarg.option('analyze', builders_1.default.analyze);
28
+ yarg
29
+ .option('analyze', builders_1.default.analyze)
30
+ .option('preinstalled', builders_1.default.preinstalled)
31
+ .option('manifest', builders_1.default.manifest)
32
+ .check((argv) => {
33
+ if (argv.manifest && !argv.preinstalled) {
34
+ throw new Error('The `--manifest` option requires the `--preinstalled` flag to be set.');
35
+ }
36
+ return true;
37
+ });
28
38
  },
29
- handler: async (argv) => (0, build_1.buildHandler)(argv.context.config, argv.analyze),
39
+ handler: async (argv) => (0, build_1.buildHandler)((0, utils_1.getConfigWithManifest)(argv.context.config, argv.manifest), {
40
+ analyze: argv.analyze,
41
+ preinstalled: argv.preinstalled,
42
+ }),
30
43
  };
31
44
  __exportStar(require("./implementation.cjs"), exports);
32
45
  var build_2 = require("./build.cjs");
@@ -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,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
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,uCAAuC;AACvC,kEAAsC;AAEtC,iDAAoD;AAEpD,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;aACnC,MAAM,CAAC,cAAc,EAAE,kBAAQ,CAAC,YAAY,CAAC;aAC7C,MAAM,CAAC,UAAU,EAAE,kBAAQ,CAAC,QAAQ,CAAC;aACrC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAA,6BAAqB,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtE,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;CACL,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';\nimport { getConfigWithManifest } from '../../utils';\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 .option('preinstalled', builders.preinstalled)\n .option('manifest', builders.manifest)\n .check((argv) => {\n if (argv.manifest && !argv.preinstalled) {\n throw new Error(\n 'The `--manifest` option requires the `--preinstalled` flag to be set.',\n );\n }\n\n return true;\n });\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(getConfigWithManifest(argv.context.config, argv.manifest), {\n analyze: argv.analyze,\n preinstalled: argv.preinstalled,\n }),\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;oBAGJ,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;AAGnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAeJ,SAAS;CAKhC,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;oBAGJ,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;AAGnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAeJ,SAAS;CAKhC,CAAC;AAEF,qCAAiC;AACjC,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,eAAe,OAAO,CAAC"}
@@ -1,12 +1,25 @@
1
1
  import { buildHandler } from "./build.mjs";
2
2
  import builders from "../../builders.mjs";
3
+ import { getConfigWithManifest } from "../../utils/index.mjs";
3
4
  const command = {
4
5
  command: ['build', 'b'],
5
6
  desc: 'Build snap from source',
6
7
  builder: (yarg) => {
7
- yarg.option('analyze', builders.analyze);
8
+ yarg
9
+ .option('analyze', builders.analyze)
10
+ .option('preinstalled', builders.preinstalled)
11
+ .option('manifest', builders.manifest)
12
+ .check((argv) => {
13
+ if (argv.manifest && !argv.preinstalled) {
14
+ throw new Error('The `--manifest` option requires the `--preinstalled` flag to be set.');
15
+ }
16
+ return true;
17
+ });
8
18
  },
9
- handler: async (argv) => buildHandler(argv.context.config, argv.analyze),
19
+ handler: async (argv) => buildHandler(getConfigWithManifest(argv.context.config, argv.manifest), {
20
+ analyze: argv.analyze,
21
+ preinstalled: argv.preinstalled,
22
+ }),
10
23
  };
11
24
  export * from "./implementation.mjs";
12
25
  export { steps } from "./build.mjs";
@@ -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,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
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/build/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAEtC,OAAO,EAAE,qBAAqB,EAAE,8BAAoB;AAEpD,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;aACnC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,YAAY,CAAC;aAC7C,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC;aACrC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtE,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;CACL,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';\nimport { getConfigWithManifest } from '../../utils';\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 .option('preinstalled', builders.preinstalled)\n .option('manifest', builders.manifest)\n .check((argv) => {\n if (argv.manifest && !argv.preinstalled) {\n throw new Error(\n 'The `--manifest` option requires the `--preinstalled` flag to be set.',\n );\n }\n\n return true;\n });\n },\n handler: async (argv: YargsArgs) =>\n buildHandler(getConfigWithManifest(argv.context.config, argv.manifest), {\n analyze: argv.analyze,\n preinstalled: argv.preinstalled,\n }),\n};\n\nexport * from './implementation';\nexport { steps } from './build';\nexport default command;\n"]}
@@ -6,7 +6,6 @@ const node_1 = require("@metamask/snaps-utils/node");
6
6
  const snaps_webpack_plugin_1 = require("@metamask/snaps-webpack-plugin");
7
7
  const utils_1 = require("@metamask/utils");
8
8
  const chalk_1 = require("chalk");
9
- const path_1 = require("path");
10
9
  const utils_2 = require("../../utils/index.cjs");
11
10
  /**
12
11
  * Check the snap manifest file at the given path. If `write` is `true`, the
@@ -21,7 +20,7 @@ const utils_2 = require("../../utils/index.cjs");
21
20
  * @returns Whether the manifest is valid.
22
21
  */
23
22
  async function manifest(path, write, exports, spinner) {
24
- const { reports, updated } = await (0, node_1.checkManifest)((0, path_1.dirname)(path), {
23
+ const { reports, updated } = await (0, node_1.checkManifest)(path, {
25
24
  exports,
26
25
  handlerEndowments: snaps_rpc_methods_1.handlerEndowments,
27
26
  updateAndWriteManifest: write,
@@ -1 +1 @@
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,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QAC9D,OAAO;QACP,iBAAiB,EAAjB,qCAAiB;QACjB,sBAAsB,EAAE,KAAK;QAC7B,WAAW,EAAE,oCAAa;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,IAAA,aAAM,EAAC,IAAA,WAAG,EAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,IAAA,cAAM,EAAC,KAAK,MAAM,CAAC,OAAO,E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ent":["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"]}
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;AAG3C,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,IAAI,EAAE;QACrD,OAAO;QACP,iBAAiB,EAAjB,qCAAiB;QACjB,sBAAsB,EAAE,KAAK;QAC7B,WAAW,EAAE,oCAAa;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,IAAA,aAAM,EAAC,IAAA,WAAG,EAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,IAAA,cAAM,EAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,IAAA,aAAK,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,IAAA,cAAM,EAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,IAAA,cAAM,EAAC,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,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;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';\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(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"]}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAI/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 +1 @@
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
+ {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAI/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"}
@@ -4,7 +4,6 @@ import { writeManifest } from "@metamask/snaps-webpack-plugin";
4
4
  import { assert } from "@metamask/utils";
5
5
  import $chalk from "chalk";
6
6
  const { red, yellow, green } = $chalk;
7
- import { dirname } from "path";
8
7
  import { error, info, warn } from "../../utils/index.mjs";
9
8
  /**
10
9
  * Check the snap manifest file at the given path. If `write` is `true`, the
@@ -19,7 +18,7 @@ import { error, info, warn } from "../../utils/index.mjs";
19
18
  * @returns Whether the manifest is valid.
20
19
  */
21
20
  export async function manifest(path, write, exports, spinner) {
22
- const { reports, updated } = await checkManifest(dirname(path), {
21
+ const { reports, updated } = await checkManifest(path, {
23
22
  exports,
24
23
  handlerEndowments,
25
24
  updateAndWriteManifest: write,