@metamask/snaps-cli 0.37.0-flask.1 → 0.38.0-flask.1

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 (256) hide show
  1. package/.browserslistrc +3 -0
  2. package/CHANGELOG.md +20 -426
  3. package/README.md +539 -63
  4. package/dist/cjs/builders.js +40 -41
  5. package/dist/cjs/builders.js.map +1 -1
  6. package/dist/cjs/cli.js +14 -14
  7. package/dist/cjs/cli.js.map +1 -1
  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/{cmds → commands}/build/index.js +18 -5
  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.map +1 -0
  21. package/dist/cjs/commands/manifest/implementation.js +34 -0
  22. package/dist/cjs/commands/manifest/implementation.js.map +1 -0
  23. package/dist/cjs/commands/manifest/index.js +50 -0
  24. package/dist/cjs/commands/manifest/index.js.map +1 -0
  25. package/dist/cjs/commands/manifest/manifest.js +55 -0
  26. package/dist/cjs/commands/manifest/manifest.js.map +1 -0
  27. package/dist/cjs/{cmds → commands}/serve/index.js +4 -2
  28. package/dist/cjs/commands/serve/index.js.map +1 -0
  29. package/dist/cjs/commands/serve/serve.js +21 -0
  30. package/dist/cjs/commands/serve/serve.js.map +1 -0
  31. package/dist/cjs/commands/watch/implementation.js +35 -0
  32. package/dist/cjs/commands/watch/implementation.js.map +1 -0
  33. package/dist/cjs/{cmds → commands}/watch/index.js +19 -4
  34. package/dist/cjs/commands/watch/index.js.map +1 -0
  35. package/dist/cjs/commands/watch/watch.js +51 -0
  36. package/dist/cjs/commands/watch/watch.js.map +1 -0
  37. package/dist/cjs/config.js +290 -0
  38. package/dist/cjs/config.js.map +1 -0
  39. package/dist/cjs/errors.js +37 -0
  40. package/dist/cjs/errors.js.map +1 -0
  41. package/dist/cjs/index.js +28 -3
  42. package/dist/cjs/index.js.map +1 -1
  43. package/dist/cjs/main.js +6 -7
  44. package/dist/cjs/main.js.map +1 -1
  45. package/dist/cjs/utils/cli.js +61 -0
  46. package/dist/cjs/utils/cli.js.map +1 -0
  47. package/dist/cjs/utils/errors.js +42 -0
  48. package/dist/cjs/utils/errors.js.map +1 -0
  49. package/dist/cjs/utils/index.js +6 -2
  50. package/dist/cjs/utils/index.js.map +1 -1
  51. package/dist/cjs/utils/legacy.js +48 -0
  52. package/dist/cjs/utils/legacy.js.map +1 -0
  53. package/dist/cjs/utils/logging.js +46 -0
  54. package/dist/cjs/utils/logging.js.map +1 -0
  55. package/dist/cjs/utils/path.js +16 -0
  56. package/dist/cjs/utils/path.js.map +1 -0
  57. package/dist/cjs/utils/steps.js +52 -0
  58. package/dist/cjs/utils/steps.js.map +1 -0
  59. package/dist/cjs/webpack/compiler.js +96 -0
  60. package/dist/cjs/webpack/compiler.js.map +1 -0
  61. package/dist/cjs/webpack/config.js +234 -0
  62. package/dist/cjs/webpack/config.js.map +1 -0
  63. package/dist/cjs/webpack/index.js +22 -0
  64. package/dist/cjs/webpack/index.js.map +1 -0
  65. package/dist/cjs/webpack/loaders/browserify.js +97 -0
  66. package/dist/cjs/webpack/loaders/browserify.js.map +1 -0
  67. package/dist/cjs/webpack/loaders/wasm.js +36 -0
  68. package/dist/cjs/webpack/loaders/wasm.js.map +1 -0
  69. package/dist/cjs/webpack/plugins.js +340 -0
  70. package/dist/cjs/webpack/plugins.js.map +1 -0
  71. package/dist/cjs/webpack/utils.js +133 -0
  72. package/dist/cjs/webpack/utils.js.map +1 -0
  73. package/dist/esm/builders.js +40 -41
  74. package/dist/esm/builders.js.map +1 -1
  75. package/dist/esm/cli.js +15 -15
  76. package/dist/esm/cli.js.map +1 -1
  77. package/dist/esm/commands/build/build.js +51 -0
  78. package/dist/esm/commands/build/build.js.map +1 -0
  79. package/dist/esm/commands/build/implementation.js +27 -0
  80. package/dist/esm/commands/build/implementation.js.map +1 -0
  81. package/dist/esm/{cmds → commands}/build/index.js +5 -5
  82. package/dist/esm/commands/build/index.js.map +1 -0
  83. package/dist/esm/commands/eval/eval.js +54 -0
  84. package/dist/esm/commands/eval/eval.js.map +1 -0
  85. package/dist/esm/commands/eval/implementation.js +24 -0
  86. package/dist/esm/commands/eval/implementation.js.map +1 -0
  87. package/dist/esm/commands/eval/index.js +22 -0
  88. package/dist/esm/commands/eval/index.js.map +1 -0
  89. package/dist/esm/commands/index.js +15 -0
  90. package/dist/esm/commands/index.js.map +1 -0
  91. package/dist/esm/commands/manifest/implementation.js +33 -0
  92. package/dist/esm/commands/manifest/implementation.js.map +1 -0
  93. package/dist/esm/commands/manifest/index.js +22 -0
  94. package/dist/esm/commands/manifest/index.js.map +1 -0
  95. package/dist/esm/commands/manifest/manifest.js +52 -0
  96. package/dist/esm/commands/manifest/manifest.js.map +1 -0
  97. package/dist/esm/{cmds → commands}/serve/index.js +4 -2
  98. package/dist/esm/commands/serve/index.js.map +1 -0
  99. package/dist/esm/commands/serve/serve.js +17 -0
  100. package/dist/esm/commands/serve/serve.js.map +1 -0
  101. package/dist/esm/commands/watch/implementation.js +34 -0
  102. package/dist/esm/commands/watch/implementation.js.map +1 -0
  103. package/dist/esm/{cmds → commands}/watch/index.js +6 -4
  104. package/dist/esm/commands/watch/index.js.map +1 -0
  105. package/dist/esm/commands/watch/watch.js +50 -0
  106. package/dist/esm/commands/watch/watch.js.map +1 -0
  107. package/dist/esm/config.js +294 -0
  108. package/dist/esm/config.js.map +1 -0
  109. package/dist/esm/errors.js +30 -0
  110. package/dist/esm/errors.js.map +1 -0
  111. package/dist/esm/index.js +3 -0
  112. package/dist/esm/index.js.map +1 -1
  113. package/dist/esm/main.js +6 -7
  114. package/dist/esm/main.js.map +1 -1
  115. package/dist/esm/utils/cli.js +43 -0
  116. package/dist/esm/utils/cli.js.map +1 -0
  117. package/dist/esm/utils/errors.js +43 -0
  118. package/dist/esm/utils/errors.js.map +1 -0
  119. package/dist/esm/utils/index.js +6 -2
  120. package/dist/esm/utils/index.js.map +1 -1
  121. package/dist/esm/utils/legacy.js +47 -0
  122. package/dist/esm/utils/legacy.js.map +1 -0
  123. package/dist/esm/utils/logging.js +40 -0
  124. package/dist/esm/utils/logging.js.map +1 -0
  125. package/dist/esm/utils/path.js +13 -0
  126. package/dist/esm/utils/path.js.map +1 -0
  127. package/dist/esm/utils/steps.js +43 -0
  128. package/dist/esm/utils/steps.js.map +1 -0
  129. package/dist/esm/webpack/compiler.js +89 -0
  130. package/dist/esm/webpack/compiler.js.map +1 -0
  131. package/dist/esm/webpack/config.js +236 -0
  132. package/dist/esm/webpack/config.js.map +1 -0
  133. package/dist/esm/webpack/index.js +5 -0
  134. package/dist/esm/webpack/index.js.map +1 -0
  135. package/dist/esm/webpack/loaders/browserify.js +82 -0
  136. package/dist/esm/webpack/loaders/browserify.js.map +1 -0
  137. package/dist/esm/webpack/loaders/wasm.js +26 -0
  138. package/dist/esm/webpack/loaders/wasm.js.map +1 -0
  139. package/dist/esm/webpack/plugins.js +343 -0
  140. package/dist/esm/webpack/plugins.js.map +1 -0
  141. package/dist/esm/webpack/utils.js +160 -0
  142. package/dist/esm/webpack/utils.js.map +1 -0
  143. package/dist/types/__fixtures__/configs/cjs.d.ts +1 -0
  144. package/dist/types/__fixtures__/configs/esm.d.ts +3 -0
  145. package/dist/types/__fixtures__/configs/invalid.d.ts +3 -0
  146. package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
  147. package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +3 -0
  148. package/dist/types/builders.d.ts +2 -21
  149. package/dist/types/cli.d.ts +1 -1
  150. package/dist/types/commands/build/build.d.ts +10 -0
  151. package/dist/types/commands/build/implementation.d.ts +10 -0
  152. package/dist/types/{cmds/eval → commands/build}/index.d.ts +1 -0
  153. package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +3 -0
  154. package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +3 -0
  155. package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +3 -0
  156. package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +3 -0
  157. package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +3 -0
  158. package/dist/types/commands/eval/eval.d.ts +14 -0
  159. package/dist/types/commands/eval/implementation.d.ts +9 -0
  160. package/dist/types/{cmds/serve → commands/eval}/index.d.ts +1 -0
  161. package/dist/types/commands/manifest/implementation.d.ts +12 -0
  162. package/dist/types/{cmds → commands}/manifest/index.d.ts +1 -0
  163. package/dist/types/commands/manifest/manifest.d.ts +14 -0
  164. package/dist/types/commands/serve/serve.d.ts +16 -0
  165. package/dist/types/commands/watch/implementation.d.ts +14 -0
  166. package/dist/types/commands/watch/index.d.ts +10 -0
  167. package/dist/types/commands/watch/watch.d.ts +19 -0
  168. package/dist/types/config.d.ts +626 -0
  169. package/dist/types/errors.d.ts +25 -0
  170. package/dist/types/index.d.ts +4 -0
  171. package/dist/types/utils/cli.d.ts +17 -0
  172. package/dist/types/utils/errors.d.ts +23 -0
  173. package/dist/types/utils/index.d.ts +6 -2
  174. package/dist/types/utils/legacy.d.ts +27 -0
  175. package/dist/types/utils/logging.d.ts +22 -0
  176. package/dist/types/utils/path.d.ts +9 -0
  177. package/dist/types/utils/steps.d.ts +17 -0
  178. package/dist/types/webpack/compiler.d.ts +29 -0
  179. package/dist/types/webpack/config.d.ts +37 -0
  180. package/dist/types/webpack/index.d.ts +3 -0
  181. package/dist/types/webpack/loaders/browserify.d.ts +16 -0
  182. package/dist/types/webpack/loaders/wasm.d.ts +20 -0
  183. package/dist/types/webpack/plugins.d.ts +147 -0
  184. package/dist/types/webpack/utils.d.ts +156 -0
  185. package/package.json +15 -7
  186. package/dist/cjs/cmds/build/buildHandler.js +0 -36
  187. package/dist/cjs/cmds/build/buildHandler.js.map +0 -1
  188. package/dist/cjs/cmds/build/bundle.js +0 -83
  189. package/dist/cjs/cmds/build/bundle.js.map +0 -1
  190. package/dist/cjs/cmds/build/index.js.map +0 -1
  191. package/dist/cjs/cmds/build/utils.js +0 -79
  192. package/dist/cjs/cmds/build/utils.js.map +0 -1
  193. package/dist/cjs/cmds/eval/evalHandler.js +0 -24
  194. package/dist/cjs/cmds/eval/evalHandler.js.map +0 -1
  195. package/dist/cjs/cmds/eval/index.js +0 -31
  196. package/dist/cjs/cmds/eval/index.js.map +0 -1
  197. package/dist/cjs/cmds/index.js.map +0 -1
  198. package/dist/cjs/cmds/manifest/index.js +0 -44
  199. package/dist/cjs/cmds/manifest/index.js.map +0 -1
  200. package/dist/cjs/cmds/manifest/manifestHandler.js +0 -47
  201. package/dist/cjs/cmds/manifest/manifestHandler.js.map +0 -1
  202. package/dist/cjs/cmds/serve/index.js.map +0 -1
  203. package/dist/cjs/cmds/serve/serveHandler.js +0 -62
  204. package/dist/cjs/cmds/serve/serveHandler.js.map +0 -1
  205. package/dist/cjs/cmds/serve/serveUtils.js +0 -37
  206. package/dist/cjs/cmds/serve/serveUtils.js.map +0 -1
  207. package/dist/cjs/cmds/watch/index.js.map +0 -1
  208. package/dist/cjs/cmds/watch/watchHandler.js +0 -91
  209. package/dist/cjs/cmds/watch/watchHandler.js.map +0 -1
  210. package/dist/cjs/utils/misc.js +0 -142
  211. package/dist/cjs/utils/misc.js.map +0 -1
  212. package/dist/cjs/utils/snap-config.js +0 -104
  213. package/dist/cjs/utils/snap-config.js.map +0 -1
  214. package/dist/esm/cmds/build/buildHandler.js +0 -36
  215. package/dist/esm/cmds/build/buildHandler.js.map +0 -1
  216. package/dist/esm/cmds/build/bundle.js +0 -81
  217. package/dist/esm/cmds/build/bundle.js.map +0 -1
  218. package/dist/esm/cmds/build/index.js.map +0 -1
  219. package/dist/esm/cmds/build/utils.js +0 -88
  220. package/dist/esm/cmds/build/utils.js.map +0 -1
  221. package/dist/esm/cmds/eval/evalHandler.js +0 -20
  222. package/dist/esm/cmds/eval/evalHandler.js.map +0 -1
  223. package/dist/esm/cmds/eval/index.js +0 -16
  224. package/dist/esm/cmds/eval/index.js.map +0 -1
  225. package/dist/esm/cmds/index.js +0 -15
  226. package/dist/esm/cmds/index.js.map +0 -1
  227. package/dist/esm/cmds/manifest/index.js +0 -29
  228. package/dist/esm/cmds/manifest/index.js.map +0 -1
  229. package/dist/esm/cmds/manifest/manifestHandler.js +0 -44
  230. package/dist/esm/cmds/manifest/manifestHandler.js.map +0 -1
  231. package/dist/esm/cmds/serve/index.js.map +0 -1
  232. package/dist/esm/cmds/serve/serveHandler.js +0 -54
  233. package/dist/esm/cmds/serve/serveHandler.js.map +0 -1
  234. package/dist/esm/cmds/serve/serveUtils.js +0 -30
  235. package/dist/esm/cmds/serve/serveUtils.js.map +0 -1
  236. package/dist/esm/cmds/watch/index.js.map +0 -1
  237. package/dist/esm/cmds/watch/watchHandler.js +0 -87
  238. package/dist/esm/cmds/watch/watchHandler.js.map +0 -1
  239. package/dist/esm/utils/misc.js +0 -139
  240. package/dist/esm/utils/misc.js.map +0 -1
  241. package/dist/esm/utils/snap-config.js +0 -107
  242. package/dist/esm/utils/snap-config.js.map +0 -1
  243. package/dist/types/cmds/build/buildHandler.d.ts +0 -13
  244. package/dist/types/cmds/build/bundle.d.ts +0 -15
  245. package/dist/types/cmds/build/utils.d.ts +0 -56
  246. package/dist/types/cmds/eval/evalHandler.d.ts +0 -9
  247. package/dist/types/cmds/manifest/manifestHandler.d.ts +0 -10
  248. package/dist/types/cmds/serve/serveHandler.d.ts +0 -10
  249. package/dist/types/cmds/serve/serveUtils.d.ts +0 -22
  250. package/dist/types/cmds/watch/index.d.ts +0 -9
  251. package/dist/types/cmds/watch/watchHandler.d.ts +0 -14
  252. package/dist/types/utils/misc.d.ts +0 -53
  253. package/dist/types/utils/snap-config.d.ts +0 -48
  254. /package/dist/cjs/{cmds → commands}/index.js +0 -0
  255. /package/dist/types/{cmds → commands}/index.d.ts +0 -0
  256. /package/dist/types/{cmds/build → commands/serve}/index.d.ts +0 -0
