@metamask/snaps-cli 0.38.1-flask.1 → 1.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 (253) hide show
  1. package/CHANGELOG.md +377 -19
  2. package/README.md +67 -542
  3. package/dist/builders.d.ts +27 -0
  4. package/dist/{esm/builders.js → builders.js} +51 -48
  5. package/dist/builders.js.map +1 -0
  6. package/dist/{types/cli.d.ts → cli.d.ts} +1 -1
  7. package/dist/cli.js +51 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/cmds/build/buildHandler.d.ts +13 -0
  10. package/dist/cmds/build/buildHandler.js +37 -0
  11. package/dist/cmds/build/buildHandler.js.map +1 -0
  12. package/dist/cmds/build/bundle.d.ts +15 -0
  13. package/dist/cmds/build/bundle.js +80 -0
  14. package/dist/cmds/build/bundle.js.map +1 -0
  15. package/dist/{types/commands/serve → cmds/build}/index.d.ts +4 -4
  16. package/dist/cmds/build/index.js +29 -0
  17. package/dist/cmds/build/index.js.map +1 -0
  18. package/dist/cmds/build/utils.d.ts +56 -0
  19. package/dist/cmds/build/utils.js +100 -0
  20. package/dist/cmds/build/utils.js.map +1 -0
  21. package/dist/cmds/eval/evalHandler.d.ts +9 -0
  22. package/dist/cmds/eval/evalHandler.js +25 -0
  23. package/dist/cmds/eval/evalHandler.js.map +1 -0
  24. package/dist/cmds/eval/index.d.ts +9 -0
  25. package/dist/cmds/eval/index.js +15 -0
  26. package/dist/cmds/eval/index.js.map +1 -0
  27. package/dist/cmds/index.js +14 -0
  28. package/dist/cmds/index.js.map +1 -0
  29. package/dist/cmds/init/index.d.ts +9 -0
  30. package/dist/cmds/init/index.js +34 -0
  31. package/dist/cmds/init/index.js.map +1 -0
  32. package/dist/cmds/init/initHandler.d.ts +26 -0
  33. package/dist/cmds/init/initHandler.js +69 -0
  34. package/dist/cmds/init/initHandler.js.map +1 -0
  35. package/dist/cmds/init/initUtils.d.ts +39 -0
  36. package/dist/cmds/init/initUtils.js +122 -0
  37. package/dist/cmds/init/initUtils.js.map +1 -0
  38. package/dist/cmds/manifest/index.d.ts +9 -0
  39. package/dist/cmds/manifest/index.js +24 -0
  40. package/dist/cmds/manifest/index.js.map +1 -0
  41. package/dist/cmds/manifest/manifestHandler.d.ts +10 -0
  42. package/dist/cmds/manifest/manifestHandler.js +50 -0
  43. package/dist/cmds/manifest/manifestHandler.js.map +1 -0
  44. package/dist/cmds/serve/index.d.ts +9 -0
  45. package/dist/cmds/serve/index.js +15 -0
  46. package/dist/cmds/serve/index.js.map +1 -0
  47. package/dist/cmds/serve/serveHandler.d.ts +10 -0
  48. package/dist/cmds/serve/serveHandler.js +59 -0
  49. package/dist/cmds/serve/serveHandler.js.map +1 -0
  50. package/dist/cmds/serve/serveUtils.d.ts +22 -0
  51. package/dist/cmds/serve/serveUtils.js +39 -0
  52. package/dist/cmds/serve/serveUtils.js.map +1 -0
  53. package/dist/cmds/watch/index.d.ts +9 -0
  54. package/dist/cmds/watch/index.js +32 -0
  55. package/dist/cmds/watch/index.js.map +1 -0
  56. package/dist/cmds/watch/watchHandler.d.ts +14 -0
  57. package/dist/cmds/watch/watchHandler.js +100 -0
  58. package/dist/cmds/watch/watchHandler.js.map +1 -0
  59. package/dist/main.js +15 -0
  60. package/dist/main.js.map +1 -0
  61. package/dist/utils/index.d.ts +2 -0
  62. package/dist/utils/index.js +19 -0
  63. package/dist/utils/index.js.map +1 -0
  64. package/dist/utils/misc.d.ts +53 -0
  65. package/dist/utils/misc.js +156 -0
  66. package/dist/utils/misc.js.map +1 -0
  67. package/dist/utils/snap-config.d.ts +48 -0
  68. package/dist/utils/snap-config.js +117 -0
  69. package/dist/utils/snap-config.js.map +1 -0
  70. package/package.json +35 -54
  71. package/.browserslistrc +0 -3
  72. package/dist/cjs/builders.js +0 -148
  73. package/dist/cjs/builders.js.map +0 -1
  74. package/dist/cjs/cli.js +0 -35
  75. package/dist/cjs/cli.js.map +0 -1
  76. package/dist/cjs/commands/build/build.js +0 -54
  77. package/dist/cjs/commands/build/build.js.map +0 -1
  78. package/dist/cjs/commands/build/implementation.js +0 -31
  79. package/dist/cjs/commands/build/implementation.js.map +0 -1
  80. package/dist/cjs/commands/build/index.js +0 -45
  81. package/dist/cjs/commands/build/index.js.map +0 -1
  82. package/dist/cjs/commands/eval/eval.js +0 -57
  83. package/dist/cjs/commands/eval/eval.js.map +0 -1
  84. package/dist/cjs/commands/eval/implementation.js +0 -27
  85. package/dist/cjs/commands/eval/implementation.js.map +0 -1
  86. package/dist/cjs/commands/eval/index.js +0 -50
  87. package/dist/cjs/commands/eval/index.js.map +0 -1
  88. package/dist/cjs/commands/index.js +0 -30
  89. package/dist/cjs/commands/index.js.map +0 -1
  90. package/dist/cjs/commands/manifest/implementation.js +0 -34
  91. package/dist/cjs/commands/manifest/implementation.js.map +0 -1
  92. package/dist/cjs/commands/manifest/index.js +0 -50
  93. package/dist/cjs/commands/manifest/index.js.map +0 -1
  94. package/dist/cjs/commands/manifest/manifest.js +0 -55
  95. package/dist/cjs/commands/manifest/manifest.js.map +0 -1
  96. package/dist/cjs/commands/serve/index.js +0 -33
  97. package/dist/cjs/commands/serve/index.js.map +0 -1
  98. package/dist/cjs/commands/serve/serve.js +0 -21
  99. package/dist/cjs/commands/serve/serve.js.map +0 -1
  100. package/dist/cjs/commands/watch/implementation.js +0 -35
  101. package/dist/cjs/commands/watch/implementation.js.map +0 -1
  102. package/dist/cjs/commands/watch/index.js +0 -47
  103. package/dist/cjs/commands/watch/index.js.map +0 -1
  104. package/dist/cjs/commands/watch/watch.js +0 -51
  105. package/dist/cjs/commands/watch/watch.js.map +0 -1
  106. package/dist/cjs/config.js +0 -290
  107. package/dist/cjs/config.js.map +0 -1
  108. package/dist/cjs/errors.js +0 -37
  109. package/dist/cjs/errors.js.map +0 -1
  110. package/dist/cjs/index.js +0 -77
  111. package/dist/cjs/index.js.map +0 -1
  112. package/dist/cjs/main.js +0 -19
  113. package/dist/cjs/main.js.map +0 -1
  114. package/dist/cjs/utils/cli.js +0 -61
  115. package/dist/cjs/utils/cli.js.map +0 -1
  116. package/dist/cjs/utils/errors.js +0 -42
  117. package/dist/cjs/utils/errors.js.map +0 -1
  118. package/dist/cjs/utils/index.js +0 -25
  119. package/dist/cjs/utils/index.js.map +0 -1
  120. package/dist/cjs/utils/legacy.js +0 -48
  121. package/dist/cjs/utils/legacy.js.map +0 -1
  122. package/dist/cjs/utils/logging.js +0 -46
  123. package/dist/cjs/utils/logging.js.map +0 -1
  124. package/dist/cjs/utils/path.js +0 -16
  125. package/dist/cjs/utils/path.js.map +0 -1
  126. package/dist/cjs/utils/steps.js +0 -52
  127. package/dist/cjs/utils/steps.js.map +0 -1
  128. package/dist/cjs/webpack/compiler.js +0 -96
  129. package/dist/cjs/webpack/compiler.js.map +0 -1
  130. package/dist/cjs/webpack/config.js +0 -234
  131. package/dist/cjs/webpack/config.js.map +0 -1
  132. package/dist/cjs/webpack/index.js +0 -22
  133. package/dist/cjs/webpack/index.js.map +0 -1
  134. package/dist/cjs/webpack/loaders/browserify.js +0 -97
  135. package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
  136. package/dist/cjs/webpack/loaders/wasm.js +0 -36
  137. package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
  138. package/dist/cjs/webpack/plugins.js +0 -340
  139. package/dist/cjs/webpack/plugins.js.map +0 -1
  140. package/dist/cjs/webpack/utils.js +0 -133
  141. package/dist/cjs/webpack/utils.js.map +0 -1
  142. package/dist/esm/builders.js.map +0 -1
  143. package/dist/esm/cli.js +0 -26
  144. package/dist/esm/cli.js.map +0 -1
  145. package/dist/esm/commands/build/build.js +0 -51
  146. package/dist/esm/commands/build/build.js.map +0 -1
  147. package/dist/esm/commands/build/implementation.js +0 -27
  148. package/dist/esm/commands/build/implementation.js.map +0 -1
  149. package/dist/esm/commands/build/index.js +0 -17
  150. package/dist/esm/commands/build/index.js.map +0 -1
  151. package/dist/esm/commands/eval/eval.js +0 -54
  152. package/dist/esm/commands/eval/eval.js.map +0 -1
  153. package/dist/esm/commands/eval/implementation.js +0 -24
  154. package/dist/esm/commands/eval/implementation.js.map +0 -1
  155. package/dist/esm/commands/eval/index.js +0 -22
  156. package/dist/esm/commands/eval/index.js.map +0 -1
  157. package/dist/esm/commands/index.js +0 -15
  158. package/dist/esm/commands/index.js.map +0 -1
  159. package/dist/esm/commands/manifest/implementation.js +0 -33
  160. package/dist/esm/commands/manifest/implementation.js.map +0 -1
  161. package/dist/esm/commands/manifest/index.js +0 -22
  162. package/dist/esm/commands/manifest/index.js.map +0 -1
  163. package/dist/esm/commands/manifest/manifest.js +0 -52
  164. package/dist/esm/commands/manifest/manifest.js.map +0 -1
  165. package/dist/esm/commands/serve/index.js +0 -18
  166. package/dist/esm/commands/serve/index.js.map +0 -1
  167. package/dist/esm/commands/serve/serve.js +0 -17
  168. package/dist/esm/commands/serve/serve.js.map +0 -1
  169. package/dist/esm/commands/watch/implementation.js +0 -34
  170. package/dist/esm/commands/watch/implementation.js.map +0 -1
  171. package/dist/esm/commands/watch/index.js +0 -19
  172. package/dist/esm/commands/watch/index.js.map +0 -1
  173. package/dist/esm/commands/watch/watch.js +0 -50
  174. package/dist/esm/commands/watch/watch.js.map +0 -1
  175. package/dist/esm/config.js +0 -294
  176. package/dist/esm/config.js.map +0 -1
  177. package/dist/esm/errors.js +0 -30
  178. package/dist/esm/errors.js.map +0 -1
  179. package/dist/esm/index.js +0 -6
  180. package/dist/esm/index.js.map +0 -1
  181. package/dist/esm/main.js +0 -10
  182. package/dist/esm/main.js.map +0 -1
  183. package/dist/esm/utils/cli.js +0 -43
  184. package/dist/esm/utils/cli.js.map +0 -1
  185. package/dist/esm/utils/errors.js +0 -43
  186. package/dist/esm/utils/errors.js.map +0 -1
  187. package/dist/esm/utils/index.js +0 -8
  188. package/dist/esm/utils/index.js.map +0 -1
  189. package/dist/esm/utils/legacy.js +0 -47
  190. package/dist/esm/utils/legacy.js.map +0 -1
  191. package/dist/esm/utils/logging.js +0 -40
  192. package/dist/esm/utils/logging.js.map +0 -1
  193. package/dist/esm/utils/path.js +0 -13
  194. package/dist/esm/utils/path.js.map +0 -1
  195. package/dist/esm/utils/steps.js +0 -43
  196. package/dist/esm/utils/steps.js.map +0 -1
  197. package/dist/esm/webpack/compiler.js +0 -89
  198. package/dist/esm/webpack/compiler.js.map +0 -1
  199. package/dist/esm/webpack/config.js +0 -236
  200. package/dist/esm/webpack/config.js.map +0 -1
  201. package/dist/esm/webpack/index.js +0 -5
  202. package/dist/esm/webpack/index.js.map +0 -1
  203. package/dist/esm/webpack/loaders/browserify.js +0 -82
  204. package/dist/esm/webpack/loaders/browserify.js.map +0 -1
  205. package/dist/esm/webpack/loaders/wasm.js +0 -26
  206. package/dist/esm/webpack/loaders/wasm.js.map +0 -1
  207. package/dist/esm/webpack/plugins.js +0 -343
  208. package/dist/esm/webpack/plugins.js.map +0 -1
  209. package/dist/esm/webpack/utils.js +0 -160
  210. package/dist/esm/webpack/utils.js.map +0 -1
  211. package/dist/types/__fixtures__/configs/cjs.d.ts +0 -1
  212. package/dist/types/__fixtures__/configs/esm.d.ts +0 -3
  213. package/dist/types/__fixtures__/configs/invalid.d.ts +0 -3
  214. package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
  215. package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +0 -3
  216. package/dist/types/builders.d.ts +0 -8
  217. package/dist/types/commands/build/build.d.ts +0 -10
  218. package/dist/types/commands/build/implementation.d.ts +0 -10
  219. package/dist/types/commands/build/index.d.ts +0 -10
  220. package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +0 -3
  221. package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +0 -3
  222. package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +0 -3
  223. package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +0 -3
  224. package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +0 -3
  225. package/dist/types/commands/eval/eval.d.ts +0 -14
  226. package/dist/types/commands/eval/implementation.d.ts +0 -9
  227. package/dist/types/commands/eval/index.d.ts +0 -10
  228. package/dist/types/commands/manifest/implementation.d.ts +0 -12
  229. package/dist/types/commands/manifest/index.d.ts +0 -10
  230. package/dist/types/commands/manifest/manifest.d.ts +0 -14
  231. package/dist/types/commands/serve/serve.d.ts +0 -16
  232. package/dist/types/commands/watch/implementation.d.ts +0 -14
  233. package/dist/types/commands/watch/index.d.ts +0 -10
  234. package/dist/types/commands/watch/watch.d.ts +0 -19
  235. package/dist/types/config.d.ts +0 -626
  236. package/dist/types/errors.d.ts +0 -25
  237. package/dist/types/index.d.ts +0 -5
  238. package/dist/types/utils/cli.d.ts +0 -17
  239. package/dist/types/utils/errors.d.ts +0 -23
  240. package/dist/types/utils/index.d.ts +0 -6
  241. package/dist/types/utils/legacy.d.ts +0 -27
  242. package/dist/types/utils/logging.d.ts +0 -22
  243. package/dist/types/utils/path.d.ts +0 -9
  244. package/dist/types/utils/steps.d.ts +0 -17
  245. package/dist/types/webpack/compiler.d.ts +0 -29
  246. package/dist/types/webpack/config.d.ts +0 -37
  247. package/dist/types/webpack/index.d.ts +0 -3
  248. package/dist/types/webpack/loaders/browserify.d.ts +0 -16
  249. package/dist/types/webpack/loaders/wasm.d.ts +0 -20
  250. package/dist/types/webpack/plugins.d.ts +0 -147
  251. package/dist/types/webpack/utils.d.ts +0 -156
  252. /package/dist/{types/commands → cmds}/index.d.ts +0 -0
  253. /package/dist/{types/main.d.ts → main.d.ts} +0 -0
