@metamask/snaps-cli 5.1.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/builders.js +10 -0
  3. package/dist/builders.js.map +1 -0
  4. package/dist/builders.mjs +10 -0
  5. package/dist/builders.mjs.map +1 -0
  6. package/dist/chunk-25SLEORF.mjs +28 -0
  7. package/dist/chunk-25SLEORF.mjs.map +1 -0
  8. package/dist/chunk-2QVYYMUD.js +365 -0
  9. package/dist/chunk-2QVYYMUD.js.map +1 -0
  10. package/dist/{esm/webpack/config.js → chunk-3LNPS7AX.js} +182 -156
  11. package/dist/chunk-3LNPS7AX.js.map +1 -0
  12. package/dist/chunk-46JUPGRY.js +22 -0
  13. package/dist/chunk-46JUPGRY.js.map +1 -0
  14. package/dist/chunk-4NHBPMKT.js +54 -0
  15. package/dist/chunk-4NHBPMKT.js.map +1 -0
  16. package/dist/chunk-4OKAI7AP.js +52 -0
  17. package/dist/chunk-4OKAI7AP.js.map +1 -0
  18. package/dist/chunk-5DDAAM2X.js +41 -0
  19. package/dist/chunk-5DDAAM2X.js.map +1 -0
  20. package/dist/chunk-5DSV76XV.mjs +10 -0
  21. package/dist/chunk-5DSV76XV.mjs.map +1 -0
  22. package/dist/chunk-5JPLNWCO.js +24 -0
  23. package/dist/chunk-5JPLNWCO.js.map +1 -0
  24. package/dist/chunk-5VAZH7L7.js +64 -0
  25. package/dist/chunk-5VAZH7L7.js.map +1 -0
  26. package/dist/chunk-5YUHRLH6.js +22 -0
  27. package/dist/chunk-5YUHRLH6.js.map +1 -0
  28. package/dist/chunk-6IF2UBYA.mjs +13 -0
  29. package/dist/chunk-6IF2UBYA.mjs.map +1 -0
  30. package/dist/chunk-6NJAXMSB.js +135 -0
  31. package/dist/chunk-6NJAXMSB.js.map +1 -0
  32. package/dist/chunk-6VFUO2H5.mjs +124 -0
  33. package/dist/chunk-6VFUO2H5.mjs.map +1 -0
  34. package/dist/chunk-7SN4Y44H.js +287 -0
  35. package/dist/chunk-7SN4Y44H.js.map +1 -0
  36. package/dist/chunk-ASOCIPDR.js +10 -0
  37. package/dist/chunk-ASOCIPDR.js.map +1 -0
  38. package/dist/chunk-B455GFXP.mjs +54 -0
  39. package/dist/chunk-B455GFXP.mjs.map +1 -0
  40. package/dist/chunk-DWS4BJTE.mjs +64 -0
  41. package/dist/chunk-DWS4BJTE.mjs.map +1 -0
  42. package/dist/chunk-EQRMXKXY.js +346 -0
  43. package/dist/chunk-EQRMXKXY.js.map +1 -0
  44. package/dist/chunk-EXGQAOQS.js +64 -0
  45. package/dist/chunk-EXGQAOQS.js.map +1 -0
  46. package/dist/chunk-EXJCMAUI.mjs +23 -0
  47. package/dist/chunk-EXJCMAUI.mjs.map +1 -0
  48. package/dist/chunk-FPG4GBXZ.js +30 -0
  49. package/dist/chunk-FPG4GBXZ.js.map +1 -0
  50. package/dist/chunk-FYTQTDZU.mjs +52 -0
  51. package/dist/chunk-FYTQTDZU.mjs.map +1 -0
  52. package/dist/chunk-G3IYVYVR.js +31 -0
  53. package/dist/chunk-G3IYVYVR.js.map +1 -0
  54. package/dist/chunk-GC7BNDLY.js +23 -0
  55. package/dist/chunk-GC7BNDLY.js.map +1 -0
  56. package/dist/chunk-GKG7TO7T.js +28 -0
  57. package/dist/chunk-GKG7TO7T.js.map +1 -0
  58. package/dist/chunk-GU2KH52B.mjs +53 -0
  59. package/dist/chunk-GU2KH52B.mjs.map +1 -0
  60. package/dist/chunk-GUXDSKV4.mjs +51 -0
  61. package/dist/chunk-GUXDSKV4.mjs.map +1 -0
  62. package/dist/chunk-HGYXRW5B.js +50 -0
  63. package/dist/chunk-HGYXRW5B.js.map +1 -0
  64. package/dist/chunk-HJ4276TR.mjs +41 -0
  65. package/dist/chunk-HJ4276TR.mjs.map +1 -0
  66. package/dist/chunk-HNLMKJBX.js +30 -0
  67. package/dist/chunk-HNLMKJBX.js.map +1 -0
  68. package/dist/chunk-IJYBCHVM.js +32 -0
  69. package/dist/chunk-IJYBCHVM.js.map +1 -0
  70. package/dist/chunk-IQTGFRWK.js +18 -0
  71. package/dist/chunk-IQTGFRWK.js.map +1 -0
  72. package/dist/chunk-IYAFFTJU.js +23 -0
  73. package/dist/chunk-IYAFFTJU.js.map +1 -0
  74. package/dist/chunk-JMISQ4HT.mjs +31 -0
  75. package/dist/chunk-JMISQ4HT.mjs.map +1 -0
  76. package/dist/chunk-K3TSXPME.js +16 -0
  77. package/dist/chunk-K3TSXPME.js.map +1 -0
  78. package/dist/{cjs/webpack/config.js → chunk-KKTPKAZN.mjs} +181 -153
  79. package/dist/chunk-KKTPKAZN.mjs.map +1 -0
  80. package/dist/chunk-KZFWI73A.js +28 -0
  81. package/dist/chunk-KZFWI73A.js.map +1 -0
  82. package/dist/chunk-L5TMG6BQ.js +37 -0
  83. package/dist/chunk-L5TMG6BQ.js.map +1 -0
  84. package/dist/chunk-MCN7UXG3.mjs +287 -0
  85. package/dist/chunk-MCN7UXG3.mjs.map +1 -0
  86. package/dist/chunk-MIV2UFTA.js +13 -0
  87. package/dist/chunk-MIV2UFTA.js.map +1 -0
  88. package/dist/chunk-MMBQXT2G.mjs +30 -0
  89. package/dist/chunk-MMBQXT2G.mjs.map +1 -0
  90. package/dist/chunk-NO53G7NT.js +61 -0
  91. package/dist/chunk-NO53G7NT.js.map +1 -0
  92. package/dist/chunk-O2QUFUOY.js +53 -0
  93. package/dist/chunk-O2QUFUOY.js.map +1 -0
  94. package/dist/chunk-OF4BF57X.mjs +22 -0
  95. package/dist/chunk-OF4BF57X.mjs.map +1 -0
  96. package/dist/chunk-OVCYXVWI.mjs +1 -0
  97. package/dist/chunk-OVCYXVWI.mjs.map +1 -0
  98. package/dist/chunk-PDNDGMB2.mjs +365 -0
  99. package/dist/chunk-PDNDGMB2.mjs.map +1 -0
  100. package/dist/chunk-QCP4QKMQ.mjs +24 -0
  101. package/dist/chunk-QCP4QKMQ.mjs.map +1 -0
  102. package/dist/chunk-QH4AQR33.mjs +61 -0
  103. package/dist/chunk-QH4AQR33.mjs.map +1 -0
  104. package/dist/chunk-S5ERYB6I.mjs +64 -0
  105. package/dist/chunk-S5ERYB6I.mjs.map +1 -0
  106. package/dist/chunk-SAEZHRJJ.mjs +23 -0
  107. package/dist/chunk-SAEZHRJJ.mjs.map +1 -0
  108. package/dist/chunk-T3KPXUAU.js +24 -0
  109. package/dist/chunk-T3KPXUAU.js.map +1 -0
  110. package/dist/chunk-T74IXMA3.mjs +50 -0
  111. package/dist/chunk-T74IXMA3.mjs.map +1 -0
  112. package/dist/chunk-TLTTWAEI.mjs +37 -0
  113. package/dist/chunk-TLTTWAEI.mjs.map +1 -0
  114. package/dist/chunk-TX4BG5GS.mjs +50 -0
  115. package/dist/chunk-TX4BG5GS.mjs.map +1 -0
  116. package/dist/chunk-UA5FEKKH.mjs +30 -0
  117. package/dist/chunk-UA5FEKKH.mjs.map +1 -0
  118. package/dist/chunk-UBWM7UOC.mjs +32 -0
  119. package/dist/chunk-UBWM7UOC.mjs.map +1 -0
  120. package/dist/chunk-USFFVX52.mjs +35 -0
  121. package/dist/chunk-USFFVX52.mjs.map +1 -0
  122. package/dist/chunk-V5Q5HRXB.mjs +30 -0
  123. package/dist/chunk-V5Q5HRXB.mjs.map +1 -0
  124. package/dist/chunk-VI3ZJJYO.mjs +346 -0
  125. package/dist/chunk-VI3ZJJYO.mjs.map +1 -0
  126. package/dist/chunk-VTJFPUIA.mjs +22 -0
  127. package/dist/chunk-VTJFPUIA.mjs.map +1 -0
  128. package/dist/chunk-WH7GOZP7.js +51 -0
  129. package/dist/chunk-WH7GOZP7.js.map +1 -0
  130. package/dist/chunk-WJNHZ4YF.js +35 -0
  131. package/dist/chunk-WJNHZ4YF.js.map +1 -0
  132. package/dist/chunk-WKL7DYYW.mjs +16 -0
  133. package/dist/chunk-WKL7DYYW.mjs.map +1 -0
  134. package/dist/chunk-X2RPNWBJ.mjs +24 -0
  135. package/dist/chunk-X2RPNWBJ.mjs.map +1 -0
  136. package/dist/chunk-X3D3MHWF.js +44 -0
  137. package/dist/chunk-X3D3MHWF.js.map +1 -0
  138. package/dist/chunk-X4FWMO4H.mjs +18 -0
  139. package/dist/chunk-X4FWMO4H.mjs.map +1 -0
  140. package/dist/chunk-Y5PQG4KA.js +1 -0
  141. package/dist/chunk-Y5PQG4KA.js.map +1 -0
  142. package/dist/chunk-YDLKS46R.js +30 -0
  143. package/dist/chunk-YDLKS46R.js.map +1 -0
  144. package/dist/chunk-YURDB35F.js +124 -0
  145. package/dist/chunk-YURDB35F.js.map +1 -0
  146. package/dist/chunk-YYYOE2GO.mjs +32 -0
  147. package/dist/chunk-YYYOE2GO.mjs.map +1 -0
  148. package/dist/chunk-ZOQ32RQI.mjs +135 -0
  149. package/dist/chunk-ZOQ32RQI.mjs.map +1 -0
  150. package/dist/cli.js +21 -0
  151. package/dist/cli.js.map +1 -0
  152. package/dist/cli.mjs +21 -0
  153. package/dist/cli.mjs.map +1 -0
  154. package/dist/commands/build/build.js +29 -0
  155. package/dist/commands/build/build.js.map +1 -0
  156. package/dist/commands/build/build.mjs +29 -0
  157. package/dist/commands/build/build.mjs.map +1 -0
  158. package/dist/commands/build/implementation.js +28 -0
  159. package/dist/commands/build/implementation.js.map +1 -0
  160. package/dist/commands/build/implementation.mjs +28 -0
  161. package/dist/commands/build/implementation.mjs.map +1 -0
  162. package/dist/commands/build/index.js +33 -0
  163. package/dist/commands/build/index.js.map +1 -0
  164. package/dist/commands/build/index.mjs +33 -0
  165. package/dist/commands/build/index.mjs.map +1 -0
  166. package/dist/commands/eval/eval.js +18 -0
  167. package/dist/commands/eval/eval.js.map +1 -0
  168. package/dist/commands/eval/eval.mjs +18 -0
  169. package/dist/commands/eval/eval.mjs.map +1 -0
  170. package/dist/commands/eval/implementation.js +9 -0
  171. package/dist/commands/eval/implementation.js.map +1 -0
  172. package/dist/commands/eval/implementation.mjs +9 -0
  173. package/dist/commands/eval/implementation.mjs.map +1 -0
  174. package/dist/commands/eval/index.js +22 -0
  175. package/dist/commands/eval/index.js.map +1 -0
  176. package/dist/commands/eval/index.mjs +22 -0
  177. package/dist/commands/eval/index.mjs.map +1 -0
  178. package/dist/commands/index.js +39 -0
  179. package/dist/commands/index.js.map +1 -0
  180. package/dist/commands/index.mjs +39 -0
  181. package/dist/commands/index.mjs.map +1 -0
  182. package/dist/commands/manifest/implementation.js +17 -0
  183. package/dist/commands/manifest/implementation.js.map +1 -0
  184. package/dist/commands/manifest/implementation.mjs +17 -0
  185. package/dist/commands/manifest/implementation.mjs.map +1 -0
  186. package/dist/commands/manifest/index.js +22 -0
  187. package/dist/commands/manifest/index.js.map +1 -0
  188. package/dist/commands/manifest/index.mjs +22 -0
  189. package/dist/commands/manifest/index.mjs.map +1 -0
  190. package/dist/commands/manifest/manifest.js +18 -0
  191. package/dist/commands/manifest/manifest.js.map +1 -0
  192. package/dist/commands/manifest/manifest.mjs +18 -0
  193. package/dist/commands/manifest/manifest.mjs.map +1 -0
  194. package/dist/commands/serve/index.js +29 -0
  195. package/dist/commands/serve/index.js.map +1 -0
  196. package/dist/commands/serve/index.mjs +29 -0
  197. package/dist/commands/serve/index.mjs.map +1 -0
  198. package/dist/commands/serve/serve.js +28 -0
  199. package/dist/commands/serve/serve.js.map +1 -0
  200. package/dist/commands/serve/serve.mjs +28 -0
  201. package/dist/commands/serve/serve.mjs.map +1 -0
  202. package/dist/commands/watch/implementation.js +28 -0
  203. package/dist/commands/watch/implementation.js.map +1 -0
  204. package/dist/commands/watch/implementation.mjs +28 -0
  205. package/dist/commands/watch/implementation.mjs.map +1 -0
  206. package/dist/commands/watch/index.js +33 -0
  207. package/dist/commands/watch/index.js.map +1 -0
  208. package/dist/commands/watch/index.mjs +33 -0
  209. package/dist/commands/watch/index.mjs.map +1 -0
  210. package/dist/commands/watch/watch.js +29 -0
  211. package/dist/commands/watch/watch.js.map +1 -0
  212. package/dist/commands/watch/watch.mjs +29 -0
  213. package/dist/commands/watch/watch.mjs.map +1 -0
  214. package/dist/config.js +36 -0
  215. package/dist/config.js.map +1 -0
  216. package/dist/config.mjs +36 -0
  217. package/dist/config.mjs.map +1 -0
  218. package/dist/errors.js +12 -0
  219. package/dist/errors.js.map +1 -0
  220. package/dist/errors.mjs +12 -0
  221. package/dist/errors.mjs.map +1 -0
  222. package/dist/index.js +43 -0
  223. package/dist/index.js.map +1 -0
  224. package/dist/index.mjs +43 -0
  225. package/dist/index.mjs.map +1 -0
  226. package/dist/main.js +49 -0
  227. package/dist/main.js.map +1 -0
  228. package/dist/main.mjs +49 -0
  229. package/dist/main.mjs.map +1 -0
  230. package/dist/structs.js +8 -0
  231. package/dist/structs.js.map +1 -0
  232. package/dist/structs.mjs +8 -0
  233. package/dist/structs.mjs.map +1 -0
  234. package/dist/tsconfig.build.tsbuildinfo +1 -0
  235. package/dist/types/commands/eval/implementation.d.ts +1 -1
  236. package/dist/types/config.d.ts +2 -2
  237. package/dist/types/structs.d.ts +20 -0
  238. package/dist/types/webpack/loaders/function.d.ts +34 -0
  239. package/dist/types/webpack/loaders/index.d.ts +3 -0
  240. package/dist/types/webpack/utils.d.ts +13 -11
  241. package/dist/types/yargs.d.js +1 -0
  242. package/dist/types/yargs.d.js.map +1 -0
  243. package/dist/types/yargs.d.mjs +2 -0
  244. package/dist/types/yargs.d.mjs.map +1 -0
  245. package/dist/utils/cli.js +14 -0
  246. package/dist/utils/cli.js.map +1 -0
  247. package/dist/utils/cli.mjs +14 -0
  248. package/dist/utils/cli.mjs.map +1 -0
  249. package/dist/utils/errors.js +11 -0
  250. package/dist/utils/errors.js.map +1 -0
  251. package/dist/utils/errors.mjs +11 -0
  252. package/dist/utils/errors.mjs.map +1 -0
  253. package/dist/utils/index.js +47 -0
  254. package/dist/utils/index.js.map +1 -0
  255. package/dist/utils/index.mjs +47 -0
  256. package/dist/utils/index.mjs.map +1 -0
  257. package/dist/utils/legacy.js +13 -0
  258. package/dist/utils/legacy.js.map +1 -0
  259. package/dist/utils/legacy.mjs +13 -0
  260. package/dist/utils/legacy.mjs.map +1 -0
  261. package/dist/utils/logging.js +12 -0
  262. package/dist/utils/logging.js.map +1 -0
  263. package/dist/utils/logging.mjs +12 -0
  264. package/dist/utils/logging.mjs.map +1 -0
  265. package/dist/utils/path.js +8 -0
  266. package/dist/utils/path.js.map +1 -0
  267. package/dist/utils/path.mjs +8 -0
  268. package/dist/utils/path.mjs.map +1 -0
  269. package/dist/utils/steps.js +11 -0
  270. package/dist/utils/steps.js.map +1 -0
  271. package/dist/utils/steps.mjs +11 -0
  272. package/dist/utils/steps.mjs.map +1 -0
  273. package/dist/webpack/compiler.js +25 -0
  274. package/dist/webpack/compiler.js.map +1 -0
  275. package/dist/webpack/compiler.mjs +25 -0
  276. package/dist/webpack/compiler.mjs.map +1 -0
  277. package/dist/webpack/config.js +24 -0
  278. package/dist/webpack/config.js.map +1 -0
  279. package/dist/webpack/config.mjs +24 -0
  280. package/dist/webpack/config.mjs.map +1 -0
  281. package/dist/webpack/index.js +44 -0
  282. package/dist/webpack/index.js.map +1 -0
  283. package/dist/webpack/index.mjs +44 -0
  284. package/dist/webpack/index.mjs.map +1 -0
  285. package/dist/webpack/loaders/browserify.js +19 -0
  286. package/dist/webpack/loaders/browserify.js.map +1 -0
  287. package/dist/webpack/loaders/browserify.mjs +19 -0
  288. package/dist/webpack/loaders/browserify.mjs.map +1 -0
  289. package/dist/webpack/loaders/function.js +10 -0
  290. package/dist/webpack/loaders/function.js.map +1 -0
  291. package/dist/webpack/loaders/function.mjs +10 -0
  292. package/dist/webpack/loaders/function.mjs.map +1 -0
  293. package/dist/webpack/loaders/index.js +25 -0
  294. package/dist/webpack/loaders/index.js.map +1 -0
  295. package/dist/webpack/loaders/index.mjs +25 -0
  296. package/dist/webpack/loaders/index.mjs.map +1 -0
  297. package/dist/webpack/loaders/wasm.js +16 -0
  298. package/dist/webpack/loaders/wasm.js.map +1 -0
  299. package/dist/webpack/loaders/wasm.mjs +16 -0
  300. package/dist/webpack/loaders/wasm.mjs.map +1 -0
  301. package/dist/webpack/plugins.js +29 -0
  302. package/dist/webpack/plugins.js.map +1 -0
  303. package/dist/webpack/plugins.mjs +29 -0
  304. package/dist/webpack/plugins.mjs.map +1 -0
  305. package/dist/webpack/server.js +10 -0
  306. package/dist/webpack/server.js.map +1 -0
  307. package/dist/webpack/server.mjs +10 -0
  308. package/dist/webpack/server.mjs.map +1 -0
  309. package/dist/webpack/utils.js +37 -0
  310. package/dist/webpack/utils.js.map +1 -0
  311. package/dist/webpack/utils.mjs +37 -0
  312. package/dist/webpack/utils.mjs.map +1 -0
  313. package/package.json +21 -21
  314. package/.browserslistrc +0 -3
  315. package/dist/cjs/builders.js +0 -148
  316. package/dist/cjs/builders.js.map +0 -1
  317. package/dist/cjs/cli.js +0 -68
  318. package/dist/cjs/cli.js.map +0 -1
  319. package/dist/cjs/commands/build/build.js +0 -54
  320. package/dist/cjs/commands/build/build.js.map +0 -1
  321. package/dist/cjs/commands/build/implementation.js +0 -31
  322. package/dist/cjs/commands/build/implementation.js.map +0 -1
  323. package/dist/cjs/commands/build/index.js +0 -45
  324. package/dist/cjs/commands/build/index.js.map +0 -1
  325. package/dist/cjs/commands/eval/eval.js +0 -57
  326. package/dist/cjs/commands/eval/eval.js.map +0 -1
  327. package/dist/cjs/commands/eval/implementation.js +0 -27
  328. package/dist/cjs/commands/eval/implementation.js.map +0 -1
  329. package/dist/cjs/commands/eval/index.js +0 -50
  330. package/dist/cjs/commands/eval/index.js.map +0 -1
  331. package/dist/cjs/commands/index.js +0 -30
  332. package/dist/cjs/commands/index.js.map +0 -1
  333. package/dist/cjs/commands/manifest/implementation.js +0 -34
  334. package/dist/cjs/commands/manifest/implementation.js.map +0 -1
  335. package/dist/cjs/commands/manifest/index.js +0 -50
  336. package/dist/cjs/commands/manifest/index.js.map +0 -1
  337. package/dist/cjs/commands/manifest/manifest.js +0 -55
  338. package/dist/cjs/commands/manifest/manifest.js.map +0 -1
  339. package/dist/cjs/commands/serve/index.js +0 -33
  340. package/dist/cjs/commands/serve/index.js.map +0 -1
  341. package/dist/cjs/commands/serve/serve.js +0 -21
  342. package/dist/cjs/commands/serve/serve.js.map +0 -1
  343. package/dist/cjs/commands/watch/implementation.js +0 -35
  344. package/dist/cjs/commands/watch/implementation.js.map +0 -1
  345. package/dist/cjs/commands/watch/index.js +0 -47
  346. package/dist/cjs/commands/watch/index.js.map +0 -1
  347. package/dist/cjs/commands/watch/watch.js +0 -51
  348. package/dist/cjs/commands/watch/watch.js.map +0 -1
  349. package/dist/cjs/config.js +0 -320
  350. package/dist/cjs/config.js.map +0 -1
  351. package/dist/cjs/errors.js +0 -37
  352. package/dist/cjs/errors.js.map +0 -1
  353. package/dist/cjs/index.js +0 -77
  354. package/dist/cjs/index.js.map +0 -1
  355. package/dist/cjs/main.js +0 -19
  356. package/dist/cjs/main.js.map +0 -1
  357. package/dist/cjs/utils/cli.js +0 -61
  358. package/dist/cjs/utils/cli.js.map +0 -1
  359. package/dist/cjs/utils/errors.js +0 -42
  360. package/dist/cjs/utils/errors.js.map +0 -1
  361. package/dist/cjs/utils/index.js +0 -25
  362. package/dist/cjs/utils/index.js.map +0 -1
  363. package/dist/cjs/utils/legacy.js +0 -48
  364. package/dist/cjs/utils/legacy.js.map +0 -1
  365. package/dist/cjs/utils/logging.js +0 -46
  366. package/dist/cjs/utils/logging.js.map +0 -1
  367. package/dist/cjs/utils/path.js +0 -16
  368. package/dist/cjs/utils/path.js.map +0 -1
  369. package/dist/cjs/utils/steps.js +0 -52
  370. package/dist/cjs/utils/steps.js.map +0 -1
  371. package/dist/cjs/webpack/compiler.js +0 -19
  372. package/dist/cjs/webpack/compiler.js.map +0 -1
  373. package/dist/cjs/webpack/config.js.map +0 -1
  374. package/dist/cjs/webpack/index.js +0 -23
  375. package/dist/cjs/webpack/index.js.map +0 -1
  376. package/dist/cjs/webpack/loaders/browserify.js +0 -97
  377. package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
  378. package/dist/cjs/webpack/loaders/wasm.js +0 -92
  379. package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
  380. package/dist/cjs/webpack/plugins.js +0 -341
  381. package/dist/cjs/webpack/plugins.js.map +0 -1
  382. package/dist/cjs/webpack/server.js +0 -139
  383. package/dist/cjs/webpack/server.js.map +0 -1
  384. package/dist/cjs/webpack/utils.js +0 -240
  385. package/dist/cjs/webpack/utils.js.map +0 -1
  386. package/dist/esm/builders.js +0 -130
  387. package/dist/esm/builders.js.map +0 -1
  388. package/dist/esm/cli.js +0 -56
  389. package/dist/esm/cli.js.map +0 -1
  390. package/dist/esm/commands/build/build.js +0 -51
  391. package/dist/esm/commands/build/build.js.map +0 -1
  392. package/dist/esm/commands/build/implementation.js +0 -27
  393. package/dist/esm/commands/build/implementation.js.map +0 -1
  394. package/dist/esm/commands/build/index.js +0 -17
  395. package/dist/esm/commands/build/index.js.map +0 -1
  396. package/dist/esm/commands/eval/eval.js +0 -54
  397. package/dist/esm/commands/eval/eval.js.map +0 -1
  398. package/dist/esm/commands/eval/implementation.js +0 -24
  399. package/dist/esm/commands/eval/implementation.js.map +0 -1
  400. package/dist/esm/commands/eval/index.js +0 -22
  401. package/dist/esm/commands/eval/index.js.map +0 -1
  402. package/dist/esm/commands/index.js +0 -15
  403. package/dist/esm/commands/index.js.map +0 -1
  404. package/dist/esm/commands/manifest/implementation.js +0 -33
  405. package/dist/esm/commands/manifest/implementation.js.map +0 -1
  406. package/dist/esm/commands/manifest/index.js +0 -22
  407. package/dist/esm/commands/manifest/index.js.map +0 -1
  408. package/dist/esm/commands/manifest/manifest.js +0 -52
  409. package/dist/esm/commands/manifest/manifest.js.map +0 -1
  410. package/dist/esm/commands/serve/index.js +0 -18
  411. package/dist/esm/commands/serve/index.js.map +0 -1
  412. package/dist/esm/commands/serve/serve.js +0 -17
  413. package/dist/esm/commands/serve/serve.js.map +0 -1
  414. package/dist/esm/commands/watch/implementation.js +0 -34
  415. package/dist/esm/commands/watch/implementation.js.map +0 -1
  416. package/dist/esm/commands/watch/index.js +0 -19
  417. package/dist/esm/commands/watch/index.js.map +0 -1
  418. package/dist/esm/commands/watch/watch.js +0 -50
  419. package/dist/esm/commands/watch/watch.js.map +0 -1
  420. package/dist/esm/config.js +0 -324
  421. package/dist/esm/config.js.map +0 -1
  422. package/dist/esm/errors.js +0 -30
  423. package/dist/esm/errors.js.map +0 -1
  424. package/dist/esm/index.js +0 -6
  425. package/dist/esm/index.js.map +0 -1
  426. package/dist/esm/main.js +0 -10
  427. package/dist/esm/main.js.map +0 -1
  428. package/dist/esm/utils/cli.js +0 -43
  429. package/dist/esm/utils/cli.js.map +0 -1
  430. package/dist/esm/utils/errors.js +0 -43
  431. package/dist/esm/utils/errors.js.map +0 -1
  432. package/dist/esm/utils/index.js +0 -8
  433. package/dist/esm/utils/index.js.map +0 -1
  434. package/dist/esm/utils/legacy.js +0 -47
  435. package/dist/esm/utils/legacy.js.map +0 -1
  436. package/dist/esm/utils/logging.js +0 -40
  437. package/dist/esm/utils/logging.js.map +0 -1
  438. package/dist/esm/utils/path.js +0 -13
  439. package/dist/esm/utils/path.js.map +0 -1
  440. package/dist/esm/utils/steps.js +0 -43
  441. package/dist/esm/utils/steps.js.map +0 -1
  442. package/dist/esm/webpack/compiler.js +0 -15
  443. package/dist/esm/webpack/compiler.js.map +0 -1
  444. package/dist/esm/webpack/config.js.map +0 -1
  445. package/dist/esm/webpack/index.js +0 -6
  446. package/dist/esm/webpack/index.js.map +0 -1
  447. package/dist/esm/webpack/loaders/browserify.js +0 -82
  448. package/dist/esm/webpack/loaders/browserify.js.map +0 -1
  449. package/dist/esm/webpack/loaders/wasm.js +0 -87
  450. package/dist/esm/webpack/loaders/wasm.js.map +0 -1
  451. package/dist/esm/webpack/plugins.js +0 -344
  452. package/dist/esm/webpack/plugins.js.map +0 -1
  453. package/dist/esm/webpack/server.js +0 -133
  454. package/dist/esm/webpack/server.js.map +0 -1
  455. package/dist/esm/webpack/utils.js +0 -271
  456. package/dist/esm/webpack/utils.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [6.0.0]