@@ -5,125 +5,124 @@ export var TranspilationModes;
5
5
  TranspilationModes["None"] = 'none';
6
6
  })(TranspilationModes || (TranspilationModes = {}));
7
7
  const builders = {
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ config: {
10
+ alias: 'c',
11
+ describe: 'Path to config file',
12
+ type: 'string',
13
+ normalize: true
14
+ },
15
+ fix: {
16
+ describe: 'Attempt to fix snap.manifest.json',
17
+ type: 'boolean'
18
+ },
19
+ input: {
20
+ alias: 'i',
21
+ describe: 'Snap bundle file to evaluate',
22
+ type: 'string',
23
+ normalize: true
24
+ },
25
+ // Deprecated Browserify options.
8
26
  bundle: {
9
27
  alias: 'b',
10
28
  describe: 'Snap bundle file',
11
29
  type: 'string',
12
- demandOption: true,
13
30
  normalize: true,
14
- default: 'dist/bundle.js'
31
+ deprecated: 'Use --input instead.'
15
32
  },
16
33
  dist: {
17
34
  alias: 'd',
18
35
  describe: 'Output directory',
19
36
  type: 'string',
20
- demandOption: true,
21
37
  normalize: true,
22
- default: 'dist'
38
+ deprecated: true
23
39
  },
24
40
  eval: {
25
41
  alias: 'e',
26
42
  describe: 'Attempt to evaluate Snap bundle in SES',
27
43
  type: 'boolean',
28
- demandOption: false,
29
- default: true
44
+ deprecated: true
30
45
  },
31
46
  manifest: {
32
47
  alias: 'm',
33
48
  describe: 'Validate snap.manifest.json',
34
49
  type: 'boolean',
35
- demandOption: false,
36
- default: true
50
+ deprecated: true
37
51
  },
38
52
  port: {
39
53
  alias: 'p',
40
54
  describe: 'Local server port for testing',
41
55
  type: 'number',
42
- demandOption: true,
43
- default: 8081,
44
56
  coerce: (arg)=>{
45
57
  const port = Number.parseInt(String(arg), 10);
46
58
  if (Number.isNaN(port)) {
47
- throw new Error(`Invalid port: ${String(arg)}`);
59
+ throw new Error(`Invalid port: "${String(arg)}".`);
48
60
  }
49
61
  return port;
50
- }
62
+ },
63
+ deprecated: true
51
64
  },
