@metamask/snaps-cli 1.0.1 → 2.0.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 (253) hide show
  1. package/.browserslistrc +3 -0
  2. package/CHANGELOG.md +32 -372
  3. package/README.md +548 -69
  4. package/dist/cjs/builders.js +148 -0
  5. package/dist/cjs/builders.js.map +1 -0
  6. package/dist/cjs/cli.js +35 -0
  7. package/dist/cjs/cli.js.map +1 -0
  8. package/dist/cjs/commands/build/build.js +54 -0
  9. package/dist/cjs/commands/build/build.js.map +1 -0
  10. package/dist/cjs/commands/build/implementation.js +31 -0
  11. package/dist/cjs/commands/build/implementation.js.map +1 -0
  12. package/dist/cjs/commands/build/index.js +45 -0
  13. package/dist/cjs/commands/build/index.js.map +1 -0
  14. package/dist/cjs/commands/eval/eval.js +57 -0
  15. package/dist/cjs/commands/eval/eval.js.map +1 -0
  16. package/dist/cjs/commands/eval/implementation.js +27 -0
  17. package/dist/cjs/commands/eval/implementation.js.map +1 -0
  18. package/dist/cjs/commands/eval/index.js +50 -0
  19. package/dist/cjs/commands/eval/index.js.map +1 -0
  20. package/dist/cjs/commands/index.js +30 -0
  21. package/dist/cjs/commands/index.js.map +1 -0
  22. package/dist/cjs/commands/manifest/implementation.js +34 -0
  23. package/dist/cjs/commands/manifest/implementation.js.map +1 -0
  24. package/dist/cjs/commands/manifest/index.js +50 -0
  25. package/dist/cjs/commands/manifest/index.js.map +1 -0
  26. package/dist/cjs/commands/manifest/manifest.js +55 -0
  27. package/dist/cjs/commands/manifest/manifest.js.map +1 -0
  28. package/dist/cjs/commands/serve/index.js +33 -0
  29. package/dist/cjs/commands/serve/index.js.map +1 -0
  30. package/dist/cjs/commands/serve/serve.js +21 -0
  31. package/dist/cjs/commands/serve/serve.js.map +1 -0
  32. package/dist/cjs/commands/watch/implementation.js +35 -0
  33. package/dist/cjs/commands/watch/implementation.js.map +1 -0
  34. package/dist/cjs/commands/watch/index.js +47 -0
  35. package/dist/cjs/commands/watch/index.js.map +1 -0
  36. package/dist/cjs/commands/watch/watch.js +51 -0
  37. package/dist/cjs/commands/watch/watch.js.map +1 -0
  38. package/dist/cjs/config.js +323 -0
  39. package/dist/cjs/config.js.map +1 -0
  40. package/dist/cjs/errors.js +37 -0
  41. package/dist/cjs/errors.js.map +1 -0
  42. package/dist/cjs/index.js +77 -0
  43. package/dist/cjs/index.js.map +1 -0
  44. package/dist/cjs/main.js +19 -0
  45. package/dist/cjs/main.js.map +1 -0
  46. package/dist/cjs/utils/cli.js +61 -0
  47. package/dist/cjs/utils/cli.js.map +1 -0
  48. package/dist/cjs/utils/errors.js +42 -0
  49. package/dist/cjs/utils/errors.js.map +1 -0
  50. package/dist/cjs/utils/index.js +25 -0
  51. package/dist/cjs/utils/index.js.map +1 -0
  52. package/dist/cjs/utils/legacy.js +48 -0
  53. package/dist/cjs/utils/legacy.js.map +1 -0
  54. package/dist/cjs/utils/logging.js +46 -0
  55. package/dist/cjs/utils/logging.js.map +1 -0
  56. package/dist/cjs/utils/path.js +16 -0
  57. package/dist/cjs/utils/path.js.map +1 -0
  58. package/dist/cjs/utils/steps.js +52 -0
  59. package/dist/cjs/utils/steps.js.map +1 -0
  60. package/dist/cjs/webpack/compiler.js +96 -0
  61. package/dist/cjs/webpack/compiler.js.map +1 -0
  62. package/dist/cjs/webpack/config.js +239 -0
  63. package/dist/cjs/webpack/config.js.map +1 -0
  64. package/dist/cjs/webpack/index.js +22 -0
  65. package/dist/cjs/webpack/index.js.map +1 -0
  66. package/dist/cjs/webpack/loaders/browserify.js +97 -0
  67. package/dist/cjs/webpack/loaders/browserify.js.map +1 -0
  68. package/dist/cjs/webpack/loaders/wasm.js +36 -0
  69. package/dist/cjs/webpack/loaders/wasm.js.map +1 -0
  70. package/dist/cjs/webpack/plugins.js +340 -0
  71. package/dist/cjs/webpack/plugins.js.map +1 -0
  72. package/dist/cjs/webpack/utils.js +181 -0
  73. package/dist/cjs/webpack/utils.js.map +1 -0
  74. package/dist/{builders.js → esm/builders.js} +48 -51
  75. package/dist/esm/builders.js.map +1 -0
  76. package/dist/esm/cli.js +26 -0
  77. package/dist/esm/cli.js.map +1 -0
  78. package/dist/esm/commands/build/build.js +51 -0
  79. package/dist/esm/commands/build/build.js.map +1 -0
  80. package/dist/esm/commands/build/implementation.js +27 -0
  81. package/dist/esm/commands/build/implementation.js.map +1 -0
  82. package/dist/esm/commands/build/index.js +17 -0
  83. package/dist/esm/commands/build/index.js.map +1 -0
  84. package/dist/esm/commands/eval/eval.js +54 -0
  85. package/dist/esm/commands/eval/eval.js.map +1 -0
  86. package/dist/esm/commands/eval/implementation.js +24 -0
  87. package/dist/esm/commands/eval/implementation.js.map +1 -0
  88. package/dist/esm/commands/eval/index.js +22 -0
  89. package/dist/esm/commands/eval/index.js.map +1 -0
  90. package/dist/esm/commands/index.js +15 -0
  91. package/dist/esm/commands/index.js.map +1 -0
  92. package/dist/esm/commands/manifest/implementation.js +33 -0
  93. package/dist/esm/commands/manifest/implementation.js.map +1 -0
  94. package/dist/esm/commands/manifest/index.js +22 -0
  95. package/dist/esm/commands/manifest/index.js.map +1 -0
  96. package/dist/esm/commands/manifest/manifest.js +52 -0
  97. package/dist/esm/commands/manifest/manifest.js.map +1 -0
  98. package/dist/esm/commands/serve/index.js +18 -0
  99. package/dist/esm/commands/serve/index.js.map +1 -0
  100. package/dist/esm/commands/serve/serve.js +17 -0
  101. package/dist/esm/commands/serve/serve.js.map +1 -0
  102. package/dist/esm/commands/watch/implementation.js +34 -0
  103. package/dist/esm/commands/watch/implementation.js.map +1 -0
  104. package/dist/esm/commands/watch/index.js +19 -0
  105. package/dist/esm/commands/watch/index.js.map +1 -0
  106. package/dist/esm/commands/watch/watch.js +50 -0
  107. package/dist/esm/commands/watch/watch.js.map +1 -0
  108. package/dist/esm/config.js +327 -0
  109. package/dist/esm/config.js.map +1 -0
  110. package/dist/esm/errors.js +30 -0
  111. package/dist/esm/errors.js.map +1 -0
  112. package/dist/esm/index.js +6 -0
  113. package/dist/esm/index.js.map +1 -0
  114. package/dist/esm/main.js +10 -0
  115. package/dist/esm/main.js.map +1 -0
  116. package/dist/esm/utils/cli.js +43 -0
  117. package/dist/esm/utils/cli.js.map +1 -0
  118. package/dist/esm/utils/errors.js +43 -0
  119. package/dist/esm/utils/errors.js.map +1 -0
  120. package/dist/esm/utils/index.js +8 -0
  121. package/dist/esm/utils/index.js.map +1 -0
  122. package/dist/esm/utils/legacy.js +47 -0
  123. package/dist/esm/utils/legacy.js.map +1 -0
  124. package/dist/esm/utils/logging.js +40 -0
  125. package/dist/esm/utils/logging.js.map +1 -0
  126. package/dist/esm/utils/path.js +13 -0
  127. package/dist/esm/utils/path.js.map +1 -0
  128. package/dist/esm/utils/steps.js +43 -0
  129. package/dist/esm/utils/steps.js.map +1 -0
  130. package/dist/esm/webpack/compiler.js +89 -0
  131. package/dist/esm/webpack/compiler.js.map +1 -0
  132. package/dist/esm/webpack/config.js +241 -0
  133. package/dist/esm/webpack/config.js.map +1 -0
  134. package/dist/esm/webpack/index.js +5 -0
  135. package/dist/esm/webpack/index.js.map +1 -0
  136. package/dist/esm/webpack/loaders/browserify.js +82 -0
  137. package/dist/esm/webpack/loaders/browserify.js.map +1 -0
  138. package/dist/esm/webpack/loaders/wasm.js +26 -0
  139. package/dist/esm/webpack/loaders/wasm.js.map +1 -0
  140. package/dist/esm/webpack/plugins.js +343 -0
  141. package/dist/esm/webpack/plugins.js.map +1 -0
  142. package/dist/esm/webpack/utils.js +208 -0
  143. package/dist/esm/webpack/utils.js.map +1 -0
  144. package/dist/types/__fixtures__/configs/cjs.d.ts +1 -0
  145. package/dist/types/__fixtures__/configs/esm.d.ts +3 -0
  146. package/dist/types/__fixtures__/configs/invalid.d.ts +3 -0
  147. package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
  148. package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +3 -0
  149. package/dist/types/builders.d.ts +8 -0
  150. package/dist/{cli.d.ts → types/cli.d.ts} +1 -1
  151. package/dist/types/commands/build/build.d.ts +10 -0
  152. package/dist/types/commands/build/implementation.d.ts +10 -0
  153. package/dist/types/commands/build/index.d.ts +10 -0
  154. package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +3 -0
  155. package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +3 -0
  156. package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +3 -0
  157. package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +3 -0
  158. package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +3 -0
  159. package/dist/types/commands/eval/eval.d.ts +14 -0
  160. package/dist/types/commands/eval/implementation.d.ts +9 -0
  161. package/dist/types/commands/eval/index.d.ts +10 -0
  162. package/dist/types/commands/manifest/implementation.d.ts +12 -0
  163. package/dist/types/commands/manifest/index.d.ts +10 -0
  164. package/dist/types/commands/manifest/manifest.d.ts +14 -0
  165. package/dist/{cmds/build → types/commands/serve}/index.d.ts +4 -4
  166. package/dist/types/commands/serve/serve.d.ts +16 -0
  167. package/dist/types/commands/watch/implementation.d.ts +14 -0
  168. package/dist/types/commands/watch/index.d.ts +10 -0
  169. package/dist/types/commands/watch/watch.d.ts +19 -0
  170. package/dist/types/config.d.ts +792 -0
  171. package/dist/types/errors.d.ts +25 -0
  172. package/dist/types/index.d.ts +5 -0
  173. package/dist/types/utils/cli.d.ts +17 -0
  174. package/dist/types/utils/errors.d.ts +23 -0
  175. package/dist/types/utils/index.d.ts +6 -0
  176. package/dist/types/utils/legacy.d.ts +27 -0
  177. package/dist/types/utils/logging.d.ts +22 -0
  178. package/dist/types/utils/path.d.ts +9 -0
  179. package/dist/types/utils/steps.d.ts +17 -0
  180. package/dist/types/webpack/compiler.d.ts +29 -0
  181. package/dist/types/webpack/config.d.ts +37 -0
  182. package/dist/types/webpack/index.d.ts +3 -0
  183. package/dist/types/webpack/loaders/browserify.d.ts +16 -0
  184. package/dist/types/webpack/loaders/wasm.d.ts +20 -0
  185. package/dist/types/webpack/plugins.d.ts +147 -0
  186. package/dist/types/webpack/utils.d.ts +188 -0
  187. package/package.json +83 -43
  188. package/dist/builders.d.ts +0 -27
  189. package/dist/builders.js.map +0 -1
  190. package/dist/cli.js +0 -51
  191. package/dist/cli.js.map +0 -1
  192. package/dist/cmds/build/buildHandler.d.ts +0 -13
  193. package/dist/cmds/build/buildHandler.js +0 -37
  194. package/dist/cmds/build/buildHandler.js.map +0 -1
  195. package/dist/cmds/build/bundle.d.ts +0 -15
  196. package/dist/cmds/build/bundle.js +0 -80
  197. package/dist/cmds/build/bundle.js.map +0 -1
  198. package/dist/cmds/build/index.js +0 -29
  199. package/dist/cmds/build/index.js.map +0 -1
  200. package/dist/cmds/build/utils.d.ts +0 -56
  201. package/dist/cmds/build/utils.js +0 -100
  202. package/dist/cmds/build/utils.js.map +0 -1
  203. package/dist/cmds/eval/evalHandler.d.ts +0 -9
  204. package/dist/cmds/eval/evalHandler.js +0 -25
  205. package/dist/cmds/eval/evalHandler.js.map +0 -1
  206. package/dist/cmds/eval/index.d.ts +0 -9
  207. package/dist/cmds/eval/index.js +0 -15
  208. package/dist/cmds/eval/index.js.map +0 -1
  209. package/dist/cmds/index.js +0 -14
  210. package/dist/cmds/index.js.map +0 -1
  211. package/dist/cmds/init/index.d.ts +0 -9
  212. package/dist/cmds/init/index.js +0 -34
  213. package/dist/cmds/init/index.js.map +0 -1
  214. package/dist/cmds/init/initHandler.d.ts +0 -26
  215. package/dist/cmds/init/initHandler.js +0 -69
  216. package/dist/cmds/init/initHandler.js.map +0 -1
  217. package/dist/cmds/init/initUtils.d.ts +0 -39
  218. package/dist/cmds/init/initUtils.js +0 -122
  219. package/dist/cmds/init/initUtils.js.map +0 -1
  220. package/dist/cmds/manifest/index.d.ts +0 -9
  221. package/dist/cmds/manifest/index.js +0 -24
  222. package/dist/cmds/manifest/index.js.map +0 -1
  223. package/dist/cmds/manifest/manifestHandler.d.ts +0 -10
  224. package/dist/cmds/manifest/manifestHandler.js +0 -50
  225. package/dist/cmds/manifest/manifestHandler.js.map +0 -1
  226. package/dist/cmds/serve/index.d.ts +0 -9
  227. package/dist/cmds/serve/index.js +0 -15
  228. package/dist/cmds/serve/index.js.map +0 -1
  229. package/dist/cmds/serve/serveHandler.d.ts +0 -10
  230. package/dist/cmds/serve/serveHandler.js +0 -59
  231. package/dist/cmds/serve/serveHandler.js.map +0 -1
  232. package/dist/cmds/serve/serveUtils.d.ts +0 -22
  233. package/dist/cmds/serve/serveUtils.js +0 -39
  234. package/dist/cmds/serve/serveUtils.js.map +0 -1
  235. package/dist/cmds/watch/index.d.ts +0 -9
  236. package/dist/cmds/watch/index.js +0 -32
  237. package/dist/cmds/watch/index.js.map +0 -1
  238. package/dist/cmds/watch/watchHandler.d.ts +0 -14
  239. package/dist/cmds/watch/watchHandler.js +0 -100
  240. package/dist/cmds/watch/watchHandler.js.map +0 -1
  241. package/dist/main.js +0 -15
  242. package/dist/main.js.map +0 -1
  243. package/dist/utils/index.d.ts +0 -2
  244. package/dist/utils/index.js +0 -19
  245. package/dist/utils/index.js.map +0 -1
  246. package/dist/utils/misc.d.ts +0 -53
  247. package/dist/utils/misc.js +0 -156
  248. package/dist/utils/misc.js.map +0 -1
  249. package/dist/utils/snap-config.d.ts +0 -48
  250. package/dist/utils/snap-config.js +0 -117
  251. package/dist/utils/snap-config.js.map +0 -1
  252. /package/dist/{cmds → types/commands}/index.d.ts +0 -0
  253. /package/dist/{main.d.ts → types/main.d.ts} +0 -0
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ TranspilationModes: function() {
13
+ return TranspilationModes;
14
+ },
15
+ default: function() {
16
+ return _default;
17
+ }
18
+ });
19
+ var TranspilationModes;
20
+ (function(TranspilationModes) {
21
+ TranspilationModes["LocalAndDeps"] = 'localAndDeps';
22
+ TranspilationModes["LocalOnly"] = 'localOnly';
23
+ TranspilationModes["None"] = 'none';
24
+ })(TranspilationModes || (TranspilationModes = {}));
25
+ const builders = {
26
+ // eslint-disable-next-line @typescript-eslint/naming-convention
27
+ config: {
28
+ alias: 'c',
29
+ describe: 'Path to config file',
30
+ type: 'string',
31
+ normalize: true
32
+ },
33
+ fix: {
34
+ describe: 'Attempt to fix snap.manifest.json',
35
+ type: 'boolean'
36
+ },
37
+ input: {
38
+ alias: 'i',
39
+ describe: 'Snap bundle file to evaluate',
40
+ type: 'string',
41
+ normalize: true
42
+ },
43
+ // Deprecated Browserify options.
44
+ bundle: {
45
+ alias: 'b',
46
+ describe: 'Snap bundle file',
47
+ type: 'string',
48
+ normalize: true,
49
+ deprecated: 'Use --input instead.'
50
+ },
51
+ dist: {
52
+ alias: 'd',
53
+ describe: 'Output directory',
54
+ type: 'string',
55
+ normalize: true,
56
+ deprecated: true
57
+ },
58
+ eval: {
59
+ alias: 'e',
60
+ describe: 'Attempt to evaluate Snap bundle in SES',
61
+ type: 'boolean',
62
+ deprecated: true
63
+ },
64
+ manifest: {
65
+ alias: 'm',
66
+ describe: 'Validate snap.manifest.json',
67
+ type: 'boolean',
68
+ deprecated: true
69
+ },
70
+ port: {
71
+ alias: 'p',
72
+ describe: 'Local server port for testing',
73
+ type: 'number',
74
+ coerce: (arg)=>{
75
+ const port = Number.parseInt(String(arg), 10);
76
+ if (Number.isNaN(port)) {
77
+ throw new Error(`Invalid port: "${String(arg)}".`);
78
+ }
79
+ return port;
80
+ },
81
+ deprecated: true
82
+ },
83
+ outfileName: {
84
+ alias: 'n',
85
+ describe: 'Output file name',
86
+ type: 'string',
87
+ deprecated: true
88
+ },
89
+ root: {
90
+ alias: 'r',
91
+ describe: 'Server root directory',
92
+ type: 'string',
93
+ normalize: true,
94
+ deprecated: true
95
+ },
96
+ sourceMaps: {
97
+ describe: 'Whether builds include sourcemaps',
98
+ type: 'boolean',
99
+ deprecated: true
100
+ },
101
+ src: {
102
+ alias: 's',
103
+ describe: 'Source file',
104
+ type: 'string',
105
+ normalize: true,
106
+ deprecated: true
107
+ },
108
+ stripComments: {
109
+ alias: 'strip',
110
+ describe: 'Whether to remove code comments from the build output',
111
+ type: 'boolean',
112
+ deprecated: true
113
+ },
114
+ suppressWarnings: {
115
+ type: 'boolean',
116
+ describe: 'Whether to suppress warnings',
117
+ deprecated: true
118
+ },
119
+ transpilationMode: {
120
+ type: 'string',
121
+ describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',
122
+ choices: Object.values(TranspilationModes),
123
+ deprecated: true
124
+ },
125
+ depsToTranspile: {
126
+ type: 'array',
127
+ describe: 'Transpile only the listed dependencies.',
128
+ deprecated: true
129
+ },
130
+ verboseErrors: {
131
+ type: 'boolean',
132
+ describe: 'Display original errors',
133
+ deprecated: true
134
+ },
135
+ writeManifest: {
136
+ describe: 'Make necessary changes to the snap manifest file',
137
+ type: 'boolean',
138
+ deprecated: true
139
+ },
140
+ serve: {
141
+ describe: 'Serve snap file(s) locally for testing',
142
+ type: 'boolean',
143
+ deprecated: true
144
+ }
145
+ };
146
+ const _default = builders;
147
+
148
+ //# sourceMappingURL=builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/builders.ts"],"sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders: Record<string, Readonly<Options>> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // Deprecated Browserify options.\n bundle: {\n alias: 'b',\n describe: 'Snap bundle file',\n type: 'string',\n normalize: true,\n deprecated: 'Use --input instead.',\n },\n\n dist: {\n alias: 'd',\n describe: 'Output directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n eval: {\n alias: 'e',\n describe: 'Attempt to evaluate Snap bundle in SES',\n type: 'boolean',\n deprecated: true,\n },\n\n manifest: {\n alias: 'm',\n describe: 'Validate snap.manifest.json',\n type: 'boolean',\n deprecated: 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 deprecated: true,\n },\n\n outfileName: {\n alias: 'n',\n describe: 'Output file name',\n type: 'string',\n deprecated: true,\n },\n\n root: {\n alias: 'r',\n describe: 'Server root directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n sourceMaps: {\n describe: 'Whether builds include sourcemaps',\n type: 'boolean',\n deprecated: true,\n },\n\n src: {\n alias: 's',\n describe: 'Source file',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n stripComments: {\n alias: 'strip',\n describe: 'Whether to remove code comments from the build output',\n type: 'boolean',\n deprecated: true,\n },\n\n suppressWarnings: {\n type: 'boolean',\n describe: 'Whether to suppress warnings',\n deprecated: true,\n },\n\n transpilationMode: {\n type: 'string',\n describe:\n 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',\n choices: Object.values(TranspilationModes),\n deprecated: true,\n },\n\n depsToTranspile: {\n type: 'array',\n describe: 'Transpile only the listed dependencies.',\n deprecated: true,\n },\n\n verboseErrors: {\n type: 'boolean',\n describe: 'Display original errors',\n deprecated: true,\n },\n\n writeManifest: {\n describe: 'Make necessary changes to the snap manifest file',\n type: 'boolean',\n deprecated: true,\n },\n\n serve: {\n describe: 'Serve snap file(s) locally for testing',\n type: 'boolean',\n deprecated: true,\n },\n};\n\nexport default builders;\n"],"names":["TranspilationModes","LocalAndDeps","LocalOnly","None","builders","config","alias","describe","type","normalize","fix","input","bundle","deprecated","dist","eval","manifest","port","coerce","arg","Number","parseInt","String","isNaN","Error","outfileName","root","sourceMaps","src","stripComments","suppressWarnings","transpilationMode","choices","Object","values","depsToTranspile","verboseErrors","writeManifest","serve"],"mappings":";;;;;;;;;;;;;;IAsJA,OAAwB;eAAxB;;;IApJO;UAAKA,kBAAkB;IAAlBA,mBACVC,kBAAe;IADLD,mBAEVE,eAAY;IAFFF,mBAGVG,UAAO;GAHGH,uBAAAA;AAMZ,MAAMI,WAA8C;IAClD,gEAAgE;IAChEC,QAAQ;QACNC,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEAC,KAAK;QACHH,UAAU;QACVC,MAAM;IACR;IAEAG,OAAO;QACLL,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEA,iCAAiC;IACjCG,QAAQ;QACNN,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAC,MAAM;QACJR,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAE,MAAM;QACJT,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAG,UAAU;QACRV,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAI,MAAM;QACJX,OAAO;QACPC,UAAU;QACVC,MAAM;QACNU,QAAQ,CAACC;YACP,MAAMF,OAAOG,OAAOC,QAAQ,CAACC,OAAOH,MAAM;YAC1C,IAAIC,OAAOG,KAAK,CAACN,OAAO;gBACtB,MAAM,IAAIO,MAAM,CAAC,eAAe,EAAEF,OAAOH,KAAK,EAAE,CAAC;YACnD;YAEA,OAAOF;QACT;QACAJ,YAAY;IACd;IAEAY,aAAa;QACXnB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAa,MAAM;QACJpB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAc,YAAY;QACVpB,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAe,KAAK;QACHtB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAgB,eAAe;QACbvB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAiB,kBAAkB;QAChBtB,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAkB,mBAAmB;QACjBvB,MAAM;QACND,UACE;QACFyB,SAASC,OAAOC,MAAM,CAAClC;QACvBa,YAAY;IACd;IAEAsB,iBAAiB;QACf3B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAuB,eAAe;QACb5B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAwB,eAAe;QACb9B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAyB,OAAO;QACL/B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;AACF;MAEA,WAAeT"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "cli", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return cli;
9
+ }
10
+ });
11
+ const _yargs = /*#__PURE__*/ _interop_require_default(require("yargs"));
12
+ const _helpers = require("yargs/helpers");
13
+ const _builders = /*#__PURE__*/ _interop_require_default(require("./builders"));
14
+ const _config = require("./config");
15
+ const _utils = require("./utils");
16
+ function _interop_require_default(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ async function cli(argv, commands) {
22
+ await (0, _yargs.default)((0, _helpers.hideBin)(argv)).scriptName('mm-snap').usage('Usage: $0 <command> [options]').example('$0 build', `Build './src/index.js' as './dist/bundle.js'`).example('$0 build --config ./snap.config.build.ts', `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`).example('$0 manifest --fix', `Check the snap manifest, and fix any errors`).example('$0 watch --port 8000', `The snap input file for changes, and serve it on port 8000`).example('$0 serve --port 8000', `Serve the snap bundle on port 8000`).command(commands).option('config', _builders.default.config).option('verboseErrors', _builders.default.verboseErrors).option('suppressWarnings', _builders.default.suppressWarnings).strict().middleware(async (args)=>{
23
+ // eslint-disable-next-line require-atomic-updates
24
+ args.context = {
25
+ config: await (0, _config.getConfigByArgv)(args)
26
+ };
27
+ (0, _utils.sanitizeInputs)(args);
28
+ }, false).demandCommand(1, 'You must specify at least one command.').fail((message, failure)=>{
29
+ (0, _utils.error)((0, _utils.getYargsErrorMessage)(message, failure));
30
+ // eslint-disable-next-line n/no-process-exit
31
+ process.exit(1);
32
+ }).help().alias('help', 'h').parseAsync();
33
+ }
34
+
35
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport builders from './builders';\nimport { getConfigByArgv } from './config';\nimport { error, getYargsErrorMessage, sanitizeInputs } from './utils';\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport async function cli(argv: string[], commands: any) {\n await yargs(hideBin(argv))\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 build', `Build './src/index.js' as './dist/bundle.js'`)\n .example(\n '$0 build --config ./snap.config.build.ts',\n `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`,\n )\n .example('$0 manifest --fix', `Check the snap manifest, and fix any errors`)\n .example(\n '$0 watch --port 8000',\n `The snap input file for changes, and serve it on port 8000`,\n )\n .example('$0 serve --port 8000', `Serve the snap bundle on port 8000`)\n\n .command(commands)\n\n .option('config', builders.config)\n .option('verboseErrors', builders.verboseErrors)\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n .middleware(async (args: any) => {\n // eslint-disable-next-line require-atomic-updates\n args.context = {\n config: await getConfigByArgv(args),\n };\n\n sanitizeInputs(args);\n }, false)\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .fail((message, failure) => {\n error(getYargsErrorMessage(message, failure));\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n })\n\n .help()\n .alias('help', 'h')\n .parseAsync();\n}\n"],"names":["cli","argv","commands","yargs","hideBin","scriptName","usage","example","command","option","builders","config","verboseErrors","suppressWarnings","strict","middleware","args","context","getConfigByArgv","sanitizeInputs","demandCommand","fail","message","failure","error","getYargsErrorMessage","process","exit","help","alias","parseAsync"],"mappings":";;;;+BAcsBA;;;eAAAA;;;8DAdJ;yBACM;iEAEH;wBACW;uBAC4B;;;;;;AASrD,eAAeA,IAAIC,IAAc,EAAEC,QAAa;IACrD,MAAMC,IAAAA,cAAK,EAACC,IAAAA,gBAAO,EAACH,OACjBI,UAAU,CAAC,WACXC,KAAK,CAAC,iCAENC,OAAO,CAAC,YAAY,CAAC,4CAA4C,CAAC,EAClEA,OAAO,CACN,4CACA,CAAC,yFAAyF,CAAC,EAE5FA,OAAO,CAAC,qBAAqB,CAAC,2CAA2C,CAAC,EAC1EA,OAAO,CACN,wBACA,CAAC,0DAA0D,CAAC,EAE7DA,OAAO,CAAC,wBAAwB,CAAC,kCAAkC,CAAC,EAEpEC,OAAO,CAACN,UAERO,MAAM,CAAC,UAAUC,iBAAQ,CAACC,MAAM,EAChCF,MAAM,CAAC,iBAAiBC,iBAAQ,CAACE,aAAa,EAC9CH,MAAM,CAAC,oBAAoBC,iBAAQ,CAACG,gBAAgB,EAEpDC,MAAM,GAENC,UAAU,CAAC,OAAOC;QACjB,kDAAkD;QAClDA,KAAKC,OAAO,GAAG;YACbN,QAAQ,MAAMO,IAAAA,uBAAe,EAACF;QAChC;QAEAG,IAAAA,qBAAc,EAACH;IACjB,GAAG,OAEFI,aAAa,CAAC,GAAG,0CAEjBC,IAAI,CAAC,CAACC,SAASC;QACdC,IAAAA,YAAK,EAACC,IAAAA,2BAAoB,EAACH,SAASC;QACpC,6CAA6C;QAC7CG,QAAQC,IAAI,CAAC;IACf,GAECC,IAAI,GACJC,KAAK,CAAC,QAAQ,KACdC,UAAU;AACf"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "buildHandler", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return buildHandler;
9
+ }
10
+ });
11
+ const _snapsutils = require("@metamask/snaps-utils");
12
+ const _path = require("path");
13
+ const _errors = require("../../errors");
14
+ const _utils = require("../../utils");
15
+ const _eval = require("../eval");
16
+ const _implementation = require("./implementation");
17
+ const steps = [
18
+ {
19
+ name: 'Checking the input file.',
20
+ task: async ({ config })=>{
21
+ const { input } = config;
22
+ if (!await (0, _snapsutils.isFile)(input)) {
23
+ throw new _errors.CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
24
+ }
25
+ }
26
+ },
27
+ {
28
+ name: 'Building the snap bundle.',
29
+ task: async ({ config, spinner })=>{
30
+ // We don't evaluate the bundle here, because it's done in a separate
31
+ // step.
32
+ return await (0, _implementation.build)(config, {
33
+ evaluate: false,
34
+ spinner
35
+ });
36
+ }
37
+ },
38
+ {
39
+ name: 'Evaluating the snap bundle.',
40
+ condition: ({ config })=>config.evaluate,
41
+ task: async ({ config, spinner })=>{
42
+ const path = (0, _path.resolve)(process.cwd(), config.output.path, config.output.filename);
43
+ await (0, _eval.evaluate)(path);
44
+ (0, _utils.info)(`Snap bundle evaluated successfully.`, spinner);
45
+ }
46
+ }
47
+ ];
48
+ async function buildHandler(config) {
49
+ return await (0, _utils.executeSteps)(steps, {
50
+ config
51
+ });
52
+ }
53
+
54
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/build/build.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve as pathResolve } from 'path';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\nimport { build } from './implementation';\n\ntype BuildContext = {\n config: ProcessedWebpackConfig;\n};\n\nconst steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\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 task: async ({ config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n return await build(config, { evaluate: false, spinner });\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n condition: ({ config }) => 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] 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 */\nexport async function buildHandler(config: ProcessedConfig): Promise<void> {\n return await executeSteps(steps, {\n config,\n });\n}\n"],"names":["buildHandler","steps","name","task","config","input","isFile","CommandError","spinner","build","evaluate","condition","path","pathResolve","process","cwd","output","filename","info","executeSteps"],"mappings":";;;;+BA4DsBA;;;eAAAA;;;4BA5DC;sBACgB;wBAGV;uBAEM;sBACV;gCACH;AAMtB,MAAMC,QAA6B;IACjC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAE;YACrB,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAElB,IAAI,CAAE,MAAME,IAAAA,kBAAM,EAACD,QAAS;gBAC1B,MAAM,IAAIE,oBAAY,CACpB,CAAC,uBAAuB,EAAEF,MAAM,mEAAmE,CAAC;YAExG;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAEI,OAAO,EAAE;YAC9B,qEAAqE;YACrE,QAAQ;YACR,OAAO,MAAMC,IAAAA,qBAAK,EAACL,QAAQ;gBAAEM,UAAU;gBAAOF;YAAQ;QACxD;IACF;IACA;QACEN,MAAM;QACNS,WAAW,CAAC,EAAEP,MAAM,EAAE,GAAKA,OAAOM,QAAQ;QAC1CP,MAAM,OAAO,EAAEC,MAAM,EAAEI,OAAO,EAAE;YAC9B,MAAMI,OAAOC,IAAAA,aAAW,EACtBC,QAAQC,GAAG,IACXX,OAAOY,MAAM,CAACJ,IAAI,EAClBR,OAAOY,MAAM,CAACC,QAAQ;YAGxB,MAAMP,IAAAA,cAAQ,EAACE;YAEfM,IAAAA,WAAI,EAAC,CAAC,mCAAmC,CAAC,EAAEV;QAC9C;IACF;CACD;AAUM,eAAeR,aAAaI,MAAuB;IACxD,OAAO,MAAMe,IAAAA,mBAAY,EAAClB,OAAO;QAC/BG;IACF;AACF"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "build", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return build;
9
+ }
10
+ });
11
+ const _webpack = require("../../webpack");
12
+ async function build(config, options) {
13
+ const compiler = await (0, _webpack.getCompiler)(config, options);
14
+ return await new Promise((resolve, reject)=>{
15
+ compiler.run((runError)=>{
16
+ if (runError) {
17
+ reject(runError);
18
+ return;
19
+ }
20
+ compiler.close((closeError)=>{
21
+ if (closeError) {
22
+ reject(closeError);
23
+ return;
24
+ }
25
+ resolve();
26
+ });
27
+ });
28
+ });
29
+ }
30
+
31
+ //# sourceMappingURL=implementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/build/implementation.ts"],"sourcesContent":["import type { ProcessedWebpackConfig } 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: ProcessedWebpackConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, options);\n return await new Promise<void>((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();\n });\n });\n });\n}\n"],"names":["build","config","options","compiler","getCompiler","Promise","resolve","reject","run","runError","close","closeError"],"mappings":";;;;+BAWsBA;;;eAAAA;;;yBATM;AASrB,eAAeA,MACpBC,MAA8B,EAC9BC,OAAwB;IAExB,MAAMC,WAAW,MAAMC,IAAAA,oBAAW,EAACH,QAAQC;IAC3C,OAAO,MAAM,IAAIG,QAAc,CAACC,SAASC;QACvCJ,SAASK,GAAG,CAAC,CAACC;YACZ,IAAIA,UAAU;gBACZF,OAAOE;gBACP;YACF;YAEAN,SAASO,KAAK,CAAC,CAACC;gBACd,IAAIA,YAAY;oBACdJ,OAAOI;oBACP;gBACF;gBAEAL;YACF;QACF;IACF;AACF"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
12
+ const _build = require("./build");
13
+ _export_star(require("./implementation"), exports);
14
+ function _export_star(from, to) {
15
+ Object.keys(from).forEach(function(k) {
16
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
17
+ Object.defineProperty(to, k, {
18
+ enumerable: true,
19
+ get: function() {
20
+ return from[k];
21
+ }
22
+ });
23
+ }
24
+ });
25
+ return from;
26
+ }
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const command = {
33
+ command: [
34
+ 'build',
35
+ 'b'
36
+ ],
37
+ desc: 'Build snap from source',
38
+ builder: (yarg)=>{
39
+ yarg.option('dist', _builders.default.dist).option('eval', _builders.default.eval).option('manifest', _builders.default.manifest).option('outfileName', _builders.default.outfileName).option('sourceMaps', _builders.default.sourceMaps).option('src', _builders.default.src).option('stripComments', _builders.default.stripComments).option('transpilationMode', _builders.default.transpilationMode).option('depsToTranspile', _builders.default.depsToTranspile).option('writeManifest', _builders.default.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode');
40
+ },
41
+ handler: async (argv)=>(0, _build.buildHandler)(argv.context.config)
42
+ };
43
+ const _default = command;
44
+
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/build/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { buildHandler } from './build';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('dist', builders.dist)\n .option('eval', builders.eval)\n .option('manifest', builders.manifest)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('src', builders.src)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('writeManifest', builders.writeManifest)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) => buildHandler(argv.context.config),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["command","desc","builder","yarg","option","builders","dist","eval","manifest","outfileName","sourceMaps","src","stripComments","transpilationMode","depsToTranspile","writeManifest","implies","handler","argv","buildHandler","context","config"],"mappings":";;;;+BA4BA;;;eAAA;;;iEA1BqB;uBAEQ;qBAuBf;;;;;;;;;;;;;;;;;;;AArBd,MAAMA,UAAU;IACdA,SAAS;QAAC;QAAS;KAAI;IACvBC,MAAM;IACNC,SAAS,CAACC;QACRA,KACGC,MAAM,CAAC,QAAQC,iBAAQ,CAACC,IAAI,EAC5BF,MAAM,CAAC,QAAQC,iBAAQ,CAACE,IAAI,EAC5BH,MAAM,CAAC,YAAYC,iBAAQ,CAACG,QAAQ,EACpCJ,MAAM,CAAC,eAAeC,iBAAQ,CAACI,WAAW,EAC1CL,MAAM,CAAC,cAAcC,iBAAQ,CAACK,UAAU,EACxCN,MAAM,CAAC,OAAOC,iBAAQ,CAACM,GAAG,EAC1BP,MAAM,CAAC,iBAAiBC,iBAAQ,CAACO,aAAa,EAC9CR,MAAM,CAAC,qBAAqBC,iBAAQ,CAACQ,iBAAiB,EACtDT,MAAM,CAAC,mBAAmBC,iBAAQ,CAACS,eAAe,EAClDV,MAAM,CAAC,iBAAiBC,iBAAQ,CAACU,aAAa,EAC9CC,OAAO,CAAC,iBAAiB,YACzBA,OAAO,CAAC,mBAAmB;IAChC;IACAC,SAAS,OAAOC,OAAoBC,IAAAA,mBAAY,EAACD,KAAKE,OAAO,CAACC,MAAM;AACtE;MAGA,WAAerB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "evaluateHandler", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return evaluateHandler;
9
+ }
10
+ });
11
+ const _snapsutils = require("@metamask/snaps-utils");
12
+ const _path = require("path");
13
+ const _errors = require("../../errors");
14
+ const _utils = require("../../utils");
15
+ const _implementation = require("./implementation");
16
+ const steps = [
17
+ {
18
+ name: 'Checking the input file.',
19
+ task: async ({ input })=>{
20
+ if (!await (0, _snapsutils.isFile)(input)) {
21
+ const relativePath = (0, _utils.getRelativePath)(input);
22
+ throw new _errors.CommandError(`Input file not found: "${relativePath}". Make sure that the "input" field in your snap config or the specified input file is correct.`);
23
+ }
24
+ }
25
+ },
26
+ {
27
+ name: 'Evaluating the snap bundle.',
28
+ task: async ({ input, spinner })=>{
29
+ await (0, _implementation.evaluate)(input);
30
+ spinner.succeed('Snap bundle evaluated successfully.');
31
+ }
32
+ }
33
+ ];
34
+ /**
35
+ * Returns the path to the bundle, based on the config and options.
36
+ *
37
+ * - If `options.input` is specified, it is used as the bundle path.
38
+ * - Otherwise, the bundle path is resolved from the config's output path and
39
+ * filename.
40
+ *
41
+ * @param config - The processed config object.
42
+ * @param options - The eval options.
43
+ * @returns The path to the bundle.
44
+ */ function getBundlePath(config, options) {
45
+ if (options.input) {
46
+ return (0, _path.resolve)(process.cwd(), options.input);
47
+ }
48
+ return (0, _path.resolve)(config.output.path, config.output.filename);
49
+ }
50
+ async function evaluateHandler(config, options = {}) {
51
+ const input = getBundlePath(config, options);
52
+ await (0, _utils.executeSteps)(steps, {
53
+ input
54
+ });
55
+ }
56
+
57
+ //# sourceMappingURL=eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/eval/eval.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve } from 'path';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, getRelativePath } from '../../utils';\nimport { evaluate } from './implementation';\n\nexport type EvalOptions = {\n input?: string;\n};\n\nexport type EvalContext = Required<EvalOptions>;\n\nconst steps: Steps<EvalContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n const relativePath = getRelativePath(input);\n throw new CommandError(\n `Input file not found: \"${relativePath}\". Make sure that the \"input\" field in your snap config or the specified input file is correct.`,\n );\n }\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n task: async ({ input, spinner }) => {\n await evaluate(input);\n spinner.succeed('Snap bundle evaluated successfully.');\n },\n },\n];\n\n/**\n * Returns the path to the bundle, based on the config and options.\n *\n * - If `options.input` is specified, it is used as the bundle path.\n * - Otherwise, the bundle path is resolved from the config's output path and\n * filename.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns The path to the bundle.\n */\nfunction getBundlePath(config: ProcessedConfig, options: EvalOptions): string {\n if (options.input) {\n return resolve(process.cwd(), options.input);\n }\n\n return resolve(config.output.path, config.output.filename);\n}\n\n/**\n * Runs the snap in a worker, to ensure SES compatibility.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns A promise that resolves once the eval has finished.\n * @throws If the eval failed.\n */\nexport async function evaluateHandler(\n config: ProcessedConfig,\n options: EvalOptions = {},\n): Promise<void> {\n const input = getBundlePath(config, options);\n await executeSteps(steps, { input });\n}\n"],"names":["evaluateHandler","steps","name","task","input","isFile","relativePath","getRelativePath","CommandError","spinner","evaluate","succeed","getBundlePath","config","options","resolve","process","cwd","output","path","filename","executeSteps"],"mappings":";;;;+BA+DsBA;;;eAAAA;;;4BA/DC;sBACC;wBAGK;uBAEiB;gCACrB;AAQzB,MAAMC,QAA4B;IAChC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAE;YACpB,IAAI,CAAE,MAAMC,IAAAA,kBAAM,EAACD,QAAS;gBAC1B,MAAME,eAAeC,IAAAA,sBAAe,EAACH;gBACrC,MAAM,IAAII,oBAAY,CACpB,CAAC,uBAAuB,EAAEF,aAAa,+FAA+F,CAAC;YAE3I;QACF;IACF;IACA;QACEJ,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAEK,OAAO,EAAE;YAC7B,MAAMC,IAAAA,wBAAQ,EAACN;YACfK,QAAQE,OAAO,CAAC;QAClB;IACF;CACD;AAED;;;;;;;;;;CAUC,GACD,SAASC,cAAcC,MAAuB,EAAEC,OAAoB;IAClE,IAAIA,QAAQV,KAAK,EAAE;QACjB,OAAOW,IAAAA,aAAO,EAACC,QAAQC,GAAG,IAAIH,QAAQV,KAAK;IAC7C;IAEA,OAAOW,IAAAA,aAAO,EAACF,OAAOK,MAAM,CAACC,IAAI,EAAEN,OAAOK,MAAM,CAACE,QAAQ;AAC3D;AAUO,eAAepB,gBACpBa,MAAuB,EACvBC,UAAuB,CAAC,CAAC;IAEzB,MAAMV,QAAQQ,cAAcC,QAAQC;IACpC,MAAMO,IAAAA,mBAAY,EAACpB,OAAO;QAAEG;IAAM;AACpC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "evaluate", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return evaluate;
9
+ }
10
+ });
11
+ const _snapsutils = require("@metamask/snaps-utils");
12
+ const _chalk = require("chalk");
13
+ const _errors = require("../../errors");
14
+ async function evaluate(path) {
15
+ try {
16
+ return await (0, _snapsutils.evalBundle)(path);
17
+ } catch (evalError) {
18
+ if (evalError instanceof _snapsutils.SnapEvalError) {
19
+ throw new _errors.CommandError(`Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\nReceived the following error from the SES environment:\n\n${(0, _snapsutils.indent)((0, _chalk.red)(evalError.output.stderr), 2)}`);
20
+ }
21
+ // If the error is not a `SnapEvalError`, we don't know what it is, so
22
+ // we just throw it.
23
+ throw evalError;
24
+ }
25
+ }
26
+
27
+ //# sourceMappingURL=implementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/eval/implementation.ts"],"sourcesContent":["import { evalBundle, SnapEvalError, indent } from '@metamask/snaps-utils';\nimport { red } from 'chalk';\n\nimport { CommandError } from '../../errors';\n\n/**\n * Evaluate the given bundle in the SES environment. This is a wrapper around\n * {@link evalBundle} that throws a {@link CommandError} if the bundle cannot be\n * evaluated.\n *\n * @param path - The path to the bundle.\n * @throws If the bundle cannot be evaluated.\n */\nexport async function evaluate(path: string) {\n try {\n return await evalBundle(path);\n } catch (evalError) {\n if (evalError instanceof SnapEvalError) {\n throw new CommandError(\n `Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\\nReceived the following error from the SES environment:\\n\\n${indent(\n red(evalError.output.stderr),\n 2,\n )}`,\n );\n }\n\n // If the error is not a `SnapEvalError`, we don't know what it is, so\n // we just throw it.\n throw evalError;\n }\n}\n"],"names":["evaluate","path","evalBundle","evalError","SnapEvalError","CommandError","indent","red","output","stderr"],"mappings":";;;;+BAasBA;;;eAAAA;;;4BAb4B;uBAC9B;wBAES;AAUtB,eAAeA,SAASC,IAAY;IACzC,IAAI;QACF,OAAO,MAAMC,IAAAA,sBAAU,EAACD;IAC1B,EAAE,OAAOE,WAAW;QAClB,IAAIA,qBAAqBC,yBAAa,EAAE;YACtC,MAAM,IAAIC,oBAAY,CACpB,CAAC,kLAAkL,EAAEC,IAAAA,kBAAM,EACzLC,IAAAA,UAAG,EAACJ,UAAUK,MAAM,CAACC,MAAM,GAC3B,GACA,CAAC;QAEP;QAEA,sEAAsE;QACtE,oBAAoB;QACpB,MAAMN;IACR;AACF"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
12
+ const _eval = require("./eval");
13
+ _export_star(require("./implementation"), exports);
14
+ function _export_star(from, to) {
15
+ Object.keys(from).forEach(function(k) {
16
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
17
+ Object.defineProperty(to, k, {
18
+ enumerable: true,
19
+ get: function() {
20
+ return from[k];
21
+ }
22
+ });
23
+ }
24
+ });
25
+ return from;
26
+ }
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const command = {
33
+ command: [
34
+ 'eval',
35
+ 'e'
36
+ ],
37
+ desc: 'Attempt to evaluate snap bundle in SES',
38
+ builder: (yarg)=>{
39
+ // Browserify options. These are merged into the config object.
40
+ yarg.option('bundle', _builders.default.bundle);
41
+ // Webpack options.
42
+ yarg.option('input', _builders.default.input);
43
+ },
44
+ handler: async (argv)=>(0, _eval.evaluateHandler)(argv.context.config, {
45
+ input: argv.input
46
+ })
47
+ };
48
+ const _default = command;
49
+
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/eval/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { evaluateHandler } from './eval';\n\nconst command = {\n command: ['eval', 'e'],\n desc: 'Attempt to evaluate snap bundle in SES',\n builder: (yarg: yargs.Argv) => {\n // Browserify options. These are merged into the config object.\n yarg.option('bundle', builders.bundle);\n\n // Webpack options.\n yarg.option('input', builders.input);\n },\n handler: async (argv: YargsArgs) =>\n evaluateHandler(argv.context.config, { input: argv.input }),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["command","desc","builder","yarg","option","builders","bundle","input","handler","argv","evaluateHandler","context","config"],"mappings":";;;;+BAqBA;;;eAAA;;;iEAnBqB;sBAEW;qBAgBlB;;;;;;;;;;;;;;;;;;;AAdd,MAAMA,UAAU;IACdA,SAAS;QAAC;QAAQ;KAAI;IACtBC,MAAM;IACNC,SAAS,CAACC;QACR,+DAA+D;QAC/DA,KAAKC,MAAM,CAAC,UAAUC,iBAAQ,CAACC,MAAM;QAErC,mBAAmB;QACnBH,KAAKC,MAAM,CAAC,SAASC,iBAAQ,CAACE,KAAK;IACrC;IACAC,SAAS,OAAOC,OACdC,IAAAA,qBAAe,EAACD,KAAKE,OAAO,CAACC,MAAM,EAAE;YAAEL,OAAOE,KAAKF,KAAK;QAAC;AAC7D;MAGA,WAAeP"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _build = /*#__PURE__*/ _interop_require_default(require("./build"));
12
+ const _eval = /*#__PURE__*/ _interop_require_default(require("./eval"));
13
+ const _manifest = /*#__PURE__*/ _interop_require_default(require("./manifest"));
14
+ const _serve = /*#__PURE__*/ _interop_require_default(require("./serve"));
15
+ const _watch = /*#__PURE__*/ _interop_require_default(require("./watch"));
16
+ function _interop_require_default(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ const commands = [
22
+ _build.default,
23
+ _eval.default,
24
+ _manifest.default,
25
+ _serve.default,
26
+ _watch.default
27
+ ];
28
+ const _default = commands;
29
+
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/index.ts"],"sourcesContent":["import buildCommand from './build';\nimport evaluateCommand from './eval';\nimport manifestCommand from './manifest';\nimport serveCommand from './serve';\nimport watchCommand from './watch';\n\nconst commands = [\n buildCommand,\n evaluateCommand,\n manifestCommand,\n serveCommand,\n watchCommand,\n];\n\nexport default commands;\n"],"names":["commands","buildCommand","evaluateCommand","manifestCommand","serveCommand","watchCommand"],"mappings":";;;;+BAcA;;;eAAA;;;8DAdyB;6DACG;iEACA;8DACH;8DACA;;;;;;AAEzB,MAAMA,WAAW;IACfC,cAAY;IACZC,aAAe;IACfC,iBAAe;IACfC,cAAY;IACZC,cAAY;CACb;MAED,WAAeL"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "manifest", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return manifest;
9
+ }
10
+ });
11
+ const _snapsutils = require("@metamask/snaps-utils");
12
+ const _chalk = require("chalk");
13
+ const _path = require("path");
14
+ const _utils = require("../../utils");
15
+ async function manifest(path, write, spinner) {
16
+ const { warnings, errors, updated } = await (0, _snapsutils.checkManifest)((0, _path.dirname)(path), write);
17
+ if (write && updated) {
18
+ (0, _utils.info)('The snap manifest file has been updated.', spinner);
19
+ }
20
+ if (!write && errors.length > 0) {
21
+ const formattedErrors = errors.map((manifestError)=>(0, _snapsutils.indent)((0, _chalk.red)(`• ${manifestError}`))).join('\n');
22
+ (0, _utils.error)(`The snap manifest file is invalid.\n\n${formattedErrors}\n\nRun the command with the \`--fix\` flag to attempt to fix the manifest.`, spinner);
23
+ spinner?.stop();
24
+ process.exitCode = 1;
25
+ return false;
26
+ }
27
+ if (warnings.length > 0) {
28
+ const formattedWarnings = warnings.map((manifestWarning)=>(0, _snapsutils.indent)((0, _chalk.yellow)(`• ${manifestWarning}`)));
29
+ (0, _utils.warn)(`The snap manifest file has warnings.\n\n${formattedWarnings.join('\n')}`, spinner);
30
+ }
31
+ return true;
32
+ }
33
+
34
+ //# sourceMappingURL=implementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/manifest/implementation.ts"],"sourcesContent":["import { checkManifest, indent } from '@metamask/snaps-utils';\nimport { red, yellow } 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 */\nexport async function manifest(\n path: string,\n write: boolean,\n spinner?: Ora,\n): Promise<boolean> {\n const { warnings, errors, updated } = await checkManifest(\n dirname(path),\n write,\n );\n\n if (write && updated) {\n info('The snap manifest file has been updated.', spinner);\n }\n\n if (!write && errors.length > 0) {\n const formattedErrors = errors\n .map((manifestError) => indent(red(`• ${manifestError}`)))\n .join('\\n');\n\n error(\n `The snap manifest file is invalid.\\n\\n${formattedErrors}\\n\\nRun the command with the \\`--fix\\` flag to attempt to fix the manifest.`,\n spinner,\n );\n\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.map((manifestWarning) =>\n indent(yellow(`• ${manifestWarning}`)),\n );\n\n warn(\n `The snap manifest file has warnings.\\n\\n${formattedWarnings.join('\\n')}`,\n spinner,\n );\n }\n\n return true;\n}\n"],"names":["manifest","path","write","spinner","warnings","errors","updated","checkManifest","dirname","info","length","formattedErrors","map","manifestError","indent","red","join","error","stop","process","exitCode","formattedWarnings","manifestWarning","yellow","warn"],"mappings":";;;;+BAiBsBA;;;eAAAA;;;4BAjBgB;uBACV;sBAEJ;uBAEU;AAY3B,eAAeA,SACpBC,IAAY,EACZC,KAAc,EACdC,OAAa;IAEb,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMC,IAAAA,yBAAa,EACvDC,IAAAA,aAAO,EAACP,OACRC;IAGF,IAAIA,SAASI,SAAS;QACpBG,IAAAA,WAAI,EAAC,4CAA4CN;IACnD;IAEA,IAAI,CAACD,SAASG,OAAOK,MAAM,GAAG,GAAG;QAC/B,MAAMC,kBAAkBN,OACrBO,GAAG,CAAC,CAACC,gBAAkBC,IAAAA,kBAAM,EAACC,IAAAA,UAAG,EAAC,CAAC,EAAE,EAAEF,cAAc,CAAC,IACtDG,IAAI,CAAC;QAERC,IAAAA,YAAK,EACH,CAAC,sCAAsC,EAAEN,gBAAgB,2EAA2E,CAAC,EACrIR;QAGFA,SAASe;QACTC,QAAQC,QAAQ,GAAG;QACnB,OAAO;IACT;IAEA,IAAIhB,SAASM,MAAM,GAAG,GAAG;QACvB,MAAMW,oBAAoBjB,SAASQ,GAAG,CAAC,CAACU,kBACtCR,IAAAA,kBAAM,EAACS,IAAAA,aAAM,EAAC,CAAC,EAAE,EAAED,gBAAgB,CAAC;QAGtCE,IAAAA,WAAI,EACF,CAAC,wCAAwC,EAAEH,kBAAkBL,IAAI,CAAC,MAAM,CAAC,EACzEb;IAEJ;IAEA,OAAO;AACT"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
12
+ const _manifest = require("./manifest");
13
+ _export_star(require("./implementation"), exports);
14
+ function _export_star(from, to) {
15
+ Object.keys(from).forEach(function(k) {
16
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
17
+ Object.defineProperty(to, k, {
18
+ enumerable: true,
19
+ get: function() {
20
+ return from[k];
21
+ }
22
+ });
23
+ }
24
+ });
25
+ return from;
26
+ }
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const command = {
33
+ command: [
34
+ 'manifest',
35
+ 'm'
36
+ ],
37
+ desc: 'Validate the snap.manifest.json file',
38
+ builder: (yarg)=>{
39
+ // Browserify options. These are merged into the config object.
40
+ yarg.option('writeManifest', _builders.default.writeManifest);
41
+ // Webpack options.
42
+ yarg.option('fix', _builders.default.fix);
43
+ },
44
+ handler: async (argv)=>(0, _manifest.manifestHandler)(argv.context.config, {
45
+ fix: argv.fix
46
+ })
47
+ };
48
+ const _default = command;
49
+
50
+ //# sourceMappingURL=index.js.map