10
+ ### Changed
11
+ - **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))
12
+ - **BREAKING:** Change config to use Webpack by default ([#2214](https://github.com/MetaMask/snaps/pull/2214))
13
+ - You can still use Browserify by specifying `bundler: 'browserify'`.
14
+
15
+ ## [5.1.1]
16
+ ### Fixed
17
+ - Support new lines in CLI message formatting ([#2194](https://github.com/MetaMask/snaps/pull/2194))
18
+
9
19
  ## [5.1.0]
10
20
  ### Changed
11
21
  - Optimize CLI Webpack configuration ([#2175](https://github.com/MetaMask/snaps/pull/2175))
@@ -109,7 +119,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
109
119
  - The version of the package no longer needs to match the version of all other
110
120
  MetaMask Snaps packages.
111
121
 
112
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@5.1.0...HEAD
122
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.0.0...HEAD
123
+ [6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@5.1.1...@metamask/snaps-cli@6.0.0
124
+ [5.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@5.1.0...@metamask/snaps-cli@5.1.1
113
125
  [5.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@5.0.0...@metamask/snaps-cli@5.1.0
114
126
  [5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@4.0.1...@metamask/snaps-cli@5.0.0
115
127
  [4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@4.0.0...@metamask/snaps-cli@4.0.1
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk6NJAXMSBjs = require('./chunk-6NJAXMSB.js');
5
+ require('./chunk-X3D3MHWF.js');
6
+
7
+
8
+
9
+ exports.TranspilationModes = _chunk6NJAXMSBjs.TranspilationModes; exports.default = _chunk6NJAXMSBjs.builders_default;
10
+ //# sourceMappingURL=builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import {
2
+ TranspilationModes,
3
+ builders_default
4
+ } from "./chunk-ZOQ32RQI.mjs";
5
+ import "./chunk-T74IXMA3.mjs";
6
+ export {
7
+ TranspilationModes,
8
+ builders_default as default
9
+ };
10
+ //# sourceMappingURL=builders.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,28 @@
1
+ import {
2
+ getCompiler
3
+ } from "./chunk-WKL7DYYW.mjs";
4
+
5
+ // src/commands/build/implementation.ts
6
+ async function build(config, options) {
7
+ const compiler = await getCompiler(config, options);
8
+ return await new Promise((resolve, reject) => {
9
+ compiler.run((runError) => {
10
+ if (runError) {
11
+ reject(runError);
12
+ return;
13
+ }
14
+ compiler.close((closeError) => {
15
+ if (closeError) {
16
+ reject(closeError);
17
+ return;
18
+ }
19
+ resolve();
20
+ });
21
+ });
22
+ });
23
+ }
24
+
25
+ export {
26
+ build
27
+ };
28
+ //# sourceMappingURL=chunk-25SLEORF.mjs.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"],"mappings":";;;;;AAWA,eAAsB,MACpB,QACA,SACA;AACA,QAAM,WAAW,MAAM,YAAY,QAAQ,OAAO;AAClD,SAAO,MAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAClD,aAAS,IAAI,CAAC,aAAa;AACzB,UAAI,UAAU;AACZ,eAAO,QAAQ;AACf;AAAA,MACF;AAEA,eAAS,MAAM,CAAC,eAAe;AAC7B,YAAI,YAAY;AACd,iBAAO,UAAU;AACjB;AAAA,QACF;AAEA,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -0,0 +1,365 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkMIV2UFTAjs = require('./chunk-MIV2UFTA.js');
4
+
5
+
6
+
7
+ var _chunkL5TMG6BQjs = require('./chunk-L5TMG6BQ.js');
8
+
9
+
10
+ var _chunk46JUPGRYjs = require('./chunk-46JUPGRY.js');
11
+
12
+ // src/config.ts
13
+ var _snapssdk = require('@metamask/snaps-sdk');
14
+
15
+
16
+
17
+
18
+
19
+
20
+ var _node = require('@metamask/snaps-utils/node');
21
+ var _utils = require('@metamask/utils');
22
+ var _core = require('@swc/core');
23
+ var _chalk = require('chalk');
24
+ var _promises = require('fs/promises');
25
+ var _module = require('module'); var _module2 = _interopRequireDefault(_module);
26
+ var _path = require('path');
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+ var _superstruct = require('superstruct');
43
+ var CONFIG_FILES = [_chunkL5TMG6BQjs.CONFIG_FILE, _chunkL5TMG6BQjs.TS_CONFIG_FILE];
44
+ var SnapsBrowserifyBundlerCustomizerFunctionStruct = _superstruct.define.call(void 0,
45
+ "function",
46
+ _superstruct.func.call(void 0, ).validator
47
+ );
48
+ var SnapsBrowserifyConfigStruct = _superstruct.object.call(void 0, {
49
+ bundler: _snapssdk.literal.call(void 0, "browserify"),
50
+ cliOptions: _superstruct.defaulted.call(void 0,
51
+ _superstruct.object.call(void 0, {
52
+ bundle: _superstruct.optional.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, )),
53
+ dist: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), "dist"),
54
+ eval: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
55
+ manifest: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
56
+ port: _superstruct.defaulted.call(void 0, _superstruct.number.call(void 0, ), 8081),
57
+ outfileName: _superstruct.defaulted.call(void 0, _superstruct.string.call(void 0, ), "bundle.js"),
58
+ root: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), process.cwd()),
59
+ sourceMaps: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
60
+ src: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), "src/index.js"),
61
+ stripComments: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
62
+ suppressWarnings: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
63
+ transpilationMode: _superstruct.defaulted.call(void 0,
64
+ _snapssdk.union.call(void 0, [_snapssdk.literal.call(void 0, "localAndDeps"), _snapssdk.literal.call(void 0, "localOnly"), _snapssdk.literal.call(void 0, "none")]),
65
+ "localOnly"
66
+ ),
67
+ depsToTranspile: _superstruct.defaulted.call(void 0, _superstruct.array.call(void 0, _superstruct.string.call(void 0, )), []),
68
+ verboseErrors: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
69
+ writeManifest: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
70
+ serve: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true)
71
+ }),
72
+ {}
73
+ ),
74
+ bundlerCustomizer: _superstruct.optional.call(void 0, SnapsBrowserifyBundlerCustomizerFunctionStruct)
75
+ });
76
+ var SnapsWebpackCustomizeWebpackConfigFunctionStruct = _superstruct.define.call(void 0,
77
+ "function",
78
+ _superstruct.func.call(void 0, ).validator
79
+ );
80
+ var SnapsWebpackConfigStruct = _superstruct.object.call(void 0, {
81
+ bundler: _superstruct.defaulted.call(void 0, _snapssdk.literal.call(void 0, "webpack"), "webpack"),
82
+ input: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), _path.resolve.call(void 0, process.cwd(), "src/index.js")),
83
+ sourceMap: _superstruct.defaulted.call(void 0, _snapssdk.union.call(void 0, [_superstruct.boolean.call(void 0, ), _snapssdk.literal.call(void 0, "inline")]), false),
84
+ evaluate: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
85
+ output: _superstruct.defaulted.call(void 0,
86
+ _superstruct.object.call(void 0, {
87
+ path: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), _path.resolve.call(void 0, process.cwd(), "dist")),
88
+ filename: _superstruct.defaulted.call(void 0, _superstruct.string.call(void 0, ), "bundle.js"),
89
+ clean: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
90
+ minimize: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true)
91
+ }),
92
+ {}
93
+ ),
94
+ manifest: _superstruct.defaulted.call(void 0,
95
+ _superstruct.object.call(void 0, {
96
+ path: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), _path.resolve.call(void 0, process.cwd(), "snap.manifest.json")),
97
+ update: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true)
98
+ }),
99
+ {}
100
+ ),
101
+ server: _superstruct.defaulted.call(void 0,
102
+ _superstruct.object.call(void 0, {
103
+ enabled: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
104
+ root: _superstruct.defaulted.call(void 0, _chunkMIV2UFTAjs.file.call(void 0, ), process.cwd()),
105
+ port: _superstruct.defaulted.call(void 0, _superstruct.number.call(void 0, ), 8081)
106
+ }),
107
+ {}
108
+ ),
109
+ environment: _superstruct.defaulted.call(void 0, _superstruct.record.call(void 0, _superstruct.string.call(void 0, ), _superstruct.unknown.call(void 0, )), {}),
110
+ stats: _superstruct.defaulted.call(void 0,
111
+ _superstruct.object.call(void 0, {
112
+ verbose: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
113
+ builtIns: _superstruct.defaulted.call(void 0,
114
+ _snapssdk.union.call(void 0, [
115
+ _superstruct.object.call(void 0, { ignore: _superstruct.defaulted.call(void 0, _superstruct.array.call(void 0, _superstruct.string.call(void 0, )), []) }),
116
+ _snapssdk.literal.call(void 0, false)
117
+ ]),
118
+ {}
119
+ ),
120
+ buffer: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true)
121
+ }),
122
+ {}
123
+ ),
124
+ polyfills: _superstruct.defaulted.call(void 0,
125
+ _snapssdk.union.call(void 0, [
126
+ _superstruct.boolean.call(void 0, ),
127
+ _superstruct.object.call(void 0, {
128
+ assert: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
129
+ buffer: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
130
+ console: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
131
+ constants: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
132
+ crypto: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
133
+ domain: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
134
+ events: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
135
+ http: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
136
+ https: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
137
+ os: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
138
+ path: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
139
+ punycode: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
140
+ process: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
141
+ querystring: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
142
+ stream: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
143
+ /* eslint-disable @typescript-eslint/naming-convention */
144
+ _stream_duplex: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
145
+ _stream_passthrough: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
146
+ _stream_readable: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
147
+ _stream_transform: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
148
+ _stream_writable: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
149
+ string_decoder: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
150
+ /* eslint-enable @typescript-eslint/naming-convention */
151
+ sys: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
152
+ timers: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
153
+ tty: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
154
+ url: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
155
+ util: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
156
+ vm: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false),
157
+ zlib: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false)
158
+ })
159
+ ]),
160
+ false
161
+ ),
162
+ customizeWebpackConfig: _superstruct.optional.call(void 0,
163
+ SnapsWebpackCustomizeWebpackConfigFunctionStruct
164
+ ),
165
+ experimental: _superstruct.defaulted.call(void 0,
166
+ _superstruct.object.call(void 0, {
167
+ wasm: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), false)
168
+ }),
169
+ {}
170
+ )
171
+ });
172
+ var SnapsConfigStruct = _superstruct.type.call(void 0, {
173
+ bundler: _superstruct.defaulted.call(void 0,
174
+ _snapssdk.union.call(void 0, [_snapssdk.literal.call(void 0, "browserify"), _snapssdk.literal.call(void 0, "webpack")]),
175
+ "webpack"
176
+ )
177
+ });
178
+ var LegacyOptionsStruct = _snapssdk.union.call(void 0, [
179
+ _node.named.call(void 0,
180
+ "object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings",
181
+ _superstruct.type.call(void 0, {
182
+ depsToTranspile: _superstruct.array.call(void 0, _superstruct.string.call(void 0, )),
183
+ transpilationMode: _snapssdk.literal.call(void 0, "localAndDeps" /* LocalAndDeps */),
184
+ writeManifest: _superstruct.boolean.call(void 0, ),
185
+ bundlerCustomizer: _superstruct.optional.call(void 0,
186
+ SnapsBrowserifyBundlerCustomizerFunctionStruct
187
+ )
188
+ })
189
+ ),
190
+ _node.named.call(void 0,
191
+ "object without `depsToTranspile`",
192
+ _superstruct.type.call(void 0, {
193
+ depsToTranspile: _node.named.call(void 0, "empty array", _superstruct.empty.call(void 0, _superstruct.array.call(void 0, ))),
194
+ transpilationMode: _snapssdk.union.call(void 0, [
195
+ _snapssdk.literal.call(void 0, "localOnly" /* LocalOnly */),
196
+ _snapssdk.literal.call(void 0, "none" /* None */)
197
+ ]),
198
+ writeManifest: _superstruct.boolean.call(void 0, ),
199
+ bundlerCustomizer: _superstruct.optional.call(void 0,
200
+ SnapsBrowserifyBundlerCustomizerFunctionStruct
201
+ )
202
+ })
203
+ )
204
+ ]);
205
+ function getConfig(config, argv) {
206
+ const prefix = "The snap config file is invalid";
207
+ const suffix = _chalk.dim.call(void 0,
208
+ // TODO: Link to `docs.metamask.io` once the docs are published.
209
+ "Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/"
210
+ );
211
+ const { bundler } = _node.createFromStruct.call(void 0,
212
+ config,
213
+ SnapsConfigStruct,
214
+ prefix,
215
+ suffix
216
+ );
217
+ if (bundler === "browserify") {
218
+ const legacyConfig = _node.createFromStruct.call(void 0,
219
+ config,
220
+ SnapsBrowserifyConfigStruct,
221
+ prefix,
222
+ suffix
223
+ );
224
+ return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));
225
+ }
226
+ return _node.createFromStruct.call(void 0, config, SnapsWebpackConfigStruct, prefix, suffix);
227
+ }
228
+ async function loadConfig(path, argv) {
229
+ try {
230
+ const contents = await _promises.readFile.call(void 0, path, "utf8");
231
+ const source = await _core.transform.call(void 0, contents, {
232
+ swcrc: false,
233
+ jsc: {
234
+ parser: {
235
+ syntax: "typescript"
236
+ }
237
+ },
238
+ module: {
239
+ type: "commonjs"
240
+ }
241
+ });
242
+ const config = new (0, _module2.default)(path);
243
+ config.paths = _module2.default._nodeModulePaths(_path.dirname.call(void 0, path));
244
+ config._compile(source.code, path);
245
+ if (!_utils.hasProperty.call(void 0, config.exports, "default")) {
246
+ return getConfig(config.exports, argv);
247
+ }
248
+ return getConfig(config.exports.default, argv);
249
+ } catch (error) {
250
+ if (error instanceof _node.SnapsStructError) {
251
+ throw new (0, _chunk46JUPGRYjs.ConfigError)(error.message);
252
+ }
253
+ throw new (0, _chunk46JUPGRYjs.ConfigError)(
254
+ `Unable to load snap config file at "${path}".
255
+
256
+ ${_node.indent.call(void 0,
257
+ error.message
258
+ )}`
259
+ );
260
+ }
261
+ }
262
+ async function resolveConfig(path, argv) {
263
+ for (const configFile of CONFIG_FILES) {
264
+ const filePath = _path.resolve.call(void 0, path, configFile);
265
+ if (await _node.isFile.call(void 0, filePath)) {
266
+ return await loadConfig(filePath, argv);
267
+ }
268
+ }
269
+ throw new (0, _chunk46JUPGRYjs.ConfigError)(
270
+ `Could not find a "snap.config.js" or "snap.config.ts" file in the current or specified directory ("${path}").`
271
+ );
272
+ }
273
+ async function getConfigByArgv(argv, cwd = process.cwd()) {
274
+ if (argv.config) {
275
+ if (!await _node.isFile.call(void 0, argv.config)) {
276
+ throw new (0, _chunk46JUPGRYjs.ConfigError)(
277
+ `Could not find a config file at "${argv.config}". Make sure that the path is correct.`
278
+ );
279
+ }
280
+ return await loadConfig(argv.config, argv);
281
+ }
282
+ return await resolveConfig(cwd, argv);
283
+ }
284
+ function mergeLegacyOptions(argv, config) {
285
+ const cliOptions = Object.keys(config.cliOptions).reduce((accumulator, key) => {
286
+ if (argv[key] !== void 0) {
287
+ return {
288
+ ...accumulator,
289
+ [key]: argv[key]
290
+ };
291
+ }
292
+ return accumulator;
293
+ }, config.cliOptions);
294
+ return {
295
+ ...config,
296
+ cliOptions
297
+ };
298
+ }
299
+ function getWebpackConfig(legacyConfig) {
300
+ const defaultConfig = _superstruct.create.call(void 0,
301
+ { bundler: "webpack" },
302
+ SnapsWebpackConfigStruct
303
+ );
304
+ const path = legacyConfig.cliOptions.bundle ? _path.dirname.call(void 0, legacyConfig.cliOptions.bundle) : legacyConfig.cliOptions.dist;
305
+ const filename = legacyConfig.cliOptions.bundle ? _path.basename.call(void 0, legacyConfig.cliOptions.bundle) : legacyConfig.cliOptions.outfileName;
306
+ return {
307
+ ...defaultConfig,
308
+ input: legacyConfig.cliOptions.src,
309
+ evaluate: legacyConfig.cliOptions.eval,
310
+ sourceMap: legacyConfig.cliOptions.sourceMaps,
311
+ output: {
312
+ path,
313
+ filename,
314
+ // The legacy config has an option to remove comments from the bundle, but
315
+ // the terser plugin does this by default, so we only enable the terser if
316
+ // the legacy config has `stripComments` set to `true`. This is not a
317
+ // perfect solution, but it's the best we can do without breaking the
318
+ // legacy config.
319
+ minimize: legacyConfig.cliOptions.stripComments,
320
+ // The legacy config does not have a `clean` option, so we default to
321
+ // `false` here.
322
+ clean: false
323
+ },
324
+ manifest: {
325
+ // The legacy config does not have a `manifest` option, so we default to
326
+ // `process.cwd()/snap.manifest.json`.
327
+ path: _path.resolve.call(void 0, process.cwd(), "snap.manifest.json"),
328
+ update: legacyConfig.cliOptions.writeManifest
329
+ },
330
+ server: {
331
+ enabled: legacyConfig.cliOptions.serve,
332
+ port: legacyConfig.cliOptions.port,
333
+ root: legacyConfig.cliOptions.root
334
+ },
335
+ stats: {
336
+ verbose: false,
337
+ // These plugins are designed to be used with the modern config format, so
338
+ // we disable them for the legacy config format.
339
+ builtIns: false,
340
+ buffer: false
341
+ },
342
+ legacy: _node.createFromStruct.call(void 0,
343
+ {
344
+ ...legacyConfig.cliOptions,
345
+ bundlerCustomizer: legacyConfig.bundlerCustomizer
346
+ },
347
+ LegacyOptionsStruct,
348
+ "Invalid Browserify CLI options"
349
+ )
350
+ };
351
+ }
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+ exports.SnapsBrowserifyConfigStruct = SnapsBrowserifyConfigStruct; exports.SnapsWebpackConfigStruct = SnapsWebpackConfigStruct; exports.SnapsConfigStruct = SnapsConfigStruct; exports.LegacyOptionsStruct = LegacyOptionsStruct; exports.getConfig = getConfig; exports.loadConfig = loadConfig; exports.resolveConfig = resolveConfig; exports.getConfigByArgv = getConfigByArgv; exports.mergeLegacyOptions = mergeLegacyOptions; exports.getWebpackConfig = getWebpackConfig;
365
+ //# sourceMappingURL=chunk-2QVYYMUD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAS,SAAS,aAAa;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAE1B,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,OAAO,YAAY;AACnB,SAAS,UAAU,SAAS,eAAe;AAE3C;AAAA,EACE;AAAA,EAC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AA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOA,UAAU,aAAa,WAAW;AAAA;AAAA;AAAA,MAIlC,OAAO;AAAA,IACT;AAAA,IACA,UAAU;AAAA;AAAA;AAAA,MAGR,MAAM,QAAQ,QAAQ,IAAI,GAAG,oBAAoB;AAAA,MACjD,QAAQ,aAAa,WAAW;AAAA,IAClC;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,aAAa,WAAW;AAAA,MACjC,MAAM,aAAa,WAAW;AAAA,MAC9B,MAAM,aAAa,WAAW;AAAA,IAChC;AAAA,IACA,OAAO;AAAA,MACL,SAAS;AAAA;AAAA;AAAA,MAIT,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,GAAG,aAAa;AAAA,QAChB,mBAAmB,aAAa;AAAA,MAClC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n indent,\n isFile,\n SnapsStructError,\n named,\n} from '@metamask/snaps-utils/node';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport type { BrowserifyObject } from 'browserify';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { basename, dirname, resolve } from 'path';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n type,\n unknown,\n empty,\n} from 'superstruct';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { TranspilationModes } from './builders';\nimport { ConfigError } from './errors';\nimport { file } from './structs';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\nexport type SnapBrowserifyConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler: 'browserify';\n\n /**\n * The options for the Snaps CLI. These are merged with the options passed to\n * the CLI, with the CLI options taking precedence.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n cliOptions?: {\n /**\n * The path to the snap bundle file.\n *\n * @default 'dist/bundle.js'\n */\n bundle?: string;\n\n /**\n * The directory to output the snap to. This is only used if `bundle` is\n * not specified.\n *\n * @default 'dist'\n */\n dist?: string;\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n eval?: boolean;\n\n /**\n * Whether to validate the snap manifest.\n *\n * @default true\n */\n manifest?: boolean;\n\n /**\n * The name of the bundle file. This is only used if `bundle` is not\n * specified.\n *\n * @default 'bundle.js'\n */\n outfileName?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n\n /**\n * The root directory to serve the snap from.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * Whether to generate source maps for the snap bundle.\n *\n * @default false\n */\n sourceMaps?: boolean;\n\n /**\n * The path to the snap entry point.\n *\n * @default 'src/index.js'\n */\n src?: string;\n\n /**\n * Whether to remove comments from the bundle.\n *\n * @default true\n */\n stripComments?: boolean;\n\n /**\n * Whether to suppress warnings.\n *\n * @default false\n */\n suppressWarnings?: boolean;\n\n /**\n * The transpilation mode to use, which determines which files are\n * transpiled.\n *\n * - `'localAndDeps'`: Transpile the snap entry point and all dependencies.\n * - `'localOnly'`: Transpile only the snap entry point.\n * - `'none'`: Don't transpile any files.\n *\n * @default 'localOnly'\n */\n transpilationMode?: 'localAndDeps' | 'localOnly' | 'none';\n\n /**\n * The dependencies to transpile when `transpilationMode` is set to\n * `'localAndDeps'`. If not specified, all dependencies will be transpiled.\n */\n depsToTranspile?: string[];\n\n /**\n * Whether to show original errors.\n *\n * @default true\n */\n verboseErrors?: boolean;\n\n /**\n * Whether to write the updated manifest to disk.\n *\n * @default true\n */\n writeManifest?: boolean;\n\n /**\n * Whether to serve the snap locally.\n *\n * @default true\n */\n serve?: boolean;\n };\n\n /**\n * A function that can be used to customize the Browserify instance used to\n * build the snap.\n *\n * @param bundler - The Browserify instance.\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n bundlerCustomizer?: (bundler: BrowserifyObject) => void;\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapWebpackConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler?: 'webpack';\n\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = SnapBrowserifyConfig | SnapWebpackConfig;\n\ntype SnapsBrowserifyBundlerCustomizerFunction = (\n bundler: BrowserifyObject,\n) => void;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsBrowserifyBundlerCustomizerFunctionStruct =\n define<SnapsBrowserifyBundlerCustomizerFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsBrowserifyConfigStruct = object({\n bundler: literal('browserify'),\n cliOptions: defaulted(\n object({\n bundle: optional(file()),\n dist: defaulted(file(), 'dist'),\n eval: defaulted(boolean(), true),\n manifest: defaulted(boolean(), true),\n port: defaulted(number(), 8081),\n outfileName: defaulted(string(), 'bundle.js'),\n root: defaulted(file(), process.cwd()),\n sourceMaps: defaulted(boolean(), false),\n src: defaulted(file(), 'src/index.js'),\n stripComments: defaulted(boolean(), true),\n suppressWarnings: defaulted(boolean(), false),\n transpilationMode: defaulted(\n union([literal('localAndDeps'), literal('localOnly'), literal('none')]),\n 'localOnly',\n ),\n depsToTranspile: defaulted(array(string()), []),\n verboseErrors: defaulted(boolean(), true),\n writeManifest: defaulted(boolean(), true),\n serve: defaulted(boolean(), true),\n }),\n {},\n ),\n bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct),\n});\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsWebpackConfigStruct = object({\n bundler: defaulted(literal('webpack'), 'webpack'),\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport const SnapsConfigStruct = type({\n bundler: defaulted(\n union([literal('browserify'), literal('webpack')]),\n 'webpack',\n ),\n});\n\nexport const LegacyOptionsStruct = union([\n named(\n 'object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings',\n type({\n depsToTranspile: array(string()),\n transpilationMode: literal(TranspilationModes.LocalAndDeps),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n named(\n 'object without `depsToTranspile`',\n type({\n depsToTranspile: named('empty array', empty(array())),\n transpilationMode: union([\n literal(TranspilationModes.LocalOnly),\n literal(TranspilationModes.None),\n ]),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n]);\n\nexport type LegacyOptions = Infer<typeof LegacyOptionsStruct>;\n\nexport type ProcessedBrowserifyConfig = Infer<\n typeof SnapsBrowserifyConfigStruct\n>;\n\nexport type ProcessedWebpackConfig = Infer<typeof SnapsWebpackConfigStruct> & {\n /**\n * The legacy Browserify config, if the bundler is Browserify. This is used\n * to support the legacy config format.\n */\n legacy?: LegacyOptions;\n};\n\nexport type ProcessedConfig = ProcessedWebpackConfig;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown, argv: YargsArgs): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n // TODO: Link to `docs.metamask.io` once the docs are published.\n 'Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/',\n );\n\n const { bundler } = createFromStruct(\n config,\n SnapsConfigStruct,\n prefix,\n suffix,\n );\n\n if (bundler === 'browserify') {\n const legacyConfig = createFromStruct(\n config,\n SnapsBrowserifyConfigStruct,\n prefix,\n suffix,\n );\n\n return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));\n }\n\n return createFromStruct(config, SnapsWebpackConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string, argv: YargsArgs) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports, argv);\n }\n\n return getConfig(config.exports.default, argv);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @param argv - The CLI arguments.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string, argv: YargsArgs) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath, argv);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config, argv);\n }\n\n return await resolveConfig(cwd, argv);\n}\n\n/**\n * Merge legacy CLI options into the config. This is used to support the legacy\n * config format, where options can be specified both in the config file and\n * through CLI flags.\n *\n * @param argv - The CLI arguments.\n * @param config - The config to merge the CLI options into.\n * @returns The config with the CLI options merged in.\n * @deprecated This function is only used to support the legacy config format.\n */\nexport function mergeLegacyOptions(\n argv: YargsArgs,\n config: ProcessedBrowserifyConfig,\n) {\n const cliOptions = Object.keys(config.cliOptions).reduce<\n ProcessedBrowserifyConfig['cliOptions']\n >((accumulator, key) => {\n if (argv[key] !== undefined) {\n return {\n ...accumulator,\n [key]: argv[key],\n };\n }\n\n return accumulator;\n }, config.cliOptions);\n\n return {\n ...config,\n cliOptions,\n };\n}\n\n/**\n * Get a Webpack config from a legacy browserify config. This is used to\n * support the legacy config format, and convert it to the new format.\n *\n * @param legacyConfig - The legacy browserify config.\n * @returns The Webpack config.\n */\nexport function getWebpackConfig(\n legacyConfig: ProcessedBrowserifyConfig,\n): ProcessedWebpackConfig {\n const defaultConfig = create(\n { bundler: 'webpack' },\n SnapsWebpackConfigStruct,\n );\n\n // The legacy config has two options for specifying the output path and\n // filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,\n // we use that as the output path and filename. Otherwise, we use `dist` and\n // `outfileName`.\n const path = legacyConfig.cliOptions.bundle\n ? dirname(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.dist;\n\n const filename = legacyConfig.cliOptions.bundle\n ? basename(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.outfileName;\n\n return {\n ...defaultConfig,\n input: legacyConfig.cliOptions.src,\n evaluate: legacyConfig.cliOptions.eval,\n sourceMap: legacyConfig.cliOptions.sourceMaps,\n output: {\n path,\n filename,\n\n // The legacy config has an option to remove comments from the bundle, but\n // the terser plugin does this by default, so we only enable the terser if\n // the legacy config has `stripComments` set to `true`. This is not a\n // perfect solution, but it's the best we can do without breaking the\n // legacy config.\n minimize: legacyConfig.cliOptions.stripComments,\n\n // The legacy config does not have a `clean` option, so we default to\n // `false` here.\n clean: false,\n },\n manifest: {\n // The legacy config does not have a `manifest` option, so we default to\n // `process.cwd()/snap.manifest.json`.\n path: resolve(process.cwd(), 'snap.manifest.json'),\n update: legacyConfig.cliOptions.writeManifest,\n },\n server: {\n enabled: legacyConfig.cliOptions.serve,\n port: legacyConfig.cliOptions.port,\n root: legacyConfig.cliOptions.root,\n },\n stats: {\n verbose: false,\n\n // These plugins are designed to be used with the modern config format, so\n // we disable them for the legacy config format.\n builtIns: false,\n buffer: false,\n },\n legacy: createFromStruct(\n {\n ...legacyConfig.cliOptions,\n bundlerCustomizer: legacyConfig.bundlerCustomizer,\n },\n LegacyOptionsStruct,\n 'Invalid Browserify CLI options',\n ),\n };\n}\n"]}