52
65
  outfileName: {
53
66
  alias: 'n',
54
67
  describe: 'Output file name',
55
68
  type: 'string',
56
- demandOption: false,
57
- default: 'bundle.js'
69
+ deprecated: true
58
70
  },
59
71
  root: {
60
72
  alias: 'r',
61
73
  describe: 'Server root directory',
62
74
  type: 'string',
63
- demandOption: true,
64
75
  normalize: true,
65
- default: '.'
76
+ deprecated: true
66
77
  },
67
78
  sourceMaps: {
68
79
  describe: 'Whether builds include sourcemaps',
69
80
  type: 'boolean',
70
- demandOption: false,
71
- default: false
81
+ deprecated: true
72
82
  },
73
83
  src: {
74
84
  alias: 's',
75
85
  describe: 'Source file',
76
86
  type: 'string',
77
- demandOption: true,
78
87
  normalize: true,
79
- default: 'src/index.js'
88
+ deprecated: true
80
89
  },
81
90
  stripComments: {
82
91
  alias: 'strip',
83
92
  describe: 'Whether to remove code comments from the build output',
84
93
  type: 'boolean',
85
- demandOption: false,
86
- default: true
94
+ deprecated: true
87
95
  },
88
96
  suppressWarnings: {
89
97
  type: 'boolean',
90
98
  describe: 'Whether to suppress warnings',
91
- demandOption: false,
92
- default: false
99
+ deprecated: true
93
100
  },
94
101
  transpilationMode: {
95
102
  type: 'string',
96
- describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing.',
97
- demandOption: false,
98
- default: TranspilationModes.LocalOnly,
99
- choices: Object.values(TranspilationModes)
103
+ describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',
104
+ choices: Object.values(TranspilationModes),
105
+ deprecated: true
100
106
  },
101
107
  depsToTranspile: {
102
108
  type: 'array',
103
109
  describe: 'Transpile only the listed dependencies.',
104
- demandOption: false
110
+ deprecated: true
105
111
  },
106
112
  verboseErrors: {
107
113
  type: 'boolean',
108
114
  describe: 'Display original errors',
109
- demandOption: false,
110
- default: true
115
+ deprecated: true
111
116
  },
112
117
  writeManifest: {
113
- describe: 'Make necessary changes to the Snap manifest file',
118
+ describe: 'Make necessary changes to the snap manifest file',
114
119
  type: 'boolean',
115
- demandOption: false,
116
- default: true
120
+ deprecated: true
117
121
  },
118
122
  serve: {
119
- describe: 'Serve Snap file(s) locally for testing',
123
+ describe: 'Serve snap file(s) locally for testing',
120
124
  type: 'boolean',
121
- demandOption: false,
122
- default: true
123
- },
124
- directory: {
125
- describe: 'the directory to use',
126
- type: 'string'
125
+ deprecated: true
127
126
  }
128
127
  };
