@metamask/snaps-cli 0.32.2 → 0.33.1-flask.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,392 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.33.1-flask.1]
10
+ ### Changed
11
+ - No changes this release.
12
+
13
+ ## [0.33.0-flask.1]
14
+ ### Changed
15
+ - Support ES2022 features ([#1373](https://github.com/MetaMask/snaps-monorepo/pull/1373))
16
+ - Automatically watch `snap.config.js` and `snap.manifest.json` files ([#1358](https://github.com/MetaMask/snaps-monorepo/pull/1358))
17
+
18
+ ## [0.32.2]
19
+ ### Changed
20
+ - No changes this release.
21
+
22
+ ## [0.32.1]
23
+ ### Changed
24
+ - No changes this release.
25
+
26
+ ## [0.32.0]
27
+ ### Changed
28
+ - No changes this release.
29
+
30
+ ## [0.31.0]
31
+ ### Changed
32
+ - **BREAKING:** Target `ES2020` ([#1247](https://github.com/MetaMask/snaps-monorepo/pull/1247))
33
+
34
+ ## [0.30.0]
35
+ ### Changed
36
+ - No changes this release.
37
+
38
+ ## [0.29.0]
39
+ ### Changed
40
+ - **BREAKING:** Change checksum calculation ([#1128](https://github.com/MetaMask/snaps-monorepo/pull/1128))
41
+ - The checksum has changed for all snaps, and needs to be updated
42
+
43
+ ## [0.28.0]
44
+ ### Changed
45
+ - No changes this release.
46
+
47
+ ## [0.27.1]
48
+ ### Changed
49
+ - No changes this release.
50
+
51
+ ## [0.27.0]
52
+ ### Changed
53
+ - No changes this release.
54
+
55
+ ## [0.26.2]
56
+ ### Changed
57
+ - No changes this release.
58
+
59
+ ## [0.26.1]
60
+ ### Changed
61
+ - No changes this release.
62
+
63
+ ## [0.26.0]
64
+ ### Fixed
65
+ - Fix post processing issue with `object.eval` ([#1040](https://github.com/MetaMask/snaps-monorepo/pull/1040))
66
+
67
+ ## [0.25.0]
68
+ ### Changed
69
+ - No changes this release.
70
+
71
+ ## [0.24.1]
72
+ ### Changed
73
+ - No changes this release.
74
+
75
+ ## [0.24.0]
76
+ ### Added
77
+ - Add permission validation to SnapManifest ([#910](https://github.com/MetaMask/snaps-monorepo/pull/910))
78
+
79
+ ### Fixed
80
+ - Remove double logging in CLI ([#958](https://github.com/MetaMask/snaps-monorepo/pull/958))
81
+
82
+ ## [0.23.0]
83
+ ### Changed
84
+ - **BREAKING:** Refactor `mm-snap init` command ([#866](https://github.com/MetaMask/snaps-monorepo/pull/866))
85
+ - `mm-snap init` only takes one optional argument now, a directory for the snap to be initialized in.
86
+ - It uses a new snap monorepo template.
87
+ - Replace auto type guard with struct ([#911](https://github.com/MetaMask/snaps-monorepo/pull/911))
88
+ - Replace JSON schema validation with structs ([#862](https://github.com/MetaMask/snaps-monorepo/pull/862))
89
+
90
+ ## [0.22.3]
91
+ ### Changed
92
+ - No changes this release.
93
+
94
+ ## [0.22.2]
95
+ ### Changed
96
+ - No changes this release.
97
+
98
+ ## [0.22.1]
99
+ ### Changed
100
+ - No changes this release.
101
+
102
+ ## [0.22.0]
103
+ ### Changed
104
+ - No changes this release.
105
+
106
+ ## [0.21.0]
107
+ ### Changed
108
+ - No changes this release.
109
+
110
+ ## [0.20.0]
111
+ ### Changed
112
+ - No changes this release.
113
+
114
+ ## [0.19.1]
115
+ ### Fixed
116
+ - Fixed 0.19.0 not being able to run ([#697](https://github.com/MetaMask/snaps-monorepo/pull/697))
117
+
118
+ ## [0.19.0]
119
+ ### Added
120
+ - Add 'Access-Control-Allow-Origin': * to serve ([#638](https://github.com/MetaMask/snaps-monorepo/pull/638))
121
+
122
+ ### Changed
123
+ - **BREAKING:** Replace RegEx-based bundle processing and comment stripping with an AST-based solution ([#583](https://github.com/MetaMask/snaps-monorepo/pull/583))
124
+
125
+ ## [0.18.1]
126
+ ### Changed
127
+ - No changes this release.
128
+
129
+ ## [0.18.0]
130
+ ### Changed
131
+ - Reduce TypeScript compilation target to ES2017 ([#628](https://github.com/MetaMask/snaps-monorepo/pull/628))
132
+ - Update template files ([#632](https://github.com/MetaMask/snaps-monorepo/pull/632))
133
+
134
+ ## [0.17.0]
135
+ ### Added
136
+ - Add a TypeScript template for `mm-snap init` ([#546](https://github.com/MetaMask/snaps-monorepo/pull/546))
137
+ - Add serving to `mm-snap watch` ([#507](https://github.com/MetaMask/snaps-monorepo/pull/507))
138
+
139
+ ### Changed
140
+ - **BREAKING:** Bump minimum Node version to 16 ([#601](https://github.com/MetaMask/snaps-monorepo/pull/601))
141
+
142
+ ### Fixed
143
+ - Fix segfault when using `mm-snap watch` ([#556](https://github.com/MetaMask/snaps-monorepo/pull/556))
144
+
145
+ ## [0.16.0]
146
+ ### Changed
147
+ - **BREAKING:** Snaps are now required to export `onRpcRequest` to receive RPC requests ([#481](https://github.com/MetaMask/snaps-monorepo/pull/481), [#533](https://github.com/MetaMask/snaps-monorepo/pull/533), [#538](https://github.com/MetaMask/snaps-monorepo/pull/538), [#541](https://github.com/MetaMask/snaps-monorepo/pull/541), [#544](https://github.com/MetaMask/snaps-monorepo/pull/544))
148
+ - The type of the function is available in `@metamask/snaps-types` as `OnRpcRequestHandler`.
149
+
150
+ ### Fixed
151
+ - Fix importing local files in TypeScript Snaps ([#527](https://github.com/MetaMask/snaps-monorepo/pull/527))
152
+ - Fix `build` command when the CLI is installed globally ([#542](https://github.com/MetaMask/snaps-monorepo/pull/542))
153
+
154
+ ## [0.15.0]
155
+ ### Added
156
+ - Add support for building TypeScript Snaps ([#443](https://github.com/MetaMask/snaps-monorepo/pull/443))
157
+
158
+ ### Fixed
159
+ - Fix an issue where comment stripping would break for large files ([#468](https://github.com/MetaMask/snaps-monorepo/pull/468))
160
+
161
+ ## [0.14.0]
162
+ ### Changed
163
+ - **BREAKING:** Increase TypeScript compilation target to ES2020 ([#449](https://github.com/MetaMask/snaps-monorepo/pull/449))
164
+ - This should not be breaking for consumers on any non-deprecated browser or Node.js version.
165
+
166
+ ## [0.13.0]
167
+ ### Changed
168
+ - No changes this release.
169
+
170
+ ## [0.12.0]
171
+ ### Changed
172
+ - No changes this release.
173
+
174
+ ## [0.11.1]
175
+ ### Changed
176
+ - No changes this release.
177
+
178
+ ## [0.11.0]
179
+ ### Added
180
+ - Add self to mock endowments ([#341](https://github.com/MetaMask/snaps-monorepo/pull/341))
181
+
182
+ ### Changed
183
+ - Bump `ses` to `0.15.15` ([#396](https://github.com/MetaMask/snaps-monorepo/pull/396))
184
+ - Upgraded TypeScript version to minimum 4.4 ([#360](https://github.com/MetaMask/snaps-monorepo/pull/360))
185
+ - Update template files ([#350](https://github.com/MetaMask/snaps-monorepo/pull/350))
186
+
187
+ ## [0.10.7]
188
+ ### Changed
189
+ - **BREAKING:** Bump minimum Node version from 12 to 14 ([#331](https://github.com/MetaMask/snaps-monorepo/pull/331))
190
+ - Update `mm-snap init` template files ([#330](https://github.com/MetaMask/snaps-monorepo/pull/330))
191
+
192
+ ### Fixed
193
+ - Fix issue where comment stripping would create invalid bundles ([#336](https://github.com/MetaMask/snaps-monorepo/pull/336))
194
+
195
+ ## [0.10.6]
196
+ ### Fixed
197
+ - Fix endowment mocking during `mm-snap eval` ([#311](https://github.com/MetaMask/snaps-monorepo/pull/311))
198
+
199
+ ## [0.10.5]
200
+ ### Changed
201
+ - No changes this release.
202
+
203
+ ## [0.10.3]
204
+ ### Fixed
205
+ - Improve dynamic mocking ([#262](https://github.com/MetaMask/snaps-monorepo/pull/262))
206
+
207
+ ## [0.10.2]
208
+ ### Fixed
209
+ - Installation failure ([#279](https://github.com/MetaMask/snaps-monorepo/pull/279))
210
+ - A faulty installation script in a dependency caused the installation of this package to fail.
211
+
212
+ ## [0.10.1]
213
+ ### Fixed
214
+ - Comment stripping will no longer remove empty block comments in strings ([#276](https://github.com/MetaMask/snaps-monorepo/pull/276))
215
+
216
+ ## [0.10.0]
217
+ ### Added
218
+ - **BREAKING:** Transform HTML comments by default ([#237](https://github.com/MetaMask/snaps-monorepo/pull/237))
219
+ - The strings `<!--` and `-->` will be transformed into `< !--` and `-- >` respectively by default. If these strings appear as operands in an expression or in a string literal, this transform will change the behavior of your program. This behavior was added because these strings are rejected by SES. The behavior can be toggled using the `--transformHtmlComments` option.
220
+ - `--transpiledDeps` flag to `build` and `watch` commands ([#221](https://github.com/MetaMask/snaps-monorepo/pull/221))
221
+ - This flag allows the user to specify which dependencies will be transpiled at build time if the `--transpilationMode` is `--localAndDeps`.
222
+ - Add CLI usage instructions to readme ([#228](https://github.com/MetaMask/snaps-monorepo/pull/228))
223
+ - Build process customization ([#251](https://github.com/MetaMask/snaps-monorepo/pull/251))
224
+ - Builds can now be customized by adding a `bundlerCustomizer` function to `snap.config.js`. See the README for details.
225
+
226
+ ### Changed
227
+ - **BREAKING:** Change Snap config file format ([#251](https://github.com/MetaMask/snaps-monorepo/pull/251))
228
+ - The CLI now expects a file `snap.config.js` instead of `snap.config.json`, with a different structure. See the README for details.
229
+ - **BREAKING:** Strip comments in source code by default ([#243](https://github.com/MetaMask/snaps-monorepo/pull/243))
230
+ - All comments will now be stripped from snap source code (including dependencies) by default.
231
+ - Enable `--verboseErrors` by default ([#249](https://github.com/MetaMask/snaps-monorepo/pull/249))
232
+
233
+ ### Fixed
234
+ - Comment stripping bug ([#270](https://github.com/MetaMask/snaps-monorepo/pull/270))
235
+ - Prior to this change, if the `--strip-comments` option was provided to `mm-snap build` and an empty block comment of the form `/**/` appeared anywhere in the source code (including dependencies), the remainder of the string after the empty block comment would be truncated. This was resolved by removing all instances of the string `/**/` from the raw bundle string.
236
+ - In an upcoming release, the string `/**/` will only be removed if it is in fact an empty block comment, and not if it e.g. appears in a string literal.
237
+ - `watch` command parity with `build` command ([#241](https://github.com/MetaMask/snaps-monorepo/pull/241))
238
+ - The `build` command had received a number of options that were not made available to the `watch` command. They now have the same options.
239
+ - Update dead link in readme ([#240](https://github.com/MetaMask/snaps-monorepo/pull/240))
240
+
241
+ ## [0.9.0]
242
+ ### Added
243
+ - Transpilation configuration ([#213](https://github.com/MetaMask/snaps-monorepo/pull/213))
244
+ - `mm-snap build` now takes a `--transpilationMode` argument which determines what will be transpiled by Babel during building: all source code (including dependencies), local source code only, or nothing.
245
+
246
+ ### Fixed
247
+ - `mm-snap build` command when CLI is installed globally ([#216](https://github.com/MetaMask/snaps-monorepo/pull/216))
248
+ - Update installation command in readme ([#205](https://github.com/MetaMask/snaps-monorepo/pull/205))
249
+
250
+ ## [0.8.0]
251
+ ### Changed
252
+ - Update template snap created by `mm-snap init` ([#195](https://github.com/MetaMask/snaps-monorepo/pull/195))
253
+ - Exit by throwing errors instead of calling `process.exit` ([#190](https://github.com/MetaMask/snaps-monorepo/pull/190))
254
+
255
+ ## [0.7.0]
256
+ ### Added
257
+ - ESM support for `mm-snap build` ([#185](https://github.com/MetaMask/snaps-monorepo/pull/185))
258
+ - The `build` command can now handle snap source code that includes ESM import / export statements. They will be transpiled to their CommonJS equivalents via Babel.
259
+
260
+ ### Fixed
261
+ - Fix `mm-snap init` `src` default value ([#186](https://github.com/MetaMask/snaps-monorepo/pull/186))
262
+ - It now correctly defaults to `src/index.js` instead of just `index.js`.
263
+ - Fix comment stripping ([#189](https://github.com/MetaMask/snaps-monorepo/pull/189))
264
+ - Comments wouldn't be stripped under certain circumstances due to a RegEx error, details [here](https://github.com/jonschlinkert/strip-comments/pull/49).
265
+
266
+ ## [0.6.3]
267
+ ### Changed
268
+ - No changes this release.
269
+
270
+ ## [0.6.2]
271
+ ### Changed
272
+ - No changes this release.
273
+
274
+ ## [0.6.1]
275
+ ### Fixed
276
+ - `mm-snap init` Snap `snap_confirm` call ([#168](https://github.com/MetaMask/snaps-monorepo/pull/168))
277
+ - The generated Snap was passing invalid parameters to the method.
278
+
279
+ ## [0.6.0]
280
+ ### Added
281
+ - Snap SVG icon support ([#163](https://github.com/MetaMask/snaps-monorepo/pull/163))
282
+
283
+ ### Changed
284
+ - **BREAKING:** Support the new Snaps publishing specification ([#140](https://github.com/MetaMask/snaps-monorepo/pull/140), [#160](https://github.com/MetaMask/snaps-monorepo/pull/160))
285
+ - This introduces several breaking changes to how Snaps are developed, hosted, and represented at runtime. See [the specification](https://github.com/MetaMask/specifications/blob/d4a5bf5d6990bb5b02a98bd3f95a24ffb28c701c/snaps/publishing.md) and the referenced pull requests for details.
286
+ - **BREAKING:** Rename Snap `name` property to `id` ([#147](https://github.com/MetaMask/snaps-monorepo/pull/147))
287
+ - **BREAKING:** Update `ses` to version `^0.15.3` ([#159](https://github.com/MetaMask/snaps-monorepo/pull/159))
288
+ - This will cause behavioral changes for code executed under SES, and may require modifications to code that previously executed without issues.
289
+
290
+ ## [0.5.0]
291
+ ### Changed
292
+ - **BREAKING:** Convert all TypeScript `interface` declarations to `type` equivalents ([#143](https://github.com/MetaMask/snaps-monorepo/pull/143))
293
+
294
+ ## [0.4.0]
295
+ ### Fixed
296
+ - Make Windows-compatible ([#131](https://github.com/MetaMask/snaps-monorepo/pull/131))
297
+
298
+ ## [0.3.1]
299
+ ### Changed
300
+ - No changes this release.
301
+
302
+ ## [0.3.0]
303
+ ### Changed
304
+ - **BREAKING:** Enforce consistent naming for Snaps-related functionality ([#119](https://github.com/MetaMask/snaps-monorepo/pull/119))
305
+
306
+ ## [0.2.2]
307
+ ### Fixed
308
+ - Package script issues ([#97](https://github.com/MetaMask/snaps-monorepo/pull/97), [#98](https://github.com/MetaMask/snaps-monorepo/pull/98))
309
+
310
+ ## [0.2.1]
311
+ ### Fixed
312
+ - Snap produced by `mm-snap init` ([#94](https://github.com/MetaMask/snaps-monorepo/pull/94))
313
+ - The template used to create the "Hello, world!" snap had become outdated due to a build-time bug.
314
+
315
+ ## [0.2.0]
316
+ ### Changed
317
+ - Update publish scripts ([#92](https://github.com/MetaMask/snaps-monorepo/pull/92))
318
+
319
+ ## [0.1.1]
320
+ ### Added
321
+ - Missing publish scripts to new packages
322
+
323
+ ## [0.1.0]
324
+ ### Changed
325
+ - **BREAKING:** Rename package to `@metamask/snaps-cli` ([#72](https://github.com/MetaMask/snaps-monorepo/pull/72))
326
+ - This package was previously named [`snaps-cli`](https://npmjs.com/package/snaps-cli).
327
+ - As part of the renaming, and due to the scope of the changes to both this package and MetaMask Snaps generally, its versioning and changelog have been reset. The original changelog can be found [here](https://github.com/MetaMask/snaps-cli/blob/main/CHANGELOG.md).
328
+
329
+ ### Removed
330
+ - Example snaps ([#72](https://github.com/MetaMask/snaps-monorepo/pull/72))
331
+ - The examples now live in their own package, [`@metamask/snap-examples`](https://npmjs.com/package/@metamask/snap-examples).
332
+
333
+ [Unreleased]: https://github.com/MetaMask/snaps-monorepo/compare/v0.33.1-flask.1...HEAD
334
+ [0.33.1-flask.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.33.0-flask.1...v0.33.1-flask.1
335
+ [0.33.0-flask.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.32.2...v0.33.0-flask.1
336
+ [0.32.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.32.1...v0.32.2
337
+ [0.32.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.32.0...v0.32.1
338
+ [0.32.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.31.0...v0.32.0
339
+ [0.31.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.30.0...v0.31.0
340
+ [0.30.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.29.0...v0.30.0
341
+ [0.29.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.28.0...v0.29.0
342
+ [0.28.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.27.1...v0.28.0
343
+ [0.27.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.27.0...v0.27.1
344
+ [0.27.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.26.2...v0.27.0
345
+ [0.26.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.26.1...v0.26.2
346
+ [0.26.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.26.0...v0.26.1
347
+ [0.26.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.25.0...v0.26.0
348
+ [0.25.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.24.1...v0.25.0
349
+ [0.24.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.24.0...v0.24.1
350
+ [0.24.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.23.0...v0.24.0
351
+ [0.23.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.22.3...v0.23.0
352
+ [0.22.3]: https://github.com/MetaMask/snaps-monorepo/compare/v0.22.2...v0.22.3
353
+ [0.22.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.22.1...v0.22.2
354
+ [0.22.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.22.0...v0.22.1
355
+ [0.22.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.21.0...v0.22.0
356
+ [0.21.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.20.0...v0.21.0
357
+ [0.20.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.19.1...v0.20.0
358
+ [0.19.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.19.0...v0.19.1
359
+ [0.19.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.18.1...v0.19.0
360
+ [0.18.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.18.0...v0.18.1
361
+ [0.18.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.17.0...v0.18.0
362
+ [0.17.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.16.0...v0.17.0
363
+ [0.16.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.15.0...v0.16.0
364
+ [0.15.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.14.0...v0.15.0
365
+ [0.14.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.13.0...v0.14.0
366
+ [0.13.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.12.0...v0.13.0
367
+ [0.12.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.11.1...v0.12.0
368
+ [0.11.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.11.0...v0.11.1
369
+ [0.11.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.7...v0.11.0
370
+ [0.10.7]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.6...v0.10.7
371
+ [0.10.6]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.5...v0.10.6
372
+ [0.10.5]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.3...v0.10.5
373
+ [0.10.3]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.2...v0.10.3
374
+ [0.10.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.1...v0.10.2
375
+ [0.10.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.10.0...v0.10.1
376
+ [0.10.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.9.0...v0.10.0
377
+ [0.9.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.8.0...v0.9.0
378
+ [0.8.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.7.0...v0.8.0
379
+ [0.7.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.6.3...v0.7.0
380
+ [0.6.3]: https://github.com/MetaMask/snaps-monorepo/compare/v0.6.2...v0.6.3
381
+ [0.6.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.6.1...v0.6.2
382
+ [0.6.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.6.0...v0.6.1
383
+ [0.6.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.5.0...v0.6.0
384
+ [0.5.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.4.0...v0.5.0
385
+ [0.4.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.3.1...v0.4.0
386
+ [0.3.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.3.0...v0.3.1
387
+ [0.3.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.2.2...v0.3.0
388
+ [0.2.2]: https://github.com/MetaMask/snaps-monorepo/compare/v0.2.1...v0.2.2
389
+ [0.2.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.2.0...v0.2.1
390
+ [0.2.0]: https://github.com/MetaMask/snaps-monorepo/compare/v0.1.1...v0.2.0
391
+ [0.1.1]: https://github.com/MetaMask/snaps-monorepo/compare/v0.1.0...v0.1.1
392
+ [0.1.0]: https://github.com/MetaMask/snaps-monorepo/releases/tag/v0.1.0
package/dist/cli.js CHANGED
@@ -16,7 +16,7 @@ const utils_1 = require("./utils");
16
16
  */
17
17
  function cli(argv, commands) {
18
18
  const rawArgv = argv.slice(2);
19
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-floating-promises
20
20
  (0, yargs_1.default)(rawArgv)
21
21
  .scriptName('mm-snap')
22
22
  .usage('Usage: $0 <command> [options]')
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyC;AAGzC,0DAAkC;AAClC,mCAMiB;AAEjB;;;;;;GAMG;AACH,SAAgB,GAAG,CAAC,IAAc,EAAE,QAAa;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9B,oEAAoE;IACpE,IAAA,eAAK,EAAC,OAAO,CAAC;SACX,UAAU,CAAC,SAAS,CAAC;SACrB,KAAK,CAAC,+BAA+B,CAAC;SAEtC,OAAO,CAAC,SAAS,EAAE,sDAAsD,CAAC;SAC1E,OAAO,CACN,iBAAiB,EACjB,wDAAwD,CACzD;SACA,OAAO,CACN,iCAAiC,EACjC,6CAA6C,CAC9C;SACA,OAAO,CACN,4CAA4C,EAC5C,2CAA2C,CAC5C;SACA,OAAO,CAAC,iBAAiB,EAAE,uCAAuC,CAAC;SACnE,OAAO,CAAC,yBAAyB,EAAE,uCAAuC,CAAC;SAC3E,OAAO,CACN,iCAAiC,EACjC,gGAAgG,CACjG;SAEA,OAAO,CAAC,QAAQ,CAAC;SAEjB,MAAM,CAAC,eAAe,EAAE,kBAAQ,CAAC,aAAa,CAAC;SAE/C,MAAM,CAAC,kBAAkB,EAAE,kBAAQ,CAAC,gBAAgB,CAAC;SAErD,MAAM,EAAE;QAET,gEAAgE;QAChE,+EAA+E;QAC/E,0FAA0F;SACzF,UAAU,CACT,CAAC,CAAC,SAAoB,EAAE,aAA+B,EAAE,EAAE;QACzD,IAAA,mBAAW,EAAC,IAAA,kBAAU,GAAE,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAC7D,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC;QAC1B,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAQ,EACT,IAAI,CACL;SAEA,IAAI,CAAC,CAAC,OAAe,EAAE,KAAY,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAA,gBAAQ,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC;SAED,aAAa,CAAC,CAAC,EAAE,wCAAwC,CAAC;SAE1D,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;AAC7B,CAAC;AAxDD,kBAwDC","sourcesContent":["import yargs, { Arguments } from 'yargs';\nimport yargsType from 'yargs/yargs';\n\nimport builders from './builders';\nimport {\n applyConfig,\n loadConfig,\n sanitizeInputs,\n setSnapGlobals,\n logError,\n} from './utils';\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport function cli(argv: string[], commands: any): void {\n const rawArgv = argv.slice(2);\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs(rawArgv)\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 init', `\\tInitialize a snap project in the current directory`)\n .example(\n '$0 init my-snap',\n `\\tInitialize a snap project in the 'my-snap' directory`,\n )\n .example(\n '$0 build -s src/index.js -d out',\n `\\tBuild 'src/index.js' as './out/bundle.js'`,\n )\n .example(\n '$0 build -s src/index.js -d out -n snap.js',\n `\\tBuild 'src/index.js' as './out/snap.js'`,\n )\n .example('$0 serve -r out', `\\tServe files in './out' on port 8080`)\n .example('$0 serve -r out -p 9000', `\\tServe files in './out' on port 9000`)\n .example(\n '$0 watch -s src/index.js -d out',\n `\\tRebuild './out/bundle.js' on changes to files in 'src/index.js' parent and child directories`,\n )\n\n .command(commands)\n\n .option('verboseErrors', builders.verboseErrors)\n\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n // Typecast: The @types/yargs type for .middleware is incorrect.\n // yargs middleware functions receive the yargs instance as a second parameter.\n // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation\n .middleware(\n ((yargsArgv: Arguments, yargsInstance: typeof yargsType) => {\n applyConfig(loadConfig(), rawArgv, yargsArgv, yargsInstance);\n setSnapGlobals(yargsArgv);\n sanitizeInputs(yargsArgv);\n }) as any,\n true,\n )\n\n .fail((message: string, error: Error, _yargs) => {\n logError(message, error);\n process.exitCode = 1;\n })\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .help()\n .alias('help', 'h').argv;\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyC;AAGzC,0DAAkC;AAClC,mCAMiB;AAEjB;;;;;;GAMG;AACH,SAAgB,GAAG,CAAC,IAAc,EAAE,QAAa;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9B,6GAA6G;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AC;AAxDD,kBAwDC","sourcesContent":["import yargs, { Arguments } from 'yargs';\nimport yargsType from 'yargs/yargs';\n\nimport builders from './builders';\nimport {\n applyConfig,\n loadConfig,\n sanitizeInputs,\n setSnapGlobals,\n logError,\n} from './utils';\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport function cli(argv: string[], commands: any): void {\n const rawArgv = argv.slice(2);\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-floating-promises\n yargs(rawArgv)\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 init', `\\tInitialize a snap project in the current directory`)\n .example(\n '$0 init my-snap',\n `\\tInitialize a snap project in the 'my-snap' directory`,\n )\n .example(\n '$0 build -s src/index.js -d out',\n `\\tBuild 'src/index.js' as './out/bundle.js'`,\n )\n .example(\n '$0 build -s src/index.js -d out -n snap.js',\n `\\tBuild 'src/index.js' as './out/snap.js'`,\n )\n .example('$0 serve -r out', `\\tServe files in './out' on port 8080`)\n .example('$0 serve -r out -p 9000', `\\tServe files in './out' on port 9000`)\n .example(\n '$0 watch -s src/index.js -d out',\n `\\tRebuild './out/bundle.js' on changes to files in 'src/index.js' parent and child directories`,\n )\n\n .command(commands)\n\n .option('verboseErrors', builders.verboseErrors)\n\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n // Typecast: The @types/yargs type for .middleware is incorrect.\n // yargs middleware functions receive the yargs instance as a second parameter.\n // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation\n .middleware(\n ((yargsArgv: Arguments, yargsInstance: typeof yargsType) => {\n applyConfig(loadConfig(), rawArgv, yargsArgv, yargsInstance);\n setSnapGlobals(yargsArgv);\n sanitizeInputs(yargsArgv);\n }) as any,\n true,\n )\n\n .fail((message: string, error: Error, _yargs) => {\n logError(message, error);\n process.exitCode = 1;\n })\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .help()\n .alias('help', 'h').argv;\n}\n"]}
@@ -43,7 +43,7 @@ async function bundle(src, dest, argv, bundlerTransform) {
43
43
  require('@babel/preset-env'),
44
44
  {
45
45
  targets: {
46
- browsers: ['chrome >= 66', 'firefox >= 68'],
46
+ browsers: ['chrome >= 90', 'firefox >= 91'],
47
47
  },
48
48
  },
49
49
  ],
@@ -51,9 +51,9 @@ async function bundle(src, dest, argv, bundlerTransform) {
51
51
  plugins: [
52
52
  require('@babel/plugin-transform-runtime'),
53
53
  require('@babel/plugin-proposal-class-properties'),
54
- require('@babel/plugin-proposal-object-rest-spread'),
55
- require('@babel/plugin-proposal-optional-chaining'),
56
- require('@babel/plugin-proposal-nullish-coalescing-operator'),
54
+ require('@babel/plugin-proposal-private-methods'),
55
+ require('@babel/plugin-proposal-class-static-block'),
56
+ require('@babel/plugin-proposal-private-property-in-object'),
57
57
  ],
58
58
  parserOpts: {
59
59
  attachComment: !argv.stripComments,
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/cmds/build/bundle.ts"],"names":[],"mappings":";;;;;;AAAA,gGAAoE;AACpE,4DAA0D;AAE1D,6CAAoD;AAEpD,mCAA+D;AAE/D,+EAA+E;AAC/E,mEAAmE;AACnE,mHAAmH;AAEnH;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,MAAM,CAC1B,GAAW,EACX,IAAY,EACZ,IAAe,EACf,gBAAsD;IAEtD,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IACtD,MAAM,eAAe,GAAG,IAAA,2BAAmB,EAAC,IAAW,CAAC,CAAC;IACzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,GAAG,EAAE;YAC9B,KAAK;YACL,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CA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metamask/snaps-browserify-plugin';\nimport browserify, { BrowserifyObject } from 'browserify';\n\nimport { TranspilationModes } from '../../builders';\nimport { YargsArgs } from '../../types/yargs';\nimport { processDependencies, writeBundleFile } from './utils';\n\n// We need to statically import all Browserify transforms and all Babel presets\n// and plugins, and calling `require` is the sanest way to do that.\n/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, node/global-require */\n\n/**\n * Builds a Snap bundle JS file from its JavaScript source.\n *\n * @param src - The source file path.\n * @param dest - The destination file path.\n * @param argv - Arguments as an object generated by `yargs`.\n * @param argv.sourceMaps - Whether to output sourcemaps.\n * @param argv.stripComments - Whether to remove comments from code.\n * @param argv.transpilationMode - The Babel transpilation mode.\n * @param bundlerTransform - An optional function which can be used to transform\n * the Browserify instance, e.g., adding a custom transform or plugin.\n */\nexport async function bundle(\n src: string,\n dest: string,\n argv: YargsArgs,\n bundlerTransform?: (bundler: BrowserifyObject) => void,\n): Promise<boolean> {\n const { sourceMaps: debug, transpilationMode } = argv;\n const babelifyOptions = processDependencies(argv as any);\n return new Promise((resolve, _reject) => {\n const bundler = browserify(src, {\n debug,\n extensions: ['.js', '.ts'],\n // Standalone is required to properly support Snaps using module.exports\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: ['chrome >= 66', 'firefox >= 68'],\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-proposal-class-properties'),\n require('@babel/plugin-proposal-object-rest-spread'),\n require('@babel/plugin-proposal-optional-chaining'),\n require('@babel/plugin-proposal-nullish-coalescing-operator'),\n ],\n parserOpts: {\n attachComment: !argv.stripComments,\n },\n ...(babelifyOptions as any),\n });\n }\n\n bundlerTransform?.(bundler);\n\n bundler.plugin<Options>(plugin, {\n stripComments: argv.stripComments,\n manifestPath: undefined,\n eval: false,\n });\n\n bundler.bundle(\n async (bundleError, bundleBuffer: Buffer) =>\n await writeBundleFile({\n bundleError,\n bundleBuffer,\n src,\n dest,\n resolve,\n }),\n );\n });\n}\n"]}
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/cmds/build/bundle.ts"],"names":[],"mappings":";;;;;;AAAA,gGAAoE;AACpE,4DAA0D;AAE1D,6CAAoD;AAEpD,mCAA+D;AAE/D,+EAA+E;AAC/E,mEAAmE;AACnE,mHAAmH;AAEnH;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,MAAM,CAC1B,GAAW,EACX,IAAY,EACZ,IAAe,EACf,gBAAsD;IAEtD,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IACtD,MAAM,eAAe,GAAG,IAAA,2BAAmB,EAAC,IAAW,CAAC,CAAC;IACzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,GAAG,EAAE;YAC9B,KAAK;YACL,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;YAC1B,wEAAwE;YACxE,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;QAEH,IAAI,iBAAiB,KAAK,6BAAkB,CAAC,IAAI,EAAE;YACjD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;gBACrC,MAAM,EAAE,iBAAiB,KAAK,6BAAkB,CAAC,YAAY;gBAC7D,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC1B,OAAO,EAAE;oBACP,OAAO,CAAC,0BAA0B,CAAC;oBACnC;wBACE,OAAO,CAAC,mBAAmB,CAAC;wBAC5B;4BACE,OAAO,EAAE;gCACP,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;6BAC5C;yBACF;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,OAAO,CAAC,iCAAiC,CAAC;oBAC1C,OAAO,CAAC,yCAAyC,CAAC;oBAClD,OAAO,CAAC,wCAAwC,CAAC;oBACjD,OAAO,CAAC,2CAA2C,CAAC;oBACpD,OAAO,CAAC,mDAAmD,CAAC;iBAC7D;gBACD,UAAU,EAAE;oBACV,aAAa,EAAE,CAAC,IAAI,CAAC,aAAa;iBACnC;gBACD,GAAI,eAAuB;aAC5B,CAAC,CAAC;SACJ;QAED,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC;QAE5B,OAAO,CAAC,MAAM,CAAU,iCAAM,EAAE;YAC9B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CACZ,KAAK,EAAE,WAAW,EAAE,YAAoB,EAAE,EAAE,CAC1C,MAAM,IAAA,uBAAe,EAAC;YACpB,WAAW;YACX,YAAY;YACZ,GAAG;YACH,IAAI;YACJ,OAAO;SACR,CAAC,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAhED,wBAgEC","sourcesContent":["import plugin, { Options } from '@metamask/snaps-browserify-plugin';\nimport browserify, { BrowserifyObject } from 'browserify';\n\nimport { TranspilationModes } from '../../builders';\nimport { YargsArgs } from '../../types/yargs';\nimport { processDependencies, writeBundleFile } from './utils';\n\n// We need to statically import all Browserify transforms and all Babel presets\n// and plugins, and calling `require` is the sanest way to do that.\n/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, node/global-require */\n\n/**\n * Builds a Snap bundle JS file from its JavaScript source.\n *\n * @param src - The source file path.\n * @param dest - The destination file path.\n * @param argv - Arguments as an object generated by `yargs`.\n * @param argv.sourceMaps - Whether to output sourcemaps.\n * @param argv.stripComments - Whether to remove comments from code.\n * @param argv.transpilationMode - The Babel transpilation mode.\n * @param bundlerTransform - An optional function which can be used to transform\n * the Browserify instance, e.g., adding a custom transform or plugin.\n */\nexport async function bundle(\n src: string,\n dest: string,\n argv: YargsArgs,\n bundlerTransform?: (bundler: BrowserifyObject) => void,\n): Promise<boolean> {\n const { sourceMaps: debug, transpilationMode } = argv;\n const babelifyOptions = processDependencies(argv as any);\n return new Promise((resolve, _reject) => {\n const bundler = browserify(src, {\n debug,\n extensions: ['.js', '.ts'],\n // Standalone is required to properly support Snaps using module.exports\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: ['chrome >= 90', 'firefox >= 91'],\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-proposal-class-properties'),\n require('@babel/plugin-proposal-private-methods'),\n require('@babel/plugin-proposal-class-static-block'),\n require('@babel/plugin-proposal-private-property-in-object'),\n ],\n parserOpts: {\n attachComment: !argv.stripComments,\n },\n ...(babelifyOptions as any),\n });\n }\n\n bundlerTransform?.(bundler);\n\n bundler.plugin<Options>(plugin, {\n stripComments: argv.stripComments,\n manifestPath: undefined,\n eval: false,\n });\n\n bundler.bundle(\n async (bundleError, bundleBuffer: Buffer) =>\n await writeBundleFile({\n bundleError,\n bundleBuffer,\n src,\n dest,\n resolve,\n }),\n );\n });\n}\n"]}
@@ -31,7 +31,7 @@ async function initHandler(argv) {
31
31
  throw new Error(`Init Error: git is not installed. Please install git to continue.`);
32
32
  }
33
33
  const directoryToUse = directory
34
- ? path_1.default.join(process.cwd(), directory)
34
+ ? path_1.default.resolve(process.cwd(), directory)
35
35
  : process.cwd();
36
36
  (0, snaps_utils_1.logInfo)(`Preparing ${directoryToUse}...`);
37
37
  await (0, initUtils_1.prepareWorkingDirectory)(directoryToUse);
@@ -1 +1 @@
1
- {"version":3,"file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,wCAAwC,CAAC,CAAC;KAC3D;IAED,IAAA,qBAAO,EAAC,4BAA4B,CAAC,CAAC;IACtC,IAAA,uBAAW,EAAC,cAAc,CAAC,CAAC;IAE5B,IAAI,CAAC,IAAA,6BAAiB,EAAC,cAAc,CAAC,EAAE;QACtC,IAAA,qBAAO,EAAC,gCAAgC,CAAC,CAAC;QAC1C,IAAA,mBAAO,EAAC,cAAc,CAAC,CAAC;KACzB;IAED,MAAM,YAAY,GAAG,cAAS,CAAC,IAAI,CAAC,cAAc,EAAE,yBAAa,CAAC,CAAC;IAEnE,MAAM,QAAQ,GAAG,CACf,MAAM,IAAA,0BAAY,EAAC,cAAS,CAAC,IAAI,CAAC,YAAY,EAAE,8BAAgB,CAAC,QAAQ,CAAC,CAAC,CAC5E,CAAC,MAAM,CAAC;IAET,MAAM,iBAAiB,GAAG,IAAA,gCAAkB,EAAC,QAAQ,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,CAClB,MAAM,IAAA,0BAAY,EAChB,cAAS,CAAC,IAAI,CAAC,YAAY,EAAE,8BAAgB,CAAC,WAAW,CAAC,CAC3D,CACF,CAAC,MAA4B,CAAC;IAE/B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3E,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QACjB,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;QACxB,GAAG,EAAE,WAAW,CAAC,IAAI,IAAI,cAAc;QACvC,YAAY;KACb,CAAC;AACJ,CAAC;AAxED,kCAwEC","sourcesContent":["import {\n NpmSnapFileNames,\n readJsonFile,\n NpmSnapPackageJson,\n createSnapManifest,\n logInfo,\n} from '@metamask/snaps-utils';\nimport {\n satisfiesVersionRange,\n SemVerRange,\n SemVerVersion,\n} from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nimport { YargsArgs } from '../../types/yargs';\nimport {\n cloneTemplate,\n gitInit,\n isGitInstalled,\n isInGitRepository,\n prepareWorkingDirectory,\n SNAP_LOCATION,\n yarnInstall,\n} from './initUtils';\n\nconst SATISFIED_VERSION = '>=16' as SemVerRange;\n\n/**\n * Creates a new snap package, based on one of the provided templates. This\n * creates all the necessary files, like `package.json`, `snap.config.js`, etc.\n * to start developing a snap.\n *\n * @param argv - The Yargs arguments object.\n * @returns The Yargs arguments augmented with the new `dist`, `outfileName` and\n * `src` properties.\n * @throws If initialization of the snap package failed.\n */\nexport async function initHandler(argv: YargsArgs) {\n const { directory } = argv;\n\n const isVersionSupported = satisfiesVersionRange(\n process.version as SemVerVersion,\n SATISFIED_VERSION,\n );\n\n if (!isVersionSupported) {\n throw new Error(\n `Init Error: You are using an outdated version of Node (${process.version}). Please update to Node ${SATISFIED_VERSION}.`,\n );\n }\n\n const gitExists = isGitInstalled();\n if (!gitExists) {\n throw new Error(\n `Init Error: git is not installed. Please install git to continue.`,\n );\n }\n\n const directoryToUse = directory\n ? pathUtils.join(process.cwd(), directory)\n : process.cwd();\n\n logInfo(`Preparing ${directoryToUse}...`);\n\n await prepareWorkingDirectory(directoryToUse);\n\n try {\n logInfo(`Cloning template...`);\n cloneTemplate(directoryToUse);\n\n await fs.rm(pathUtils.join(directoryToUse, '.git'), {\n force: true,\n recursive: true,\n });\n } catch (error) {\n throw new Error('Init Error: Failed to create template.');\n }\n\n logInfo('Installing dependencies...');\n yarnInstall(directoryToUse);\n\n if (!isInGitRepository(directoryToUse)) {\n logInfo('Initializing git repository...');\n gitInit(directoryToUse);\n }\n\n const snapLocation = pathUtils.join(directoryToUse, SNAP_LOCATION);\n\n const manifest = (\n await readJsonFile(pathUtils.join(snapLocation, NpmSnapFileNames.Manifest))\n ).result;\n\n const validatedManifest = createSnapManifest(manifest);\n\n const packageJson = (\n await readJsonFile(\n pathUtils.join(snapLocation, NpmSnapFileNames.PackageJson),\n )\n ).result as NpmSnapPackageJson;\n\n const distPath = validatedManifest.source.location.npm.filePath.split('/');\n\n return {\n ...argv,\n dist: distPath[0],\n outfileName: distPath[1],\n src: packageJson.main || 'src/index.js',\n snapLocation,\n };\n}\n"]}
1
+ {"version":3,"file":"initHandler.js","sourceRoot":"","sources":["../../../src/cmds/init/initHandler.ts"],"names":[],"mappings":";;;;;;AAAA,uDAM+B;AAC/B,2CAIyB;AACzB,2BAAoC;AACpC,gDAA6B;AAG7B,2CAQqB;AAErB,MAAM,iBAAiB,GAAG,MAAqB,CAAC;AAEhD;;;;;;;;;GASG;AACI,KAAK,UAAU,WAAW,CAAC,IAAe;IAC/C,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAE3B,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,EAC9C,OAAO,CAAC,OAAwB,EAChC,iBAAiB,CAClB,CAAC;IAEF,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAI,KAAK,CACb,0DAA0D,OAAO,CAAC,OAAO,4BAA4B,iBAAiB,GAAG,CAC1H,CAAC;KACH;IAED,MAAM,SAAS,GAAG,IAAA,0BAAc,GAAE,CAAC;IACnC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;KACH;IAED,MAAM,cAAc,GAAG,SAAS;QAC9B,CAAC,CAAC,cAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC;QAC7C,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAElB,IAAA,qBAAO,EAAC,aAAa,cAAc,KAAK,CAAC,CAAC;IAE1C,MAAM,IAAA,mCAAuB,EAAC,cAAc,CAAC,CAAC;IAE9C,IAAI;QACF,IAAA,qBAAO,EAAC,qBAAqB,CAAC,CAAC;QAC/B,IAAA,yBAAa,EAAC,cAAc,CAAC,CAAC;QAE9B,MAAM,aAAE,CAAC,EAAE,CAAC,cAAS,CAAC,IA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napFileNames,\n readJsonFile,\n NpmSnapPackageJson,\n createSnapManifest,\n logInfo,\n} from '@metamask/snaps-utils';\nimport {\n satisfiesVersionRange,\n SemVerRange,\n SemVerVersion,\n} from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nimport { YargsArgs } from '../../types/yargs';\nimport {\n cloneTemplate,\n gitInit,\n isGitInstalled,\n isInGitRepository,\n prepareWorkingDirectory,\n SNAP_LOCATION,\n yarnInstall,\n} from './initUtils';\n\nconst SATISFIED_VERSION = '>=16' as SemVerRange;\n\n/**\n * Creates a new snap package, based on one of the provided templates. This\n * creates all the necessary files, like `package.json`, `snap.config.js`, etc.\n * to start developing a snap.\n *\n * @param argv - The Yargs arguments object.\n * @returns The Yargs arguments augmented with the new `dist`, `outfileName` and\n * `src` properties.\n * @throws If initialization of the snap package failed.\n */\nexport async function initHandler(argv: YargsArgs) {\n const { directory } = argv;\n\n const isVersionSupported = satisfiesVersionRange(\n process.version as SemVerVersion,\n SATISFIED_VERSION,\n );\n\n if (!isVersionSupported) {\n throw new Error(\n `Init Error: You are using an outdated version of Node (${process.version}). Please update to Node ${SATISFIED_VERSION}.`,\n );\n }\n\n const gitExists = isGitInstalled();\n if (!gitExists) {\n throw new Error(\n `Init Error: git is not installed. Please install git to continue.`,\n );\n }\n\n const directoryToUse = directory\n ? pathUtils.resolve(process.cwd(), directory)\n : process.cwd();\n\n logInfo(`Preparing ${directoryToUse}...`);\n\n await prepareWorkingDirectory(directoryToUse);\n\n try {\n logInfo(`Cloning template...`);\n cloneTemplate(directoryToUse);\n\n await fs.rm(pathUtils.join(directoryToUse, '.git'), {\n force: true,\n recursive: true,\n });\n } catch (error) {\n throw new Error('Init Error: Failed to create template.');\n }\n\n logInfo('Installing dependencies...');\n yarnInstall(directoryToUse);\n\n if (!isInGitRepository(directoryToUse)) {\n logInfo('Initializing git repository...');\n gitInit(directoryToUse);\n }\n\n const snapLocation = pathUtils.join(directoryToUse, SNAP_LOCATION);\n\n const manifest = (\n await readJsonFile(pathUtils.join(snapLocation, NpmSnapFileNames.Manifest))\n ).result;\n\n const validatedManifest = createSnapManifest(manifest);\n\n const packageJson = (\n await readJsonFile(\n pathUtils.join(snapLocation, NpmSnapFileNames.PackageJson),\n )\n ).result as NpmSnapPackageJson;\n\n const distPath = validatedManifest.source.location.npm.filePath.split('/');\n\n return {\n ...argv,\n dist: distPath[0],\n outfileName: distPath[1],\n src: packageJson.main || 'src/index.js',\n snapLocation,\n };\n}\n"]}
@@ -111,7 +111,7 @@ function yarnInstall(directory) {
111
111
  try {
112
112
  (0, child_process_1.execSync)('yarn install', {
113
113
  stdio: [0, 1, 2],
114
- cwd: path_1.default.resolve(__dirname, directory),
114
+ cwd: directory,
115
115
  });
116
116
  }
117
117
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"initUtils.js","sourceRoot":"","sources":["../../../src/cmds/init/initUtils.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAyC;AACzC,2BAAoC;AACpC,gDAA6B;AAEhB,QAAA,gBAAgB,GAC3B,wDAAwD,CAAC;AAE9C,QAAA,aAAa,GAAG,gBAAgB,CAAC;AAE9C;;;;GAIG;AACI,KAAK,UAAU,uBAAuB,CAC3C,SAAiB;IAEjB,IAAI;QACF,MAAM,kBAAkB,GAAG,SAAS,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC;QAEvD,IAAI,CAAC,kBAAkB,EAAE;YACvB,IAAI;gBACF,MAAM,aAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAChD;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAChE;SACF;QAED,MAAM,aAAa,GAAG,MAAM,aAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,aAAa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E;QACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACrE;AACH,CAAC;AATD,0BASC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,SAAiB;IAC3C,IAAI;QACF,IAAA,wBAAQ,EAAC,cAAc,EAAE;YACvB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAChB,GAAG,EAAE,cAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;KAChE;AACH,CAAC;AATD,kCASC","sourcesContent":["import { execSync } from 'child_process';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nexport const TEMPLATE_GIT_URL =\n 'https://github.com/MetaMask/template-snap-monorepo.git';\n\nexport const SNAP_LOCATION = 'packages/snap/';\n\n/**\n * Checks if the destination folder exists and if it's empty. Otherwise create it.\n *\n * @param directory - The desination folder.\n */\nexport async function prepareWorkingDirectory(\n directory: string,\n): Promise<void> {\n try {\n const isCurrentDirectory = directory === process.cwd();\n\n if (!isCurrentDirectory) {\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch (error) {\n throw new Error('Init Error: Failed to create new directory.');\n }\n }\n\n const existingFiles = await fs.readdir(directory);\n\n if (existingFiles.length > 0) {\n throw new Error(`Directory ${directory} not empty.`);\n }\n } catch (error) {\n throw new Error(\n `Init Error: Failed to prepare working directory with message: ${error.message}`,\n );\n }\n}\n\n/**\n * Clones the template in a directory.\n *\n * @param directory - The directory to clone the template in.\n */\nexport function cloneTemplate(directory: string) {\n try {\n execSync(`git clone --depth=1 ${TEMPLATE_GIT_URL} ${directory}`, {\n stdio: [2],\n });\n } catch (error) {\n throw new Error('Init Error: Failed to clone the template.');\n }\n}\n\n/**\n * Check if git is installed.\n *\n * @returns True if git is installed, or false otherwise.\n */\nexport function isGitInstalled() {\n try {\n execSync('git --version', { stdio: 'ignore' });\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Check if the actual working dir is a git repository.\n *\n * @param directory - The directory to check.\n * @returns True if it's a git repository otherwise false.\n */\nexport function isInGitRepository(directory: string) {\n try {\n execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n cwd: pathUtils.resolve(__dirname, directory),\n });\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Init a git repository.\n *\n * @param directory - The directory to init.\n */\nexport function gitInit(directory: string) {\n try {\n execSync('git init', {\n stdio: 'ignore',\n cwd: pathUtils.resolve(__dirname, directory),\n });\n } catch (error) {\n throw new Error('Init Error: Failed to init a new git repository.');\n }\n}\n\n/**\n * Install dependencies in a yarn project.\n *\n * @param directory - The directory containing the project.\n */\nexport function yarnInstall(directory: string) {\n try {\n execSync('yarn install', {\n stdio: [0, 1, 2],\n cwd: pathUtils.resolve(__dirname, directory),\n });\n } catch (error) {\n throw new Error('Init Error: Failed to install dependencies.');\n }\n}\n"]}
1
+ {"version":3,"file":"initUtils.js","sourceRoot":"","sources":["../../../src/cmds/init/initUtils.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAyC;AACzC,2BAAoC;AACpC,gDAA6B;AAEhB,QAAA,gBAAgB,GAC3B,wDAAwD,CAAC;AAE9C,QAAA,aAAa,GAAG,gBAAgB,CAAC;AAE9C;;;;GAIG;AACI,KAAK,UAAU,uBAAuB,CAC3C,SAAiB;IAEjB,IAAI;QACF,MAAM,kBAAkB,GAAG,SAAS,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC;QAEvD,IAAI,CAAC,kBAAkB,EAAE;YACvB,IAAI;gBACF,MAAM,aAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAChD;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAChE;SACF;QAED,MAAM,aAAa,GAA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nB,KAAK,EAAE,QAAQ;YACf,GAAG,EAAE,cAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACrE;AACH,CAAC;AATD,0BASC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,SAAiB;IAC3C,IAAI;QACF,IAAA,wBAAQ,EAAC,cAAc,EAAE;YACvB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAChB,GAAG,EAAE,SAAS;SACf,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;KAChE;AACH,CAAC;AATD,kCASC","sourcesContent":["import { execSync } from 'child_process';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nexport const TEMPLATE_GIT_URL =\n 'https://github.com/MetaMask/template-snap-monorepo.git';\n\nexport const SNAP_LOCATION = 'packages/snap/';\n\n/**\n * Checks if the destination folder exists and if it's empty. Otherwise create it.\n *\n * @param directory - The desination folder.\n */\nexport async function prepareWorkingDirectory(\n directory: string,\n): Promise<void> {\n try {\n const isCurrentDirectory = directory === process.cwd();\n\n if (!isCurrentDirectory) {\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch (error) {\n throw new Error('Init Error: Failed to create new directory.');\n }\n }\n\n const existingFiles = await fs.readdir(directory);\n\n if (existingFiles.length > 0) {\n throw new Error(`Directory ${directory} not empty.`);\n }\n } catch (error) {\n throw new Error(\n `Init Error: Failed to prepare working directory with message: ${error.message}`,\n );\n }\n}\n\n/**\n * Clones the template in a directory.\n *\n * @param directory - The directory to clone the template in.\n */\nexport function cloneTemplate(directory: string) {\n try {\n execSync(`git clone --depth=1 ${TEMPLATE_GIT_URL} ${directory}`, {\n stdio: [2],\n });\n } catch (error) {\n throw new Error('Init Error: Failed to clone the template.');\n }\n}\n\n/**\n * Check if git is installed.\n *\n * @returns True if git is installed, or false otherwise.\n */\nexport function isGitInstalled() {\n try {\n execSync('git --version', { stdio: 'ignore' });\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Check if the actual working dir is a git repository.\n *\n * @param directory - The directory to check.\n * @returns True if it's a git repository otherwise false.\n */\nexport function isInGitRepository(directory: string) {\n try {\n execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n cwd: pathUtils.resolve(__dirname, directory),\n });\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Init a git repository.\n *\n * @param directory - The directory to init.\n */\nexport function gitInit(directory: string) {\n try {\n execSync('git init', {\n stdio: 'ignore',\n cwd: pathUtils.resolve(__dirname, directory),\n });\n } catch (error) {\n throw new Error('Init Error: Failed to init a new git repository.');\n }\n}\n\n/**\n * Install dependencies in a yarn project.\n *\n * @param directory - The directory containing the project.\n */\nexport function yarnInstall(directory: string) {\n try {\n execSync('yarn install', {\n stdio: [0, 1, 2],\n cwd: directory,\n });\n } catch (error) {\n throw new Error('Init Error: Failed to install dependencies.');\n }\n}\n"]}
@@ -11,7 +11,7 @@ export declare function logServerListening(port: number): void;
11
11
  * @param request.url - The URL of the request.
12
12
  */
13
13
  export declare function logRequest(request: {
14
- url: string;
14
+ url?: string;
15
15
  }): void;
16
16
  /**
17
17
  * Log an error message.
@@ -18,7 +18,7 @@ exports.logServerListening = logServerListening;
18
18
  * @param request.url - The URL of the request.
19
19
  */
20
20
  function logRequest(request) {
21
- (0, snaps_utils_1.logInfo)(`Handling incoming request for: ${request.url}`);
21
+ (0, snaps_utils_1.logInfo)(`Handling incoming request for: ${request.url ?? 'unknown'}`);
22
22
  }
23
23
  exports.logRequest = logRequest;
24
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"serveUtils.js","sourceRoot":"","sources":["../../../src/cmds/serve/serveUtils.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAE1D;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAA,qBAAO,EAAC,yCAAyC,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC;AAFD,gDAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAAwB;IACjD,IAAA,qBAAO,EAAC,kCAAkC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3D,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAAY,EAAE,IAAY;IACvD,IAAK,KAAa,CAAC,IAAI,KAAK,YAAY,EAAE;QACxC,IAAA,sBAAQ,EAAC,sBAAsB,IAAI,kBAAkB,CAAC,CAAC;KACxD;SAAM;QACL,IAAA,sBAAQ,EAAC,iBAAiB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KAC5C;AACH,CAAC;AAND,wCAMC","sourcesContent":["import { logError, logInfo } from '@metamask/snaps-utils';\n\n/**\n * Log a message with the URL and port of the server.\n *\n * @param port - The port that the server is running on.\n */\nexport function logServerListening(port: number) {\n logInfo(`Server listening on: http://localhost:${port}`);\n}\n\n/**\n * Log a message with the request URL.\n *\n * @param request - The request object.\n * @param request.url - The URL of the request.\n */\nexport function logRequest(request: { url: string }) {\n logInfo(`Handling incoming request for: ${request.url}`);\n}\n\n/**\n * Log an error message.\n *\n * @param error - The error to log.\n * @param port - The port that the server is running on.\n */\nexport function logServerError(error: Error, port: number) {\n if ((error as any).code === 'EADDRINUSE') {\n logError(`Server error: Port ${port} already in use.`);\n } else {\n logError(`Server error: ${error.message}`);\n }\n}\n"]}
1
+ {"version":3,"file":"serveUtils.js","sourceRoot":"","sources":["../../../src/cmds/serve/serveUtils.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAE1D;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAA,qBAAO,EAAC,yCAAyC,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC;AAFD,gDAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAAyB;IAClD,IAAA,qBAAO,EAAC,kCAAkC,OAAO,CAAC,GAAG,IAAI,SAAS,EAAE,CAAC,CAAC;AACxE,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAAY,EAAE,IAAY;IACvD,IAAK,KAAa,CAAC,IAAI,KAAK,YAAY,EAAE;QACxC,IAAA,sBAAQ,EAAC,sBAAsB,IAAI,kBAAkB,CAAC,CAAC;KACxD;SAAM;QACL,IAAA,sBAAQ,EAAC,iBAAiB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KAC5C;AACH,CAAC;AAND,wCAMC","sourcesContent":["import { logError, logInfo } from '@metamask/snaps-utils';\n\n/**\n * Log a message with the URL and port of the server.\n *\n * @param port - The port that the server is running on.\n */\nexport function logServerListening(port: number) {\n logInfo(`Server listening on: http://localhost:${port}`);\n}\n\n/**\n * Log a message with the request URL.\n *\n * @param request - The request object.\n * @param request.url - The URL of the request.\n */\nexport function logRequest(request: { url?: string }) {\n logInfo(`Handling incoming request for: ${request.url ?? 'unknown'}`);\n}\n\n/**\n * Log an error message.\n *\n * @param error - The error to log.\n * @param port - The port that the server is running on.\n */\nexport function logServerError(error: Error, port: number) {\n if ((error as any).code === 'EADDRINUSE') {\n logError(`Server error: Port ${port} already in use.`);\n } else {\n logError(`Server error: ${error.message}`);\n }\n}\n"]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.watch = void 0;
7
7
  const snaps_utils_1 = require("@metamask/snaps-utils");
8
8
  const chokidar_1 = __importDefault(require("chokidar"));
9
+ const path_1 = __importDefault(require("path"));
9
10
  const utils_1 = require("../../utils");
10
11
  const bundle_1 = require("../build/bundle");
11
12
  const evalHandler_1 = require("../eval/evalHandler");
@@ -30,9 +31,8 @@ async function watch(argv) {
30
31
  }
31
32
  await (0, snaps_utils_1.validateFilePath)(src);
32
33
  await (0, snaps_utils_1.validateDirPath)(dist, true);
33
- const rootDir = src.includes('/')
34
- ? src.substring(0, src.lastIndexOf('/') + 1)
35
- : '.';
34
+ const srcDir = path_1.default.dirname(src);
35
+ const watchDirs = [srcDir, snaps_utils_1.NpmSnapFileNames.Manifest, utils_1.CONFIG_FILE];
36
36
  const outfilePath = (0, snaps_utils_1.getOutfilePath)(dist, outfileName);
37
37
  const buildSnap = async (path, logMessage) => {
38
38
  if (logMessage !== undefined) {
@@ -54,7 +54,7 @@ async function watch(argv) {
54
54
  }
55
55
  };
56
56
  chokidar_1.default
57
- .watch(rootDir, {
57
+ .watch(watchDirs, {
58
58
  ignoreInitial: true,
59
59
  ignored: [
60
60
  '**/node_modules/**',
@@ -92,9 +92,8 @@ async function watch(argv) {
92
92
  .on('unlink', (path) => (0, snaps_utils_1.logInfo)(`File removed: ${path}`))
93
93
  .on('error', (error) => {
94
94
  (0, snaps_utils_1.logError)(`Watcher error: ${error.message}`, error);
95
- })
96
- .add(rootDir);
97
- (0, snaps_utils_1.logInfo)(`Watching '${rootDir}' for changes...`);
95
+ });
96
+ (0, snaps_utils_1.logInfo)(`Watching ${watchDirs.map((dir) => `'${dir}'`).join(', ')} for changes...`);
98
97
  }
99
98
  exports.watch = watch;
100
99
  //# sourceMappingURL=watchHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"watchHandler.js","sourceRoot":"","sources":["../../../src/cmds/watch/watchHandler.ts"],"names":[],"mappings":";;;;;;AAAA,uDAO+B;AAC/B,wDAAgC;AAGhC,uCAAyC;AACzC,4CAAyC;AACzC,qDAAkD;AAClD,iEAA8D;AAC9D,wDAA8C;AAE9C;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,KAAK,CAAC,IAAe;IACzC,MAAM,EACJ,IAAI,EACJ,IAAI,EAAE,UAAU,EAChB,QAAQ,EACR,WAAW,EACX,GAAG,EACH,KAAK,EAAE,WAAW,GACnB,GAAG,IAAI,CAAC;IACT,IAAI,WAAW,EAAE;QACf,IAAA,iCAAmB,EAAC,WAAW,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,EAAE,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC;SAED,GAAG,CAAC,OAAO,CAAC,CAAC;IAEhB,IAAA,qBAAO,EAAC,aAAa,OAAO,kBAAkB,CAAC,CAAC;AAClD,CAAC;AA5FD,sBA4FC","sourcesContent":["import {\n getOutfilePath,\n logError,\n logInfo,\n validateDirPath,\n validateFilePath,\n validateOutfileName,\n} from '@metamask/snaps-utils';\nimport chokidar from 'chokidar';\n\nimport { YargsArgs } from '../../types/yargs';\nimport { loadConfig } from '../../utils';\nimport { bundle } from '../build/bundle';\nimport { evalHandler } from '../eval/evalHandler';\nimport { manifestHandler } from '../manifest/manifestHandler';\nimport { serve } from '../serve/serveHandler';\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 argv - Arguments as an object generated by Yargs.\n * @param argv.src - The source file path.\n * @param argv.dist - The output directory path.\n * @param argv.'outfileName' - The output file name.\n */\nexport async function watch(argv: YargsArgs): Promise<void> {\n const {\n dist,\n eval: shouldEval,\n manifest,\n outfileName,\n src,\n serve: shouldServe,\n } = argv;\n if (outfileName) {\n validateOutfileName(outfileName);\n }\n await validateFilePath(src);\n await validateDirPath(dist, true);\n const rootDir = src.includes('/')\n ? src.substring(0, src.lastIndexOf('/') + 1)\n : '.';\n const outfilePath = getOutfilePath(dist, outfileName);\n\n const buildSnap = async (path?: string, logMessage?: string) => {\n if (logMessage !== undefined) {\n logInfo(logMessage);\n }\n\n try {\n await bundle(src, outfilePath, argv, loadConfig().bundlerCustomizer);\n\n if (manifest) {\n await manifestHandler(argv);\n }\n\n if (shouldEval) {\n await evalHandler({ ...argv, bundle: outfilePath });\n }\n } catch (error) {\n logError(\n `Error ${\n path === undefined\n ? 'during initial build'\n : `while processing \"${path}\"`\n }.`,\n error,\n );\n }\n };\n\n chokidar\n .watch(rootDir, {\n ignoreInitial: true,\n ignored: [\n '**/node_modules/**',\n `**/${dist}/**`,\n `**/test/**`,\n `**/tests/**`,\n `**/*.test.js`,\n `**/*.test.ts`,\n /* istanbul ignore next */\n (str: string) => str !== '.' && str.startsWith('.'),\n ],\n })\n\n .on('ready', () => {\n buildSnap()\n .then(() => {\n if (shouldServe) {\n return serve(argv);\n }\n\n return undefined;\n })\n .catch((error) => {\n logError('Error during initial build.', error);\n });\n })\n .on('add', (path) => {\n buildSnap(path, `File added: ${path}`).catch((error) => {\n logError(`Error while processing \"${path}\".`, error);\n });\n })\n .on('change', (path) => {\n buildSnap(path, `File changed: ${path}`).catch((error) => {\n logError(`Error while processing \"${path}\".`, error);\n });\n })\n .on('unlink', (path) => logInfo(`File removed: ${path}`))\n .on('error', (error: Error) => {\n logError(`Watcher error: ${error.message}`, error);\n })\n\n .add(rootDir);\n\n logInfo(`Watching '${rootDir}' for changes...`);\n}\n"]}
1
+ {"version":3,"file":"watchHandler.js","sourceRoot":"","sources":["../../../src/cmds/watch/watchHandler.ts"],"names":[],"mappings":";;;;;;AAAA,uDAQ+B;AAC/B,wDAAgC;AAChC,gDAA6B;AAG7B,uCAAsD;AACtD,4CAAyC;AACzC,qDAAkD;AAClD,iEAA8D;AAC9D,wDAA8C;AAE9C;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,KAAK,CAAC,IAAe;IACzC,MAAM,EACJ,IAAI,EACJ,IAAI,EAAE,UAAU,EAChB,QAAQ,EACR,WAAW,EACX,GAAG,EACH,KAAK,EAAE,WAAW,GACnB,GAAG,IAAI,CAAC;IACT,IAAI,WAAW,EAAE;QACf,IAAA,iCAAmB,EAAC,WAAW,CAAC,CAAC;KAClC;IACD,MAAM,IAAA,8BAAgB,EAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,IAAA,6BAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,cAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,CAAC,MAAM,EA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o,\n validateDirPath,\n validateFilePath,\n validateOutfileName,\n NpmSnapFileNames,\n} from '@metamask/snaps-utils';\nimport chokidar from 'chokidar';\nimport pathUtils from 'path';\n\nimport { YargsArgs } from '../../types/yargs';\nimport { CONFIG_FILE, loadConfig } from '../../utils';\nimport { bundle } from '../build/bundle';\nimport { evalHandler } from '../eval/evalHandler';\nimport { manifestHandler } from '../manifest/manifestHandler';\nimport { serve } from '../serve/serveHandler';\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 argv - Arguments as an object generated by Yargs.\n * @param argv.src - The source file path.\n * @param argv.dist - The output directory path.\n * @param argv.'outfileName' - The output file name.\n */\nexport async function watch(argv: YargsArgs): Promise<void> {\n const {\n dist,\n eval: shouldEval,\n manifest,\n outfileName,\n src,\n serve: shouldServe,\n } = argv;\n if (outfileName) {\n validateOutfileName(outfileName);\n }\n await validateFilePath(src);\n await validateDirPath(dist, true);\n const srcDir = pathUtils.dirname(src);\n const watchDirs = [srcDir, NpmSnapFileNames.Manifest, CONFIG_FILE];\n const outfilePath = getOutfilePath(dist, outfileName);\n\n const buildSnap = async (path?: string, logMessage?: string) => {\n if (logMessage !== undefined) {\n logInfo(logMessage);\n }\n\n try {\n await bundle(src, outfilePath, argv, loadConfig().bundlerCustomizer);\n\n if (manifest) {\n await manifestHandler(argv);\n }\n\n if (shouldEval) {\n await evalHandler({ ...argv, bundle: outfilePath });\n }\n } catch (error) {\n logError(\n `Error ${\n path === undefined\n ? 'during initial build'\n : `while processing \"${path}\"`\n }.`,\n error,\n );\n }\n };\n\n chokidar\n .watch(watchDirs, {\n ignoreInitial: true,\n ignored: [\n '**/node_modules/**',\n `**/${dist}/**`,\n `**/test/**`,\n `**/tests/**`,\n `**/*.test.js`,\n `**/*.test.ts`,\n /* istanbul ignore next */\n (str: string) => str !== '.' && str.startsWith('.'),\n ],\n })\n\n .on('ready', () => {\n buildSnap()\n .then(() => {\n if (shouldServe) {\n return serve(argv);\n }\n\n return undefined;\n })\n .catch((error) => {\n logError('Error during initial build.', error);\n });\n })\n .on('add', (path) => {\n buildSnap(path, `File added: ${path}`).catch((error) => {\n logError(`Error while processing \"${path}\".`, error);\n });\n })\n .on('change', (path) => {\n buildSnap(path, `File changed: ${path}`).catch((error) => {\n logError(`Error while processing \"${path}\".`, error);\n });\n })\n .on('unlink', (path) => logInfo(`File removed: ${path}`))\n .on('error', (error: Error) => {\n logError(`Watcher error: ${error.message}`, error);\n });\n\n logInfo(\n `Watching ${watchDirs.map((dir) => `'${dir}'`).join(', ')} for changes...`,\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-cli",
3
- "version": "0.32.2",
3
+ "version": "0.33.1-flask.1",
4
4
  "description": "A CLI for developing MetaMask Snaps.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "build:clean": "yarn clean && yarn build",
24
24
  "build:watch": "tsc-watch --onSuccess 'yarn build:chmod'",
25
25
  "clean": "rimraf '*.tsbuildinfo' 'dist/*'",
26
- "test": "jest && yarn posttest",
26
+ "test": "jest --runInBand && yarn posttest",
27
27
  "posttest": "jest-it-up",
28
28
  "test:watch": "yarn test --watch",
29
29
  "test:ci": "yarn test",
@@ -33,20 +33,19 @@
33
33
  "lint": "yarn lint:eslint && yarn lint:misc --check",
34
34
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
35
35
  "prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
36
- "publish:preview": "yarn npm publish --tag preview",
37
- "publish:package": "../../scripts/publish-package.sh"
36
+ "publish:preview": "yarn npm publish --tag preview"
38
37
  },
39
38
  "dependencies": {
40
- "@babel/core": "^7.16.7",
39
+ "@babel/core": "^7.20.12",
41
40
  "@babel/plugin-proposal-class-properties": "^7.16.7",
42
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
43
- "@babel/plugin-proposal-object-rest-spread": "^7.16.7",
44
- "@babel/plugin-proposal-optional-chaining": "^7.16.7",
41
+ "@babel/plugin-proposal-class-static-block": "^7.21.0",
42
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
43
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.0",
45
44
  "@babel/plugin-transform-runtime": "^7.16.7",
46
- "@babel/preset-env": "^7.16.7",
47
- "@babel/preset-typescript": "^7.16.7",
48
- "@metamask/snaps-browserify-plugin": "^0.32.2",
49
- "@metamask/snaps-utils": "^0.32.2",
45
+ "@babel/preset-env": "^7.20.12",
46
+ "@babel/preset-typescript": "^7.20.12",
47
+ "@metamask/snaps-browserify-plugin": "^0.33.1-flask.1",
48
+ "@metamask/snaps-utils": "^0.33.1-flask.1",
50
49
  "@metamask/utils": "^5.0.0",
51
50
  "babelify": "^10.0.0",
52
51
  "browserify": "^17.0.0",
@@ -55,25 +54,28 @@
55
54
  "serve-handler": "^6.1.5",
56
55
  "ses": "^0.18.1",
57
56
  "superstruct": "^1.0.3",
58
- "yargs": "^16.2.0",
57
+ "yargs": "^17.7.1",
59
58
  "yargs-parser": "^20.2.2"
60
59
  },
61
60
  "devDependencies": {
62
- "@lavamoat/allow-scripts": "^2.0.3",
61
+ "@lavamoat/allow-scripts": "^2.3.1",
63
62
  "@metamask/auto-changelog": "^3.1.0",
64
63
  "@metamask/eslint-config": "^11.0.0",
65
64
  "@metamask/eslint-config-jest": "^11.0.0",
66
65
  "@metamask/eslint-config-nodejs": "^11.0.1",
67
66
  "@metamask/eslint-config-typescript": "^11.0.0",
68
- "@types/browserify": "^12.0.36",
67
+ "@types/browserify": "^12.0.37",
69
68
  "@types/is-url": "^1.2.28",
70
69
  "@types/jest": "^27.5.1",
71
- "@types/node": "^14.14.25",
70
+ "@types/node": "^17.0.36",
72
71
  "@types/rimraf": "^3.0.0",
73
72
  "@types/serve-handler": "^6.1.0",
74
- "@types/yargs": "^15.0.12",
73
+ "@types/yargs": "^17.0.24",
75
74
  "@typescript-eslint/eslint-plugin": "^5.42.1",
76
75
  "@typescript-eslint/parser": "^5.42.1",
76
+ "babel-jest": "^29.5.0",
77
+ "clet": "^1.0.1",
78
+ "cross-fetch": "^3.1.5",
77
79
  "deepmerge": "^4.2.2",
78
80
  "eslint": "^8.27.0",
79
81
  "eslint-config-prettier": "^8.5.0",
@@ -85,12 +87,12 @@
85
87
  "execa": "^5.1.1",
86
88
  "jest": "^29.0.2",
87
89
  "jest-it-up": "^2.0.0",
88
- "memfs": "^3.4.10",
90
+ "memfs": "^3.4.13",
89
91
  "prettier": "^2.7.1",
90
92
  "prettier-plugin-packagejson": "^2.2.11",
91
- "rimraf": "^3.0.2",
92
- "ts-jest": "^29.0.0",
93
- "ts-node": "^10.7.0",
93
+ "rimraf": "^4.1.2",
94
+ "ts-jest": "^29.0.2",
95
+ "ts-node": "^10.9.1",
94
96
  "tsc-watch": "^4.5.0",
95
97
  "typescript": "~4.8.4"
96
98
  },
@@ -106,4 +108,4 @@
106
108
  "@lavamoat/preinstall-always-fail": false
107
109
  }
108
110
  }
109
- }
111
+ }