@metamask/snaps-cli 6.7.0 → 7.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 (213) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +11 -244
  3. package/dist/builders.cjs +0 -97
  4. package/dist/builders.cjs.map +1 -1
  5. package/dist/builders.d.cts +0 -94
  6. package/dist/builders.d.cts.map +1 -1
  7. package/dist/builders.d.mts +0 -94
  8. package/dist/builders.d.mts.map +1 -1
  9. package/dist/builders.mjs +0 -96
  10. package/dist/builders.mjs.map +1 -1
  11. package/dist/cli.cjs +4 -9
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.d.cts.map +1 -1
  14. package/dist/cli.d.mts.map +1 -1
  15. package/dist/cli.mjs +4 -16
  16. package/dist/cli.mjs.map +1 -1
  17. package/dist/commands/build/build.cjs +7 -7
  18. package/dist/commands/build/build.cjs.map +1 -1
  19. package/dist/commands/build/build.d.cts.map +1 -1
  20. package/dist/commands/build/build.d.mts.map +1 -1
  21. package/dist/commands/build/build.mjs +2 -2
  22. package/dist/commands/build/build.mjs.map +1 -1
  23. package/dist/commands/build/implementation.cjs.map +1 -1
  24. package/dist/commands/build/implementation.d.cts +2 -2
  25. package/dist/commands/build/implementation.d.cts.map +1 -1
  26. package/dist/commands/build/implementation.d.mts +2 -2
  27. package/dist/commands/build/implementation.d.mts.map +1 -1
  28. package/dist/commands/build/implementation.mjs.map +1 -1
  29. package/dist/commands/build/index.cjs +2 -14
  30. package/dist/commands/build/index.cjs.map +1 -1
  31. package/dist/commands/build/index.d.cts.map +1 -1
  32. package/dist/commands/build/index.d.mts.map +1 -1
  33. package/dist/commands/build/index.mjs +2 -14
  34. package/dist/commands/build/index.mjs.map +1 -1
  35. package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs +0 -1
  36. package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs.map +1 -1
  37. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.cts.map +1 -1
  38. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.mts.map +1 -1
  39. package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs +0 -1
  40. package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs.map +1 -1
  41. package/dist/commands/eval/__test__/webpack/good/snap.config.cjs +0 -1
  42. package/dist/commands/eval/__test__/webpack/good/snap.config.cjs.map +1 -1
  43. package/dist/commands/eval/__test__/webpack/good/snap.config.d.cts.map +1 -1
  44. package/dist/commands/eval/__test__/webpack/good/snap.config.d.mts.map +1 -1
  45. package/dist/commands/eval/__test__/webpack/good/snap.config.mjs +0 -1
  46. package/dist/commands/eval/__test__/webpack/good/snap.config.mjs.map +1 -1
  47. package/dist/commands/eval/__test__/webpack/snap.config.cjs +0 -1
  48. package/dist/commands/eval/__test__/webpack/snap.config.cjs.map +1 -1
  49. package/dist/commands/eval/__test__/webpack/snap.config.d.cts.map +1 -1
  50. package/dist/commands/eval/__test__/webpack/snap.config.d.mts.map +1 -1
  51. package/dist/commands/eval/__test__/webpack/snap.config.mjs +0 -1
  52. package/dist/commands/eval/__test__/webpack/snap.config.mjs.map +1 -1
  53. package/dist/commands/eval/eval.cjs +1 -1
  54. package/dist/commands/eval/eval.cjs.map +1 -1
  55. package/dist/commands/eval/eval.d.cts.map +1 -1
  56. package/dist/commands/eval/eval.d.mts.map +1 -1
  57. package/dist/commands/eval/eval.mjs +1 -1
  58. package/dist/commands/eval/eval.mjs.map +1 -1
  59. package/dist/commands/eval/index.cjs +1 -4
  60. package/dist/commands/eval/index.cjs.map +1 -1
  61. package/dist/commands/eval/index.d.cts.map +1 -1
  62. package/dist/commands/eval/index.d.mts.map +1 -1
  63. package/dist/commands/eval/index.mjs +1 -4
  64. package/dist/commands/eval/index.mjs.map +1 -1
  65. package/dist/commands/manifest/index.cjs +1 -4
  66. package/dist/commands/manifest/index.cjs.map +1 -1
  67. package/dist/commands/manifest/index.d.cts.map +1 -1
  68. package/dist/commands/manifest/index.d.mts.map +1 -1
  69. package/dist/commands/manifest/index.mjs +1 -4
  70. package/dist/commands/manifest/index.mjs.map +1 -1
  71. package/dist/commands/manifest/manifest.cjs +5 -6
  72. package/dist/commands/manifest/manifest.cjs.map +1 -1
  73. package/dist/commands/manifest/manifest.d.cts.map +1 -1
  74. package/dist/commands/manifest/manifest.d.mts.map +1 -1
  75. package/dist/commands/manifest/manifest.mjs +5 -6
  76. package/dist/commands/manifest/manifest.mjs.map +1 -1
  77. package/dist/commands/serve/index.cjs +2 -2
  78. package/dist/commands/serve/index.cjs.map +1 -1
  79. package/dist/commands/serve/index.d.cts.map +1 -1
  80. package/dist/commands/serve/index.d.mts.map +1 -1
  81. package/dist/commands/serve/index.mjs +2 -2
  82. package/dist/commands/serve/index.mjs.map +1 -1
  83. package/dist/commands/watch/implementation.cjs +2 -0
  84. package/dist/commands/watch/implementation.cjs.map +1 -1
  85. package/dist/commands/watch/implementation.d.cts +2 -2
  86. package/dist/commands/watch/implementation.d.cts.map +1 -1
  87. package/dist/commands/watch/implementation.d.mts +2 -2
  88. package/dist/commands/watch/implementation.d.mts.map +1 -1
  89. package/dist/commands/watch/implementation.mjs +2 -0
  90. package/dist/commands/watch/implementation.mjs.map +1 -1
  91. package/dist/commands/watch/index.cjs +2 -17
  92. package/dist/commands/watch/index.cjs.map +1 -1
  93. package/dist/commands/watch/index.d.cts.map +1 -1
  94. package/dist/commands/watch/index.d.mts.map +1 -1
  95. package/dist/commands/watch/index.mjs +2 -17
  96. package/dist/commands/watch/index.mjs.map +1 -1
  97. package/dist/commands/watch/watch.cjs +1 -1
  98. package/dist/commands/watch/watch.cjs.map +1 -1
  99. package/dist/commands/watch/watch.d.cts.map +1 -1
  100. package/dist/commands/watch/watch.d.mts.map +1 -1
  101. package/dist/commands/watch/watch.mjs +1 -1
  102. package/dist/commands/watch/watch.mjs.map +1 -1
  103. package/dist/config.cjs +11 -155
  104. package/dist/config.cjs.map +1 -1
  105. package/dist/config.d.cts +216 -314
  106. package/dist/config.d.cts.map +1 -1
  107. package/dist/config.d.mts +216 -314
  108. package/dist/config.d.mts.map +1 -1
  109. package/dist/config.mjs +13 -155
  110. package/dist/config.mjs.map +1 -1
  111. package/dist/main.cjs +0 -1
  112. package/dist/main.cjs.map +1 -1
  113. package/dist/main.mjs +0 -1
  114. package/dist/main.mjs.map +1 -1
  115. package/dist/utils/index.cjs +0 -1
  116. package/dist/utils/index.cjs.map +1 -1
  117. package/dist/utils/index.d.cts +0 -1
  118. package/dist/utils/index.d.cts.map +1 -1
  119. package/dist/utils/index.d.mts +0 -1
  120. package/dist/utils/index.d.mts.map +1 -1
  121. package/dist/utils/index.mjs +0 -1
  122. package/dist/utils/index.mjs.map +1 -1
  123. package/dist/utils/steps.cjs.map +1 -1
  124. package/dist/utils/steps.d.cts +1 -1
  125. package/dist/utils/steps.d.cts.map +1 -1
  126. package/dist/utils/steps.d.mts +1 -1
  127. package/dist/utils/steps.d.mts.map +1 -1
  128. package/dist/utils/steps.mjs.map +1 -1
  129. package/dist/webpack/compiler.cjs.map +1 -1
  130. package/dist/webpack/compiler.d.cts +2 -2
  131. package/dist/webpack/compiler.d.cts.map +1 -1
  132. package/dist/webpack/compiler.d.mts +2 -2
  133. package/dist/webpack/compiler.d.mts.map +1 -1
  134. package/dist/webpack/compiler.mjs.map +1 -1
  135. package/dist/webpack/config.cjs +1 -2
  136. package/dist/webpack/config.cjs.map +1 -1
  137. package/dist/webpack/config.d.cts +2 -2
  138. package/dist/webpack/config.d.cts.map +1 -1
  139. package/dist/webpack/config.d.mts +2 -2
  140. package/dist/webpack/config.d.mts.map +1 -1
  141. package/dist/webpack/config.mjs +1 -2
  142. package/dist/webpack/config.mjs.map +1 -1
  143. package/dist/webpack/loaders/function.cjs +7 -10
  144. package/dist/webpack/loaders/function.cjs.map +1 -1
  145. package/dist/webpack/loaders/function.d.cts +1 -0
  146. package/dist/webpack/loaders/function.d.cts.map +1 -1
  147. package/dist/webpack/loaders/function.d.mts +1 -0
  148. package/dist/webpack/loaders/function.d.mts.map +1 -1
  149. package/dist/webpack/loaders/function.mjs +6 -9
  150. package/dist/webpack/loaders/function.mjs.map +1 -1
  151. package/dist/webpack/loaders/index.cjs +1 -3
  152. package/dist/webpack/loaders/index.cjs.map +1 -1
  153. package/dist/webpack/loaders/index.d.cts +0 -1
  154. package/dist/webpack/loaders/index.d.cts.map +1 -1
  155. package/dist/webpack/loaders/index.d.mts +0 -1
  156. package/dist/webpack/loaders/index.d.mts.map +1 -1
  157. package/dist/webpack/loaders/index.mjs +0 -1
  158. package/dist/webpack/loaders/index.mjs.map +1 -1
  159. package/dist/webpack/loaders/wasm.cjs +0 -2
  160. package/dist/webpack/loaders/wasm.cjs.map +1 -1
  161. package/dist/webpack/loaders/wasm.d.cts.map +1 -1
  162. package/dist/webpack/loaders/wasm.d.mts.map +1 -1
  163. package/dist/webpack/loaders/wasm.mjs +0 -2
  164. package/dist/webpack/loaders/wasm.mjs.map +1 -1
  165. package/dist/webpack/plugins.cjs +15 -20
  166. package/dist/webpack/plugins.cjs.map +1 -1
  167. package/dist/webpack/plugins.d.cts +13 -3
  168. package/dist/webpack/plugins.d.cts.map +1 -1
  169. package/dist/webpack/plugins.d.mts +13 -3
  170. package/dist/webpack/plugins.d.mts.map +1 -1
  171. package/dist/webpack/plugins.mjs +4 -9
  172. package/dist/webpack/plugins.mjs.map +1 -1
  173. package/dist/webpack/utils.cjs +5 -21
  174. package/dist/webpack/utils.cjs.map +1 -1
  175. package/dist/webpack/utils.d.cts +6 -36
  176. package/dist/webpack/utils.d.cts.map +1 -1
  177. package/dist/webpack/utils.d.mts +6 -36
  178. package/dist/webpack/utils.d.mts.map +1 -1
  179. package/dist/webpack/utils.mjs +4 -18
  180. package/dist/webpack/utils.mjs.map +1 -1
  181. package/package.json +13 -38
  182. package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs +0 -10
  183. package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs.map +0 -1
  184. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts +0 -4
  185. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts.map +0 -1
  186. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts +0 -4
  187. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts.map +0 -1
  188. package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs +0 -8
  189. package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs.map +0 -1
  190. package/dist/commands/eval/__test__/browserify/good/snap.config.cjs +0 -10
  191. package/dist/commands/eval/__test__/browserify/good/snap.config.cjs.map +0 -1
  192. package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts +0 -4
  193. package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts.map +0 -1
  194. package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts +0 -4
  195. package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts.map +0 -1
  196. package/dist/commands/eval/__test__/browserify/good/snap.config.mjs +0 -8
  197. package/dist/commands/eval/__test__/browserify/good/snap.config.mjs.map +0 -1
  198. package/dist/utils/legacy.cjs +0 -53
  199. package/dist/utils/legacy.cjs.map +0 -1
  200. package/dist/utils/legacy.d.cts +0 -28
  201. package/dist/utils/legacy.d.cts.map +0 -1
  202. package/dist/utils/legacy.d.mts +0 -28
  203. package/dist/utils/legacy.d.mts.map +0 -1
  204. package/dist/utils/legacy.mjs +0 -47
  205. package/dist/utils/legacy.mjs.map +0 -1
  206. package/dist/webpack/loaders/browserify.cjs +0 -84
  207. package/dist/webpack/loaders/browserify.cjs.map +0 -1
  208. package/dist/webpack/loaders/browserify.d.cts +0 -18
  209. package/dist/webpack/loaders/browserify.d.cts.map +0 -1
  210. package/dist/webpack/loaders/browserify.d.mts +0 -18
  211. package/dist/webpack/loaders/browserify.d.mts.map +0 -1
  212. package/dist/webpack/loaders/browserify.mjs +0 -88
  213. package/dist/webpack/loaders/browserify.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,2BAAuB;AAEtC,OAAO,EAAE,YAAY,EAAE,oBAAgB;AAEvC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wCAAwC;IAC9C,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI;KACnD,CAAC;CACL,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { serveHandler } from './serve';\n\nconst command = {\n command: ['serve', 's'],\n desc: 'Locally serve Snap file(s) for testing',\n builder: (yarg: yargs.Argv) => {\n yarg.option('root', builders.root).option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n serveHandler(argv.context.config, {\n port: argv.port ?? argv.context.config.server.port,\n }),\n};\n\nexport default command;\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wCAAwC;IAC9C,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI;KACnD,CAAC;CACL,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { serveHandler } from './serve';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['serve', 's'],\n desc: 'Locally serve Snap file(s) for testing',\n builder: (yarg: yargs.Argv) => {\n yarg.option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n serveHandler(argv.context.config, {\n port: argv.port ?? argv.context.config.server.port,\n }),\n};\n\nexport default command;\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watch = void 0;
4
+ const utils_1 = require("@metamask/utils");
4
5
  const path_1 = require("path");
5
6
  const webpack_1 = require("../../webpack/index.cjs");
6
7
  /**
@@ -30,6 +31,7 @@ async function watch(config, options) {
30
31
  reject(watchError);
31
32
  return;
32
33
  }
34
+ (0, utils_1.assert)(compiler.watching, 'Expected `compiler.watching` to be set.');
33
35
  resolve(compiler.watching);
34
36
  });
35
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":";;;AAAA,+BAAgC;AAKhC,qDAA4C;AAE5C;;;;;;;;;GASG;AACI,KAAK,UAAU,KAAK,CACzB,MAA8B,EAC9B,OAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,QAAQ,CAAC,KAAK,CACZ;YACE,OAAO,EAAE;gBACP,sBAAsB;gBACtB,MAAM,IAAA,eAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;aAC1C;SACF,EACD,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA5BD,sBA4BC","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"]}
1
+ {"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,+BAAgC;AAKhC,qDAA4C;AAE5C;;;;;;;;;GASG;AACI,KAAK,UAAU,KAAK,CAAC,MAAuB,EAAE,OAAwB;IAC3E,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,QAAQ,CAAC,KAAK,CACZ;YACE,OAAO,EAAE;gBACP,sBAAsB;gBACtB,MAAM,IAAA,eAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;aAC1C;SACF,EACD,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,IAAA,cAAM,EAAC,QAAQ,CAAC,QAAQ,EAAE,yCAAyC,CAAC,CAAC;YACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,sBA0BC","sourcesContent":["import { assert } from '@metamask/utils';\nimport { basename } from 'path';\nimport type { Watching } from 'webpack';\n\nimport type { ProcessedConfig } 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(config: ProcessedConfig, options?: WebpackOptions) {\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 assert(compiler.watching, 'Expected `compiler.watching` to be set.');\n resolve(compiler.watching);\n },\n );\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Watching } from "webpack";
2
- import type { ProcessedWebpackConfig } from "../../config.cjs";
2
+ import type { ProcessedConfig } from "../../config.cjs";
3
3
  import type { WebpackOptions } from "../../webpack/index.cjs";
4
4
  /**
5
5
  * Build the snap bundle and watch for changes. This uses Webpack to build the
@@ -11,5 +11,5 @@ import type { WebpackOptions } from "../../webpack/index.cjs";
11
11
  * The promise resolves with a Webpack watching instance that can be used to
12
12
  * close the watcher.
13
13
  */
14
- export declare function watch(config: ProcessedWebpackConfig, options?: WebpackOptions): Promise<Watching>;
14
+ export declare function watch(config: ProcessedConfig, options?: WebpackOptions): Promise<Watching>;
15
15
  //# sourceMappingURL=implementation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAqB;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,qBA0BzB"}
1
+ {"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBA0B5E"}
@@ -1,5 +1,5 @@
1
1
  import type { Watching } from "webpack";
2
- import type { ProcessedWebpackConfig } from "../../config.mjs";
2
+ import type { ProcessedConfig } from "../../config.mjs";
3
3
  import type { WebpackOptions } from "../../webpack/index.mjs";
4
4
  /**
5
5
  * Build the snap bundle and watch for changes. This uses Webpack to build the
@@ -11,5 +11,5 @@ import type { WebpackOptions } from "../../webpack/index.mjs";
11
11
  * The promise resolves with a Webpack watching instance that can be used to
12
12
  * close the watcher.
13
13
  */
14
- export declare function watch(config: ProcessedWebpackConfig, options?: WebpackOptions): Promise<Watching>;
14
+ export declare function watch(config: ProcessedConfig, options?: WebpackOptions): Promise<Watching>;
15
15
  //# sourceMappingURL=implementation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAqB;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,qBA0BzB"}
1
+ {"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBA0B5E"}
@@ -1,3 +1,4 @@
1
+ import { assert } from "@metamask/utils";
1
2
  import { basename } from "path";
2
3
  import { getCompiler } from "../../webpack/index.mjs";
3
4
  /**
@@ -27,6 +28,7 @@ export async function watch(config, options) {
27
28
  reject(watchError);
28
29
  return;
29
30
  }
31
+ assert(compiler.watching, 'Expected `compiler.watching` to be set.');
30
32
  resolve(compiler.watching);
31
33
  });
32
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa;AAKhC,OAAO,EAAE,WAAW,EAAE,gCAAsB;AAE5C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,MAA8B,EAC9B,OAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,QAAQ,CAAC,KAAK,CACZ;YACE,OAAO,EAAE;gBACP,sBAAsB;gBACtB,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;aAC1C;SACF,EACD,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","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"]}
1
+ {"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB;AACzC,OAAO,EAAE,QAAQ,EAAE,aAAa;AAKhC,OAAO,EAAE,WAAW,EAAE,gCAAsB;AAE5C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,MAAuB,EAAE,OAAwB;IAC3E,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,QAAQ,CAAC,KAAK,CACZ;YACE,OAAO,EAAE;gBACP,sBAAsB;gBACtB,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;aAC1C;SACF,EACD,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,yCAAyC,CAAC,CAAC;YACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/utils';\nimport { basename } from 'path';\nimport type { Watching } from 'webpack';\n\nimport type { ProcessedConfig } 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(config: ProcessedConfig, options?: WebpackOptions) {\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 assert(compiler.watching, 'Expected `compiler.watching` to be set.');\n resolve(compiler.watching);\n },\n );\n });\n}\n"]}
@@ -17,28 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- const builders_1 = __importDefault(require("../../builders.cjs"));
21
20
  const watch_1 = require("./watch.cjs");
21
+ const builders_1 = __importDefault(require("../../builders.cjs"));
22
22
  const command = {
23
23
  command: ['watch', 'w'],
24
24
  desc: 'Build Snap on change',
25
25
  builder: (yarg) => {
26
- yarg
27
- .option('src', builders_1.default.src)
28
- .option('eval', builders_1.default.eval)
29
- .option('dist', builders_1.default.dist)
30
- .option('outfileName', builders_1.default.outfileName)
31
- .option('sourceMaps', builders_1.default.sourceMaps)
32
- .option('stripComments', builders_1.default.stripComments)
33
- .option('transpilationMode', builders_1.default.transpilationMode)
34
- .option('depsToTranspile', builders_1.default.depsToTranspile)
35
- .option('manifest', builders_1.default.manifest)
36
- .option('writeManifest', builders_1.default.writeManifest)
37
- .option('serve', builders_1.default.serve)
38
- .option('root', builders_1.default.root)
39
- .option('port', builders_1.default.port)
40
- .implies('writeManifest', 'manifest')
41
- .implies('depsToTranspile', 'transpilationMode');
26
+ yarg.option('port', builders_1.default.port);
42
27
  },
43
28
  handler: async (argv) => (0, watch_1.watchHandler)(argv.context.config, {
44
29
  port: argv.port,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,kEAAsC;AAEtC,uCAAuC;AAEvC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI;aACD,MAAM,CAAC,KAAK,EAAE,kBAAQ,CAAC,GAAG,CAAC;aAC3B,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,aAAa,EAAE,kBAAQ,CAAC,WAAW,CAAC;aAC3C,MAAM,CAAC,YAAY,EAAE,kBAAQ,CAAC,UAAU,CAAC;aACzC,MAAM,CAAC,eAAe,EAAE,kBAAQ,CAAC,aAAa,CAAC;aAC/C,MAAM,CAAC,mBAAmB,EAAE,kBAAQ,CAAC,iBAAiB,CAAC;aACvD,MAAM,CAAC,iBAAiB,EAAE,kBAAQ,CAAC,eAAe,CAAC;aACnD,MAAM,CAAC,UAAU,EAAE,kBAAQ,CAAC,QAAQ,CAAC;aACrC,MAAM,CAAC,eAAe,EAAE,kBAAQ,CAAC,aAAa,CAAC;aAC/C,MAAM,CAAC,OAAO,EAAE,kBAAQ,CAAC,KAAK,CAAC;aAC/B,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC;aAC7B,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC;aACpC,OAAO,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;CACL,CAAC;AAEF,uDAAiC;AACjC,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { watchHandler } from './watch';\n\nconst command = {\n command: ['watch', 'w'],\n desc: 'Build Snap on change',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('src', builders.src)\n .option('eval', builders.eval)\n .option('dist', builders.dist)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('manifest', builders.manifest)\n .option('writeManifest', builders.writeManifest)\n .option('serve', builders.serve)\n .option('root', builders.root)\n .option('port', builders.port)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) =>\n watchHandler(argv.context.config, {\n port: argv.port,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,uCAAuC;AACvC,kEAAsC;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;CACL,CAAC;AAEF,uDAAiC;AACjC,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { watchHandler } from './watch';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['watch', 'w'],\n desc: 'Build Snap on change',\n builder: (yarg: yargs.Argv) => {\n yarg.option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n watchHandler(argv.context.config, {\n port: argv.port,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAG/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAGnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAkBJ,SAAS;CAIhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAIhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAG/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAGnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAkBJ,SAAS;CAIhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAIhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
@@ -1,25 +1,10 @@
1
- import builders from "../../builders.mjs";
2
1
  import { watchHandler } from "./watch.mjs";
2
+ import builders from "../../builders.mjs";
3
3
  const command = {
4
4
  command: ['watch', 'w'],
5
5
  desc: 'Build Snap on change',
6
6
  builder: (yarg) => {
7
- yarg
8
- .option('src', builders.src)
9
- .option('eval', builders.eval)
10
- .option('dist', builders.dist)
11
- .option('outfileName', builders.outfileName)
12
- .option('sourceMaps', builders.sourceMaps)
13
- .option('stripComments', builders.stripComments)
14
- .option('transpilationMode', builders.transpilationMode)
15
- .option('depsToTranspile', builders.depsToTranspile)
16
- .option('manifest', builders.manifest)
17
- .option('writeManifest', builders.writeManifest)
18
- .option('serve', builders.serve)
19
- .option('root', builders.root)
20
- .option('port', builders.port)
21
- .implies('writeManifest', 'manifest')
22
- .implies('depsToTranspile', 'transpilationMode');
7
+ yarg.option('port', builders.port);
23
8
  },
24
9
  handler: async (argv) => watchHandler(argv.context.config, {
25
10
  port: argv.port,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,2BAAuB;AAEtC,OAAO,EAAE,YAAY,EAAE,oBAAgB;AAEvC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI;aACD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;aAC3B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC;aAC3C,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC;aACzC,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,aAAa,CAAC;aAC/C,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,iBAAiB,CAAC;aACvD,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,eAAe,CAAC;aACnD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC;aACrC,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,aAAa,CAAC;aAC/C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;aAC/B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;aAC7B,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC;aACpC,OAAO,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;CACL,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { watchHandler } from './watch';\n\nconst command = {\n command: ['watch', 'w'],\n desc: 'Build Snap on change',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('src', builders.src)\n .option('eval', builders.eval)\n .option('dist', builders.dist)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('manifest', builders.manifest)\n .option('writeManifest', builders.writeManifest)\n .option('serve', builders.serve)\n .option('root', builders.root)\n .option('port', builders.port)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) =>\n watchHandler(argv.context.config, {\n port: argv.port,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/watch/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;CACL,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { watchHandler } from './watch';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['watch', 'w'],\n desc: 'Build Snap on change',\n builder: (yarg: yargs.Argv) => {\n yarg.option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n watchHandler(argv.context.config, {\n port: argv.port,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watchHandler = void 0;
4
4
  const node_1 = require("@metamask/snaps-utils/node");
5
+ const implementation_1 = require("./implementation.cjs");
5
6
  const errors_1 = require("../../errors.cjs");
6
7
  const utils_1 = require("../../utils/index.cjs");
7
8
  const webpack_1 = require("../../webpack/index.cjs");
8
- const implementation_1 = require("./implementation.cjs");
9
9
  const steps = [
10
10
  {
11
11
  name: 'Checking the input file.',
@@ -1 +1 @@
1
- {"version":3,"file":"watch.cjs","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAGpD,6CAA4C;AAE5C,iDAAiD;AACjD,qDAA0C;AAC1C,yDAAyC;AAczC,MAAM,KAAK,GAAwB;IACjC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;QAChD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEzE,IAAA,YAAI,EAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,IAAA,sBAAK,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;KACF;CACF,CAAC;AAEF;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAqB;IAErB,MAAM,IAAA,oBAAY,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC;AALD,oCAKC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { getServer } from '../../webpack';\nimport { watch } from './implementation';\n\ntype WatchOptions = {\n /**\n * The port to listen on.\n */\n port?: number;\n};\n\ntype WatchContext = {\n config: ProcessedWebpackConfig;\n options: WatchOptions;\n};\n\nconst steps: Steps<WatchContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Starting the development server.',\n condition: ({ config }) => config.server.enabled,\n task: async ({ config, options, spinner }) => {\n const server = getServer(config);\n const { port } = await server.listen(options.port ?? config.server.port);\n\n info(`The server is listening on http://localhost:${port}.`, spinner);\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n await watch(config, { spinner });\n },\n },\n];\n\n/**\n * Watch a directory and its subdirectories for changes, and build when files\n * are added or changed.\n *\n * Ignores 'node_modules' and dotfiles.\n * Creates destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function watchHandler(\n config: ProcessedConfig,\n options: WatchOptions,\n): Promise<void> {\n await executeSteps(steps, { config, options });\n}\n"]}
1
+ {"version":3,"file":"watch.cjs","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD,yDAAyC;AAEzC,6CAA4C;AAE5C,iDAAiD;AACjD,qDAA0C;AAc1C,MAAM,KAAK,GAAwB;IACjC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;QAChD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEzE,IAAA,YAAI,EAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,IAAA,sBAAK,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;KACF;CACF,CAAC;AAEF;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAqB;IAErB,MAAM,IAAA,oBAAY,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC;AALD,oCAKC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport { watch } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { getServer } from '../../webpack';\n\ntype WatchOptions = {\n /**\n * The port to listen on.\n */\n port?: number;\n};\n\ntype WatchContext = {\n config: ProcessedConfig;\n options: WatchOptions;\n};\n\nconst steps: Steps<WatchContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Starting the development server.',\n condition: ({ config }) => config.server.enabled,\n task: async ({ config, options, spinner }) => {\n const server = getServer(config);\n const { port } = await server.listen(options.port ?? config.server.port);\n\n info(`The server is listening on http://localhost:${port}.`, spinner);\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n await watch(config, { spinner });\n },\n },\n];\n\n/**\n * Watch a directory and its subdirectories for changes, and build when files\n * are added or changed.\n *\n * Ignores 'node_modules' and dotfiles.\n * Creates destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function watchHandler(\n config: ProcessedConfig,\n options: WatchOptions,\n): Promise<void> {\n await executeSteps(steps, { config, options });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAA0B,yBAAqB;AAO5E,KAAK,YAAY,GAAG;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAsCF;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAEf"}
1
+ {"version":3,"file":"watch.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,YAAY,GAAG;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAsCF;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAA0B,yBAAqB;AAO5E,KAAK,YAAY,GAAG;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAsCF;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAEf"}
1
+ {"version":3,"file":"watch.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,YAAY,GAAG;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAsCF;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -1,8 +1,8 @@
1
1
  import { isFile } from "@metamask/snaps-utils/node";
2
+ import { watch } from "./implementation.mjs";
2
3
  import { CommandError } from "../../errors.mjs";
3
4
  import { executeSteps, info } from "../../utils/index.mjs";
4
5
  import { getServer } from "../../webpack/index.mjs";
5
- import { watch } from "./implementation.mjs";
6
6
  const steps = [
7
7
  {
8
8
  name: 'Checking the input file.',
@@ -1 +1 @@
1
- {"version":3,"file":"watch.mjs","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AAGpD,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAAoB;AACjD,OAAO,EAAE,SAAS,EAAE,gCAAsB;AAC1C,OAAO,EAAE,KAAK,EAAE,6BAAyB;AAczC,MAAM,KAAK,GAAwB;IACjC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;QAChD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEzE,IAAI,CAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;KACF;CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAqB;IAErB,MAAM,YAAY,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { getServer } from '../../webpack';\nimport { watch } from './implementation';\n\ntype WatchOptions = {\n /**\n * The port to listen on.\n */\n port?: number;\n};\n\ntype WatchContext = {\n config: ProcessedWebpackConfig;\n options: WatchOptions;\n};\n\nconst steps: Steps<WatchContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Starting the development server.',\n condition: ({ config }) => config.server.enabled,\n task: async ({ config, options, spinner }) => {\n const server = getServer(config);\n const { port } = await server.listen(options.port ?? config.server.port);\n\n info(`The server is listening on http://localhost:${port}.`, spinner);\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n await watch(config, { spinner });\n },\n },\n];\n\n/**\n * Watch a directory and its subdirectories for changes, and build when files\n * are added or changed.\n *\n * Ignores 'node_modules' and dotfiles.\n * Creates destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function watchHandler(\n config: ProcessedConfig,\n options: WatchOptions,\n): Promise<void> {\n await executeSteps(steps, { config, options });\n}\n"]}
1
+ {"version":3,"file":"watch.mjs","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AAEpD,OAAO,EAAE,KAAK,EAAE,6BAAyB;AAEzC,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAAoB;AACjD,OAAO,EAAE,SAAS,EAAE,gCAAsB;AAc1C,MAAM,KAAK,GAAwB;IACjC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;QAChD,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEzE,IAAI,CAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;KACF;CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAqB;IAErB,MAAM,YAAY,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport { watch } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { getServer } from '../../webpack';\n\ntype WatchOptions = {\n /**\n * The port to listen on.\n */\n port?: number;\n};\n\ntype WatchContext = {\n config: ProcessedConfig;\n options: WatchOptions;\n};\n\nconst steps: Steps<WatchContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Starting the development server.',\n condition: ({ config }) => config.server.enabled,\n task: async ({ config, options, spinner }) => {\n const server = getServer(config);\n const { port } = await server.listen(options.port ?? config.server.port);\n\n info(`The server is listening on http://localhost:${port}.`, spinner);\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n await watch(config, { spinner });\n },\n },\n];\n\n/**\n * Watch a directory and its subdirectories for changes, and build when files\n * are added or changed.\n *\n * Ignores 'node_modules' and dotfiles.\n * Creates destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function watchHandler(\n config: ProcessedConfig,\n options: WatchOptions,\n): Promise<void> {\n await executeSteps(steps, { config, options });\n}\n"]}
package/dist/config.cjs CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWebpackConfig = exports.mergeLegacyOptions = exports.getConfigByArgv = exports.resolveConfig = exports.loadConfig = exports.getConfig = exports.LegacyOptionsStruct = exports.SnapsConfigStruct = exports.SnapsWebpackConfigStruct = exports.SnapsBrowserifyConfigStruct = void 0;
6
+ exports.getConfigByArgv = exports.resolveConfig = exports.loadConfig = exports.getConfig = exports.SnapsConfigStruct = void 0;
7
7
  const snaps_sdk_1 = require("@metamask/snaps-sdk");
8
8
  const node_1 = require("@metamask/snaps-utils/node");
9
9
  const superstruct_1 = require("@metamask/superstruct");
@@ -13,7 +13,6 @@ const chalk_1 = require("chalk");
13
13
  const promises_1 = require("fs/promises");
14
14
  const module_1 = __importDefault(require("module"));
15
15
  const path_1 = require("path");
16
- const builders_1 = require("./builders.cjs");
17
16
  const errors_1 = require("./errors.cjs");
18
17
  const structs_1 = require("./structs.cjs");
19
18
  const utils_2 = require("./utils/index.cjs");
@@ -21,35 +20,8 @@ const CONFIG_FILES = [utils_2.CONFIG_FILE, utils_2.TS_CONFIG_FILE];
21
20
  // This struct is essentially the same as the `func` struct, but it's defined
22
21
  // separately so that we include the function type in the inferred TypeScript
23
22
  // type definitions.
24
- const SnapsBrowserifyBundlerCustomizerFunctionStruct = (0, superstruct_1.define)('function', (0, superstruct_1.func)().validator);
25
- exports.SnapsBrowserifyConfigStruct = (0, superstruct_1.object)({
26
- bundler: (0, snaps_sdk_1.literal)('browserify'),
27
- cliOptions: (0, superstruct_1.defaulted)((0, superstruct_1.object)({
28
- bundle: (0, superstruct_1.optional)((0, structs_1.file)()),
29
- dist: (0, superstruct_1.defaulted)((0, structs_1.file)(), 'dist'),
30
- eval: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
31
- manifest: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
32
- port: (0, superstruct_1.defaulted)((0, superstruct_1.number)(), 8081),
33
- outfileName: (0, superstruct_1.defaulted)((0, superstruct_1.string)(), 'bundle.js'),
34
- root: (0, superstruct_1.defaulted)((0, structs_1.file)(), process.cwd()),
35
- sourceMaps: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), false),
36
- src: (0, superstruct_1.defaulted)((0, structs_1.file)(), 'src/index.js'),
37
- stripComments: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
38
- suppressWarnings: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), false),
39
- transpilationMode: (0, superstruct_1.defaulted)((0, snaps_sdk_1.union)([(0, snaps_sdk_1.literal)('localAndDeps'), (0, snaps_sdk_1.literal)('localOnly'), (0, snaps_sdk_1.literal)('none')]), 'localOnly'),
40
- depsToTranspile: (0, superstruct_1.defaulted)((0, superstruct_1.array)((0, superstruct_1.string)()), []),
41
- verboseErrors: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
42
- writeManifest: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
43
- serve: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
44
- }), {}),
45
- bundlerCustomizer: (0, superstruct_1.optional)(SnapsBrowserifyBundlerCustomizerFunctionStruct),
46
- });
47
- // This struct is essentially the same as the `func` struct, but it's defined
48
- // separately so that we include the function type in the inferred TypeScript
49
- // type definitions.
50
23
  const SnapsWebpackCustomizeWebpackConfigFunctionStruct = (0, superstruct_1.define)('function', (0, superstruct_1.func)().validator);
