@metamask/snaps-cli 0.37.1-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 -431
  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
@@ -23,125 +23,124 @@ var TranspilationModes;
23
23
  TranspilationModes["None"] = 'none';
24
24
  })(TranspilationModes || (TranspilationModes = {}));
25
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.
26
44
  bundle: {
27
45
  alias: 'b',
28
46
  describe: 'Snap bundle file',
29
47
  type: 'string',
30
- demandOption: true,
31
48
  normalize: true,
32
- default: 'dist/bundle.js'
49
+ deprecated: 'Use --input instead.'
33
50
  },
34
51
  dist: {
35
52
  alias: 'd',
36
53
  describe: 'Output directory',
37
54
  type: 'string',
38
- demandOption: true,
39
55
  normalize: true,
40
- default: 'dist'
56
+ deprecated: true
41
57
  },
42
58
  eval: {
43
59
  alias: 'e',
44
60
  describe: 'Attempt to evaluate Snap bundle in SES',
45
61
  type: 'boolean',
46
- demandOption: false,
47
- default: true
62
+ deprecated: true
48
63
  },
49
64
  manifest: {
50
65
  alias: 'm',
51
66
  describe: 'Validate snap.manifest.json',
52
67
  type: 'boolean',
53
- demandOption: false,
54
- default: true
68
+ deprecated: true
55
69
  },
56
70
  port: {
57
71
  alias: 'p',
58
72
  describe: 'Local server port for testing',
59
73
  type: 'number',
60
- demandOption: true,
61
- default: 8081,
62
74
  coerce: (arg)=>{
63
75
  const port = Number.parseInt(String(arg), 10);
64
76
  if (Number.isNaN(port)) {
65
- throw new Error(`Invalid port: ${String(arg)}`);
77
+ throw new Error(`Invalid port: "${String(arg)}".`);
66
78
  }
67
79
  return port;
68
- }
80
+ },
81
+ deprecated: true
69
82
  },
70
83
  outfileName: {
71
84
  alias: 'n',
72
85
  describe: 'Output file name',
73
86
  type: 'string',
74
- demandOption: false,
75
- default: 'bundle.js'
87
+ deprecated: true
76
88
  },
77
89
  root: {
78
90
  alias: 'r',
79
91
  describe: 'Server root directory',
80
92
  type: 'string',
81
- demandOption: true,
82
93
  normalize: true,
83
- default: '.'
94
+ deprecated: true
84
95
  },
85
96
  sourceMaps: {
86
97
  describe: 'Whether builds include sourcemaps',
87
98
  type: 'boolean',
88
- demandOption: false,
89
- default: false
99
+ deprecated: true
90
100
  },
91
101
  src: {
92
102
  alias: 's',
93
103
  describe: 'Source file',
94
104
  type: 'string',
95
- demandOption: true,
96
105
  normalize: true,
97
- default: 'src/index.js'
106
+ deprecated: true
98
107
  },
99
108
  stripComments: {
100
109
  alias: 'strip',
101
110
  describe: 'Whether to remove code comments from the build output',
102
111
  type: 'boolean',
103
- demandOption: false,
104
- default: true
112
+ deprecated: true
105
113
  },
106
114
  suppressWarnings: {
107
115
  type: 'boolean',
108
116
  describe: 'Whether to suppress warnings',
109
- demandOption: false,
110
- default: false
117
+ deprecated: true
111
118
  },
112
119
  transpilationMode: {
113
120
  type: 'string',
114
- describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing.',
115
- demandOption: false,
116
- default: TranspilationModes.LocalOnly,
117
- choices: Object.values(TranspilationModes)
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
118
124
  },
119
125
  depsToTranspile: {
120
126
  type: 'array',
121
127
  describe: 'Transpile only the listed dependencies.',
122
- demandOption: false
128
+ deprecated: true
123
129
  },
124
130
  verboseErrors: {
125
131
  type: 'boolean',
126
132
  describe: 'Display original errors',
127
- demandOption: false,
128
- default: true
133
+ deprecated: true
129
134
  },
130
135
  writeManifest: {
131
- describe: 'Make necessary changes to the Snap manifest file',
136
+ describe: 'Make necessary changes to the snap manifest file',
132
137
  type: 'boolean',
133
- demandOption: false,
134
- default: true
138
+ deprecated: true
135
139
  },
136
140
  serve: {
137
- describe: 'Serve Snap file(s) locally for testing',
141
+ describe: 'Serve snap file(s) locally for testing',
138
142
  type: 'boolean',
139
- demandOption: false,
140
- default: true
141
- },
142
- directory: {
143
- describe: 'the directory to use',
144
- type: 'string'
143
+ deprecated: true
145
144
  }
