@metamask/snaps-cli 5.1.1 → 6.0.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 (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-26C34AS7.mjs +287 -0
  7. package/dist/chunk-26C34AS7.mjs.map +1 -0
  8. package/dist/chunk-2SUDRRT6.mjs +50 -0
  9. package/dist/chunk-2SUDRRT6.mjs.map +1 -0
  10. package/dist/chunk-3WWFQLH4.mjs +30 -0
  11. package/dist/chunk-3WWFQLH4.mjs.map +1 -0
  12. package/dist/chunk-45LOTCC4.mjs +1 -0
  13. package/dist/chunk-45LOTCC4.mjs.map +1 -0
  14. package/dist/chunk-4QUVE3EK.js +53 -0
  15. package/dist/chunk-4QUVE3EK.js.map +1 -0
  16. package/dist/chunk-5CLEKHXE.js +54 -0
  17. package/dist/chunk-5CLEKHXE.js.map +1 -0
  18. package/dist/chunk-5KQNAW4C.mjs +346 -0
  19. package/dist/chunk-5KQNAW4C.mjs.map +1 -0
  20. package/dist/chunk-6EEZHGF5.js +23 -0
  21. package/dist/chunk-6EEZHGF5.js.map +1 -0
  22. package/dist/chunk-7NQQGJZJ.mjs +35 -0
  23. package/dist/chunk-7NQQGJZJ.mjs.map +1 -0
  24. package/dist/chunk-7RHK2YTB.mjs +32 -0
  25. package/dist/chunk-7RHK2YTB.mjs.map +1 -0
  26. package/dist/chunk-AZMQTZXZ.mjs +28 -0
  27. package/dist/chunk-AZMQTZXZ.mjs.map +1 -0
  28. package/dist/chunk-B3NNVTA6.js +32 -0
  29. package/dist/chunk-B3NNVTA6.js.map +1 -0
  30. package/dist/chunk-BALQOCUO.js +22 -0
  31. package/dist/chunk-BALQOCUO.js.map +1 -0
  32. package/dist/chunk-BVPYLBE5.js +365 -0
  33. package/dist/chunk-BVPYLBE5.js.map +1 -0
  34. package/dist/chunk-BYNQODL3.mjs +23 -0
  35. package/dist/chunk-BYNQODL3.mjs.map +1 -0
  36. package/dist/chunk-C44RRX3H.js +18 -0
  37. package/dist/chunk-C44RRX3H.js.map +1 -0
  38. package/dist/chunk-C46KEPAC.js +37 -0
  39. package/dist/chunk-C46KEPAC.js.map +1 -0
  40. package/dist/chunk-CGJKCIHP.js +28 -0
  41. package/dist/chunk-CGJKCIHP.js.map +1 -0
  42. package/dist/chunk-CIYE263O.js +30 -0
  43. package/dist/chunk-CIYE263O.js.map +1 -0
  44. package/dist/chunk-DBLADLQ4.js +10 -0
  45. package/dist/chunk-DBLADLQ4.js.map +1 -0
  46. package/dist/chunk-EDEA4QTA.js +35 -0
  47. package/dist/chunk-EDEA4QTA.js.map +1 -0
  48. package/dist/chunk-ERSRIVYH.mjs +64 -0
  49. package/dist/chunk-ERSRIVYH.mjs.map +1 -0
  50. package/dist/chunk-G3COWLG5.mjs +23 -0
  51. package/dist/chunk-G3COWLG5.mjs.map +1 -0
  52. package/dist/chunk-GKRRE4WN.mjs +30 -0
  53. package/dist/chunk-GKRRE4WN.mjs.map +1 -0
  54. package/dist/chunk-HQBA5RU6.mjs +54 -0
  55. package/dist/chunk-HQBA5RU6.mjs.map +1 -0
  56. package/dist/chunk-HYPSSFE5.mjs +13 -0
  57. package/dist/chunk-HYPSSFE5.mjs.map +1 -0
  58. package/dist/chunk-JAHNVVLT.mjs +18 -0
  59. package/dist/chunk-JAHNVVLT.mjs.map +1 -0
  60. package/dist/chunk-JCVSYVPD.mjs +24 -0
  61. package/dist/chunk-JCVSYVPD.mjs.map +1 -0
  62. package/dist/chunk-JI3B665Z.js +24 -0
  63. package/dist/chunk-JI3B665Z.js.map +1 -0
  64. package/dist/chunk-JL3URCHO.mjs +53 -0
  65. package/dist/chunk-JL3URCHO.mjs.map +1 -0
  66. package/dist/chunk-K26BOY6Z.mjs +51 -0
  67. package/dist/chunk-K26BOY6Z.mjs.map +1 -0
  68. package/dist/chunk-K5QMGTQL.mjs +22 -0
  69. package/dist/chunk-K5QMGTQL.mjs.map +1 -0
  70. package/dist/chunk-KLOPX6DO.js +51 -0
  71. package/dist/chunk-KLOPX6DO.js.map +1 -0
  72. package/dist/chunk-KUSHMQXD.js +64 -0
  73. package/dist/chunk-KUSHMQXD.js.map +1 -0
  74. package/dist/chunk-L72RLBV5.mjs +37 -0
  75. package/dist/chunk-L72RLBV5.mjs.map +1 -0
  76. package/dist/chunk-MDHJ5HLM.js +287 -0
  77. package/dist/chunk-MDHJ5HLM.js.map +1 -0
  78. package/dist/chunk-MR44GPM3.mjs +135 -0
  79. package/dist/chunk-MR44GPM3.mjs.map +1 -0
  80. package/dist/chunk-MUYXNION.js +30 -0
  81. package/dist/chunk-MUYXNION.js.map +1 -0
  82. package/dist/chunk-OKDY7C7S.js +346 -0
  83. package/dist/chunk-OKDY7C7S.js.map +1 -0
  84. package/dist/chunk-OPE2PGM6.mjs +24 -0
  85. package/dist/chunk-OPE2PGM6.mjs.map +1 -0
  86. package/dist/chunk-PDYQXXLP.js +30 -0
  87. package/dist/chunk-PDYQXXLP.js.map +1 -0
  88. package/dist/chunk-PFB25A2Q.mjs +52 -0
  89. package/dist/chunk-PFB25A2Q.mjs.map +1 -0
  90. package/dist/chunk-QFK7JVP3.js +52 -0
  91. package/dist/chunk-QFK7JVP3.js.map +1 -0
  92. package/dist/chunk-QHCKVO3P.js +28 -0
  93. package/dist/chunk-QHCKVO3P.js.map +1 -0
  94. package/dist/chunk-QMD3VO6R.mjs +30 -0
  95. package/dist/chunk-QMD3VO6R.mjs.map +1 -0
  96. package/dist/chunk-R6NBQKVH.js +16 -0
  97. package/dist/chunk-R6NBQKVH.js.map +1 -0
  98. package/dist/chunk-R77RJHC5.mjs +44 -0
  99. package/dist/chunk-R77RJHC5.mjs.map +1 -0
  100. package/dist/chunk-S45DIQPN.js +13 -0
  101. package/dist/chunk-S45DIQPN.js.map +1 -0
  102. package/dist/chunk-S76EZ6HY.js +23 -0
  103. package/dist/chunk-S76EZ6HY.js.map +1 -0
  104. package/dist/chunk-S7UP2YYF.js +135 -0
  105. package/dist/chunk-S7UP2YYF.js.map +1 -0
  106. package/dist/chunk-SVYNCWMH.js +61 -0
  107. package/dist/chunk-SVYNCWMH.js.map +1 -0
  108. package/dist/chunk-SYRWT2KT.mjs +124 -0
  109. package/dist/chunk-SYRWT2KT.mjs.map +1 -0
  110. package/dist/chunk-T7NEPTM5.mjs +61 -0
  111. package/dist/chunk-T7NEPTM5.mjs.map +1 -0
  112. package/dist/chunk-TDSL55B3.mjs +10 -0
  113. package/dist/chunk-TDSL55B3.mjs.map +1 -0
  114. package/dist/chunk-TJ2F3J6X.js +31 -0
  115. package/dist/chunk-TJ2F3J6X.js.map +1 -0
  116. package/dist/chunk-U4VFMIGO.js +24 -0
  117. package/dist/chunk-U4VFMIGO.js.map +1 -0
  118. package/dist/chunk-VXOV3ZCB.js +1 -0
  119. package/dist/chunk-VXOV3ZCB.js.map +1 -0
  120. package/dist/chunk-WO7DMSQU.mjs +16 -0
  121. package/dist/chunk-WO7DMSQU.mjs.map +1 -0
  122. package/dist/chunk-WP2N4NCO.js +50 -0
  123. package/dist/chunk-WP2N4NCO.js.map +1 -0
  124. package/dist/chunk-WYDHPUWV.mjs +28 -0
  125. package/dist/chunk-WYDHPUWV.mjs.map +1 -0
  126. package/dist/chunk-X3D3MHWF.js +44 -0
  127. package/dist/chunk-X3D3MHWF.js.map +1 -0
  128. package/dist/chunk-X7TESUC7.mjs +22 -0
  129. package/dist/chunk-X7TESUC7.mjs.map +1 -0
  130. package/dist/chunk-X7VYAL2L.mjs +365 -0
  131. package/dist/chunk-X7VYAL2L.mjs.map +1 -0
  132. package/dist/chunk-XGWLFH7Y.js +41 -0
  133. package/dist/chunk-XGWLFH7Y.js.map +1 -0
  134. package/dist/{cjs/webpack/config.js → chunk-XUYXKO4F.js} +181 -153
  135. package/dist/chunk-XUYXKO4F.js.map +1 -0
  136. package/dist/chunk-XZJLYKES.mjs +64 -0
  137. package/dist/chunk-XZJLYKES.mjs.map +1 -0
  138. package/dist/chunk-YCYGKEXF.mjs +41 -0
  139. package/dist/chunk-YCYGKEXF.mjs.map +1 -0
  140. package/dist/chunk-YGEAZQSC.js +124 -0
  141. package/dist/chunk-YGEAZQSC.js.map +1 -0
  142. package/dist/chunk-YQ2E7NEA.js +64 -0
  143. package/dist/chunk-YQ2E7NEA.js.map +1 -0
  144. package/dist/chunk-YQVCFM6L.js +22 -0
  145. package/dist/chunk-YQVCFM6L.js.map +1 -0
  146. package/dist/{esm/webpack/config.js → chunk-YWCNJELN.mjs} +182 -156
  147. package/dist/chunk-YWCNJELN.mjs.map +1 -0
  148. package/dist/chunk-ZAW4ZWQX.mjs +31 -0
  149. package/dist/chunk-ZAW4ZWQX.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 +1 -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 -254
  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 -285
  456. package/dist/esm/webpack/utils.js.map +0 -1
@@ -0,0 +1,346 @@
1
+ import {
2
+ evaluate
3
+ } from "./chunk-3WWFQLH4.mjs";
4
+ import {
5
+ formatText,
6
+ pluralize
7
+ } from "./chunk-26C34AS7.mjs";
8
+ import {
9
+ getErrorMessage
10
+ } from "./chunk-7RHK2YTB.mjs";
11
+ import {
12
+ error,
13
+ info,
14
+ warn
15
+ } from "./chunk-ZAW4ZWQX.mjs";
16
+ import {
17
+ __privateAdd,
18
+ __privateGet,
19
+ __privateMethod,
20
+ __privateSet
21
+ } from "./chunk-R77RJHC5.mjs";
22
+
23
+ // src/webpack/plugins.ts
24
+ import { assert, hasProperty, isObject } from "@metamask/utils";
25
+ import { bold, dim, red, yellow } from "chalk";
26
+ import { isBuiltin } from "module";
27
+ import { WebpackError } from "webpack";
28
+ var _spinner, _getStatsErrorMessage, getStatsErrorMessage_fn;
29
+ var SnapsStatsPlugin = class {
30
+ constructor(options = {
31
+ verbose: false
32
+ }, spinner) {
33
+ /**
34
+ * Get the error message for the given stats error.
35
+ *
36
+ * @param statsError - The stats error.
37
+ * @param color - The color to use for the error message.
38
+ * @returns The error message.
39
+ */
40
+ __privateAdd(this, _getStatsErrorMessage);
41
+ /**
42
+ * The spinner to use for logging.
43
+ */
44
+ __privateAdd(this, _spinner, void 0);
45
+ this.options = options;
46
+ __privateSet(this, _spinner, spinner);
47
+ }
48
+ /**
49
+ * Apply the plugin to the Webpack compiler.
50
+ *
51
+ * @param compiler - The Webpack compiler.
52
+ */
53
+ apply(compiler) {
54
+ compiler.hooks.afterDone.tap(this.constructor.name, (stats) => {
55
+ if (!stats) {
56
+ return;
57
+ }
58
+ const { modules, time, errors, warnings } = stats.toJson();
59
+ assert(modules, "Modules must be defined in stats.");
60
+ assert(time, "Time must be defined in stats.");
61
+ if (errors?.length) {
62
+ const formattedErrors = errors.map((statsError) => __privateMethod(this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsError)).join("\n\n");
63
+ error(
64
+ `Compiled ${modules.length} ${pluralize(
65
+ modules.length,
66
+ "file"
67
+ )} in ${time}ms with ${errors.length} ${pluralize(
68
+ errors.length,
69
+ "error"
70
+ )}.
71
+
72
+ ${formattedErrors}
73
+ `,
74
+ __privateGet(this, _spinner)
75
+ );
76
+ __privateGet(this, _spinner)?.stop();
77
+ process.exitCode = 1;
78
+ return;
79
+ }
80
+ if (warnings?.length) {
81
+ const formattedWarnings = warnings.map(
82
+ (statsWarning) => __privateMethod(this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsWarning, yellow)
83
+ ).join("\n\n");
84
+ warn(
85
+ `Compiled ${modules.length} ${pluralize(
86
+ modules.length,
87
+ "file"
88
+ )} in ${time}ms with ${warnings.length} ${pluralize(
89
+ warnings.length,
90
+ "warning"
91
+ )}.
92
+
93
+ ${formattedWarnings}
94
+ `,
95
+ __privateGet(this, _spinner)
96
+ );
97
+ } else {
98
+ info(
99
+ `Compiled ${modules.length} ${pluralize(
100
+ modules.length,
101
+ "file"
102
+ )} in ${time}ms.`,
103
+ __privateGet(this, _spinner)
104
+ );
105
+ }
106
+ if (compiler.watchMode) {
107
+ __privateGet(this, _spinner)?.succeed("Done!");
108
+ }
109
+ });
110
+ }
111
+ };
112
+ _spinner = new WeakMap();
113
+ _getStatsErrorMessage = new WeakSet();
114
+ getStatsErrorMessage_fn = function(statsError, color = red) {
115
+ const baseMessage = this.options.verbose ? getErrorMessage(statsError) : statsError.message;
116
+ const [first, ...rest] = baseMessage.split("\n");
117
+ return [
118
+ color(formatText(`\u2022 ${first}`, 4, 2)),
119
+ ...rest.map((message) => formatText(color(message), 4)),
120
+ statsError.details && `
121
+ ${formatText(dim(statsError.details), 6)}`
122
+ ].filter(Boolean).join("\n");
123
+ };
124
+ var _spinner2, _safeEvaluate, safeEvaluate_fn;
125
+ var SnapsWatchPlugin = class {
126
+ constructor(options, spinner) {
127
+ /**
128
+ * Safely evaluate the bundle at the given path. If an error occurs, it will
129
+ * be logged to the console, rather than throwing an error.
130
+ *
131
+ * This function should never throw an error.
132
+ *
133
+ * @param bundlePath - The path to the bundle.
134
+ */
135
+ __privateAdd(this, _safeEvaluate);
136
+ /**
137
+ * The spinner to use for logging.
138
+ */
139
+ __privateAdd(this, _spinner2, void 0);
140
+ this.options = options;
141
+ __privateSet(this, _spinner2, spinner);
142
+ }
143
+ /**
144
+ * Apply the plugin to the Webpack compiler.
145
+ *
146
+ * @param compiler - The Webpack compiler.
147
+ */
148
+ apply(compiler) {
149
+ compiler.hooks.invalid.tap(this.constructor.name, (file) => {
150
+ __privateGet(this, _spinner2)?.start();
151
+ info(`Changes detected in ${yellow(file)}, recompiling.`, __privateGet(this, _spinner2));
152
+ });
153
+ compiler.hooks.afterEmit.tapPromise(
154
+ this.constructor.name,
155
+ async ({ fileDependencies }) => {
156
+ this.options.files?.forEach(
157
+ fileDependencies.add.bind(fileDependencies)
158
+ );
159
+ if (this.options.bundle && this.options.evaluate) {
160
+ await __privateMethod(this, _safeEvaluate, safeEvaluate_fn).call(this, this.options.bundle);
161
+ }
162
+ }
163
+ );
164
+ }
165
+ };
166
+ _spinner2 = new WeakMap();
167
+ _safeEvaluate = new WeakSet();
168
+ safeEvaluate_fn = async function(bundlePath) {
169
+ try {
170
+ await evaluate(bundlePath);
171
+ info(`Snap bundle evaluated successfully.`, __privateGet(this, _spinner2));
172
+ } catch (evaluateError) {
173
+ error(evaluateError.message, __privateGet(this, _spinner2));
174
+ }
175
+ };
176
+ var _source, _spinner3;
177
+ var SnapsBuiltInResolver = class {
178
+ constructor(options = {
179
+ ignore: []
180
+ }, spinner) {
181
+ /**
182
+ * The built-in modules that have been imported, but not resolved.
183
+ */
184
+ this.unresolvedModules = /* @__PURE__ */ new Set();
185
+ /**
186
+ * The name of the resolver hook to tap into.
187
+ */
188
+ __privateAdd(this, _source, "described-resolve");
189
+ /**
190
+ * The spinner to use for logging.
191
+ */
192
+ __privateAdd(this, _spinner3, void 0);
193
+ this.options = options;
194
+ __privateSet(this, _spinner3, spinner);
195
+ }
196
+ /**
197
+ * Apply the plugin to the Webpack resolver.
198
+ *
199
+ * @param resolver - The Webpack resolver.
200
+ */
201
+ apply(resolver) {
202
+ resolver.getHook(__privateGet(this, _source)).tapAsync(
203
+ this.constructor.name,
204
+ ({ module: isModule, request }, _, callback) => {
205
+ if (!isModule || !request) {
206
+ return callback();
207
+ }
208
+ const baseRequest = request.split("/")[0];
209
+ if (isBuiltin(baseRequest) && !this.options.ignore?.includes(baseRequest)) {
210
+ const fallback = resolver.options.fallback.find(
211
+ ({ name }) => name === baseRequest
212
+ );
213
+ if (fallback && !fallback.alias) {
214
+ this.unresolvedModules.add(baseRequest);
215
+ }
216
+ }
217
+ return callback();
218
+ }
219
+ );
220
+ }
221
+ };
222
+ _source = new WeakMap();
223
+ _spinner3 = new WeakMap();
224
+ var _checkBuiltIns, checkBuiltIns_fn, _isProvidePlugin, isProvidePlugin_fn, _checkBuffer, checkBuffer_fn;
225
+ var SnapsBundleWarningsPlugin = class {
226
+ constructor(options = {
227
+ buffer: true,
228
+ builtIns: true
229
+ }) {
230
+ /**
231
+ * Check if a built-in module is used, but not provided by Webpack's
232
+ * `fallback` configuration.
233
+ *
234
+ * @param compiler - The Webpack compiler.
235
+ */
236
+ __privateAdd(this, _checkBuiltIns);
237
+ /**
238
+ * Check if the given instance is a `ProvidePlugin`. This is not guaranteed to
239
+ * be accurate, but it's good enough for our purposes. If we were to use
240
+ * `instanceof` instead, it might not work if multiple versions of Webpack are
241
+ * installed.
242
+ *
243
+ * @param instance - The instance to check.
244
+ * @returns Whether the instance is a `ProvidePlugin`, i.e., whether it's an
245
+ * object with the name `ProvidePlugin` and a `definitions` property.
246
+ */
247
+ __privateAdd(this, _isProvidePlugin);
248
+ /**
249
+ * Check if the `Buffer` global is used, but not provided by Webpack's
250
+ * `DefinePlugin`.
251
+ *
252
+ * @param compiler - The Webpack compiler.
253
+ */
254
+ __privateAdd(this, _checkBuffer);
255
+ this.options = options;
256
+ }
257
+ /**
258
+ * Apply the plugin to the Webpack compiler.
259
+ *
260
+ * @param compiler - The Webpack compiler.
261
+ */
262
+ apply(compiler) {
263
+ if (this.options.builtIns) {
264
+ __privateMethod(this, _checkBuiltIns, checkBuiltIns_fn).call(this, compiler);
265
+ }
266
+ if (this.options.buffer) {
267
+ __privateMethod(this, _checkBuffer, checkBuffer_fn).call(this, compiler);
268
+ }
269
+ }
270
+ };
271
+ _checkBuiltIns = new WeakSet();
272
+ checkBuiltIns_fn = function(compiler) {
273
+ compiler.hooks.afterCompile.tap(this.constructor.name, (compilation) => {
274
+ if (!this.options.builtInResolver) {
275
+ return;
276
+ }
277
+ const { unresolvedModules } = this.options.builtInResolver;
278
+ if (unresolvedModules.size === 0) {
279
+ return;
280
+ }
281
+ const formattedModules = new Array(...unresolvedModules).map((name) => `\u2022 ${name}`).join("\n");
282
+ const webpackError = new WebpackError(
283
+ `The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided. The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must set ${bold(
284
+ "`polyfills`"
285
+ )} to ${bold(
286
+ "`true`"
287
+ )} or an object with the builtins to polyfill as the key and ${bold(
288
+ "`true`"
289
+ )} as the value. To disable this warning, set ${bold(
290
+ "`stats.builtIns`"
291
+ )} to ${bold(
292
+ "`false`"
293
+ )} in your snap config file, or add the module to the ${bold(
294
+ "`stats.builtIns.ignore`"
295
+ )} array.`
296
+ );
297
+ webpackError.details = formattedModules;
298
+ compilation.warnings.push(webpackError);
299
+ });
300
+ };
301
+ _isProvidePlugin = new WeakSet();
302
+ isProvidePlugin_fn = function(instance) {
303
+ return isObject(instance) && instance.constructor.name === "ProvidePlugin" && hasProperty(instance, "definitions");
304
+ };
305
+ _checkBuffer = new WeakSet();
306
+ checkBuffer_fn = function(compiler) {
307
+ const plugin = compiler.options.plugins?.find(
308
+ (instance) => __privateMethod(this, _isProvidePlugin, isProvidePlugin_fn).call(this, instance)
309
+ );
310
+ if (plugin) {
311
+ const { definitions } = plugin;
312
+ if (definitions.Buffer) {
313
+ return;
314
+ }
315
+ }
316
+ compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
317
+ compilation.hooks.afterProcessAssets.tap(
318
+ this.constructor.name,
319
+ (assets) => {
320
+ const bufferAssets = Object.entries(assets).filter(([name]) => name.endsWith(".js")).filter(([, asset]) => asset.source().includes("Buffer"));
321
+ if (bufferAssets.length === 0) {
322
+ return;
323
+ }
324
+ compilation.warnings.push(
325
+ new WebpackError(
326
+ `The snap attempted to use the Node.js Buffer global, which is not supported in the MetaMask Snaps CLI by default. To use the Buffer global, you must polyfill Buffer by setting ${bold(
327
+ "`buffer`"
328
+ )} to ${bold("`true`")} in the ${bold(
329
+ "`polyfills`"
330
+ )} config object in your snap config. To disable this warning, set ${bold(
331
+ "`stats.buffer`"
332
+ )} to ${bold("`false`")} in your snap config file.`
333
+ )
334
+ );
335
+ }
336
+ );
337
+ });
338
+ };
339
+
340
+ export {
341
+ SnapsStatsPlugin,
342
+ SnapsWatchPlugin,
343
+ SnapsBuiltInResolver,
344
+ SnapsBundleWarningsPlugin
345
+ };
346
+ //# sourceMappingURL=chunk-5KQNAW4C.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webpack/plugins.ts"],"sourcesContent":["import { assert, hasProperty, isObject } from '@metamask/utils';\nimport { bold, dim, red, yellow } from 'chalk';\nimport { isBuiltin } from 'module';\nimport type { Ora } from 'ora';\nimport type {\n Compiler,\n ProvidePlugin,\n ResolvePluginInstance,\n Resolver,\n StatsError,\n WebpackPluginInstance,\n} from 'webpack';\nimport { WebpackError } from 'webpack';\n\nimport { evaluate } from '../commands/eval';\nimport { error, getErrorMessage, info, warn } from '../utils';\nimport { formatText, pluralize } from './utils';\n\nexport type SnapsStatsPluginOptions = {\n /**\n * Whether to log the verbose stats.\n */\n verbose?: boolean;\n};\n\n/**\n * A plugin that logs the stats after compilation. This is useful for logging\n * the number of files compiled, and the time taken to compile them.\n */\nexport class SnapsStatsPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsStatsPluginOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(\n options: SnapsStatsPluginOptions = {\n verbose: false,\n },\n spinner?: Ora,\n ) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n compiler.hooks.afterDone.tap(this.constructor.name, (stats) => {\n if (!stats) {\n return;\n }\n\n const { modules, time, errors, warnings } = stats.toJson();\n\n assert(modules, 'Modules must be defined in stats.');\n assert(time, 'Time must be defined in stats.');\n\n if (errors?.length) {\n const formattedErrors = errors\n .map((statsError) => this.#getStatsErrorMessage(statsError))\n .join('\\n\\n');\n\n error(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms with ${errors.length} ${pluralize(\n errors.length,\n 'error',\n )}.\\n\\n${formattedErrors}\\n`,\n this.#spinner,\n );\n\n this.#spinner?.stop();\n\n process.exitCode = 1;\n return;\n }\n\n if (warnings?.length) {\n const formattedWarnings = warnings\n .map((statsWarning) =>\n this.#getStatsErrorMessage(statsWarning, yellow),\n )\n .join('\\n\\n');\n\n warn(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms with ${warnings.length} ${pluralize(\n warnings.length,\n 'warning',\n )}.\\n\\n${formattedWarnings}\\n`,\n this.#spinner,\n );\n } else {\n info(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms.`,\n this.#spinner,\n );\n }\n\n if (compiler.watchMode) {\n // The spinner may be restarted by the watch plugin, outside of the\n // `executeSteps` flow, so we stop it here just in case.\n this.#spinner?.succeed('Done!');\n }\n });\n }\n\n /**\n * Get the error message for the given stats error.\n *\n * @param statsError - The stats error.\n * @param color - The color to use for the error message.\n * @returns The error message.\n */\n #getStatsErrorMessage(statsError: StatsError, color = red) {\n const baseMessage = this.options.verbose\n ? getErrorMessage(statsError)\n : statsError.message;\n\n const [first, ...rest] = baseMessage.split('\\n');\n\n return [\n color(formatText(`• ${first}`, 4, 2)),\n ...rest.map((message) => formatText(color(message), 4)),\n statsError.details && `\\n${formatText(dim(statsError.details), 6)}`,\n ]\n .filter(Boolean)\n .join('\\n');\n }\n}\n\n/**\n * The options for the {@link SnapsWatchPlugin}.\n */\nexport type SnapsWatchPluginOptions = {\n /**\n * The bundle path. This is the file that will be evaluated, if the `evaluate`\n * option is set.\n */\n bundle?: string;\n\n /**\n * Whether to evaluate the bundle. This only applies if the `bundle` option is\n * set.\n */\n evaluate?: boolean;\n\n /**\n * The extra files to watch.\n */\n files?: string[];\n};\n\n/**\n * A plugin that adds extra files to watch. This is useful for watching files\n * that are not imported by the entry point, such as the `snap.manifest.json`\n * file.\n */\nexport class SnapsWatchPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsWatchPluginOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(options: SnapsWatchPluginOptions, spinner?: Ora) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n compiler.hooks.invalid.tap(this.constructor.name, (file) => {\n this.#spinner?.start();\n info(`Changes detected in ${yellow(file)}, recompiling.`, this.#spinner);\n });\n\n compiler.hooks.afterEmit.tapPromise(\n this.constructor.name,\n async ({ fileDependencies }) => {\n this.options.files?.forEach(\n fileDependencies.add.bind(fileDependencies),\n );\n\n if (this.options.bundle && this.options.evaluate) {\n await this.#safeEvaluate(this.options.bundle);\n }\n },\n );\n }\n\n /**\n * Safely evaluate the bundle at the given path. If an error occurs, it will\n * be logged to the console, rather than throwing an error.\n *\n * This function should never throw an error.\n *\n * @param bundlePath - The path to the bundle.\n */\n async #safeEvaluate(bundlePath: string) {\n try {\n await evaluate(bundlePath);\n info(`Snap bundle evaluated successfully.`, this.#spinner);\n } catch (evaluateError) {\n error(evaluateError.message, this.#spinner);\n }\n }\n}\n\n/**\n * The options for the {@link SnapsBuiltInResolver}.\n */\nexport type SnapsBuiltInResolverOptions = {\n /**\n * The built-in modules to ignore.\n */\n ignore?: string[];\n};\n\n/**\n * A plugin that logs a message when a built-in module is not resolved. The\n * MetaMask Snaps CLI does not support built-in modules by default, and this\n * plugin is used to warn the user when they try to import a built-in module,\n * when no fallback is configured.\n */\nexport class SnapsBuiltInResolver implements ResolvePluginInstance {\n /**\n * The built-in modules that have been imported, but not resolved.\n */\n readonly unresolvedModules = new Set<string>();\n\n /**\n * The name of the resolver hook to tap into.\n */\n readonly #source = 'described-resolve';\n\n /**\n * The options for the plugin.\n */\n readonly options: SnapsBuiltInResolverOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(\n options: SnapsBuiltInResolverOptions = {\n ignore: [],\n },\n spinner?: Ora,\n ) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack resolver.\n *\n * @param resolver - The Webpack resolver.\n */\n apply(resolver: Resolver) {\n resolver\n .getHook(this.#source)\n .tapAsync(\n this.constructor.name,\n ({ module: isModule, request }, _, callback) => {\n if (!isModule || !request) {\n return callback();\n }\n\n const baseRequest = request.split('/')[0];\n if (\n isBuiltin(baseRequest) &&\n !this.options.ignore?.includes(baseRequest)\n ) {\n const fallback = resolver.options.fallback.find(\n ({ name }) => name === baseRequest,\n );\n\n if (fallback && !fallback.alias) {\n this.unresolvedModules.add(baseRequest);\n }\n }\n\n return callback();\n },\n );\n }\n}\n\n/**\n * The options for the {@link SnapsBundleWarningsPlugin}.\n */\nexport type SnapsBundleWarningsPluginOptions = {\n /**\n * The {@link SnapsBuiltInResolver} instance to use for detecting built-in\n * modules.\n */\n builtInResolver?: SnapsBuiltInResolver | false;\n\n /**\n * Whether to show warnings if built-in modules are used, but not provided by\n * Webpack's `fallback` configuration.\n */\n builtIns?: boolean;\n\n /**\n * Whether to show warnings if the `Buffer` global is used, but not provided\n * by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n};\n\n/**\n * A plugin that logs a message when:\n *\n * - A built-in module is not resolved. The MetaMask Snaps CLI does not support\n * built-in modules by default, and this plugin is used to warn the user when\n * they try to import a built-in module, when no fallback is configured.\n * - A snap uses the `Buffer` global. The MetaMask Snaps CLI does not support\n * the `Buffer` global by default, and this plugin is used to warn the user when\n * they try to use the `Buffer` global.\n *\n * We use both a resolver and a plugin, because the resolver is used to detect\n * when a built-in module is imported, and the plugin is used to log a single\n * message when the compilation is complete. We can't do everything in a single\n * plugin, because the resolver doesn't have access to the compilation, and the\n * plugin doesn't have access to the resolver.\n */\n\nexport class SnapsBundleWarningsPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsBundleWarningsPluginOptions;\n\n constructor(\n options: SnapsBundleWarningsPluginOptions = {\n buffer: true,\n builtIns: true,\n },\n ) {\n this.options = options;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n if (this.options.builtIns) {\n this.#checkBuiltIns(compiler);\n }\n\n if (this.options.buffer) {\n this.#checkBuffer(compiler);\n }\n }\n\n /**\n * Check if a built-in module is used, but not provided by Webpack's\n * `fallback` configuration.\n *\n * @param compiler - The Webpack compiler.\n */\n #checkBuiltIns(compiler: Compiler) {\n compiler.hooks.afterCompile.tap(this.constructor.name, (compilation) => {\n if (!this.options.builtInResolver) {\n return;\n }\n\n const { unresolvedModules } = this.options.builtInResolver;\n if (unresolvedModules.size === 0) {\n return;\n }\n\n const formattedModules = new Array(...unresolvedModules)\n .map((name) => `• ${name}`)\n .join('\\n');\n\n const webpackError = new WebpackError(\n `The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided. The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must set ${bold(\n '`polyfills`',\n )} to ${bold(\n '`true`',\n )} or an object with the builtins to polyfill as the key and ${bold(\n '`true`',\n )} as the value. To disable this warning, set ${bold(\n '`stats.builtIns`',\n )} to ${bold(\n '`false`',\n )} in your snap config file, or add the module to the ${bold(\n '`stats.builtIns.ignore`',\n )} array.`,\n );\n\n webpackError.details = formattedModules;\n compilation.warnings.push(webpackError);\n });\n }\n\n /**\n * Check if the given instance is a `ProvidePlugin`. This is not guaranteed to\n * be accurate, but it's good enough for our purposes. If we were to use\n * `instanceof` instead, it might not work if multiple versions of Webpack are\n * installed.\n *\n * @param instance - The instance to check.\n * @returns Whether the instance is a `ProvidePlugin`, i.e., whether it's an\n * object with the name `ProvidePlugin` and a `definitions` property.\n */\n #isProvidePlugin(instance: unknown): instance is ProvidePlugin {\n return (\n isObject(instance) &&\n instance.constructor.name === 'ProvidePlugin' &&\n hasProperty(instance, 'definitions')\n );\n }\n\n /**\n * Check if the `Buffer` global is used, but not provided by Webpack's\n * `DefinePlugin`.\n *\n * @param compiler - The Webpack compiler.\n */\n #checkBuffer(compiler: Compiler) {\n const plugin = compiler.options.plugins?.find((instance) =>\n this.#isProvidePlugin(instance),\n ) as ProvidePlugin | undefined;\n\n // If the `ProvidePlugin` is configured to provide `Buffer`, then we don't\n // need to warn the user.\n if (plugin) {\n const { definitions } = plugin;\n if (definitions.Buffer) {\n return;\n }\n }\n\n compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {\n compilation.hooks.afterProcessAssets.tap(\n this.constructor.name,\n (assets) => {\n // Check if assets use `Buffer`.\n const bufferAssets = Object.entries(assets)\n .filter(([name]) => name.endsWith('.js'))\n .filter(([, asset]) => asset.source().includes('Buffer'));\n\n if (bufferAssets.length === 0) {\n return;\n }\n\n compilation.warnings.push(\n new WebpackError(\n `The snap attempted to use the Node.js Buffer global, which is not supported in the MetaMask Snaps CLI by default. To use the Buffer global, you must polyfill Buffer by setting ${bold(\n '`buffer`',\n )} to ${bold('`true`')} in the ${bold(\n '`polyfills`',\n )} config object in your snap config. To disable this warning, set ${bold(\n '`stats.buffer`',\n )} to ${bold('`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A,cAC/B;AAAA,YACF,CAAC,oEAAoE;AAAA,cACnE;AAAA,YACF,CAAC,OAAO,KAAK,SAAS,CAAC;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["_spinner"]}
@@ -0,0 +1,23 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkKLOPX6DOjs = require('./chunk-KLOPX6DO.js');
4
+
5
+
6
+ var _chunkS7UP2YYFjs = require('./chunk-S7UP2YYF.js');
7
+
8
+ // src/commands/eval/index.ts
9
+ var command = {
10
+ command: ["eval", "e"],
11
+ desc: "Attempt to evaluate snap bundle in SES",
12
+ builder: (yarg) => {
13
+ yarg.option("bundle", _chunkS7UP2YYFjs.builders_default.bundle);
14
+ yarg.option("input", _chunkS7UP2YYFjs.builders_default.input);
15
+ },
16
+ handler: async (argv) => _chunkKLOPX6DOjs.evaluateHandler.call(void 0, argv.context.config, { input: argv.input })
17
+ };
18
+ var eval_default = command;
19
+
20
+
21
+
22
+ exports.eval_default = eval_default;
23
+ //# sourceMappingURL=chunk-6EEZHGF5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/eval/index.ts"],"names":[],"mappings":";;;;;;;;AAMA,IAAM,UAAU;AAAA,EACd,SAAS,CAAC,QAAQ,GAAG;AAAA,EACrB,MAAM;AAAA,EACN,SAAS,CAAC,SAAqB;AAE7B,SAAK,OAAO,UAAU,iBAAS,MAAM;AAGrC,SAAK,OAAO,SAAS,iBAAS,KAAK;AAAA,EACrC;AAAA,EACA,SAAS,OAAO,SACd,gBAAgB,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;AAC9D;AAGA,IAAO,eAAQ","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"]}
@@ -0,0 +1,35 @@
1
+ import {
2
+ getCompiler
3
+ } from "./chunk-WO7DMSQU.mjs";
4
+
5
+ // src/commands/watch/implementation.ts
6
+ import { basename } from "path";
7
+ async function watch(config, options) {
8
+ const compiler = await getCompiler(config, {
9
+ evaluate: config.evaluate,
10
+ watch: true,
11
+ spinner: options?.spinner
12
+ });
13
+ return new Promise((resolve, reject) => {
14
+ compiler.watch(
15
+ {
16
+ ignored: [
17
+ "**/node_modules/**/*",
18
+ `**/${basename(config.output.path)}/**/*`
19
+ ]
20
+ },
21
+ (watchError) => {
22
+ if (watchError) {
23
+ reject(watchError);
24
+ return;
25
+ }
26
+ resolve(compiler.watching);
27
+ }
28
+ );
29
+ });
30
+ }
31
+
32
+ export {
33
+ watch
34
+ };
35
+ //# sourceMappingURL=chunk-7NQQGJZJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/watch/implementation.ts"],"sourcesContent":["import { basename } from 'path';\nimport type { Watching } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle and watch for changes. This uses Webpack to build the\n * 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 for the first time.\n * The promise resolves with a Webpack watching instance that can be used to\n * close the watcher.\n */\nexport async function watch(\n config: ProcessedWebpackConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, {\n evaluate: config.evaluate,\n watch: true,\n spinner: options?.spinner,\n });\n\n return new Promise<Watching>((resolve, reject) => {\n compiler.watch(\n {\n ignored: [\n '**/node_modules/**/*',\n `**/${basename(config.output.path)}/**/*`,\n ],\n },\n (watchError) => {\n if (watchError) {\n reject(watchError);\n return;\n }\n\n resolve(compiler.watching);\n },\n );\n });\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAiBzB,eAAsB,MACpB,QACA,SACA;AACA,QAAM,WAAW,MAAM,YAAY,QAAQ;AAAA,IACzC,UAAU,OAAO;AAAA,IACjB,OAAO;AAAA,IACP,SAAS,SAAS;AAAA,EACpB,CAAC;AAED,SAAO,IAAI,QAAkB,CAAC,SAAS,WAAW;AAChD,aAAS;AAAA,MACP;AAAA,QACE,SAAS;AAAA,UACP;AAAA,UACA,MAAM,SAAS,OAAO,OAAO,IAAI,CAAC;AAAA,QACpC;AAAA,MACF;AAAA,MACA,CAAC,eAAe;AACd,YAAI,YAAY;AACd,iBAAO,UAAU;AACjB;AAAA,QACF;AAEA,gBAAQ,SAAS,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,32 @@
1
+ import {
2
+ CLIError
3
+ } from "./chunk-X7TESUC7.mjs";
4
+
5
+ // src/utils/errors.ts
6
+ import { hasProperty, isObject } from "@metamask/utils";
7
+ function getYargsErrorMessage(message, error) {
8
+ if (error) {
9
+ if (error instanceof CLIError) {
10
+ return error.message;
11
+ }
12
+ return getErrorMessage(error);
13
+ }
14
+ return message;
15
+ }
16
+ function getErrorMessage(error) {
17
+ if (isObject(error)) {
18
+ if (hasProperty(error, "stack") && typeof error.stack === "string") {
19
+ return error.stack;
20
+ }
21
+ if (hasProperty(error, "message") && typeof error.message === "string") {
22
+ return error.message;
23
+ }
24
+ }
25
+ return String(error);
26
+ }
27
+
28
+ export {
29
+ getYargsErrorMessage,
30
+ getErrorMessage
31
+ };
32
+ //# sourceMappingURL=chunk-7RHK2YTB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/errors.ts"],"sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\nimport { CLIError } from '../errors';\n\n/**\n * Get the error message from an error in a Yargs `fail` handler. If the error\n * is not `undefined`, {@link getErrorMessage} is used to get the error message.\n * Otherwise, the given message is returned.\n *\n * @param message - The error message.\n * @param error - The error object. This may be `undefined`.\n * @returns The error message.\n */\nexport function getYargsErrorMessage(message: string, error?: unknown): string {\n if (error) {\n if (error instanceof CLIError) {\n return error.message;\n }\n\n return getErrorMessage(error);\n }\n\n return message;\n}\n\n/**\n * Get the error message from an error.\n *\n * - If the error is an object with a `stack` property, the `stack` property is\n * returned.\n * - If the error is an object with a `message` property, the `message`\n * property is returned.\n * - Otherwise, the error is converted to a string and returned.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isObject(error)) {\n if (hasProperty(error, 'stack') && typeof error.stack === 'string') {\n return error.stack;\n }\n\n if (hasProperty(error, 'message') && typeof error.message === 'string') {\n return error.message;\n }\n }\n\n return String(error);\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,gBAAgB;AAa/B,SAAS,qBAAqB,SAAiB,OAAyB;AAC7E,MAAI,OAAO;AACT,QAAI,iBAAiB,UAAU;AAC7B,aAAO,MAAM;AAAA,IACf;AAEA,WAAO,gBAAgB,KAAK;AAAA,EAC9B;AAEA,SAAO;AACT;AAcO,SAAS,gBAAgB,OAAwB;AACtD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,UAAU,UAAU;AAClE,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,YAAY,OAAO,SAAS,KAAK,OAAO,MAAM,YAAY,UAAU;AACtE,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,OAAO,KAAK;AACrB;","names":[]}
@@ -0,0 +1,28 @@
1
+ // src/webpack/loaders/function.ts
2
+ var loader = function(content) {
3
+ const { fn } = this.getOptions();
4
+ return fn.bind(this)(content);
5
+ };
6
+ var function_default = loader;
7
+ function getFunctionLoader(fn, options) {
8
+ return {
9
+ // We use `__filename` as the loader, so Webpack will execute the loader in
10
+ // this file, with the actual function in the options.
11
+ loader: __filename,
12
+ options: {
13
+ fn,
14
+ ...options
15
+ }
16
+ };
17
+ }
18
+ if (typeof module !== "undefined" && process?.env?.NODE_ENV !== "test") {
19
+ module.exports = loader;
20
+ module.exports.getFunctionLoader = getFunctionLoader;
21
+ module.exports.raw = true;
22
+ }
23
+
24
+ export {
25
+ function_default,
26
+ getFunctionLoader
27
+ };
28
+ //# sourceMappingURL=chunk-AZMQTZXZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webpack/loaders/function.ts"],"sourcesContent":["import type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Options for the function loader.\n */\nexport type FunctionLoaderOptions = {\n /**\n * The function to execute. This is bound to the loader context, so it can\n * access the loader options and other properties.\n */\n fn: LoaderDefinitionFunction;\n};\n\n/**\n * A loader that executes a function. See {@link getFunctionLoader} for more\n * information.\n *\n * @param content - The input file contents as a `Uint8Array`.\n * @returns The output of the function.\n */\nconst loader: LoaderDefinitionFunction<FunctionLoaderOptions> = function (\n content,\n) {\n const { fn } = this.getOptions();\n return fn.bind(this)(content);\n};\n\nexport default loader;\n\n/**\n * Get a loader that executes the given function. This is useful for executing\n * loaders without needing to pass a file to Webpack.\n *\n * @param fn - The function to execute.\n * @param options - The options to pass to the loader.\n * @returns The loader definition.\n */\nexport function getFunctionLoader<Options>(\n fn: LoaderDefinitionFunction<Options>,\n options: Options,\n) {\n return {\n // We use `__filename` as the loader, so Webpack will execute the loader in\n // this file, with the actual function in the options.\n loader: __filename,\n options: {\n fn,\n ...options,\n },\n };\n}\n\n// When running as CJS, we need to export the loader as a default export, since\n// `tsup` exports it as `loader_default`.\n// istanbul ignore next 3\n// eslint-disable-next-line n/no-process-env\nif (typeof module !== 'undefined' && process?.env?.NODE_ENV !== 'test') {\n module.exports = loader;\n module.exports.getFunctionLoader = getFunctionLoader;\n module.exports.raw = true;\n}\n"],"mappings":";AAoBA,IAAM,SAA0D,SAC9D,SACA;AACA,QAAM,EAAE,GAAG,IAAI,KAAK,WAAW;AAC/B,SAAO,GAAG,KAAK,IAAI,EAAE,OAAO;AAC9B;AAEA,IAAO,mBAAQ;AAUR,SAAS,kBACd,IACA,SACA;AACA,SAAO;AAAA;AAAA;AAAA,IAGL,QAAQ;AAAA,IACR,SAAS;AAAA,MACP;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAMA,IAAI,OAAO,WAAW,eAAe,SAAS,KAAK,aAAa,QAAQ;AACtE,SAAO,UAAU;AACjB,SAAO,QAAQ,oBAAoB;AACnC,SAAO,QAAQ,MAAM;AACvB;","names":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkBALQOCUOjs = require('./chunk-BALQOCUO.js');
4
+
5
+ // src/utils/errors.ts
6
+ var _utils = require('@metamask/utils');
7
+ function getYargsErrorMessage(message, error) {
8
+ if (error) {
9
+ if (error instanceof _chunkBALQOCUOjs.CLIError) {
10
+ return error.message;
11
+ }
12
+ return getErrorMessage(error);
13
+ }
14
+ return message;
15
+ }
16
+ function getErrorMessage(error) {
17
+ if (_utils.isObject.call(void 0, error)) {
18
+ if (_utils.hasProperty.call(void 0, error, "stack") && typeof error.stack === "string") {
19
+ return error.stack;
20
+ }
21
+ if (_utils.hasProperty.call(void 0, error, "message") && typeof error.message === "string") {
22
+ return error.message;
23
+ }
24
+ }
25
+ return String(error);
26
+ }
27
+
28
+
29
+
30
+
31
+ exports.getYargsErrorMessage = getYargsErrorMessage; exports.getErrorMessage = getErrorMessage;
32
+ //# sourceMappingURL=chunk-B3NNVTA6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/errors.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,aAAa,gBAAgB;AAa/B,SAAS,qBAAqB,SAAiB,OAAyB;AAC7E,MAAI,OAAO;AACT,QAAI,iBAAiB,UAAU;AAC7B,aAAO,MAAM;AAAA,IACf;AAEA,WAAO,gBAAgB,KAAK;AAAA,EAC9B;AAEA,SAAO;AACT;AAcO,SAAS,gBAAgB,OAAwB;AACtD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,UAAU,UAAU;AAClE,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,YAAY,OAAO,SAAS,KAAK,OAAO,MAAM,YAAY,UAAU;AACtE,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,OAAO,KAAK;AACrB","sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\nimport { CLIError } from '../errors';\n\n/**\n * Get the error message from an error in a Yargs `fail` handler. If the error\n * is not `undefined`, {@link getErrorMessage} is used to get the error message.\n * Otherwise, the given message is returned.\n *\n * @param message - The error message.\n * @param error - The error object. This may be `undefined`.\n * @returns The error message.\n */\nexport function getYargsErrorMessage(message: string, error?: unknown): string {\n if (error) {\n if (error instanceof CLIError) {\n return error.message;\n }\n\n return getErrorMessage(error);\n }\n\n return message;\n}\n\n/**\n * Get the error message from an error.\n *\n * - If the error is an object with a `stack` property, the `stack` property is\n * returned.\n * - If the error is an object with a `message` property, the `message`\n * property is returned.\n * - Otherwise, the error is converted to a string and returned.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isObject(error)) {\n if (hasProperty(error, 'stack') && typeof error.stack === 'string') {\n return error.stack;\n }\n\n if (hasProperty(error, 'message') && typeof error.message === 'string') {\n return error.message;\n }\n }\n\n return String(error);\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/errors.ts
2
+ var _chalk = require('chalk');
3
+ var CLIError = class extends Error {
4
+ };
5
+ var CommandError = class extends CLIError {
6
+ constructor(message, name = "Error") {
7
+ super(message);
8
+ this.name = _chalk.bold.call(void 0, _chalk.red.call(void 0, name));
9
+ }
10
+ };
11
+ var ConfigError = class extends CommandError {
12
+ constructor(message) {
13
+ super(message, "Config Error");
14
+ }
15
+ };
16
+
17
+
18
+
19
+
20
+
21
+ exports.CLIError = CLIError; exports.CommandError = CommandError; exports.ConfigError = ConfigError;
22
+ //# sourceMappingURL=chunk-BALQOCUO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,SAAS,MAAM,WAAW;AAWnB,IAAM,WAAN,cAAuB,MAAM;AAAC;AAO9B,IAAM,eAAN,cAA2B,SAAS;AAAA,EACzC,YAAY,SAAiB,OAAO,SAAS;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,IAAI,IAAI,CAAC;AAAA,EAC5B;AACF;AAKO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C,YAAY,SAAiB;AAC3B,UAAM,SAAS,cAAc;AAAA,EAC/B;AACF","sourcesContent":["import { bold, red } from 'chalk';\n\n/**\n * An error that is thrown when the CLI fails. This is the base error for all\n * CLI errors. It is not thrown directly, but is instead extended by other\n * errors.\n *\n * This error is assumed to have all the information needed to display a\n * readable error message, so it does not include the stack trace when it is\n * thrown.\n */\nexport class CLIError extends Error {}\n\n/**\n * An error that is thrown when a command fails.\n *\n * It wraps the error prefix in a bold red \"Error\" string.\n */\nexport class CommandError extends CLIError {\n constructor(message: string, name = 'Error') {\n super(message);\n this.name = bold(red(name));\n }\n}\n\n/**\n * An error that is thrown when the config file cannot be loaded.\n */\nexport class ConfigError extends CommandError {\n constructor(message: string) {\n super(message, 'Config Error');\n }\n}\n"]}