129
128
  export default builders;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/builders.ts"],"sourcesContent":["import type { Options, PositionalOptions } from 'yargs';\n\nexport type SnapsCliBuilders = {\n readonly bundle: Readonly<Options>;\n readonly dist: Readonly<Options>;\n readonly eval: Readonly<Options>;\n readonly manifest: Readonly<Options>;\n readonly outfileName: Readonly<Options>;\n readonly port: Readonly<Options>;\n readonly root: Readonly<Options>;\n readonly sourceMaps: Readonly<Options>;\n readonly src: Readonly<Options>;\n readonly stripComments: Readonly<Options>;\n readonly suppressWarnings: Readonly<Options>;\n readonly transpilationMode: Readonly<Options>;\n readonly depsToTranspile: Readonly<Options>;\n readonly verboseErrors: Readonly<Options>;\n readonly writeManifest: Readonly<Options>;\n readonly serve: Readonly<Options>;\n readonly directory: Readonly<PositionalOptions>;\n};\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders: SnapsCliBuilders = {\n bundle: {\n alias: 'b',\n describe: 'Snap bundle file',\n type: 'string',\n demandOption: true,\n normalize: true,\n default: 'dist/bundle.js',\n },\n\n dist: {\n alias: 'd',\n describe: 'Output directory',\n type: 'string',\n demandOption: true,\n normalize: true,\n default: 'dist',\n },\n\n eval: {\n alias: 'e',\n describe: 'Attempt to evaluate Snap bundle in SES',\n type: 'boolean',\n demandOption: false,\n default: true,\n },\n\n manifest: {\n alias: 'm',\n describe: 'Validate snap.manifest.json',\n type: 'boolean',\n demandOption: false,\n default: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n demandOption: true,\n default: 8081,\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 return port;\n },\n },\n\n outfileName: {\n alias: 'n',\n describe: 'Output file name',\n type: 'string',\n demandOption: false,\n default: 'bundle.js',\n },\n\n root: {\n alias: 'r',\n describe: 'Server root directory',\n type: 'string',\n demandOption: true,\n normalize: true,\n default: '.',\n },\n\n sourceMaps: {\n describe: 'Whether builds include sourcemaps',\n type: 'boolean',\n demandOption: false,\n default: false,\n },\n\n src: {\n alias: 's',\n describe: 'Source file',\n type: 'string',\n demandOption: true,\n normalize: true,\n default: 'src/index.js',\n },\n\n stripComments: {\n alias: 'strip',\n describe: 'Whether to remove code comments from the build output',\n type: 'boolean',\n demandOption: false,\n default: true,\n },\n\n suppressWarnings: {\n type: 'boolean',\n describe: 'Whether to suppress warnings',\n demandOption: false,\n default: false,\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 demandOption: false,\n default: TranspilationModes.LocalOnly,\n choices: Object.values(TranspilationModes),\n },\n\n depsToTranspile: {\n type: 'array',\n describe: 'Transpile only the listed dependencies.',\n demandOption: false,\n },\n\n verboseErrors: {\n type: 'boolean',\n describe: 'Display original errors',\n demandOption: false,\n default: true,\n },\n\n writeManifest: {\n describe: 'Make necessary changes to the Snap manifest file',\n type: 'boolean',\n demandOption: false,\n default: true,\n },\n\n serve: {\n describe: 'Serve Snap file(s) locally for testing',\n type: 'boolean',\n demandOption: false,\n default: true,\n },\n\n directory: {\n describe: 'the directory to use',\n type: 'string',\n },\n};\n\nexport default builders;\n"],"names":["TranspilationModes","LocalAndDeps","LocalOnly","None","builders","bundle","alias","describe","type","demandOption","normalize","default","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","directory"],"mappings":"WAsBO;UAAKA,kBAAkB;IAAlBA,mBACVC,kBAAe;IADLD,mBAEVE,eAAY;IAFFF,mBAGVG,UAAO;GAHGH,uBAAAA;AAMZ,MAAMI,WAA6B;IACjCC,QAAQ;QACNC,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdC,WAAW;QACXC,SAAS;IACX;IAEAC,MAAM;QACJN,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdC,WAAW;QACXC,SAAS;IACX;IAEAE,MAAM;QACJP,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAG,UAAU;QACRR,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAI,MAAM;QACJT,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;QACTK,QAAQ,CAACC;YACP,MAAMF,OAAOG,OAAOC,QAAQ,CAACC,OAAOH,MAAM;YAC1C,IAAIC,OAAOG,KAAK,CAACN,OAAO;gBACtB,MAAM,IAAIO,MAAM,CAAC,cAAc,EAAEF,OAAOH,KAAK,CAAC;YAChD;YACA,OAAOF;QACT;IACF;IAEAQ,aAAa;QACXjB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAa,MAAM;QACJlB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdC,WAAW;QACXC,SAAS;IACX;IAEAc,YAAY;QACVlB,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAe,KAAK;QACHpB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdC,WAAW;QACXC,SAAS;IACX;IAEAgB,eAAe;QACbrB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAiB,kBAAkB;QAChBpB,MAAM;QACND,UAAU;QACVE,cAAc;QACdE,SAAS;IACX;IAEAkB,mBAAmB;QACjBrB,MAAM;QACND,UACE;QACFE,cAAc;QACdE,SAASX,mBAAmBE,SAAS;QACrC4B,SAASC,OAAOC,MAAM,CAAChC;IACzB;IAEAiC,iBAAiB;QACfzB,MAAM;QACND,UAAU;QACVE,cAAc;IAChB;IAEAyB,eAAe;QACb1B,MAAM;QACND,UAAU;QACVE,cAAc;QACdE,SAAS;IACX;IAEAwB,eAAe;QACb5B,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEAyB,OAAO;QACL7B,UAAU;QACVC,MAAM;QACNC,cAAc;QACdE,SAAS;IACX;IAEA0B,WAAW;QACT9B,UAAU;QACVC,MAAM;IACR;AACF;AAEA,eAAeJ,SAAS"}
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":"WAEO;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;AAEA,eAAeT,SAAS"}
package/dist/esm/cli.js CHANGED
@@ -1,26 +1,26 @@
1
1
  import yargs from 'yargs';
2
+ import { hideBin } from 'yargs/helpers';
2
3
  import builders from './builders';