51
- exports.SnapsWebpackConfigStruct = (0, superstruct_1.object)({
52
- bundler: (0, superstruct_1.defaulted)((0, snaps_sdk_1.literal)('webpack'), 'webpack'),
24
+ exports.SnapsConfigStruct = (0, superstruct_1.object)({
53
25
  input: (0, superstruct_1.defaulted)((0, structs_1.file)(), (0, path_1.resolve)(process.cwd(), 'src/index.js')),
54
26
  sourceMap: (0, superstruct_1.defaulted)((0, snaps_sdk_1.union)([(0, superstruct_1.boolean)(), (0, snaps_sdk_1.literal)('inline')]), false),
55
27
  evaluate: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), true),
@@ -124,43 +96,17 @@ exports.SnapsWebpackConfigStruct = (0, superstruct_1.object)({
124
96
  wasm: (0, superstruct_1.defaulted)((0, superstruct_1.boolean)(), false),
125
97
  }), {}),
126
98
  });
127
- exports.SnapsConfigStruct = (0, superstruct_1.type)({
128
- bundler: (0, superstruct_1.defaulted)((0, snaps_sdk_1.union)([(0, snaps_sdk_1.literal)('browserify'), (0, snaps_sdk_1.literal)('webpack')]), 'webpack'),
129
- });
130
- exports.LegacyOptionsStruct = (0, snaps_sdk_1.union)([
131
- (0, node_1.named)('object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings', (0, superstruct_1.type)({
132
- depsToTranspile: (0, superstruct_1.array)((0, superstruct_1.string)()),
133
- transpilationMode: (0, snaps_sdk_1.literal)(builders_1.TranspilationModes.LocalAndDeps),
134
- writeManifest: (0, superstruct_1.boolean)(),
135
- bundlerCustomizer: (0, superstruct_1.optional)(SnapsBrowserifyBundlerCustomizerFunctionStruct),
136
- })),
137
- (0, node_1.named)('object without `depsToTranspile`', (0, superstruct_1.type)({
138
- depsToTranspile: (0, node_1.named)('empty array', (0, superstruct_1.empty)((0, superstruct_1.array)())),
139
- transpilationMode: (0, snaps_sdk_1.union)([
140
- (0, snaps_sdk_1.literal)(builders_1.TranspilationModes.LocalOnly),
141
- (0, snaps_sdk_1.literal)(builders_1.TranspilationModes.None),
142
- ]),
143
- writeManifest: (0, superstruct_1.boolean)(),
144
- bundlerCustomizer: (0, superstruct_1.optional)(SnapsBrowserifyBundlerCustomizerFunctionStruct),
145
- })),
146
- ]);
147
99
  /**
148
100
  * Get a validated snap config. This validates the config and adds default
149
101
  * values for any missing properties.
150
102
  *
151
103
  * @param config - The config to validate.
152
- * @param argv - The CLI arguments.
153
104
  * @returns The validated config.
154
105
  */
