@metamask/snaps-cli 0.33.1-flask.1 → 0.34.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 CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.34.1-flask.1]
10
+ ### Changed
11
+ - No changes this release.
12
+
13
+ ## [0.34.0-flask.1]
14
+ ### Removed
15
+ - **BREAKING:** Remove `init` command ([#1268](https://github.com/MetaMask/snaps/pull/1268))
16
+
9
17
  ## [0.33.1-flask.1]
10
18
  ### Changed
11
19
  - No changes this release.
@@ -330,63 +338,65 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
330
338
  - Example snaps ([#72](https://github.com/MetaMask/snaps-monorepo/pull/72))
331
339
  - The examples now live in their own package, [`@metamask/snap-examples`](https://npmjs.com/package/@metamask/snap-examples).
332
340
 
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
341
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/v0.34.1-flask.1...HEAD
342
+ [0.34.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.34.0-flask.1...v0.34.1-flask.1
343
+ [0.34.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.33.1-flask.1...v0.34.0-flask.1
344
+ [0.33.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.33.0-flask.1...v0.33.1-flask.1
345
+ [0.33.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.32.2...v0.33.0-flask.1
346
+ [0.32.2]: https://github.com/MetaMask/snaps/compare/v0.32.1...v0.32.2
347
+ [0.32.1]: https://github.com/MetaMask/snaps/compare/v0.32.0...v0.32.1
348
+ [0.32.0]: https://github.com/MetaMask/snaps/compare/v0.31.0...v0.32.0
349
+ [0.31.0]: https://github.com/MetaMask/snaps/compare/v0.30.0...v0.31.0
350
+ [0.30.0]: https://github.com/MetaMask/snaps/compare/v0.29.0...v0.30.0
351
+ [0.29.0]: https://github.com/MetaMask/snaps/compare/v0.28.0...v0.29.0
352
+ [0.28.0]: https://github.com/MetaMask/snaps/compare/v0.27.1...v0.28.0
353
+ [0.27.1]: https://github.com/MetaMask/snaps/compare/v0.27.0...v0.27.1
354
+ [0.27.0]: https://github.com/MetaMask/snaps/compare/v0.26.2...v0.27.0
355
+ [0.26.2]: https://github.com/MetaMask/snaps/compare/v0.26.1...v0.26.2
356
+ [0.26.1]: https://github.com/MetaMask/snaps/compare/v0.26.0...v0.26.1
357
+ [0.26.0]: https://github.com/MetaMask/snaps/compare/v0.25.0...v0.26.0
358
+ [0.25.0]: https://github.com/MetaMask/snaps/compare/v0.24.1...v0.25.0
359
+ [0.24.1]: https://github.com/MetaMask/snaps/compare/v0.24.0...v0.24.1
360
+ [0.24.0]: https://github.com/MetaMask/snaps/compare/v0.23.0...v0.24.0
361
+ [0.23.0]: https://github.com/MetaMask/snaps/compare/v0.22.3...v0.23.0
362
+ [0.22.3]: https://github.com/MetaMask/snaps/compare/v0.22.2...v0.22.3
363
+ [0.22.2]: https://github.com/MetaMask/snaps/compare/v0.22.1...v0.22.2
364
+ [0.22.1]: https://github.com/MetaMask/snaps/compare/v0.22.0...v0.22.1
365
+ [0.22.0]: https://github.com/MetaMask/snaps/compare/v0.21.0...v0.22.0
366
+ [0.21.0]: https://github.com/MetaMask/snaps/compare/v0.20.0...v0.21.0
367
+ [0.20.0]: https://github.com/MetaMask/snaps/compare/v0.19.1...v0.20.0
368
+ [0.19.1]: https://github.com/MetaMask/snaps/compare/v0.19.0...v0.19.1
369
+ [0.19.0]: https://github.com/MetaMask/snaps/compare/v0.18.1...v0.19.0
370
+ [0.18.1]: https://github.com/MetaMask/snaps/compare/v0.18.0...v0.18.1
371
+ [0.18.0]: https://github.com/MetaMask/snaps/compare/v0.17.0...v0.18.0
372
+ [0.17.0]: https://github.com/MetaMask/snaps/compare/v0.16.0...v0.17.0
373
+ [0.16.0]: https://github.com/MetaMask/snaps/compare/v0.15.0...v0.16.0
374
+ [0.15.0]: https://github.com/MetaMask/snaps/compare/v0.14.0...v0.15.0
375
+ [0.14.0]: https://github.com/MetaMask/snaps/compare/v0.13.0...v0.14.0
376
+ [0.13.0]: https://github.com/MetaMask/snaps/compare/v0.12.0...v0.13.0
377
+ [0.12.0]: https://github.com/MetaMask/snaps/compare/v0.11.1...v0.12.0
378
+ [0.11.1]: https://github.com/MetaMask/snaps/compare/v0.11.0...v0.11.1
379
+ [0.11.0]: https://github.com/MetaMask/snaps/compare/v0.10.7...v0.11.0
380
+ [0.10.7]: https://github.com/MetaMask/snaps/compare/v0.10.6...v0.10.7
381
+ [0.10.6]: https://github.com/MetaMask/snaps/compare/v0.10.5...v0.10.6
382
+ [0.10.5]: https://github.com/MetaMask/snaps/compare/v0.10.3...v0.10.5
383
+ [0.10.3]: https://github.com/MetaMask/snaps/compare/v0.10.2...v0.10.3
384
+ [0.10.2]: https://github.com/MetaMask/snaps/compare/v0.10.1...v0.10.2
385
+ [0.10.1]: https://github.com/MetaMask/snaps/compare/v0.10.0...v0.10.1
386
+ [0.10.0]: https://github.com/MetaMask/snaps/compare/v0.9.0...v0.10.0
387
+ [0.9.0]: https://github.com/MetaMask/snaps/compare/v0.8.0...v0.9.0
388
+ [0.8.0]: https://github.com/MetaMask/snaps/compare/v0.7.0...v0.8.0
389
+ [0.7.0]: https://github.com/MetaMask/snaps/compare/v0.6.3...v0.7.0
390
+ [0.6.3]: https://github.com/MetaMask/snaps/compare/v0.6.2...v0.6.3
391
+ [0.6.2]: https://github.com/MetaMask/snaps/compare/v0.6.1...v0.6.2
392
+ [0.6.1]: https://github.com/MetaMask/snaps/compare/v0.6.0...v0.6.1
393
+ [0.6.0]: https://github.com/MetaMask/snaps/compare/v0.5.0...v0.6.0
394
+ [0.5.0]: https://github.com/MetaMask/snaps/compare/v0.4.0...v0.5.0
395
+ [0.4.0]: https://github.com/MetaMask/snaps/compare/v0.3.1...v0.4.0
396
+ [0.3.1]: https://github.com/MetaMask/snaps/compare/v0.3.0...v0.3.1
397
+ [0.3.0]: https://github.com/MetaMask/snaps/compare/v0.2.2...v0.3.0
398
+ [0.2.2]: https://github.com/MetaMask/snaps/compare/v0.2.1...v0.2.2
399
+ [0.2.1]: https://github.com/MetaMask/snaps/compare/v0.2.0...v0.2.1
400
+ [0.2.0]: https://github.com/MetaMask/snaps/compare/v0.1.1...v0.2.0
401
+ [0.1.1]: https://github.com/MetaMask/snaps/compare/v0.1.0...v0.1.1
402
+ [0.1.0]: https://github.com/MetaMask/snaps/releases/tag/v0.1.0
package/README.md CHANGED
@@ -18,12 +18,11 @@ Install a dev dependency in your snap project or globally using `yarn` or `npm`:
18
18
  Usage: mm-snap <command> [options]
19
19
 
20
20
  Commands:
21
- mm-snap build Build Snap from source [aliases: b]
22
- mm-snap eval Attempt to evaluate Snap bundle in SES [aliases: e]
23
- mm-snap init [directory] Initialize Snap package [aliases: i]
24
- mm-snap manifest Validate the snap.manifest.json file [aliases: m]
25
- mm-snap serve Locally serve Snap file(s) for testing [aliases: s]
26
- mm-snap watch Build Snap on change [aliases: w]
21
+ mm-snap build Build Snap from source [aliases: b]
22
+ mm-snap eval Attempt to evaluate Snap bundle in SES [aliases: e]
23
+ mm-snap manifest Validate the snap.manifest.json file [aliases: m]
24
+ mm-snap serve Locally serve Snap file(s) for testing [aliases: s]
25
+ mm-snap watch Build Snap on change [aliases: w]
27
26
 
28
27
  Options:
29
28
  --version Show version number [boolean]
@@ -5,10 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const build_1 = __importDefault(require("./build"));
7
7
  const eval_1 = __importDefault(require("./eval"));
8
- const init_1 = __importDefault(require("./init"));
9
8
  const manifest_1 = __importDefault(require("./manifest"));
10
9
  const serve_1 = __importDefault(require("./serve"));
11
10
  const watch_1 = __importDefault(require("./watch"));
12
- const commands = [build_1.default, eval_1.default, init_1.default, manifest_1.default, serve_1.default, watch_1.default];
11
+ const commands = [build_1.default, eval_1.default, manifest_1.default, serve_1.default, watch_1.default];
13
12
  exports.default = commands;
14
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,kDAA8B;AAC9B,kDAA0B;AAC1B,0DAAkC;AAClC,oDAA4B;AAC5B,oDAA4B;AAE5B,MAAM,QAAQ,GAAG,CAAC,eAAK,EAAE,cAAQ,EAAE,cAAI,EAAE,kBAAQ,EAAE,eAAK,EAAE,eAAK,CAAC,CAAC;AACjE,kBAAe,QAAQ,CAAC","sourcesContent":["import build from './build';\nimport evaluate from './eval';\nimport init from './init';\nimport manifest from './manifest';\nimport serve from './serve';\nimport watch from './watch';\n\nconst commands = [build, evaluate, init, manifest, serve, watch];\nexport default commands;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,kDAA8B;AAC9B,0DAAkC;AAClC,oDAA4B;AAC5B,oDAA4B;AAE5B,MAAM,QAAQ,GAAG,CAAC,eAAK,EAAE,cAAQ,EAAE,kBAAQ,EAAE,eAAK,EAAE,eAAK,CAAC,CAAC;AAC3D,kBAAe,QAAQ,CAAC","sourcesContent":["import build from './build';\nimport evaluate from './eval';\nimport manifest from './manifest';\nimport serve from './serve';\nimport watch from './watch';\n\nconst commands = [build, evaluate, manifest, serve, watch];\nexport default commands;\n"]}
@@ -0,0 +1 @@
1
+ export * as utils from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.utils = void 0;
27
+ exports.utils = __importStar(require("./utils"));
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC","sourcesContent":["export * as utils from './utils';\n"]}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@metamask/snaps-cli",
3
- "version": "0.33.1-flask.1",
3
+ "version": "0.34.1-flask.1",
4
4
  "description": "A CLI for developing MetaMask Snaps.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/MetaMask/snaps-monorepo.git"
7
+ "url": "https://github.com/MetaMask/snaps.git"
8
8
  },
9
9
  "license": "ISC",
10
+ "main": "dist/index.js",
10
11
  "bin": {
11
12
  "mm-snap": "./dist/main.js"
12
13
  },
@@ -28,12 +29,13 @@
28
29
  "test:watch": "yarn test --watch",
29
30
  "test:ci": "yarn test",
30
31
  "lint:changelog": "yarn auto-changelog validate",
31
- "lint:eslint": "eslint . --cache --ext js,ts",
32
- "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",
33
- "lint": "yarn lint:eslint && yarn lint:misc --check",
32
+ "lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
33
+ "lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
34
+ "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog",
34
35
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
35
36
  "prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
36
- "publish:preview": "yarn npm publish --tag preview"
37
+ "publish:preview": "yarn npm publish --tag preview",
38
+ "lint:ci": "yarn lint"
37
39
  },
38
40
  "dependencies": {
39
41
  "@babel/core": "^7.20.12",
@@ -44,9 +46,9 @@
44
46
  "@babel/plugin-transform-runtime": "^7.16.7",
45
47
  "@babel/preset-env": "^7.20.12",
46
48
  "@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",
49
- "@metamask/utils": "^5.0.0",
49
+ "@metamask/snaps-browserify-plugin": "^0.34.1-flask.1",
50
+ "@metamask/snaps-utils": "^0.34.1-flask.1",
51
+ "@metamask/utils": "^6.0.0",
50
52
  "babelify": "^10.0.0",
51
53
  "browserify": "^17.0.0",
52
54
  "chokidar": "^3.5.2",
@@ -64,6 +66,8 @@
64
66
  "@metamask/eslint-config-jest": "^11.0.0",
65
67
  "@metamask/eslint-config-nodejs": "^11.0.1",
66
68
  "@metamask/eslint-config-typescript": "^11.0.0",
69
+ "@swc/core": "^1.3.61",
70
+ "@swc/jest": "^0.2.26",
67
71
  "@types/browserify": "^12.0.37",
68
72
  "@types/is-url": "^1.2.28",
69
73
  "@types/jest": "^27.5.1",
@@ -91,7 +95,6 @@
91
95
  "prettier": "^2.7.1",
92
96
  "prettier-plugin-packagejson": "^2.2.11",
93
97
  "rimraf": "^4.1.2",
94
- "ts-jest": "^29.0.2",
95
98
  "ts-node": "^10.9.1",
96
99
  "tsc-watch": "^4.5.0",
97
100
  "typescript": "~4.8.4"
@@ -1,9 +0,0 @@
1
- import yargs from 'yargs';
2
- import { YargsArgs } from '../../types/yargs';
3
- declare const _default: {
4
- command: string[];
5
- desc: string;
6
- builder: (yarg: yargs.Argv) => void;
7
- handler: (argv: YargsArgs) => Promise<void>;
8
- };
9
- export = _default;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const snaps_utils_1 = require("@metamask/snaps-utils");
6
- const builders_1 = __importDefault(require("../../builders"));
7
- const buildHandler_1 = require("../build/buildHandler");
8
- const initHandler_1 = require("./initHandler");
9
- /**
10
- * The main entrypoint for the init command. This calls the init handler to
11
- * initialize the snap package, builds the snap, and then updates the manifest
12
- * with the shasum of the built snap.
13
- *
14
- * @param argv - The Yargs arguments object.
15
- */
16
- async function init(argv) {
17
- const newArgs = await (0, initHandler_1.initHandler)(argv);
18
- process.chdir(newArgs.snapLocation);
19
- await (0, buildHandler_1.build)({
20
- ...newArgs,
21
- manifest: false,
22
- eval: true,
23
- });
24
- (0, snaps_utils_1.logInfo)('\nSnap project successfully initiated!');
25
- }
26
- module.exports = {
27
- command: ['init [directory]', 'i [directory]'],
28
- desc: 'Initialize Snap package',
29
- builder: (yarg) => {
30
- yarg.positional('directory', builders_1.default.directory);
31
- },
32
- handler: async (argv) => init(argv),
33
- };
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cmds/init/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAgD;AAGhD,8DAAsC;AAEtC,wDAA8C;AAC9C,+CAA4C;AAW5C;;;;;;GAMG;AACH,KAAK,UAAU,IAAI,CAAC,IAAe;IACjC,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAW,EAAC,IAAI,CAAC,CAAC;IAExC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpC,MAAM,IAAA,oBAAK,EAAC;QACV,GAAG,OAAO;QACV,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,IAAA,qBAAO,EAAC,wCAAwC,CAAC,CAAC;AACpD,CAAC;AA5BD,iBAAS;IACP,OAAO,EAAE,CAAC,kBAAkB,EAAE,eAAe,CAAC;IAC9C,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,kBAAQ,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;CAC/C,CAAC","sourcesContent":["import { logInfo } from '@metamask/snaps-utils';\nimport yargs from 'yargs';\n\nimport builders from '../../builders';\nimport { YargsArgs } from '../../types/yargs';\nimport { build } from '../build/buildHandler';\nimport { initHandler } from './initHandler';\n\nexport = {\n command: ['init [directory]', 'i [directory]'],\n desc: 'Initialize Snap package',\n builder: (yarg: yargs.Argv) => {\n yarg.positional('directory', builders.directory);\n },\n handler: async (argv: YargsArgs) => init(argv),\n};\n\n/**\n * The main entrypoint for the init command. This calls the init handler to\n * initialize the snap package, builds the snap, and then updates the manifest\n * with the shasum of the built snap.\n *\n * @param argv - The Yargs arguments object.\n */\nasync function init(argv: YargsArgs): Promise<void> {\n const newArgs = await initHandler(argv);\n\n process.chdir(newArgs.snapLocation);\n\n await build({\n ...newArgs,\n manifest: false,\n eval: true,\n });\n\n logInfo('\\nSnap project successfully initiated!');\n}\n"]}
@@ -1,26 +0,0 @@
1
- import { YargsArgs } from '../../types/yargs';
2
- /**
3
- * Creates a new snap package, based on one of the provided templates. This
4
- * creates all the necessary files, like `package.json`, `snap.config.js`, etc.
5
- * to start developing a snap.
6
- *
7
- * @param argv - The Yargs arguments object.
8
- * @returns The Yargs arguments augmented with the new `dist`, `outfileName` and
9
- * `src` properties.
10
- * @throws If initialization of the snap package failed.
11
- */
12
- export declare function initHandler(argv: YargsArgs): Promise<{
13
- dist: string;
14
- outfileName: string;
15
- src: string;
16
- snapLocation: string;
17
- sourceMaps: boolean;
18
- stripComments: boolean;
19
- transformHtmlComments: boolean;
20
- port: number;
21
- eval: boolean;
22
- serve: boolean;
23
- directory?: string | undefined;
24
- _?: (string | number)[] | undefined;
25
- $0?: string | undefined;
26
- }>;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initHandler = void 0;
7
- const snaps_utils_1 = require("@metamask/snaps-utils");
8
- const utils_1 = require("@metamask/utils");
9
- const fs_1 = require("fs");
10
- const path_1 = __importDefault(require("path"));
11
- const initUtils_1 = require("./initUtils");
12
- const SATISFIED_VERSION = '>=16';
13
- /**
14
- * Creates a new snap package, based on one of the provided templates. This
15
- * creates all the necessary files, like `package.json`, `snap.config.js`, etc.
16
- * to start developing a snap.
17
- *
18
- * @param argv - The Yargs arguments object.
19
- * @returns The Yargs arguments augmented with the new `dist`, `outfileName` and
20
- * `src` properties.
21
- * @throws If initialization of the snap package failed.
22
- */
23
- async function initHandler(argv) {
24
- const { directory } = argv;
25
- const isVersionSupported = (0, utils_1.satisfiesVersionRange)(process.version, SATISFIED_VERSION);
26
- if (!isVersionSupported) {
27
- throw new Error(`Init Error: You are using an outdated version of Node (${process.version}). Please update to Node ${SATISFIED_VERSION}.`);
28
- }
29
- const gitExists = (0, initUtils_1.isGitInstalled)();
30
- if (!gitExists) {
31
- throw new Error(`Init Error: git is not installed. Please install git to continue.`);
32
- }
33
- const directoryToUse = directory
34
- ? path_1.default.resolve(process.cwd(), directory)
35
- : process.cwd();
36
- (0, snaps_utils_1.logInfo)(`Preparing ${directoryToUse}...`);
37
- await (0, initUtils_1.prepareWorkingDirectory)(directoryToUse);
38
- try {
39
- (0, snaps_utils_1.logInfo)(`Cloning template...`);
40
- (0, initUtils_1.cloneTemplate)(directoryToUse);
41
- await fs_1.promises.rm(path_1.default.join(directoryToUse, '.git'), {
42
- force: true,
43
- recursive: true,
44
- });
45
- }
46
- catch (error) {
47
- throw new Error('Init Error: Failed to create template.');
48
- }
49
- (0, snaps_utils_1.logInfo)('Installing dependencies...');
50
- (0, initUtils_1.yarnInstall)(directoryToUse);
51
- if (!(0, initUtils_1.isInGitRepository)(directoryToUse)) {
52
- (0, snaps_utils_1.logInfo)('Initializing git repository...');
53
- (0, initUtils_1.gitInit)(directoryToUse);
54
- }
55
- const snapLocation = path_1.default.join(directoryToUse, initUtils_1.SNAP_LOCATION);
56
- const manifest = (await (0, snaps_utils_1.readJsonFile)(path_1.default.join(snapLocation, snaps_utils_1.NpmSnapFileNames.Manifest))).result;
57
- const validatedManifest = (0, snaps_utils_1.createSnapManifest)(manifest);
58
- const packageJson = (await (0, snaps_utils_1.readJsonFile)(path_1.default.join(snapLocation, snaps_utils_1.NpmSnapFileNames.PackageJson))).result;
59
- const distPath = validatedManifest.source.location.npm.filePath.split('/');
60
- return {
61
- ...argv,
62
- dist: distPath[0],
63
- outfileName: distPath[1],
64
- src: packageJson.main || 'src/index.js',
65
- snapLocation,
66
- };
67
- }
68
- exports.initHandler = initHandler;
69
- //# sourceMappingURL=initHandler.js.map
@@ -1 +0,0 @@
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,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE;YAClD,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,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.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"]}
@@ -1,39 +0,0 @@
1
- export declare const TEMPLATE_GIT_URL = "https://github.com/MetaMask/template-snap-monorepo.git";
2
- export declare const SNAP_LOCATION = "packages/snap/";
3
- /**
4
- * Checks if the destination folder exists and if it's empty. Otherwise create it.
5
- *
6
- * @param directory - The desination folder.
7
- */
8
- export declare function prepareWorkingDirectory(directory: string): Promise<void>;
9
- /**
10
- * Clones the template in a directory.
11
- *
12
- * @param directory - The directory to clone the template in.
13
- */
14
- export declare function cloneTemplate(directory: string): void;
15
- /**
16
- * Check if git is installed.
17
- *
18
- * @returns True if git is installed, or false otherwise.
19
- */
20
- export declare function isGitInstalled(): boolean;
21
- /**
22
- * Check if the actual working dir is a git repository.
23
- *
24
- * @param directory - The directory to check.
25
- * @returns True if it's a git repository otherwise false.
26
- */
27
- export declare function isInGitRepository(directory: string): boolean;
28
- /**
29
- * Init a git repository.
30
- *
31
- * @param directory - The directory to init.
32
- */
33
- export declare function gitInit(directory: string): void;
34
- /**
35
- * Install dependencies in a yarn project.
36
- *
37
- * @param directory - The directory containing the project.
38
- */
39
- export declare function yarnInstall(directory: string): void;
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.yarnInstall = exports.gitInit = exports.isInGitRepository = exports.isGitInstalled = exports.cloneTemplate = exports.prepareWorkingDirectory = exports.SNAP_LOCATION = exports.TEMPLATE_GIT_URL = void 0;
7
- const child_process_1 = require("child_process");
8
- const fs_1 = require("fs");
9
- const path_1 = __importDefault(require("path"));
10
- exports.TEMPLATE_GIT_URL = 'https://github.com/MetaMask/template-snap-monorepo.git';
11
- exports.SNAP_LOCATION = 'packages/snap/';
12
- /**
13
- * Checks if the destination folder exists and if it's empty. Otherwise create it.
14
- *
15
- * @param directory - The desination folder.
16
- */
17
- async function prepareWorkingDirectory(directory) {
18
- try {
19
- const isCurrentDirectory = directory === process.cwd();
20
- if (!isCurrentDirectory) {
21
- try {
22
- await fs_1.promises.mkdir(directory, { recursive: true });
23
- }
24
- catch (error) {
25
- throw new Error('Init Error: Failed to create new directory.');
26
- }
27
- }
28
- const existingFiles = await fs_1.promises.readdir(directory);
29
- if (existingFiles.length > 0) {
30
- throw new Error(`Directory ${directory} not empty.`);
31
- }
32
- }
33
- catch (error) {
34
- throw new Error(`Init Error: Failed to prepare working directory with message: ${error.message}`);
35
- }
36
- }
37
- exports.prepareWorkingDirectory = prepareWorkingDirectory;
38
- /**
39
- * Clones the template in a directory.
40
- *
41
- * @param directory - The directory to clone the template in.
42
- */
43
- function cloneTemplate(directory) {
44
- try {
45
- (0, child_process_1.execSync)(`git clone --depth=1 ${exports.TEMPLATE_GIT_URL} ${directory}`, {
46
- stdio: [2],
47
- });
48
- }
49
- catch (error) {
50
- throw new Error('Init Error: Failed to clone the template.');
51
- }
52
- }
53
- exports.cloneTemplate = cloneTemplate;
54
- /**
55
- * Check if git is installed.
56
- *
57
- * @returns True if git is installed, or false otherwise.
58
- */
59
- function isGitInstalled() {
60
- try {
61
- (0, child_process_1.execSync)('git --version', { stdio: 'ignore' });
62
- return true;
63
- }
64
- catch (error) {
65
- return false;
66
- }
67
- }
68
- exports.isGitInstalled = isGitInstalled;
69
- /**
70
- * Check if the actual working dir is a git repository.
71
- *
72
- * @param directory - The directory to check.
73
- * @returns True if it's a git repository otherwise false.
74
- */
75
- function isInGitRepository(directory) {
76
- try {
77
- (0, child_process_1.execSync)('git rev-parse --is-inside-work-tree', {
78
- stdio: 'ignore',
79
- cwd: path_1.default.resolve(__dirname, directory),
80
- });
81
- return true;
82
- }
83
- catch (error) {
84
- return false;
85
- }
86
- }
87
- exports.isInGitRepository = isInGitRepository;
88
- /**
89
- * Init a git repository.
90
- *
91
- * @param directory - The directory to init.
92
- */
93
- function gitInit(directory) {
94
- try {
95
- (0, child_process_1.execSync)('git init', {
96
- stdio: 'ignore',
97
- cwd: path_1.default.resolve(__dirname, directory),
98
- });
99
- }
100
- catch (error) {
101
- throw new Error('Init Error: Failed to init a new git repository.');
102
- }
103
- }
104
- exports.gitInit = gitInit;
105
- /**
106
- * Install dependencies in a yarn project.
107
- *
108
- * @param directory - The directory containing the project.
109
- */
110
- function yarnInstall(directory) {
111
- try {
112
- (0, child_process_1.execSync)('yarn install', {
113
- stdio: [0, 1, 2],
114
- cwd: directory,
115
- });
116
- }
117
- catch (error) {
118
- throw new Error('Init Error: Failed to install dependencies.');
119
- }
120
- }
121
- exports.yarnInstall = yarnInstall;
122
- //# sourceMappingURL=initUtils.js.map
@@ -1 +0,0 @@
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,SAAS,aAAa,CAAC,CAAC;SACtD;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,iEAAiE,KAAK,CAAC,OAAO,EAAE,CACjF,CAAC;KACH;AACH,CAAC;AAxBD,0DAwBC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,SAAiB;IAC7C,IAAI;QACF,IAAA,wBAAQ,EAAC,uBAAuB,wBAAgB,IAAI,SAAS,EAAE,EAAE;YAC/D,KAAK,EAAE,CAAC,CAAC,CAAC;SACX,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;AACH,CAAC;AARD,sCAQC;AAED;;;;GAIG;AACH,SAAgB,cAAc;IAC5B,IAAI;QACF,IAAA,wBAAQ,EAAC,eAAe,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,wCAOC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI;QACF,IAAA,wBAAQ,EAAC,qCAAqC,EAAE;YAC9C,KAAK,EAAE,QAAQ;YACf,GAAG,EAAE,cAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAVD,8CAUC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,IAAI;QACF,IAAA,wBAAQ,EAAC,UAAU,EAAE;YACnB,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"]}