3
- import { applyConfig, loadConfig, sanitizeInputs, setSnapGlobals, logError } from './utils';
4
+ import { getConfigByArgv } from './config';
5
+ import { error, getYargsErrorMessage, sanitizeInputs } from './utils';
4
6
  /**
5
7
  * The main CLI entry point function. This processes the command line args, and
6
8
  * runs the appropriate function.
7
9
  *
8
10
  * @param argv - The raw command line arguments, i.e., `process.argv`.
9
11
  * @param commands - The list of commands to use.
10
- */ export function cli(argv, commands) {
11
- const rawArgv = argv.slice(2);
12
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-floating-promises
13
- yargs(rawArgv).scriptName('mm-snap').usage('Usage: $0 <command> [options]').example('$0 init', `\tInitialize a snap project in the current directory`).example('$0 init my-snap', `\tInitialize a snap project in the 'my-snap' directory`).example('$0 build -s src/index.js -d out', `\tBuild 'src/index.js' as './out/bundle.js'`).example('$0 build -s src/index.js -d out -n snap.js', `\tBuild 'src/index.js' as './out/snap.js'`).example('$0 serve -r out', `\tServe files in './out' on port 8080`).example('$0 serve -r out -p 9000', `\tServe files in './out' on port 9000`).example('$0 watch -s src/index.js -d out', `\tRebuild './out/bundle.js' on changes to files in 'src/index.js' parent and child directories`).command(commands).option('verboseErrors', builders.verboseErrors).option('suppressWarnings', builders.suppressWarnings).strict()// Typecast: The @types/yargs type for .middleware is incorrect.
14
- // yargs middleware functions receive the yargs instance as a second parameter.
15
- // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation
16
- .middleware((yargsArgv, yargsInstance)=>{
17
- applyConfig(loadConfig(), rawArgv, yargsArgv, yargsInstance);
18
- setSnapGlobals(yargsArgv);
19
- sanitizeInputs(yargsArgv);
20
- }, true).fail((message, error, _yargs)=>{
21
- logError(message, error);
22
- process.exitCode = 1;
23
- }).demandCommand(1, 'You must specify at least one command.').help().alias('help', 'h').argv;
12
+ */ export async function cli(argv, commands) {
13
+ await yargs(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.config).option('verboseErrors', builders.verboseErrors).option('suppressWarnings', builders.suppressWarnings).strict().middleware(async (args)=>{
14
+ // eslint-disable-next-line require-atomic-updates
15
+ args.context = {
16
+ config: await getConfigByArgv(args)
17
+ };
18
+ sanitizeInputs(args);
19
+ }, false).demandCommand(1, 'You must specify at least one command.').fail((message, failure)=>{
20
+ error(getYargsErrorMessage(message, failure));
21
+ // eslint-disable-next-line n/no-process-exit
22
+ process.exit(1);
23
+ }).help().alias('help', 'h').parseAsync();
24
24
  }
25
25
 
26
26
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import type { Arguments } from 'yargs';\nimport yargs from 'yargs';\nimport type yargsType from 'yargs/yargs';\n\nimport builders from './builders';\nimport {\n applyConfig,\n loadConfig,\n sanitizeInputs,\n setSnapGlobals,\n logError,\n} 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 function cli(argv: string[], commands: any): void {\n const rawArgv = argv.slice(2);\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-floating-promises\n yargs(rawArgv)\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 init', `\\tInitialize a snap project in the current directory`)\n .example(\n '$0 init my-snap',\n `\\tInitialize a snap project in the 'my-snap' directory`,\n )\n .example(\n '$0 build -s src/index.js -d out',\n `\\tBuild 'src/index.js' as './out/bundle.js'`,\n )\n .example(\n '$0 build -s src/index.js -d out -n snap.js',\n `\\tBuild 'src/index.js' as './out/snap.js'`,\n )\n .example('$0 serve -r out', `\\tServe files in './out' on port 8080`)\n .example('$0 serve -r out -p 9000', `\\tServe files in './out' on port 9000`)\n .example(\n '$0 watch -s src/index.js -d out',\n `\\tRebuild './out/bundle.js' on changes to files in 'src/index.js' parent and child directories`,\n )\n\n .command(commands)\n\n .option('verboseErrors', builders.verboseErrors)\n\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n // Typecast: The @types/yargs type for .middleware is incorrect.\n // yargs middleware functions receive the yargs instance as a second parameter.\n // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation\n .middleware(\n ((yargsArgv: Arguments, yargsInstance: typeof yargsType) => {\n applyConfig(loadConfig(), rawArgv, yargsArgv, yargsInstance);\n setSnapGlobals(yargsArgv);\n sanitizeInputs(yargsArgv);\n }) as any,\n true,\n )\n\n .fail((message: string, error: Error, _yargs) => {\n logError(message, error);\n process.exitCode = 1;\n })\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .help()\n .alias('help', 'h').argv;\n}\n"],"names":["yargs","builders","applyConfig","loadConfig","sanitizeInputs","setSnapGlobals","logError","cli","argv","commands","rawArgv","slice","scriptName","usage","example","command","option","verboseErrors","suppressWarnings","strict","middleware","yargsArgv","yargsInstance","fail","message","error","_yargs","process","exitCode","demandCommand","help","alias"],"mappings":"AACA,OAAOA,WAAW,QAAQ;AAG1B,OAAOC,cAAc,aAAa;AAClC,SACEC,WAAW,EACXC,UAAU,EACVC,cAAc,EACdC,cAAc,EACdC,QAAQ,QACH,UAAU;AAEjB;;;;;;CAMC,GACD,OAAO,SAASC,IAAIC,IAAc,EAAEC,QAAa;IAC/C,MAAMC,UAAUF,KAAKG,KAAK,CAAC;IAC3B,6GAA6G;IAC7GX,MAAMU,SACHE,UAAU,CAAC,WACXC,KAAK,CAAC,iCAENC,OAAO,CAAC,WAAW,CAAC,oDAAoD,CAAC,EACzEA,OAAO,CACN,mBACA,CAAC,sDAAsD,CAAC,EAEzDA,OAAO,CACN,mCACA,CAAC,2CAA2C,CAAC,EAE9CA,OAAO,CACN,8CACA,CAAC,yCAAyC,CAAC,EAE5CA,OAAO,CAAC,mBAAmB,CAAC,qCAAqC,CAAC,EAClEA,OAAO,CAAC,2BAA2B,CAAC,qCAAqC,CAAC,EAC1EA,OAAO,CACN,mCACA,CAAC,8FAA8F,CAAC,EAGjGC,OAAO,CAACN,UAERO,MAAM,CAAC,iBAAiBf,SAASgB,aAAa,EAE9CD,MAAM,CAAC,oBAAoBf,SAASiB,gBAAgB,EAEpDC,MAAM,EAEP,gEAAgE;IAChE,+EAA+E;IAC/E,0FAA0F;KACzFC,UAAU,CACR,CAACC,WAAsBC;QACtBpB,YAAYC,cAAcO,SAASW,WAAWC;QAC9CjB,eAAegB;QACfjB,eAAeiB;IACjB,GACA,MAGDE,IAAI,CAAC,CAACC,SAAiBC,OAAcC;QACpCpB,SAASkB,SAASC;QAClBE,QAAQC,QAAQ,GAAG;IACrB,GAECC,aAAa,CAAC,GAAG,0CAEjBC,IAAI,GACJC,KAAK,CAAC,QAAQ,KAAKvB,IAAI;AAC5B"}
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":["yargs","hideBin","builders","getConfigByArgv","error","getYargsErrorMessage","sanitizeInputs","cli","argv","commands","scriptName","usage","example","command","option","config","verboseErrors","suppressWarnings","strict","middleware","args","context","demandCommand","fail","message","failure","process","exit","help","alias","parseAsync"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,gBAAgB;AAExC,OAAOC,cAAc,aAAa;AAClC,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,KAAK,EAAEC,oBAAoB,EAAEC,cAAc,QAAQ,UAAU;AAEtE;;;;;;CAMC,GACD,OAAO,eAAeC,IAAIC,IAAc,EAAEC,QAAa;IACrD,MAAMT,MAAMC,QAAQO,OACjBE,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,CAACJ,UAERK,MAAM,CAAC,UAAUZ,SAASa,MAAM,EAChCD,MAAM,CAAC,iBAAiBZ,SAASc,aAAa,EAC9CF,MAAM,CAAC,oBAAoBZ,SAASe,gBAAgB,EAEpDC,MAAM,GAENC,UAAU,CAAC,OAAOC;QACjB,kDAAkD;QAClDA,KAAKC,OAAO,GAAG;YACbN,QAAQ,MAAMZ,gBAAgBiB;QAChC;QAEAd,eAAec;IACjB,GAAG,OAEFE,aAAa,CAAC,GAAG,0CAEjBC,IAAI,CAAC,CAACC,SAASC;QACdrB,MAAMC,qBAAqBmB,SAASC;QACpC,6CAA6C;QAC7CC,QAAQC,IAAI,CAAC;IACf,GAECC,IAAI,GACJC,KAAK,CAAC,QAAQ,KACdC,UAAU;AACf"}
@@ -0,0 +1,51 @@
1
+ import { isFile } from '@metamask/snaps-utils';
2
+ import { resolve as pathResolve } from 'path';
3
+ import { CommandError } from '../../errors';
4
+ import { executeSteps, info } from '../../utils';
5
+ import { evaluate } from '../eval';
6
+ import { build } from './implementation';
7
+ const steps = [
8
+ {
9
+ name: 'Checking the input file.',
10
+ task: async ({ config })=>{
11
+ const { input } = config;
12
+ if (!await isFile(input)) {
13
+ throw new CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
14
+ }
15
+ }
16
+ },
17
+ {
18
+ name: 'Building the snap bundle.',
19
+ task: async ({ config, spinner })=>{
20
+ // We don't evaluate the bundle here, because it's done in a separate
21
+ // step.
22
+ return await build(config, {
23
+ evaluate: false,
24
+ spinner
25
+ });
26
+ }
27
+ },
28
+ {
29
+ name: 'Evaluating the snap bundle.',
30
+ condition: ({ config })=>config.evaluate,
31
+ task: async ({ config, spinner })=>{
32
+ const path = pathResolve(process.cwd(), config.output.path, config.output.filename);
33
+ await evaluate(path);
34
+ info(`Snap bundle evaluated successfully.`, spinner);
35
+ }
36
+ }
37
+ ];
38
+ /**
39
+ * Build all files in the given source directory to the given destination
40
+ * directory.
41
+ *
42
+ * This creates the destination directory if it doesn't exist.
43
+ *
44
+ * @param config - The config object.
45
+ */ export async function buildHandler(config) {
46
+ return await executeSteps(steps, {
47
+ config
48
+ });
49
+ }
50
+
51
+ //# 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":["isFile","resolve","pathResolve","CommandError","executeSteps","info","evaluate","build","steps","name","task","config","input","spinner","condition","path","process","cwd","output","filename","buildHandler"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,WAAWC,WAAW,QAAQ,OAAO;AAG9C,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,YAAY,EAAEC,IAAI,QAAQ,cAAc;AACjD,SAASC,QAAQ,QAAQ,UAAU;AACnC,SAASC,KAAK,QAAQ,mBAAmB;AAMzC,MAAMC,QAA6B;IACjC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAE;YACrB,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAElB,IAAI,CAAE,MAAMX,OAAOY,QAAS;gBAC1B,MAAM,IAAIT,aACR,CAAC,uBAAuB,EAAES,MAAM,mEAAmE,CAAC;YAExG;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAE;YAC9B,qEAAqE;YACrE,QAAQ;YACR,OAAO,MAAMN,MAAMI,QAAQ;gBAAEL,UAAU;gBAAOO;YAAQ;QACxD;IACF;IACA;QACEJ,MAAM;QACNK,WAAW,CAAC,EAAEH,MAAM,EAAE,GAAKA,OAAOL,QAAQ;QAC1CI,MAAM,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAE;YAC9B,MAAME,OAAOb,YACXc,QAAQC,GAAG,IACXN,OAAOO,MAAM,CAACH,IAAI,EAClBJ,OAAOO,MAAM,CAACC,QAAQ;YAGxB,MAAMb,SAASS;YAEfV,KAAK,CAAC,mCAAmC,CAAC,EAAEQ;QAC9C;IACF;CACD;AAED;;;;;;;CAOC,GACD,OAAO,eAAeO,aAAaT,MAAuB;IACxD,OAAO,MAAMP,aAAaI,OAAO;QAC/BG;IACF;AACF"}
@@ -0,0 +1,27 @@
1
+ import { getCompiler } from '../../webpack';
2
+ /**
3
+ * Build the snap bundle. This uses Webpack to build the bundle.
4
+ *
5
+ * @param config - The config object.
6
+ * @param options - The Webpack options.
7
+ * @returns A promise that resolves when the bundle is built.
8
+ */ export async function build(config, options) {
9
+ const compiler = await getCompiler(config, options);
10
+ return await new Promise((resolve, reject)=>{
11
+ compiler.run((runError)=>{
12
+ if (runError) {
13
+ reject(runError);
14
+ return;
15
+ }
16
+ compiler.close((closeError)=>{
17
+ if (closeError) {
18
+ reject(closeError);
19
+ return;
20
+ }
21
+ resolve();
22
+ });
23
+ });
24
+ });
25
+ }
26
+
27
+ //# 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":["getCompiler","build","config","options","compiler","Promise","resolve","reject","run","runError","close","closeError"],"mappings":"AAEA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C;;;;;;CAMC,GACD,OAAO,eAAeC,MACpBC,MAA8B,EAC9BC,OAAwB;IAExB,MAAMC,WAAW,MAAMJ,YAAYE,QAAQC;IAC3C,OAAO,MAAM,IAAIE,QAAc,CAACC,SAASC;QACvCH,SAASI,GAAG,CAAC,CAACC;YACZ,IAAIA,UAAU;gBACZF,OAAOE;gBACP;YACF;YAEAL,SAASM,KAAK,CAAC,CAACC;gBACd,IAAIA,YAAY;oBACdJ,OAAOI;oBACP;gBACF;gBAEAL;YACF;QACF;IACF;AACF"}
@@ -1,17 +1,17 @@
1
1
  import builders from '../../builders';
2
- import { build } from './buildHandler';
3
- import { processInvalidTranspilation } from './utils';
2
+ import { buildHandler } from './build';
4
3
  const command = {
5
4
  command: [
6
5
  'build',
7
6
  'b'
8
7
  ],
9
- desc: 'Build Snap from source',
8
+ desc: 'Build snap from source',
10
9
  builder: (yarg)=>{
11
- yarg.option('dist', builders.dist).option('eval', builders.eval).option('manifest', builders.manifest).option('outfileName', builders.outfileName).option('sourceMaps', builders.sourceMaps).option('src', builders.src).option('stripComments', builders.stripComments).option('transpilationMode', builders.transpilationMode).option('depsToTranspile', builders.depsToTranspile).option('writeManifest', builders.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode').middleware((argv)=>processInvalidTranspilation(argv));
10
+ yarg.option('dist', builders.dist).option('eval', builders.eval).option('manifest', builders.manifest).option('outfileName', builders.outfileName).option('sourceMaps', builders.sourceMaps).option('src', builders.src).option('stripComments', builders.stripComments).option('transpilationMode', builders.transpilationMode).option('depsToTranspile', builders.depsToTranspile).option('writeManifest', builders.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode');
12
11
  },
13
- handler: async (argv)=>build(argv)
12
+ handler: async (argv)=>buildHandler(argv.context.config)
14
13
  };
14
+ export * from './implementation';
15
15
  export default command;
16
16
 
17
17
  //# 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":["builders","buildHandler","command","desc","builder","yarg","option","dist","eval","manifest","outfileName","sourceMaps","src","stripComments","transpilationMode","depsToTranspile","writeManifest","implies","handler","argv","context","config"],"mappings":"AAEA,OAAOA,cAAc,iBAAiB;AAEtC,SAASC,YAAY,QAAQ,UAAU;AAEvC,MAAMC,UAAU;IACdA,SAAS;QAAC;QAAS;KAAI;IACvBC,MAAM;IACNC,SAAS,CAACC;QACRA,KACGC,MAAM,CAAC,QAAQN,SAASO,IAAI,EAC5BD,MAAM,CAAC,QAAQN,SAASQ,IAAI,EAC5BF,MAAM,CAAC,YAAYN,SAASS,QAAQ,EACpCH,MAAM,CAAC,eAAeN,SAASU,WAAW,EAC1CJ,MAAM,CAAC,cAAcN,SAASW,UAAU,EACxCL,MAAM,CAAC,OAAON,SAASY,GAAG,EAC1BN,MAAM,CAAC,iBAAiBN,SAASa,aAAa,EAC9CP,MAAM,CAAC,qBAAqBN,SAASc,iBAAiB,EACtDR,MAAM,CAAC,mBAAmBN,SAASe,eAAe,EAClDT,MAAM,CAAC,iBAAiBN,SAASgB,aAAa,EAC9CC,OAAO,CAAC,iBAAiB,YACzBA,OAAO,CAAC,mBAAmB;IAChC;IACAC,SAAS,OAAOC,OAAoBlB,aAAakB,KAAKC,OAAO,CAACC,MAAM;AACtE;AAEA,cAAc,mBAAmB;AACjC,eAAenB,QAAQ"}
@@ -0,0 +1,54 @@
1
+ import { isFile } from '@metamask/snaps-utils';
2
+ import { resolve } from 'path';
3
+ import { CommandError } from '../../errors';
4
+ import { executeSteps, getRelativePath } from '../../utils';
5
+ import { evaluate } from './implementation';
6
+ const steps = [
7
+ {
8
+ name: 'Checking the input file.',
9
+ task: async ({ input })=>{
10
+ if (!await isFile(input)) {
11
+ const relativePath = getRelativePath(input);
12
+ throw new CommandError(`Input file not found: "${relativePath}". Make sure that the "input" field in your snap config or the specified input file is correct.`);
13
+ }
14
+ }
15
+ },
16
+ {
17
+ name: 'Evaluating the snap bundle.',
18
+ task: async ({ input, spinner })=>{
19
+ await evaluate(input);
20
+ spinner.succeed('Snap bundle evaluated successfully.');
21
+ }
22
+ }
23
+ ];
24
+ /**
25
+ * Returns the path to the bundle, based on the config and options.
26
+ *
27
+ * - If `options.input` is specified, it is used as the bundle path.
28
+ * - Otherwise, the bundle path is resolved from the config's output path and
29
+ * filename.
30
+ *
31
+ * @param config - The processed config object.
32
+ * @param options - The eval options.
33
+ * @returns The path to the bundle.
34
+ */ function getBundlePath(config, options) {
35
+ if (options.input) {
36
+ return resolve(process.cwd(), options.input);
37
+ }
38
+ return resolve(config.output.path, config.output.filename);
39
+ }
40
+ /**
41
+ * Runs the snap in a worker, to ensure SES compatibility.
42
+ *
43
+ * @param config - The processed config object.
44
+ * @param options - The eval options.
45
+ * @returns A promise that resolves once the eval has finished.
46
+ * @throws If the eval failed.
47
+ */ export async function evaluateHandler(config, options = {}) {
48
+ const input = getBundlePath(config, options);
49
+ await executeSteps(steps, {
50
+ input
51
+ });
52
+ }
53
+
54
+ //# 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":["isFile","resolve","CommandError","executeSteps","getRelativePath","evaluate","steps","name","task","input","relativePath","spinner","succeed","getBundlePath","config","options","process","cwd","output","path","filename","evaluateHandler"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,OAAO;AAG/B,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,YAAY,EAAEC,eAAe,QAAQ,cAAc;AAC5D,SAASC,QAAQ,QAAQ,mBAAmB;AAQ5C,MAAMC,QAA4B;IAChC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAE;YACpB,IAAI,CAAE,MAAMT,OAAOS,QAAS;gBAC1B,MAAMC,eAAeN,gBAAgBK;gBACrC,MAAM,IAAIP,aACR,CAAC,uBAAuB,EAAEQ,aAAa,+FAA+F,CAAC;YAE3I;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAEE,OAAO,EAAE;YAC7B,MAAMN,SAASI;YACfE,QAAQC,OAAO,CAAC;QAClB;IACF;CACD;AAED;;;;;;;;;;CAUC,GACD,SAASC,cAAcC,MAAuB,EAAEC,OAAoB;IAClE,IAAIA,QAAQN,KAAK,EAAE;QACjB,OAAOR,QAAQe,QAAQC,GAAG,IAAIF,QAAQN,KAAK;IAC7C;IAEA,OAAOR,QAAQa,OAAOI,MAAM,CAACC,IAAI,EAAEL,OAAOI,MAAM,CAACE,QAAQ;AAC3D;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,gBACpBP,MAAuB,EACvBC,UAAuB,CAAC,CAAC;IAEzB,MAAMN,QAAQI,cAAcC,QAAQC;IACpC,MAAMZ,aAAaG,OAAO;QAAEG;IAAM;AACpC"}
@@ -0,0 +1,24 @@
1
+ import { evalBundle, SnapEvalError, indent } from '@metamask/snaps-utils';
2
+ import { red } from 'chalk';
3
+ import { CommandError } from '../../errors';
4
+ /**
5
+ * Evaluate the given bundle in the SES environment. This is a wrapper around
6
+ * {@link evalBundle} that throws a {@link CommandError} if the bundle cannot be
7
+ * evaluated.
8
+ *
9
+ * @param path - The path to the bundle.
10
+ * @throws If the bundle cannot be evaluated.
11
+ */ export async function evaluate(path) {
12
+ try {
13
+ return await evalBundle(path);
14
+ } catch (evalError) {
15
+ if (evalError instanceof SnapEvalError) {
16
+ throw new 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${indent(red(evalError.output.stderr), 2)}`);
17
+ }
18
+ // If the error is not a `SnapEvalError`, we don't know what it is, so
19
+ // we just throw it.
20
+ throw evalError;
21
+ }
22
+ }
23
+
24
+ //# 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":["evalBundle","SnapEvalError","indent","red","CommandError","evaluate","path","evalError","output","stderr"],"mappings":"AAAA,SAASA,UAAU,EAAEC,aAAa,EAAEC,MAAM,QAAQ,wBAAwB;AAC1E,SAASC,GAAG,QAAQ,QAAQ;AAE5B,SAASC,YAAY,QAAQ,eAAe;AAE5C;;;;;;;CAOC,GACD,OAAO,eAAeC,SAASC,IAAY;IACzC,IAAI;QACF,OAAO,MAAMN,WAAWM;IAC1B,EAAE,OAAOC,WAAW;QAClB,IAAIA,qBAAqBN,eAAe;YACtC,MAAM,IAAIG,aACR,CAAC,kLAAkL,EAAEF,OACnLC,IAAII,UAAUC,MAAM,CAACC,MAAM,GAC3B,GACA,CAAC;QAEP;QAEA,sEAAsE;QACtE,oBAAoB;QACpB,MAAMF;IACR;AACF"}
@@ -0,0 +1,22 @@
1
+ import builders from '../../builders';
2
+ import { evaluateHandler } from './eval';
3
+ const command = {
4
+ command: [
5
+ 'eval',
6
+ 'e'
7
+ ],
8
+ desc: 'Attempt to evaluate snap bundle in SES',
9
+ builder: (yarg)=>{
10
+ // Browserify options. These are merged into the config object.
11
+ yarg.option('bundle', builders.bundle);
12
+ // Webpack options.
13
+ yarg.option('input', builders.input);
14
+ },
15
+ handler: async (argv)=>evaluateHandler(argv.context.config, {
16
+ input: argv.input
17
+ })
18
+ };
19
+ export * from './implementation';
20
+ export default command;
21
+
22
+ //# 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":["builders","evaluateHandler","command","desc","builder","yarg","option","bundle","input","handler","argv","context","config"],"mappings":"AAEA,OAAOA,cAAc,iBAAiB;AAEtC,SAASC,eAAe,QAAQ,SAAS;AAEzC,MAAMC,UAAU;IACdA,SAAS;QAAC;QAAQ;KAAI;IACtBC,MAAM;IACNC,SAAS,CAACC;QACR,+DAA+D;QAC/DA,KAAKC,MAAM,CAAC,UAAUN,SAASO,MAAM;QAErC,mBAAmB;QACnBF,KAAKC,MAAM,CAAC,SAASN,SAASQ,KAAK;IACrC;IACAC,SAAS,OAAOC,OACdT,gBAAgBS,KAAKC,OAAO,CAACC,MAAM,EAAE;YAAEJ,OAAOE,KAAKF,KAAK;QAAC;AAC7D;AAEA,cAAc,mBAAmB;AACjC,eAAeN,QAAQ"}
@@ -0,0 +1,15 @@
1
+ import buildCommand from './build';
2
+ import evaluateCommand from './eval';
3
+ import manifestCommand from './manifest';
4
+ import serveCommand from './serve';
5
+ import watchCommand from './watch';
6
+ const commands = [
7
+ buildCommand,
8
+ evaluateCommand,
9
+ manifestCommand,
10
+ serveCommand,
11
+ watchCommand
12
+ ];
13
+ export default commands;
14
+
15
+ //# 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":["buildCommand","evaluateCommand","manifestCommand","serveCommand","watchCommand","commands"],"mappings":"AAAA,OAAOA,kBAAkB,UAAU;AACnC,OAAOC,qBAAqB,SAAS;AACrC,OAAOC,qBAAqB,aAAa;AACzC,OAAOC,kBAAkB,UAAU;AACnC,OAAOC,kBAAkB,UAAU;AAEnC,MAAMC,WAAW;IACfL;IACAC;IACAC;IACAC;IACAC;CACD;AAED,eAAeC,SAAS"}
@@ -0,0 +1,33 @@
1
+ import { checkManifest, indent } from '@metamask/snaps-utils';
2
+ import { red, yellow } from 'chalk';
3
+ import { dirname } from 'path';
4
+ import { error, info, warn } from '../../utils';
5
+ /**
6
+ * Check the snap manifest file at the given path. If `write` is `true`, the
7
+ * manifest will be written to disk if it is invalid. If `write` is `false`,
8
+ * the manifest will not be written to disk, and the function will log any
9
+ * errors and warnings to the console.
10
+ *
11
+ * @param path - The path to the manifest file.
12
+ * @param write - Whether to write the manifest to disk if it is invalid.
13
+ * @param spinner - An optional spinner to use for logging.
14
+ */ export async function manifest(path, write, spinner) {
15
+ const { warnings, errors, updated } = await checkManifest(dirname(path), write);
16
+ if (write && updated) {
17
+ info('The snap manifest file has been updated.', spinner);
18
+ }
19
+ if (!write && errors.length > 0) {
20
+ const formattedErrors = errors.map((manifestError)=>indent(red(`• ${manifestError}`))).join('\n');
21
+ 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);
22
+ spinner?.stop();
23
+ process.exitCode = 1;
24
+ return false;
25
+ }
26
+ if (warnings.length > 0) {
27
+ const formattedWarnings = warnings.map((manifestWarning)=>indent(yellow(`• ${manifestWarning}`)));
28
+ warn(`The snap manifest file has warnings.\n\n${formattedWarnings.join('\n')}`, spinner);
29
+ }
30
+ return true;
31
+ }
32
+
33
+ //# 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":["checkManifest","indent","red","yellow","dirname","error","info","warn","manifest","path","write","spinner","warnings","errors","updated","length","formattedErrors","map","manifestError","join","stop","process","exitCode","formattedWarnings","manifestWarning"],"mappings":"AAAA,SAASA,aAAa,EAAEC,MAAM,QAAQ,wBAAwB;AAC9D,SAASC,GAAG,EAAEC,MAAM,QAAQ,QAAQ;AAEpC,SAASC,OAAO,QAAQ,OAAO;AAE/B,SAASC,KAAK,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAEhD;;;;;;;;;CASC,GACD,OAAO,eAAeC,SACpBC,IAAY,EACZC,KAAc,EACdC,OAAa;IAEb,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMd,cAC1CI,QAAQK,OACRC;IAGF,IAAIA,SAASI,SAAS;QACpBR,KAAK,4CAA4CK;IACnD;IAEA,IAAI,CAACD,SAASG,OAAOE,MAAM,GAAG,GAAG;QAC/B,MAAMC,kBAAkBH,OACrBI,GAAG,CAAC,CAACC,gBAAkBjB,OAAOC,IAAI,CAAC,EAAE,EAAEgB,cAAc,CAAC,IACtDC,IAAI,CAAC;QAERd,MACE,CAAC,sCAAsC,EAAEW,gBAAgB,2EAA2E,CAAC,EACrIL;QAGFA,SAASS;QACTC,QAAQC,QAAQ,GAAG;QACnB,OAAO;IACT;IAEA,IAAIV,SAASG,MAAM,GAAG,GAAG;QACvB,MAAMQ,oBAAoBX,SAASK,GAAG,CAAC,CAACO,kBACtCvB,OAAOE,OAAO,CAAC,EAAE,EAAEqB,gBAAgB,CAAC;QAGtCjB,KACE,CAAC,wCAAwC,EAAEgB,kBAAkBJ,IAAI,CAAC,MAAM,CAAC,EACzER;IAEJ;IAEA,OAAO;AACT"}
@@ -0,0 +1,22 @@
1
+ import builders from '../../builders';
2
+ import { manifestHandler } from './manifest';
3
+ const command = {
4
+ command: [
5
+ 'manifest',
6
+ 'm'
7
+ ],
8
+ desc: 'Validate the snap.manifest.json file',
9
+ builder: (yarg)=>{
10
+ // Browserify options. These are merged into the config object.
11
+ yarg.option('writeManifest', builders.writeManifest);
12
+ // Webpack options.
13
+ yarg.option('fix', builders.fix);
14
+ },
15
+ handler: async (argv)=>manifestHandler(argv.context.config, {
16
+ fix: argv.fix
17
+ })
18
+ };
19
+ export * from './implementation';
20
+ export default command;
21
+
22
+ //# sourceMappingURL=index.js.map