155
- function getConfig(config, argv) {
106
+ function getConfig(config) {
156
107
  const prefix = 'The snap config file is invalid';
157
108
  const suffix = (0, chalk_1.dim)('Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/');
158
- const { bundler } = (0, node_1.createFromStruct)(config, exports.SnapsConfigStruct, prefix, suffix);
159
- if (bundler === 'browserify') {
160
- const legacyConfig = (0, node_1.createFromStruct)(config, exports.SnapsBrowserifyConfigStruct, prefix, suffix);
161
- return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));
162
- }
163
- return (0, node_1.createFromStruct)(config, exports.SnapsWebpackConfigStruct, prefix, suffix);
109
+ return (0, node_1.createFromStruct)(config, exports.SnapsConfigStruct, prefix, suffix);
164
110
  }
165
111
  exports.getConfig = getConfig;
166
112
  /**
@@ -171,12 +117,11 @@ exports.getConfig = getConfig;
171
117
  * `module.exports` or `export default`.
172
118
  *
173
119
  * @param path - The full path to the config file.
174
- * @param argv - The CLI arguments.
175
120
  * @returns The validated config.
176
121
  * @throws If the config file is invalid, or if the config file does not have a
177
122
  * default export.
178
123
  */
179
- async function loadConfig(path, argv) {
124
+ async function loadConfig(path) {
180
125
  try {
181
126
  const contents = await (0, promises_1.readFile)(path, 'utf8');
182
127
  const source = await (0, core_1.transform)(contents, {
@@ -196,9 +141,9 @@ async function loadConfig(path, argv) {
196
141
  // @ts-expect-error - This function is not typed.
197
142
  config._compile(source.code, path);
198
143
  if (!(0, utils_1.hasProperty)(config.exports, 'default')) {
199
- return getConfig(config.exports, argv);
144
+ return getConfig(config.exports);
200
145
  }
201
- return getConfig(config.exports.default, argv);
146
+ return getConfig(config.exports.default);
202
147
  }
203
148
  catch (error) {
204
149
  if (error instanceof node_1.SnapsStructError) {
@@ -214,15 +159,14 @@ exports.loadConfig = loadConfig;
214
159
  *
215
160
  * @param path - The path to resolve the snap config from. Defaults to the
216
161
  * current working directory.
217
- * @param argv - The CLI arguments.
218
162
  * @returns The resolved and validated snap config.
219
163
  * @throws If a snap config could not be found.
220
164
  */
221
- async function resolveConfig(path, argv) {
165
+ async function resolveConfig(path) {
222
166
  for (const configFile of CONFIG_FILES) {
223
167
  const filePath = (0, path_1.resolve)(path, configFile);
224
168
  if (await (0, node_1.isFile)(filePath)) {
225
- return await loadConfig(filePath, argv);
169
+ return await loadConfig(filePath);
226
170
  }
227
171
  }
228
172
  throw new errors_1.ConfigError(`Could not find a "snap.config.js" or "snap.config.ts" file in the current or specified directory ("${path}").`);
@@ -242,97 +186,9 @@ async function getConfigByArgv(argv, cwd = process.cwd()) {
242
186
  if (!(await (0, node_1.isFile)(argv.config))) {
243
187
  throw new errors_1.ConfigError(`Could not find a config file at "${argv.config}". Make sure that the path is correct.`);
244
188
  }
245
- return await loadConfig(argv.config, argv);
189
+ return await loadConfig(argv.config);
246
190
  }
247
- return await resolveConfig(cwd, argv);
191
+ return await resolveConfig(cwd);
248
192
  }
249
193
  exports.getConfigByArgv = getConfigByArgv;
250
- /**
251
- * Merge legacy CLI options into the config. This is used to support the legacy
252
- * config format, where options can be specified both in the config file and
253
- * through CLI flags.
254
- *
255
- * @param argv - The CLI arguments.
256
- * @param config - The config to merge the CLI options into.
257
- * @returns The config with the CLI options merged in.
258
- * @deprecated This function is only used to support the legacy config format.
259
- */
260
- function mergeLegacyOptions(argv, config) {
261
- const cliOptions = Object.keys(config.cliOptions).reduce((accumulator, key) => {
262
- if (argv[key] !== undefined) {
263
- return {
264
- ...accumulator,
265
- [key]: argv[key],
266
- };
267
- }
268
- return accumulator;
269
- }, config.cliOptions);
270
- return {
271
- ...config,
272
- cliOptions,
273
- };
274
- }
275
- exports.mergeLegacyOptions = mergeLegacyOptions;
276
- /**
277
- * Get a Webpack config from a legacy browserify config. This is used to
278
- * support the legacy config format, and convert it to the new format.
279
- *
280
- * @param legacyConfig - The legacy browserify config.
281
- * @returns The Webpack config.
282
- */
283
- function getWebpackConfig(legacyConfig) {
284
- const defaultConfig = (0, superstruct_1.create)({ bundler: 'webpack' }, exports.SnapsWebpackConfigStruct);
285
- // The legacy config has two options for specifying the output path and
286
- // filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,
287
- // we use that as the output path and filename. Otherwise, we use `dist` and
288
- // `outfileName`.
289
- const path = legacyConfig.cliOptions.bundle
290
- ? (0, path_1.dirname)(legacyConfig.cliOptions.bundle)
291
- : legacyConfig.cliOptions.dist;
292
- const filename = legacyConfig.cliOptions.bundle
293
- ? (0, path_1.basename)(legacyConfig.cliOptions.bundle)
294
- : legacyConfig.cliOptions.outfileName;
295
- return {
296
- ...defaultConfig,
297
- input: legacyConfig.cliOptions.src,
298
- evaluate: legacyConfig.cliOptions.eval,
299
- sourceMap: legacyConfig.cliOptions.sourceMaps,
300
- output: {
301
- path,
302
- filename,
303
- // The legacy config has an option to remove comments from the bundle, but
304
- // the terser plugin does this by default, so we only enable the terser if
305
- // the legacy config has `stripComments` set to `true`. This is not a
306
- // perfect solution, but it's the best we can do without breaking the
307
- // legacy config.
308
- minimize: legacyConfig.cliOptions.stripComments,
309
- // The legacy config does not have a `clean` option, so we default to
310
- // `false` here.
311
- clean: false,
312
- },
313
- manifest: {
314
- // The legacy config does not have a `manifest` option, so we default to
315
- // `process.cwd()/snap.manifest.json`.
316
- path: (0, path_1.resolve)(process.cwd(), 'snap.manifest.json'),
317
- update: legacyConfig.cliOptions.writeManifest,
318
- },
319
- server: {
320
- enabled: legacyConfig.cliOptions.serve,
321
- port: legacyConfig.cliOptions.port,
322
- root: legacyConfig.cliOptions.root,
323
- },
324
- stats: {
325
- verbose: false,
326
- // These plugins are designed to be used with the modern config format, so
327
- // we disable them for the legacy config format.
328
- builtIns: false,
329
- buffer: false,
330
- },
331
- legacy: (0, node_1.createFromStruct)({
332
- ...legacyConfig.cliOptions,
333
- bundlerCustomizer: legacyConfig.bundlerCustomizer,
334
- }, exports.LegacyOptionsStruct, 'Invalid Browserify CLI options'),
335
- };
336
- }
337
- exports.getWebpackConfig = getWebpackConfig;
338
194
  //# sourceMappingURL=config.cjs.map