146
145
  };
147
146
  const _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":";;;;;;;;;;;;;;IAwKA,OAAwB;eAAxB;;;IAlJO;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;MAEA,WAAeJ"}
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"}
package/dist/cjs/cli.js CHANGED
@@ -9,27 +9,27 @@ Object.defineProperty(exports, "cli", {
9
9
  }
10
10
  });
11
11
  const _yargs = /*#__PURE__*/ _interop_require_default(require("yargs"));
12
+ const _helpers = require("yargs/helpers");
12
13
  const _builders = /*#__PURE__*/ _interop_require_default(require("./builders"));
14
+ const _config = require("./config");
13
15
  const _utils = require("./utils");
14
16
  function _interop_require_default(obj) {
15
17
  return obj && obj.__esModule ? obj : {
16
18
  default: obj
17
19
  };
18
20
  }
19
- function cli(argv, commands) {
20
- const rawArgv = argv.slice(2);
21
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-floating-promises
22
- (0, _yargs.default)(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.default.verboseErrors).option('suppressWarnings', _builders.default.suppressWarnings).strict()// Typecast: The @types/yargs type for .middleware is incorrect.
23
- // yargs middleware functions receive the yargs instance as a second parameter.
24
- // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation
25
- .middleware((yargsArgv, yargsInstance)=>{
26
- (0, _utils.applyConfig)((0, _utils.loadConfig)(), rawArgv, yargsArgv, yargsInstance);
27
- (0, _utils.setSnapGlobals)(yargsArgv);
28
- (0, _utils.sanitizeInputs)(yargsArgv);
29
- }, true).fail((message, error, _yargs)=>{
30
- (0, _utils.logError)(message, error);
31
- process.exitCode = 1;
32
- }).demandCommand(1, 'You must specify at least one command.').help().alias('help', 'h').argv;
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
33
  }
34
34
 
35
35
  //# 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":["cli","argv","commands","rawArgv","slice","yargs","scriptName","usage","example","command","option","builders","verboseErrors","suppressWarnings","strict","middleware","yargsArgv","yargsInstance","applyConfig","loadConfig","setSnapGlobals","sanitizeInputs","fail","message","error","_yargs","logError","process","exitCode","demandCommand","help","alias"],"mappings":";;;;+BAoBgBA;;;eAAAA;;;8DAnBE;iEAGG;uBAOd;;;;;;AASA,SAASA,IAAIC,IAAc,EAAEC,QAAa;IAC/C,MAAMC,UAAUF,KAAKG,KAAK,CAAC;IAC3B,6GAA6G;IAC7GC,IAAAA,cAAK,EAACF,SACHG,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,CAACP,UAERQ,MAAM,CAAC,iBAAiBC,iBAAQ,CAACC,aAAa,EAE9CF,MAAM,CAAC,oBAAoBC,iBAAQ,CAACE,gBAAgB,EAEpDC,MAAM,EAEP,gEAAgE;IAChE,+EAA+E;IAC/E,0FAA0F;KACzFC,UAAU,CACR,CAACC,WAAsBC;QACtBC,IAAAA,kBAAW,EAACC,IAAAA,iBAAU,KAAIhB,SAASa,WAAWC;QAC9CG,IAAAA,qBAAc,EAACJ;QACfK,IAAAA,qBAAc,EAACL;IACjB,GACA,MAGDM,IAAI,CAAC,CAACC,SAAiBC,OAAcC;QACpCC,IAAAA,eAAQ,EAACH,SAASC;QAClBG,QAAQC,QAAQ,GAAG;IACrB,GAECC,aAAa,CAAC,GAAG,0CAEjBC,IAAI,GACJC,KAAK,CAAC,QAAQ,KAAK9B,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":["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"}
@@ -9,8 +9,21 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
12
- const _buildHandler = require("./buildHandler");
13
- const _utils = require("./utils");
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
+ }
14
27
  function _interop_require_default(obj) {
15
28
  return obj && obj.__esModule ? obj : {
16
29
  default: obj
@@ -21,11 +34,11 @@ const command = {
21
34
  'build',
22
35
  'b'
23
36
  ],
24
- desc: 'Build Snap from source',
37
+ desc: 'Build snap from source',
25
38
  builder: (yarg)=>{
26
- 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').middleware((argv)=>(0, _utils.processInvalidTranspilation)(argv));
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');
27
40
  },
28
- handler: async (argv)=>(0, _buildHandler.build)(argv)
41
+ handler: async (argv)=>(0, _build.buildHandler)(argv.context.config)
29
42
  };
30
43
  const _default = command;
31
44
 
@@ -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 @@
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