@@ -1,133 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- BROWSERSLIST_FILE: function() {
13
- return BROWSERSLIST_FILE;
14
- },
15
- getDefaultLoader: function() {
16
- return getDefaultLoader;
17
- },
18
- getDevTool: function() {
19
- return getDevTool;
20
- },
21
- getProgressHandler: function() {
22
- return getProgressHandler;
23
- },
24
- getBrowserslistTargets: function() {
25
- return getBrowserslistTargets;
26
- },
27
- pluralize: function() {
28
- return pluralize;
29
- }
30
- });
31
- const _chalk = require("chalk");
32
- const _fs = require("fs");
33
- const _path = require("path");
34
- const BROWSERSLIST_FILE = (0, _path.resolve)((0, _path.dirname)(// eslint-disable-next-line n/no-extraneous-require
35
- require.resolve('@metamask/snaps-cli/package.json')), '.browserslistrc');
36
- async function getDefaultLoader({ legacy, sourceMap }) {
37
- if (legacy) {
38
- return {
39
- /**
40
- * If the snap uses the legacy config, we use the custom `browserify`
41
- * loader. This uses the legacy Browserify config to transpile the code.
42
- * This is necessary for backwards compatibility with the
43
- * `bundlerCustomizer` function.
44
- */ loader: (0, _path.resolve)(__dirname, 'loaders', 'browserify'),
45
- /**
46
- * The options for the `browserify` loader. These can be overridden in the
47
- * snap config.
48
- */ options: legacy
49
- };
50
- }
51
- const targets = await getBrowserslistTargets();
52
- return {
53
- /**
54
- * We use the `swc-loader` to transpile TypeScript and JavaScript files.
55
- * This is a Webpack loader that uses the `SWC` compiler, which is a much
56
- * faster alternative to Babel and TypeScript's own compiler.
57
- */ loader: 'swc-loader',
58
- /**
59
- * The options for the `swc-loader`. These can be overridden in the
60
- * `.swcrc` file.
61
- *
62
- * @see https://swc.rs/docs/configuration/swcrc
63
- */ options: {
64
- sync: false,
65
- /**
66
- * This tells SWC to generate source maps. We set it to the
67
- * `sourceMap` value from the config object.
68
- *
69
- * This must be enabled if source maps are enabled in the config.
70
- */ sourceMaps: Boolean(getDevTool(sourceMap)),
71
- jsc: {
72
- /**
73
- * MetaMask targets ES2020, so we set the target to ES2020. This
74
- * ensures that the code is transpiled to ES2020, and that the
75
- * necessary polyfills are added.
76
- *
77
- * @see https://swc.rs/docs/configuration/compilation#jsctarget
78
- */ target: 'es2020',
79
- parser: {
80
- /**
81
- * This tells the parser to parse TypeScript files. If you
82
- * don't need to support TypeScript, you can set this to
83
- * `ecmascript` instead, but there's no harm in leaving it
84
- * as `typescript`.
85
- *
86
- * @see https://swc.rs/docs/configuration/compilation#jscparser
87
- */ syntax: 'typescript'
88
- }
89
- },
90
- /**
91
- * The module configuration. This tells SWC how to output the
92
- * transpiled code.
93
- *
94
- * @see https://swc.rs/docs/configuration/modules
95
- */ module: {
96
- /**
97
- * This tells SWC to output CommonJS modules. MetaMask Snaps
98
- * doesn't support ES modules yet, so this is necessary.
99
- *
100
- * @see https://swc.rs/docs/configuration/modules#commonjs
101
- */ type: 'commonjs'
102
- },
103
- env: {
104
- targets: targets.join(', ')
105
- }
106
- }
107
- };
108
- }
109
- function getDevTool(sourceMap) {
110
- if (sourceMap === 'inline') {
111
- return 'inline-source-map';
112
- }
113
- if (sourceMap === true) {
114
- return 'source-map';
115
- }
116
- return false;
117
- }
118
- function getProgressHandler(spinner, spinnerText) {
119
- return (percentage)=>{
120
- if (spinner && spinnerText) {
121
- spinner.text = `${spinnerText} ${(0, _chalk.dim)(`(${Math.round(percentage * 100)}%)`)}`;
122
- }
123
- };
124
- }
125
- async function getBrowserslistTargets() {
126
- const contents = await _fs.promises.readFile(BROWSERSLIST_FILE, 'utf8');
127
- return contents.split('\n').map((line)=>line.trim()).filter((line)=>line && !line.startsWith('#'));
128
- }
129
- function pluralize(count, singular, plural = `${singular}s`) {
130
- return count === 1 ? singular : plural;
131
- }
132
-
133
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/webpack/utils.ts"],"sourcesContent":["import { dim } from 'chalk';\nimport { promises as fs } from 'fs';\nimport type { Ora } from 'ora';\nimport { dirname, resolve } from 'path';\nimport type { Configuration } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\n\nexport const BROWSERSLIST_FILE = resolve(\n dirname(\n // eslint-disable-next-line n/no-extraneous-require\n require.resolve('@metamask/snaps-cli/package.json'),\n ),\n '.browserslistrc',\n);\n\n/**\n * Get the default loader for JavaScript and TypeScript files, based on the\n * config object.\n *\n * - If the `legacy` option is set, we use the custom `browserify` loader. This\n * uses the legacy Browserify config to transpile the code.\n * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the\n * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's\n * own compiler.\n *\n * @param config - The processed snap Webpack config.\n * @param config.legacy - The legacy config object, if any.\n * @param config.sourceMap - Whether to generate source maps.\n * @see https://swc.rs/docs/usage/swc-loader\n * @returns The default loader.\n */\nexport async function getDefaultLoader({\n legacy,\n sourceMap,\n}: ProcessedWebpackConfig) {\n if (legacy) {\n return {\n /**\n * If the snap uses the legacy config, we use the custom `browserify`\n * loader. This uses the legacy Browserify config to transpile the code.\n * This is necessary for backwards compatibility with the\n * `bundlerCustomizer` function.\n */\n loader: resolve(__dirname, 'loaders', 'browserify'),\n\n /**\n * The options for the `browserify` loader. These can be overridden in the\n * snap config.\n */\n options: legacy,\n };\n }\n\n const targets = await getBrowserslistTargets();\n return {\n /**\n * We use the `swc-loader` to transpile TypeScript and JavaScript files.\n * This is a Webpack loader that uses the `SWC` compiler, which is a much\n * faster alternative to Babel and TypeScript's own compiler.\n */\n loader: 'swc-loader',\n\n /**\n * The options for the `swc-loader`. These can be overridden in the\n * `.swcrc` file.\n *\n * @see https://swc.rs/docs/configuration/swcrc\n */\n options: {\n sync: false,\n\n /**\n * This tells SWC to generate source maps. We set it to the\n * `sourceMap` value from the config object.\n *\n * This must be enabled if source maps are enabled in the config.\n */\n sourceMaps: Boolean(getDevTool(sourceMap)),\n\n jsc: {\n /**\n * MetaMask targets ES2020, so we set the target to ES2020. This\n * ensures that the code is transpiled to ES2020, and that the\n * necessary polyfills are added.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctarget\n */\n target: 'es2020',\n\n parser: {\n /**\n * This tells the parser to parse TypeScript files. If you\n * don't need to support TypeScript, you can set this to\n * `ecmascript` instead, but there's no harm in leaving it\n * as `typescript`.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n */\n syntax: 'typescript',\n },\n },\n\n /**\n * The module configuration. This tells SWC how to output the\n * transpiled code.\n *\n * @see https://swc.rs/docs/configuration/modules\n */\n module: {\n /**\n * This tells SWC to output CommonJS modules. MetaMask Snaps\n * doesn't support ES modules yet, so this is necessary.\n *\n * @see https://swc.rs/docs/configuration/modules#commonjs\n */\n type: 'commonjs',\n },\n\n env: {\n targets: targets.join(', '),\n },\n },\n };\n}\n\n/**\n * Get the Webpack devtool configuration based on the given snap config.\n *\n * - If `sourceMap` is `inline`, return `inline-source-map`.\n * - If `sourceMap` is `true`, return `source-map`.\n * - Otherwise, return `false`.\n *\n * @param sourceMap - The `sourceMap` value from the snap config.\n * @returns The Webpack devtool configuration.\n */\nexport function getDevTool(\n sourceMap: ProcessedWebpackConfig['sourceMap'],\n): Configuration['devtool'] {\n if (sourceMap === 'inline') {\n return 'inline-source-map';\n }\n\n if (sourceMap === true) {\n return 'source-map';\n }\n\n return false;\n}\n\n/**\n * Get a function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n *\n * @param spinner - The spinner to update.\n * @param spinnerText - The initial spinner text. This will be prepended to the\n * percentage.\n * @returns A function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n */\n// Note: This is extracted for testing purposes.\nexport function getProgressHandler(spinner?: Ora, spinnerText?: string) {\n return (percentage: number) => {\n if (spinner && spinnerText) {\n spinner.text = `${spinnerText} ${dim(\n `(${Math.round(percentage * 100)}%)`,\n )}`;\n }\n };\n}\n\n/**\n * Get the targets from the `.browserslistrc` file.\n *\n * @returns The browser targets as an array of strings.\n */\nexport async function getBrowserslistTargets() {\n const contents = await fs.readFile(BROWSERSLIST_FILE, 'utf8');\n return contents\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#'));\n}\n\n/**\n * Get a singular or plural string based on the given count. This is useful for\n * generating messages like \"1 error\" or \"2 errors\". By default, the plural\n * string is the singular string with an \"s\" appended to it.\n *\n * This assumes that the text is in English, and likely won't work for some\n * other languages.\n *\n * @param count - The count.\n * @param singular - The singular string.\n * @param plural - The plural string.\n * @returns The singular or plural string.\n * @example\n * ```typescript\n * pluralize(1, 'error'); // => 'error'\n * pluralize(2, 'error'); // => 'errors'\n * pluralize(1, 'error', 'problem'); // => 'error'\n * pluralize(2, 'error', 'problems'); // => 'problems'\n * ```\n */\nexport function pluralize(\n count: number,\n singular: string,\n plural = `${singular}s`,\n) {\n return count === 1 ? singular : plural;\n}\n"],"names":["BROWSERSLIST_FILE","getDefaultLoader","getDevTool","getProgressHandler","getBrowserslistTargets","pluralize","resolve","dirname","require","legacy","sourceMap","loader","__dirname","options","targets","sync","sourceMaps","Boolean","jsc","target","parser","syntax","module","type","env","join","spinner","spinnerText","percentage","text","dim","Math","round","contents","fs","readFile","split","map","line","trim","filter","startsWith","count","singular","plural"],"mappings":";;;;;;;;;;;IAQaA,iBAAiB;eAAjBA;;IAwBSC,gBAAgB;eAAhBA;;IAwGNC,UAAU;eAAVA;;IAyBAC,kBAAkB;eAAlBA;;IAeMC,sBAAsB;eAAtBA;;IA4BNC,SAAS;eAATA;;;uBA5MI;oBACW;sBAEE;AAK1B,MAAML,oBAAoBM,IAAAA,aAAO,EACtCC,IAAAA,aAAO,EACL,mDAAmD;AACnDC,QAAQF,OAAO,CAAC,sCAElB;AAmBK,eAAeL,iBAAiB,EACrCQ,MAAM,EACNC,SAAS,EACc;IACvB,IAAID,QAAQ;QACV,OAAO;YACL;;;;;OAKC,GACDE,QAAQL,IAAAA,aAAO,EAACM,WAAW,WAAW;YAEtC;;;OAGC,GACDC,SAASJ;QACX;IACF;IAEA,MAAMK,UAAU,MAAMV;IACtB,OAAO;QACL;;;;KAIC,GACDO,QAAQ;QAER;;;;;KAKC,GACDE,SAAS;YACPE,MAAM;YAEN;;;;;OAKC,GACDC,YAAYC,QAAQf,WAAWQ;YAE/BQ,KAAK;gBACH;;;;;;SAMC,GACDC,QAAQ;gBAERC,QAAQ;oBACN;;;;;;;WAOC,GACDC,QAAQ;gBACV;YACF;YAEA;;;;;OAKC,GACDC,QAAQ;gBACN;;;;;SAKC,GACDC,MAAM;YACR;YAEAC,KAAK;gBACHV,SAASA,QAAQW,IAAI,CAAC;YACxB;QACF;IACF;AACF;AAYO,SAASvB,WACdQ,SAA8C;IAE9C,IAAIA,cAAc,UAAU;QAC1B,OAAO;IACT;IAEA,IAAIA,cAAc,MAAM;QACtB,OAAO;IACT;IAEA,OAAO;AACT;AAaO,SAASP,mBAAmBuB,OAAa,EAAEC,WAAoB;IACpE,OAAO,CAACC;QACN,IAAIF,WAAWC,aAAa;YAC1BD,QAAQG,IAAI,GAAG,CAAC,EAAEF,YAAY,CAAC,EAAEG,IAAAA,UAAG,EAClC,CAAC,CAAC,EAAEC,KAAKC,KAAK,CAACJ,aAAa,KAAK,EAAE,CAAC,EACpC,CAAC;QACL;IACF;AACF;AAOO,eAAexB;IACpB,MAAM6B,WAAW,MAAMC,YAAE,CAACC,QAAQ,CAACnC,mBAAmB;IACtD,OAAOiC,SACJG,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,MAAM,CAAC,CAACF,OAASA,QAAQ,CAACA,KAAKG,UAAU,CAAC;AAC/C;AAsBO,SAASpC,UACdqC,KAAa,EACbC,QAAgB,EAChBC,SAAS,CAAC,EAAED,SAAS,CAAC,CAAC;IAEvB,OAAOD,UAAU,IAAIC,WAAWC;AAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/builders.ts"],"sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders: Record<string, Readonly<Options>> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n // Deprecated Browserify options.\n bundle: {\n alias: 'b',\n describe: 'Snap bundle file',\n type: 'string',\n normalize: true,\n deprecated: 'Use --input instead.',\n },\n\n dist: {\n alias: 'd',\n describe: 'Output directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n eval: {\n alias: 'e',\n describe: 'Attempt to evaluate Snap bundle in SES',\n type: 'boolean',\n deprecated: true,\n },\n\n manifest: {\n alias: 'm',\n describe: 'Validate snap.manifest.json',\n type: 'boolean',\n deprecated: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n deprecated: true,\n },\n\n outfileName: {\n alias: 'n',\n describe: 'Output file name',\n type: 'string',\n deprecated: true,\n },\n\n root: {\n alias: 'r',\n describe: 'Server root directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n sourceMaps: {\n describe: 'Whether builds include sourcemaps',\n type: 'boolean',\n deprecated: true,\n },\n\n src: {\n alias: 's',\n describe: 'Source file',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n stripComments: {\n alias: 'strip',\n describe: 'Whether to remove code comments from the build output',\n type: 'boolean',\n deprecated: true,\n },\n\n suppressWarnings: {\n type: 'boolean',\n describe: 'Whether to suppress warnings',\n deprecated: true,\n },\n\n transpilationMode: {\n type: 'string',\n describe:\n 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',\n choices: Object.values(TranspilationModes),\n deprecated: true,\n },\n\n depsToTranspile: {\n type: 'array',\n describe: 'Transpile only the listed dependencies.',\n deprecated: true,\n },\n\n verboseErrors: {\n type: 'boolean',\n describe: 'Display original errors',\n deprecated: true,\n },\n\n writeManifest: {\n describe: 'Make necessary changes to the snap manifest file',\n type: 'boolean',\n deprecated: true,\n },\n\n serve: {\n describe: 'Serve snap file(s) locally for testing',\n type: 'boolean',\n deprecated: true,\n },\n};\n\nexport default builders;\n"],"names":["TranspilationModes","LocalAndDeps","LocalOnly","None","builders","config","alias","describe","type","normalize","fix","input","bundle","deprecated","dist","eval","manifest","port","coerce","arg","Number","parseInt","String","isNaN","Error","outfileName","root","sourceMaps","src","stripComments","suppressWarnings","transpilationMode","choices","Object","values","depsToTranspile","verboseErrors","writeManifest","serve"],"mappings":"WAEO;UAAKA,kBAAkB;IAAlBA,mBACVC,kBAAe;IADLD,mBAEVE,eAAY;IAFFF,mBAGVG,UAAO;GAHGH,uBAAAA;AAMZ,MAAMI,WAA8C;IAClD,gEAAgE;IAChEC,QAAQ;QACNC,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEAC,KAAK;QACHH,UAAU;QACVC,MAAM;IACR;IAEAG,OAAO;QACLL,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEA,iCAAiC;IACjCG,QAAQ;QACNN,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAC,MAAM;QACJR,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAE,MAAM;QACJT,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAG,UAAU;QACRV,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAI,MAAM;QACJX,OAAO;QACPC,UAAU;QACVC,MAAM;QACNU,QAAQ,CAACC;YACP,MAAMF,OAAOG,OAAOC,QAAQ,CAACC,OAAOH,MAAM;YAC1C,IAAIC,OAAOG,KAAK,CAACN,OAAO;gBACtB,MAAM,IAAIO,MAAM,CAAC,eAAe,EAAEF,OAAOH,KAAK,EAAE,CAAC;YACnD;YAEA,OAAOF;QACT;QACAJ,YAAY;IACd;IAEAY,aAAa;QACXnB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAa,MAAM;QACJpB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAc,YAAY;QACVpB,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAe,KAAK;QACHtB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAgB,eAAe;QACbvB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAiB,kBAAkB;QAChBtB,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAkB,mBAAmB;QACjBvB,MAAM;QACND,UACE;QACFyB,SAASC,OAAOC,MAAM,CAAClC;QACvBa,YAAY;IACd;IAEAsB,iBAAiB;QACf3B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAuB,eAAe;QACb5B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAwB,eAAe;QACb9B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAyB,OAAO;QACL/B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;AACF;AAEA,eAAeT,SAAS"}
package/dist/esm/cli.js DELETED
@@ -1,26 +0,0 @@
1
- import yargs from 'yargs';
2
- import { hideBin } from 'yargs/helpers';
3
- import builders from './builders';
4
- import { getConfigByArgv } from './config';
5
- import { error, getYargsErrorMessage, sanitizeInputs } from './utils';
6
- /**
7
- * The main CLI entry point function. This processes the command line args, and
8
- * runs the appropriate function.
9
- *
10
- * @param argv - The raw command line arguments, i.e., `process.argv`.
11
- * @param commands - The list of commands to use.
12
- */ export async function cli(argv, commands) {
13
- await yargs(hideBin(argv)).scriptName('mm-snap').usage('Usage: $0 <command> [options]').example('$0 build', `Build './src/index.js' as './dist/bundle.js'`).example('$0 build --config ./snap.config.build.ts', `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`).example('$0 manifest --fix', `Check the snap manifest, and fix any errors`).example('$0 watch --port 8000', `The snap input file for changes, and serve it on port 8000`).example('$0 serve --port 8000', `Serve the snap bundle on port 8000`).command(commands).option('config', builders.config).option('verboseErrors', builders.verboseErrors).option('suppressWarnings', builders.suppressWarnings).strict().middleware(async (args)=>{
14
- // eslint-disable-next-line require-atomic-updates
15
- args.context = {
16
- config: await getConfigByArgv(args)
17
- };
18
- sanitizeInputs(args);
19
- }, false).demandCommand(1, 'You must specify at least one command.').fail((message, failure)=>{
20
- error(getYargsErrorMessage(message, failure));
21
- // eslint-disable-next-line n/no-process-exit
22
- process.exit(1);
23
- }).help().alias('help', 'h').parseAsync();
24
- }
25
-
26
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport builders from './builders';\nimport { getConfigByArgv } from './config';\nimport { error, getYargsErrorMessage, sanitizeInputs } from './utils';\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport async function cli(argv: string[], commands: any) {\n await yargs(hideBin(argv))\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 build', `Build './src/index.js' as './dist/bundle.js'`)\n .example(\n '$0 build --config ./snap.config.build.ts',\n `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`,\n )\n .example('$0 manifest --fix', `Check the snap manifest, and fix any errors`)\n .example(\n '$0 watch --port 8000',\n `The snap input file for changes, and serve it on port 8000`,\n )\n .example('$0 serve --port 8000', `Serve the snap bundle on port 8000`)\n\n .command(commands)\n\n .option('config', builders.config)\n .option('verboseErrors', builders.verboseErrors)\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n .middleware(async (args: any) => {\n // eslint-disable-next-line require-atomic-updates\n args.context = {\n config: await getConfigByArgv(args),\n };\n\n sanitizeInputs(args);\n }, false)\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .fail((message, failure) => {\n error(getYargsErrorMessage(message, failure));\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n })\n\n .help()\n .alias('help', 'h')\n .parseAsync();\n}\n"],"names":["yargs","hideBin","builders","getConfigByArgv","error","getYargsErrorMessage","sanitizeInputs","cli","argv","commands","scriptName","usage","example","command","option","config","verboseErrors","suppressWarnings","strict","middleware","args","context","demandCommand","fail","message","failure","process","exit","help","alias","parseAsync"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,gBAAgB;AAExC,OAAOC,cAAc,aAAa;AAClC,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,KAAK,EAAEC,oBAAoB,EAAEC,cAAc,QAAQ,UAAU;AAEtE;;;;;;CAMC,GACD,OAAO,eAAeC,IAAIC,IAAc,EAAEC,QAAa;IACrD,MAAMT,MAAMC,QAAQO,OACjBE,UAAU,CAAC,WACXC,KAAK,CAAC,iCAENC,OAAO,CAAC,YAAY,CAAC,4CAA4C,CAAC,EAClEA,OAAO,CACN,4CACA,CAAC,yFAAyF,CAAC,EAE5FA,OAAO,CAAC,qBAAqB,CAAC,2CAA2C,CAAC,EAC1EA,OAAO,CACN,wBACA,CAAC,0DAA0D,CAAC,EAE7DA,OAAO,CAAC,wBAAwB,CAAC,kCAAkC,CAAC,EAEpEC,OAAO,CAACJ,UAERK,MAAM,CAAC,UAAUZ,SAASa,MAAM,EAChCD,MAAM,CAAC,iBAAiBZ,SAASc,aAAa,EAC9CF,MAAM,CAAC,oBAAoBZ,SAASe,gBAAgB,EAEpDC,MAAM,GAENC,UAAU,CAAC,OAAOC;QACjB,kDAAkD;QAClDA,KAAKC,OAAO,GAAG;YACbN,QAAQ,MAAMZ,gBAAgBiB;QAChC;QAEAd,eAAec;IACjB,GAAG,OAEFE,aAAa,CAAC,GAAG,0CAEjBC,IAAI,CAAC,CAACC,SAASC;QACdrB,MAAMC,qBAAqBmB,SAASC;QACpC,6CAA6C;QAC7CC,QAAQC,IAAI,CAAC;IACf,GAECC,IAAI,GACJC,KAAK,CAAC,QAAQ,KACdC,UAAU;AACf"}
@@ -1,51 +0,0 @@
1
- import { isFile } from '@metamask/snaps-utils';
2
- import { resolve as pathResolve } from 'path';
3
- import { CommandError } from '../../errors';
4
- import { executeSteps, info } from '../../utils';
5
- import { evaluate } from '../eval';
6
- import { build } from './implementation';
7
- const steps = [
8
- {
9
- name: 'Checking the input file.',
10
- task: async ({ config })=>{
11
- const { input } = config;
12
- if (!await isFile(input)) {
13
- throw new CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
14
- }
15
- }
16
- },
17
- {
18
- name: 'Building the snap bundle.',
19
- task: async ({ config, spinner })=>{
20
- // We don't evaluate the bundle here, because it's done in a separate
21
- // step.
22
- return await build(config, {
23
- evaluate: false,
24
- spinner
25
- });
26
- }
27
- },
28
- {
29
- name: 'Evaluating the snap bundle.',
30
- condition: ({ config })=>config.evaluate,
31
- task: async ({ config, spinner })=>{
32
- const path = pathResolve(process.cwd(), config.output.path, config.output.filename);
33
- await evaluate(path);
34
- info(`Snap bundle evaluated successfully.`, spinner);
35
- }
36
- }
37
- ];
38
- /**
39
- * Build all files in the given source directory to the given destination
40
- * directory.
41
- *
42
- * This creates the destination directory if it doesn't exist.
43
- *
44
- * @param config - The config object.
45
- */ export async function buildHandler(config) {
46
- return await executeSteps(steps, {
47
- config
48
- });
49
- }
50
-
51
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/build/build.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve as pathResolve } from 'path';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\nimport { build } from './implementation';\n\ntype BuildContext = {\n config: ProcessedWebpackConfig;\n};\n\nconst steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n return await build(config, { evaluate: false, spinner });\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n condition: ({ config }) => config.evaluate,\n task: async ({ config, spinner }) => {\n const path = pathResolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n */\nexport async function buildHandler(config: ProcessedConfig): Promise<void> {\n return await executeSteps(steps, {\n config,\n });\n}\n"],"names":["isFile","resolve","pathResolve","CommandError","executeSteps","info","evaluate","build","steps","name","task","config","input","spinner","condition","path","process","cwd","output","filename","buildHandler"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,WAAWC,WAAW,QAAQ,OAAO;AAG9C,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,YAAY,EAAEC,IAAI,QAAQ,cAAc;AACjD,SAASC,QAAQ,QAAQ,UAAU;AACnC,SAASC,KAAK,QAAQ,mBAAmB;AAMzC,MAAMC,QAA6B;IACjC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAE;YACrB,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAElB,IAAI,CAAE,MAAMX,OAAOY,QAAS;gBAC1B,MAAM,IAAIT,aACR,CAAC,uBAAuB,EAAES,MAAM,mEAAmE,CAAC;YAExG;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAE;YAC9B,qEAAqE;YACrE,QAAQ;YACR,OAAO,MAAMN,MAAMI,QAAQ;gBAAEL,UAAU;gBAAOO;YAAQ;QACxD;IACF;IACA;QACEJ,MAAM;QACNK,WAAW,CAAC,EAAEH,MAAM,EAAE,GAAKA,OAAOL,QAAQ;QAC1CI,MAAM,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAE;YAC9B,MAAME,OAAOb,YACXc,QAAQC,GAAG,IACXN,OAAOO,MAAM,CAACH,IAAI,EAClBJ,OAAOO,MAAM,CAACC,QAAQ;YAGxB,MAAMb,SAASS;YAEfV,KAAK,CAAC,mCAAmC,CAAC,EAAEQ;QAC9C;IACF;CACD;AAED;;;;;;;CAOC,GACD,OAAO,eAAeO,aAAaT,MAAuB;IACxD,OAAO,MAAMP,aAAaI,OAAO;QAC/BG;IACF;AACF"}
@@ -1,27 +0,0 @@
1
- import { getCompiler } from '../../webpack';
2
- /**
3
- * Build the snap bundle. This uses Webpack to build the bundle.
4
- *
5
- * @param config - The config object.
6
- * @param options - The Webpack options.
7
- * @returns A promise that resolves when the bundle is built.
8
- */ export async function build(config, options) {
9
- const compiler = await getCompiler(config, options);
10
- return await new Promise((resolve, reject)=>{
11
- compiler.run((runError)=>{
12
- if (runError) {
13
- reject(runError);
14
- return;
15
- }
16
- compiler.close((closeError)=>{
17
- if (closeError) {
18
- reject(closeError);
19
- return;
20
- }
21
- resolve();
22
- });
23
- });
24
- });
25
- }
26
-
27
- //# sourceMappingURL=implementation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/build/implementation.ts"],"sourcesContent":["import type { ProcessedWebpackConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(\n config: ProcessedWebpackConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, options);\n return await new Promise<void>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve();\n });\n });\n });\n}\n"],"names":["getCompiler","build","config","options","compiler","Promise","resolve","reject","run","runError","close","closeError"],"mappings":"AAEA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C;;;;;;CAMC,GACD,OAAO,eAAeC,MACpBC,MAA8B,EAC9BC,OAAwB;IAExB,MAAMC,WAAW,MAAMJ,YAAYE,QAAQC;IAC3C,OAAO,MAAM,IAAIE,QAAc,CAACC,SAASC;QACvCH,SAASI,GAAG,CAAC,CAACC;YACZ,IAAIA,UAAU;gBACZF,OAAOE;gBACP;YACF;YAEAL,SAASM,KAAK,CAAC,CAACC;gBACd,IAAIA,YAAY;oBACdJ,OAAOI;oBACP;gBACF;gBAEAL;YACF;QACF;IACF;AACF"}
@@ -1,17 +0,0 @@
1
- import builders from '../../builders';
2
- import { buildHandler } from './build';
3
- const command = {
4
- command: [
5
- 'build',
6
- 'b'
7
- ],
8
- desc: 'Build snap from source',
9
- builder: (yarg)=>{
10
- yarg.option('dist', builders.dist).option('eval', builders.eval).option('manifest', builders.manifest).option('outfileName', builders.outfileName).option('sourceMaps', builders.sourceMaps).option('src', builders.src).option('stripComments', builders.stripComments).option('transpilationMode', builders.transpilationMode).option('depsToTranspile', builders.depsToTranspile).option('writeManifest', builders.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode');
11
- },
12
- handler: async (argv)=>buildHandler(argv.context.config)
13
- };
14
- export * from './implementation';
15
- export default command;
16
-
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/build/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { buildHandler } from './build';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('dist', builders.dist)\n .option('eval', builders.eval)\n .option('manifest', builders.manifest)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('src', builders.src)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('writeManifest', builders.writeManifest)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) => buildHandler(argv.context.config),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["builders","buildHandler","command","desc","builder","yarg","option","dist","eval","manifest","outfileName","sourceMaps","src","stripComments","transpilationMode","depsToTranspile","writeManifest","implies","handler","argv","context","config"],"mappings":"AAEA,OAAOA,cAAc,iBAAiB;AAEtC,SAASC,YAAY,QAAQ,UAAU;AAEvC,MAAMC,UAAU;IACdA,SAAS;QAAC;QAAS;KAAI;IACvBC,MAAM;IACNC,SAAS,CAACC;QACRA,KACGC,MAAM,CAAC,QAAQN,SAASO,IAAI,EAC5BD,MAAM,CAAC,QAAQN,SAASQ,IAAI,EAC5BF,MAAM,CAAC,YAAYN,SAASS,QAAQ,EACpCH,MAAM,CAAC,eAAeN,SAASU,WAAW,EAC1CJ,MAAM,CAAC,cAAcN,SAASW,UAAU,EACxCL,MAAM,CAAC,OAAON,SAASY,GAAG,EAC1BN,MAAM,CAAC,iBAAiBN,SAASa,aAAa,EAC9CP,MAAM,CAAC,qBAAqBN,SAASc,iBAAiB,EACtDR,MAAM,CAAC,mBAAmBN,SAASe,eAAe,EAClDT,MAAM,CAAC,iBAAiBN,SAASgB,aAAa,EAC9CC,OAAO,CAAC,iBAAiB,YACzBA,OAAO,CAAC,mBAAmB;IAChC;IACAC,SAAS,OAAOC,OAAoBlB,aAAakB,KAAKC,OAAO,CAACC,MAAM;AACtE;AAEA,cAAc,mBAAmB;AACjC,eAAenB,QAAQ"}
@@ -1,54 +0,0 @@
1
- import { isFile } from '@metamask/snaps-utils';
2
- import { resolve } from 'path';
3
- import { CommandError } from '../../errors';
4
- import { executeSteps, getRelativePath } from '../../utils';
5
- import { evaluate } from './implementation';
6
- const steps = [
7
- {
8
- name: 'Checking the input file.',
9
- task: async ({ input })=>{
10
- if (!await isFile(input)) {
11
- const relativePath = getRelativePath(input);
12
- throw new CommandError(`Input file not found: "${relativePath}". Make sure that the "input" field in your snap config or the specified input file is correct.`);
13
- }
14
- }
15
- },
16
- {
17
- name: 'Evaluating the snap bundle.',
18
- task: async ({ input, spinner })=>{
19
- await evaluate(input);
20
- spinner.succeed('Snap bundle evaluated successfully.');
21
- }
22
- }
23
- ];
24
- /**
25
- * Returns the path to the bundle, based on the config and options.
26
- *
27
- * - If `options.input` is specified, it is used as the bundle path.
28
- * - Otherwise, the bundle path is resolved from the config's output path and
29
- * filename.
30
- *
31
- * @param config - The processed config object.
32
- * @param options - The eval options.
33
- * @returns The path to the bundle.
34
- */ function getBundlePath(config, options) {
35
- if (options.input) {
36
- return resolve(process.cwd(), options.input);
37
- }
38
- return resolve(config.output.path, config.output.filename);
39
- }
40
- /**
41
- * Runs the snap in a worker, to ensure SES compatibility.
42
- *
43
- * @param config - The processed config object.
44
- * @param options - The eval options.
45
- * @returns A promise that resolves once the eval has finished.
46
- * @throws If the eval failed.
47
- */ export async function evaluateHandler(config, options = {}) {
48
- const input = getBundlePath(config, options);
49
- await executeSteps(steps, {
50
- input
51
- });
52
- }
53
-
54
- //# sourceMappingURL=eval.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/eval/eval.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve } from 'path';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, getRelativePath } from '../../utils';\nimport { evaluate } from './implementation';\n\nexport type EvalOptions = {\n input?: string;\n};\n\nexport type EvalContext = Required<EvalOptions>;\n\nconst steps: Steps<EvalContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n const relativePath = getRelativePath(input);\n throw new CommandError(\n `Input file not found: \"${relativePath}\". Make sure that the \"input\" field in your snap config or the specified input file is correct.`,\n );\n }\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n task: async ({ input, spinner }) => {\n await evaluate(input);\n spinner.succeed('Snap bundle evaluated successfully.');\n },\n },\n];\n\n/**\n * Returns the path to the bundle, based on the config and options.\n *\n * - If `options.input` is specified, it is used as the bundle path.\n * - Otherwise, the bundle path is resolved from the config's output path and\n * filename.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns The path to the bundle.\n */\nfunction getBundlePath(config: ProcessedConfig, options: EvalOptions): string {\n if (options.input) {\n return resolve(process.cwd(), options.input);\n }\n\n return resolve(config.output.path, config.output.filename);\n}\n\n/**\n * Runs the snap in a worker, to ensure SES compatibility.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns A promise that resolves once the eval has finished.\n * @throws If the eval failed.\n */\nexport async function evaluateHandler(\n config: ProcessedConfig,\n options: EvalOptions = {},\n): Promise<void> {\n const input = getBundlePath(config, options);\n await executeSteps(steps, { input });\n}\n"],"names":["isFile","resolve","CommandError","executeSteps","getRelativePath","evaluate","steps","name","task","input","relativePath","spinner","succeed","getBundlePath","config","options","process","cwd","output","path","filename","evaluateHandler"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,OAAO;AAG/B,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,YAAY,EAAEC,eAAe,QAAQ,cAAc;AAC5D,SAASC,QAAQ,QAAQ,mBAAmB;AAQ5C,MAAMC,QAA4B;IAChC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAE;YACpB,IAAI,CAAE,MAAMT,OAAOS,QAAS;gBAC1B,MAAMC,eAAeN,gBAAgBK;gBACrC,MAAM,IAAIP,aACR,CAAC,uBAAuB,EAAEQ,aAAa,+FAA+F,CAAC;YAE3I;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAEE,OAAO,EAAE;YAC7B,MAAMN,SAASI;YACfE,QAAQC,OAAO,CAAC;QAClB;IACF;CACD;AAED;;;;;;;;;;CAUC,GACD,SAASC,cAAcC,MAAuB,EAAEC,OAAoB;IAClE,IAAIA,QAAQN,KAAK,EAAE;QACjB,OAAOR,QAAQe,QAAQC,GAAG,IAAIF,QAAQN,KAAK;IAC7C;IAEA,OAAOR,QAAQa,OAAOI,MAAM,CAACC,IAAI,EAAEL,OAAOI,MAAM,CAACE,QAAQ;AAC3D;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,gBACpBP,MAAuB,EACvBC,UAAuB,CAAC,CAAC;IAEzB,MAAMN,QAAQI,cAAcC,QAAQC;IACpC,MAAMZ,aAAaG,OAAO;QAAEG;IAAM;AACpC"}
@@ -1,24 +0,0 @@
1
- import { evalBundle, SnapEvalError, indent } from '@metamask/snaps-utils';
2
- import { red } from 'chalk';
3
- import { CommandError } from '../../errors';
4
- /**
5
- * Evaluate the given bundle in the SES environment. This is a wrapper around
6
- * {@link evalBundle} that throws a {@link CommandError} if the bundle cannot be
7
- * evaluated.
8
- *
9
- * @param path - The path to the bundle.
10
- * @throws If the bundle cannot be evaluated.
11
- */ export async function evaluate(path) {
12
- try {
13
- return await evalBundle(path);
14
- } catch (evalError) {
15
- if (evalError instanceof SnapEvalError) {
16
- throw new CommandError(`Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\nReceived the following error from the SES environment:\n\n${indent(red(evalError.output.stderr), 2)}`);
17
- }
18
- // If the error is not a `SnapEvalError`, we don't know what it is, so
19
- // we just throw it.
20
- throw evalError;
21
- }
22
- }
23
-
24
- //# sourceMappingURL=implementation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/eval/implementation.ts"],"sourcesContent":["import { evalBundle, SnapEvalError, indent } from '@metamask/snaps-utils';\nimport { red } from 'chalk';\n\nimport { CommandError } from '../../errors';\n\n/**\n * Evaluate the given bundle in the SES environment. This is a wrapper around\n * {@link evalBundle} that throws a {@link CommandError} if the bundle cannot be\n * evaluated.\n *\n * @param path - The path to the bundle.\n * @throws If the bundle cannot be evaluated.\n */\nexport async function evaluate(path: string) {\n try {\n return await evalBundle(path);\n } catch (evalError) {\n if (evalError instanceof SnapEvalError) {\n throw new CommandError(\n `Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\\nReceived the following error from the SES environment:\\n\\n${indent(\n red(evalError.output.stderr),\n 2,\n )}`,\n );\n }\n\n // If the error is not a `SnapEvalError`, we don't know what it is, so\n // we just throw it.\n throw evalError;\n }\n}\n"],"names":["evalBundle","SnapEvalError","indent","red","CommandError","evaluate","path","evalError","output","stderr"],"mappings":"AAAA,SAASA,UAAU,EAAEC,aAAa,EAAEC,MAAM,QAAQ,wBAAwB;AAC1E,SAASC,GAAG,QAAQ,QAAQ;AAE5B,SAASC,YAAY,QAAQ,eAAe;AAE5C;;;;;;;CAOC,GACD,OAAO,eAAeC,SAASC,IAAY;IACzC,IAAI;QACF,OAAO,MAAMN,WAAWM;IAC1B,EAAE,OAAOC,WAAW;QAClB,IAAIA,qBAAqBN,eAAe;YACtC,MAAM,IAAIG,aACR,CAAC,kLAAkL,EAAEF,OACnLC,IAAII,UAAUC,MAAM,CAACC,MAAM,GAC3B,GACA,CAAC;QAEP;QAEA,sEAAsE;QACtE,oBAAoB;QACpB,MAAMF;IACR;AACF"}
@@ -1,22 +0,0 @@
1
- import builders from '../../builders';
2
- import { evaluateHandler } from './eval';
3
- const command = {
4
- command: [
5
- 'eval',
6
- 'e'
7
- ],
8
- desc: 'Attempt to evaluate snap bundle in SES',
9
- builder: (yarg)=>{
10
- // Browserify options. These are merged into the config object.
11
- yarg.option('bundle', builders.bundle);
12
- // Webpack options.
13
- yarg.option('input', builders.input);
14
- },
15
- handler: async (argv)=>evaluateHandler(argv.context.config, {
16
- input: argv.input
17
- })
18
- };
19
- export * from './implementation';
20
- export default command;
21
-
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/eval/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { evaluateHandler } from './eval';\n\nconst command = {\n command: ['eval', 'e'],\n desc: 'Attempt to evaluate snap bundle in SES',\n builder: (yarg: yargs.Argv) => {\n // Browserify options. These are merged into the config object.\n yarg.option('bundle', builders.bundle);\n\n // Webpack options.\n yarg.option('input', builders.input);\n },\n handler: async (argv: YargsArgs) =>\n evaluateHandler(argv.context.config, { input: argv.input }),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["builders","evaluateHandler","command","desc","builder","yarg","option","bundle","input","handler","argv","context","config"],"mappings":"AAEA,OAAOA,cAAc,iBAAiB;AAEtC,SAASC,eAAe,QAAQ,SAAS;AAEzC,MAAMC,UAAU;IACdA,SAAS;QAAC;QAAQ;KAAI;IACtBC,MAAM;IACNC,SAAS,CAACC;QACR,+DAA+D;QAC/DA,KAAKC,MAAM,CAAC,UAAUN,SAASO,MAAM;QAErC,mBAAmB;QACnBF,KAAKC,MAAM,CAAC,SAASN,SAASQ,KAAK;IACrC;IACAC,SAAS,OAAOC,OACdT,gBAAgBS,KAAKC,OAAO,CAACC,MAAM,EAAE;YAAEJ,OAAOE,KAAKF,KAAK;QAAC;AAC7D;AAEA,cAAc,mBAAmB;AACjC,eAAeN,QAAQ"}
@@ -1,15 +0,0 @@
1
- import buildCommand from './build';
2
- import evaluateCommand from './eval';
3
- import manifestCommand from './manifest';
4
- import serveCommand from './serve';
5
- import watchCommand from './watch';
6
- const commands = [
7
- buildCommand,
8
- evaluateCommand,
9
- manifestCommand,
10
- serveCommand,
11
- watchCommand
12
- ];
13
- export default commands;
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/commands/index.ts"],"sourcesContent":["import buildCommand from './build';\nimport evaluateCommand from './eval';\nimport manifestCommand from './manifest';\nimport serveCommand from './serve';\nimport watchCommand from './watch';\n\nconst commands = [\n buildCommand,\n evaluateCommand,\n manifestCommand,\n serveCommand,\n watchCommand,\n];\n\nexport default commands;\n"],"names":["buildCommand","evaluateCommand","manifestCommand","serveCommand","watchCommand","commands"],"mappings":"AAAA,OAAOA,kBAAkB,UAAU;AACnC,OAAOC,qBAAqB,SAAS;AACrC,OAAOC,qBAAqB,aAAa;AACzC,OAAOC,kBAAkB,UAAU;AACnC,OAAOC,kBAAkB,UAAU;AAEnC,MAAMC,WAAW;IACfL;IACAC;IACAC;IACAC;IACAC;CACD;AAED,eAAeC,SAAS"}
@@ -1,33 +0,0 @@
1
- import { checkManifest, indent } from '@metamask/snaps-utils';
2
- import { red, yellow } from 'chalk';
3
- import { dirname } from 'path';
4
- import { error, info, warn } from '../../utils';
5
- /**
6
- * Check the snap manifest file at the given path. If `write` is `true`, the
7
- * manifest will be written to disk if it is invalid. If `write` is `false`,
8
- * the manifest will not be written to disk, and the function will log any
9
- * errors and warnings to the console.
10
- *
11
- * @param path - The path to the manifest file.
12
- * @param write - Whether to write the manifest to disk if it is invalid.
13
- * @param spinner - An optional spinner to use for logging.
14
- */ export async function manifest(path, write, spinner) {
15
- const { warnings, errors, updated } = await checkManifest(dirname(path), write);
16
- if (write && updated) {
17
- info('The snap manifest file has been updated.', spinner);
18
- }
19
- if (!write && errors.length > 0) {
20
- const formattedErrors = errors.map((manifestError)=>indent(red(`• ${manifestError}`))).join('\n');
21
- error(`The snap manifest file is invalid.\n\n${formattedErrors}\n\nRun the command with the \`--fix\` flag to attempt to fix the manifest.`, spinner);
22
- spinner?.stop();
23
- process.exitCode = 1;
24
- return false;
25
- }
26
- if (warnings.length > 0) {
27
- const formattedWarnings = warnings.map((manifestWarning)=>indent(yellow(`• ${manifestWarning}`)));
28
- warn(`The snap manifest file has warnings.\n\n${formattedWarnings.join('\n')}`, spinner);
29
- }
30
- return true;
31
- }
32
-
33
- //# sourceMappingURL=implementation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/manifest/implementation.ts"],"sourcesContent":["import { checkManifest, indent } from '@metamask/snaps-utils';\nimport { red, yellow } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param spinner - An optional spinner to use for logging.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n spinner?: Ora,\n): Promise<boolean> {\n const { warnings, errors, updated } = await checkManifest(\n dirname(path),\n write,\n );\n\n if (write && updated) {\n info('The snap manifest file has been updated.', spinner);\n }\n\n if (!write && errors.length > 0) {\n const formattedErrors = errors\n .map((manifestError) => indent(red(`• ${manifestError}`)))\n .join('\\n');\n\n error(\n `The snap manifest file is invalid.\\n\\n${formattedErrors}\\n\\nRun the command with the \\`--fix\\` flag to attempt to fix the manifest.`,\n spinner,\n );\n\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.map((manifestWarning) =>\n indent(yellow(`• ${manifestWarning}`)),\n );\n\n warn(\n `The snap manifest file has warnings.\\n\\n${formattedWarnings.join('\\n')}`,\n spinner,\n );\n }\n\n return true;\n}\n"],"names":["checkManifest","indent","red","yellow","dirname","error","info","warn","manifest","path","write","spinner","warnings","errors","updated","length","formattedErrors","map","manifestError","join","stop","process","exitCode","formattedWarnings","manifestWarning"],"mappings":"AAAA,SAASA,aAAa,EAAEC,MAAM,QAAQ,wBAAwB;AAC9D,SAASC,GAAG,EAAEC,MAAM,QAAQ,QAAQ;AAEpC,SAASC,OAAO,QAAQ,OAAO;AAE/B,SAASC,KAAK,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAEhD;;;;;;;;;CASC,GACD,OAAO,eAAeC,SACpBC,IAAY,EACZC,KAAc,EACdC,OAAa;IAEb,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMd,cAC1CI,QAAQK,OACRC;IAGF,IAAIA,SAASI,SAAS;QACpBR,KAAK,4CAA4CK;IACnD;IAEA,IAAI,CAACD,SAASG,OAAOE,MAAM,GAAG,GAAG;QAC/B,MAAMC,kBAAkBH,OACrBI,GAAG,CAAC,CAACC,gBAAkBjB,OAAOC,IAAI,CAAC,EAAE,EAAEgB,cAAc,CAAC,IACtDC,IAAI,CAAC;QAERd,MACE,CAAC,sCAAsC,EAAEW,gBAAgB,2EAA2E,CAAC,EACrIL;QAGFA,SAASS;QACTC,QAAQC,QAAQ,GAAG;QACnB,OAAO;IACT;IAEA,IAAIV,SAASG,MAAM,GAAG,GAAG;QACvB,MAAMQ,oBAAoBX,SAASK,GAAG,CAAC,CAACO,kBACtCvB,OAAOE,OAAO,CAAC,EAAE,EAAEqB,gBAAgB,CAAC;QAGtCjB,KACE,CAAC,wCAAwC,EAAEgB,kBAAkBJ,IAAI,CAAC,MAAM,CAAC,EACzER;IAEJ;IAEA,OAAO;AACT"}
@@ -1,22 +0,0 @@
1
- import builders from '../../builders';
2
- import { manifestHandler } from './manifest';
3
- const command = {
4
- command: [
5
- 'manifest',
6
- 'm'
7
- ],
8
- desc: 'Validate the snap.manifest.json file',
9
- builder: (yarg)=>{
10
- // Browserify options. These are merged into the config object.
11
- yarg.option('writeManifest', builders.writeManifest);
12
- // Webpack options.
13
- yarg.option('fix', builders.fix);
14
- },
15
- handler: async (argv)=>manifestHandler(argv.context.config, {
16
- fix: argv.fix
17
- })
18
- };
19
- export * from './implementation';
20
- export default command;
21
-
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/manifest/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { manifestHandler } from './manifest';\n\nconst command = {\n command: ['manifest', 'm'],\n desc: 'Validate the snap.manifest.json file',\n builder: (yarg: yargs.Argv) => {\n // Browserify options. These are merged into the config object.\n yarg.option('writeManifest', builders.writeManifest);\n\n // Webpack options.\n yarg.option('fix', builders.fix);\n },\n handler: async (argv: YargsArgs) =>\n manifestHandler(argv.context.config, { fix: argv.fix }),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["builders","manifestHandler","command","desc","builder","yarg","option","writeManifest","fix","handler","argv","context","config"],"mappings":"AAEA,OAAOA,cAAc,iBAAiB;AAEtC,SAASC,eAAe,QAAQ,aAAa;AAE7C,MAAMC,UAAU;IACdA,SAAS;QAAC;QAAY;KAAI;IAC1BC,MAAM;IACNC,SAAS,CAACC;QACR,+DAA+D;QAC/DA,KAAKC,MAAM,CAAC,iBAAiBN,SAASO,aAAa;QAEnD,mBAAmB;QACnBF,KAAKC,MAAM,CAAC,OAAON,SAASQ,GAAG;IACjC;IACAC,SAAS,OAAOC,OACdT,gBAAgBS,KAAKC,OAAO,CAACC,MAAM,EAAE;YAAEJ,KAAKE,KAAKF,GAAG;QAAC;AACzD;AAEA,cAAc,mBAAmB;AACjC,eAAeN,QAAQ"}
@@ -1,52 +0,0 @@
1
- import { isFile } from '@metamask/snaps-utils';
2
- import { CommandError } from '../../errors';
3
- import { executeSteps } from '../../utils';
4
- import { manifest } from './implementation';
5
- const steps = [
6
- {
7
- name: 'Checking the input file.',
8
- task: async ({ input })=>{
9
- if (!await isFile(input)) {
10
- throw new CommandError(`Manifest file not found: "${input}". Make sure that the \`snap.manifest.json\` file exists.`);
11
- }
12
- }
13
- },
14
- {
15
- name: 'Validating the snap manifest.',
16
- task: async ({ input, config, options, spinner })=>{
17
- const write = getWriteManifest(config, options);
18
- const valid = await manifest(input, write, spinner);
19
- if (valid) {
20
- spinner.succeed('The snap manifest file is valid.');
21
- }
22
- }
23
- }
24
- ];
25
- /**
26
- * Get whether to write the manifest to disk.
27
- *
28
- * @param config - The config object.
29
- * @param options - The options object.
30
- * @returns Whether to write the manifest to disk.
31
- */ function getWriteManifest(config, options) {
32
- if (typeof options.fix === 'boolean') {
33
- return options.fix;
34
- }
35
- return config.legacy?.writeManifest ?? false;
36
- }
37
- /**
38
- * Validates a snap.manifest.json file. Attempts to fix the manifest and write
39
- * the fixed version to disk if `writeManifest` is true. Throws if validation
40
- * fails.
41
- *
42
- * @param config - The config object.
43
- * @param options - The options object.
44
- */ export async function manifestHandler(config, options) {
45
- await executeSteps(steps, {
46
- input: config.manifest.path,
47
- config,
48
- options
49
- });
50
- }
51
-
52
- //# sourceMappingURL=manifest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/manifest/manifest.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps } from '../../utils';\nimport { manifest } from './implementation';\n\ntype ManifestOptions = {\n fix?: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n};\n\nconst steps: Steps<ManifestContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n throw new CommandError(\n `Manifest file not found: \"${input}\". Make sure that the \\`snap.manifest.json\\` file exists.`,\n );\n }\n },\n },\n {\n name: 'Validating the snap manifest.',\n task: async ({ input, config, options, spinner }) => {\n const write = getWriteManifest(config, options);\n const valid = await manifest(input, write, spinner);\n\n if (valid) {\n spinner.succeed('The snap manifest file is valid.');\n }\n },\n },\n];\n\n/**\n * Get whether to write the manifest to disk.\n *\n * @param config - The config object.\n * @param options - The options object.\n * @returns Whether to write the manifest to disk.\n */\nfunction getWriteManifest(config: ProcessedConfig, options: ManifestOptions) {\n if (typeof options.fix === 'boolean') {\n return options.fix;\n }\n\n return config.legacy?.writeManifest ?? false;\n}\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function manifestHandler(\n config: ProcessedConfig,\n options: ManifestOptions,\n) {\n await executeSteps(steps, {\n input: config.manifest.path,\n config,\n options,\n });\n}\n"],"names":["isFile","CommandError","executeSteps","manifest","steps","name","task","input","config","options","spinner","write","getWriteManifest","valid","succeed","fix","legacy","writeManifest","manifestHandler","path"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAG/C,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,QAAQ,QAAQ,mBAAmB;AAY5C,MAAMC,QAAgC;IACpC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAE;YACpB,IAAI,CAAE,MAAMP,OAAOO,QAAS;gBAC1B,MAAM,IAAIN,aACR,CAAC,0BAA0B,EAAEM,MAAM,yDAAyD,CAAC;YAEjG;QACF;IACF;IACA;QACEF,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE;YAC9C,MAAMC,QAAQC,iBAAiBJ,QAAQC;YACvC,MAAMI,QAAQ,MAAMV,SAASI,OAAOI,OAAOD;YAE3C,IAAIG,OAAO;gBACTH,QAAQI,OAAO,CAAC;YAClB;QACF;IACF;CACD;AAED;;;;;;CAMC,GACD,SAASF,iBAAiBJ,MAAuB,EAAEC,OAAwB;IACzE,IAAI,OAAOA,QAAQM,GAAG,KAAK,WAAW;QACpC,OAAON,QAAQM,GAAG;IACpB;IAEA,OAAOP,OAAOQ,MAAM,EAAEC,iBAAiB;AACzC;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,gBACpBV,MAAuB,EACvBC,OAAwB;IAExB,MAAMP,aAAaE,OAAO;QACxBG,OAAOC,OAAOL,QAAQ,CAACgB,IAAI;QAC3BX;QACAC;IACF;AACF"}
@@ -1,18 +0,0 @@
1
- import builders from '../../builders';
2
- import { serveHandler } from './serve';
3
- const command = {
4
- command: [
5
- 'serve',
6
- 's'
7
- ],
8
- desc: 'Locally serve Snap file(s) for testing',
9
- builder: (yarg)=>{
10
- yarg.option('root', builders.root).option('port', builders.port);
11
- },
12
- handler: async (argv)=>serveHandler(argv.context.config, {
13
- port: argv.port ?? argv.context.config.server.port
14
- })
15
- };
16
- export default command;
17
-
18
- //# sourceMappingURL=index.js.map