@metamask/snaps-cli 6.7.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -1
- package/README.md +12 -244
- package/dist/builders.cjs +5 -97
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +5 -94
- package/dist/builders.d.cts.map +1 -1
- package/dist/builders.d.mts +5 -94
- package/dist/builders.d.mts.map +1 -1
- package/dist/builders.mjs +5 -96
- package/dist/builders.mjs.map +1 -1
- package/dist/cli.cjs +4 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts.map +1 -1
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +4 -16
- package/dist/cli.mjs.map +1 -1
- package/dist/commands/build/build.cjs +15 -11
- package/dist/commands/build/build.cjs.map +1 -1
- package/dist/commands/build/build.d.cts +8 -0
- package/dist/commands/build/build.d.cts.map +1 -1
- package/dist/commands/build/build.d.mts +8 -0
- package/dist/commands/build/build.d.mts.map +1 -1
- package/dist/commands/build/build.mjs +9 -5
- package/dist/commands/build/build.mjs.map +1 -1
- package/dist/commands/build/implementation.cjs.map +1 -1
- package/dist/commands/build/implementation.d.cts +2 -2
- package/dist/commands/build/implementation.d.cts.map +1 -1
- package/dist/commands/build/implementation.d.mts +2 -2
- package/dist/commands/build/implementation.d.mts.map +1 -1
- package/dist/commands/build/implementation.mjs.map +1 -1
- package/dist/commands/build/index.cjs +5 -14
- package/dist/commands/build/index.cjs.map +1 -1
- package/dist/commands/build/index.d.cts +1 -0
- package/dist/commands/build/index.d.cts.map +1 -1
- package/dist/commands/build/index.d.mts +1 -0
- package/dist/commands/build/index.d.mts.map +1 -1
- package/dist/commands/build/index.mjs +3 -14
- package/dist/commands/build/index.mjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs +0 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.d.cts.map +1 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.d.mts.map +1 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs +0 -1
- package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.cjs +0 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.cjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.d.cts.map +1 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.d.mts.map +1 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.mjs +0 -1
- package/dist/commands/eval/__test__/webpack/good/snap.config.mjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/snap.config.cjs +0 -1
- package/dist/commands/eval/__test__/webpack/snap.config.cjs.map +1 -1
- package/dist/commands/eval/__test__/webpack/snap.config.d.cts.map +1 -1
- package/dist/commands/eval/__test__/webpack/snap.config.d.mts.map +1 -1
- package/dist/commands/eval/__test__/webpack/snap.config.mjs +0 -1
- package/dist/commands/eval/__test__/webpack/snap.config.mjs.map +1 -1
- package/dist/commands/eval/eval.cjs +1 -1
- package/dist/commands/eval/eval.cjs.map +1 -1
- package/dist/commands/eval/eval.d.cts.map +1 -1
- package/dist/commands/eval/eval.d.mts.map +1 -1
- package/dist/commands/eval/eval.mjs +1 -1
- package/dist/commands/eval/eval.mjs.map +1 -1
- package/dist/commands/eval/index.cjs +1 -4
- package/dist/commands/eval/index.cjs.map +1 -1
- package/dist/commands/eval/index.d.cts.map +1 -1
- package/dist/commands/eval/index.d.mts.map +1 -1
- package/dist/commands/eval/index.mjs +1 -4
- package/dist/commands/eval/index.mjs.map +1 -1
- package/dist/commands/index.cjs +2 -0
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts.map +1 -1
- package/dist/commands/index.d.mts.map +1 -1
- package/dist/commands/index.mjs +2 -0
- package/dist/commands/index.mjs.map +1 -1
- package/dist/commands/manifest/index.cjs +1 -4
- package/dist/commands/manifest/index.cjs.map +1 -1
- package/dist/commands/manifest/index.d.cts.map +1 -1
- package/dist/commands/manifest/index.d.mts.map +1 -1
- package/dist/commands/manifest/index.mjs +1 -4
- package/dist/commands/manifest/index.mjs.map +1 -1
- package/dist/commands/manifest/manifest.cjs +5 -6
- package/dist/commands/manifest/manifest.cjs.map +1 -1
- package/dist/commands/manifest/manifest.d.cts.map +1 -1
- package/dist/commands/manifest/manifest.d.mts.map +1 -1
- package/dist/commands/manifest/manifest.mjs +5 -6
- package/dist/commands/manifest/manifest.mjs.map +1 -1
- package/dist/commands/sandbox/index.cjs +17 -0
- package/dist/commands/sandbox/index.cjs.map +1 -0
- package/dist/commands/sandbox/index.d.cts +10 -0
- package/dist/commands/sandbox/index.d.cts.map +1 -0
- package/dist/commands/sandbox/index.d.mts +10 -0
- package/dist/commands/sandbox/index.d.mts.map +1 -0
- package/dist/commands/sandbox/index.mjs +12 -0
- package/dist/commands/sandbox/index.mjs.map +1 -0
- package/dist/commands/sandbox/sandbox.cjs +33 -0
- package/dist/commands/sandbox/sandbox.cjs.map +1 -0
- package/dist/commands/sandbox/sandbox.d.cts +14 -0
- package/dist/commands/sandbox/sandbox.d.cts.map +1 -0
- package/dist/commands/sandbox/sandbox.d.mts +14 -0
- package/dist/commands/sandbox/sandbox.d.mts.map +1 -0
- package/dist/commands/sandbox/sandbox.mjs +29 -0
- package/dist/commands/sandbox/sandbox.mjs.map +1 -0
- package/dist/commands/sandbox/server.cjs +27 -0
- package/dist/commands/sandbox/server.cjs.map +1 -0
- package/dist/commands/sandbox/server.d.cts +14 -0
- package/dist/commands/sandbox/server.d.cts.map +1 -0
- package/dist/commands/sandbox/server.d.mts +14 -0
- package/dist/commands/sandbox/server.d.mts.map +1 -0
- package/dist/commands/sandbox/server.mjs +25 -0
- package/dist/commands/sandbox/server.mjs.map +1 -0
- package/dist/commands/serve/index.cjs +2 -2
- package/dist/commands/serve/index.cjs.map +1 -1
- package/dist/commands/serve/index.d.cts.map +1 -1
- package/dist/commands/serve/index.d.mts.map +1 -1
- package/dist/commands/serve/index.mjs +2 -2
- package/dist/commands/serve/index.mjs.map +1 -1
- package/dist/commands/watch/implementation.cjs +2 -0
- package/dist/commands/watch/implementation.cjs.map +1 -1
- package/dist/commands/watch/implementation.d.cts +2 -2
- package/dist/commands/watch/implementation.d.cts.map +1 -1
- package/dist/commands/watch/implementation.d.mts +2 -2
- package/dist/commands/watch/implementation.d.mts.map +1 -1
- package/dist/commands/watch/implementation.mjs +2 -0
- package/dist/commands/watch/implementation.mjs.map +1 -1
- package/dist/commands/watch/index.cjs +2 -17
- package/dist/commands/watch/index.cjs.map +1 -1
- package/dist/commands/watch/index.d.cts.map +1 -1
- package/dist/commands/watch/index.d.mts.map +1 -1
- package/dist/commands/watch/index.mjs +2 -17
- package/dist/commands/watch/index.mjs.map +1 -1
- package/dist/commands/watch/watch.cjs +1 -1
- package/dist/commands/watch/watch.cjs.map +1 -1
- package/dist/commands/watch/watch.d.cts.map +1 -1
- package/dist/commands/watch/watch.d.mts.map +1 -1
- package/dist/commands/watch/watch.mjs +1 -1
- package/dist/commands/watch/watch.mjs.map +1 -1
- package/dist/config.cjs +11 -155
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +216 -314
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +216 -314
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +13 -155
- package/dist/config.mjs.map +1 -1
- package/dist/main.cjs +0 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +0 -1
- package/dist/main.mjs.map +1 -1
- package/dist/utils/index.cjs +0 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +0 -1
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +0 -1
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +0 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/steps.cjs.map +1 -1
- package/dist/utils/steps.d.cts +1 -1
- package/dist/utils/steps.d.cts.map +1 -1
- package/dist/utils/steps.d.mts +1 -1
- package/dist/utils/steps.d.mts.map +1 -1
- package/dist/utils/steps.mjs.map +1 -1
- package/dist/webpack/compiler.cjs.map +1 -1
- package/dist/webpack/compiler.d.cts +2 -2
- package/dist/webpack/compiler.d.cts.map +1 -1
- package/dist/webpack/compiler.d.mts +2 -2
- package/dist/webpack/compiler.d.mts.map +1 -1
- package/dist/webpack/compiler.mjs.map +1 -1
- package/dist/webpack/config.cjs +1 -2
- package/dist/webpack/config.cjs.map +1 -1
- package/dist/webpack/config.d.cts +2 -2
- package/dist/webpack/config.d.cts.map +1 -1
- package/dist/webpack/config.d.mts +2 -2
- package/dist/webpack/config.d.mts.map +1 -1
- package/dist/webpack/config.mjs +1 -2
- package/dist/webpack/config.mjs.map +1 -1
- package/dist/webpack/loaders/function.cjs +7 -10
- package/dist/webpack/loaders/function.cjs.map +1 -1
- package/dist/webpack/loaders/function.d.cts +1 -0
- package/dist/webpack/loaders/function.d.cts.map +1 -1
- package/dist/webpack/loaders/function.d.mts +1 -0
- package/dist/webpack/loaders/function.d.mts.map +1 -1
- package/dist/webpack/loaders/function.mjs +6 -9
- package/dist/webpack/loaders/function.mjs.map +1 -1
- package/dist/webpack/loaders/index.cjs +1 -3
- package/dist/webpack/loaders/index.cjs.map +1 -1
- package/dist/webpack/loaders/index.d.cts +0 -1
- package/dist/webpack/loaders/index.d.cts.map +1 -1
- package/dist/webpack/loaders/index.d.mts +0 -1
- package/dist/webpack/loaders/index.d.mts.map +1 -1
- package/dist/webpack/loaders/index.mjs +0 -1
- package/dist/webpack/loaders/index.mjs.map +1 -1
- package/dist/webpack/loaders/wasm.cjs +0 -2
- package/dist/webpack/loaders/wasm.cjs.map +1 -1
- package/dist/webpack/loaders/wasm.d.cts.map +1 -1
- package/dist/webpack/loaders/wasm.d.mts.map +1 -1
- package/dist/webpack/loaders/wasm.mjs +0 -2
- package/dist/webpack/loaders/wasm.mjs.map +1 -1
- package/dist/webpack/plugins.cjs +15 -20
- package/dist/webpack/plugins.cjs.map +1 -1
- package/dist/webpack/plugins.d.cts +13 -3
- package/dist/webpack/plugins.d.cts.map +1 -1
- package/dist/webpack/plugins.d.mts +13 -3
- package/dist/webpack/plugins.d.mts.map +1 -1
- package/dist/webpack/plugins.mjs +4 -9
- package/dist/webpack/plugins.mjs.map +1 -1
- package/dist/webpack/server.cjs +83 -72
- package/dist/webpack/server.cjs.map +1 -1
- package/dist/webpack/server.d.cts +6 -1
- package/dist/webpack/server.d.cts.map +1 -1
- package/dist/webpack/server.d.mts +6 -1
- package/dist/webpack/server.d.mts.map +1 -1
- package/dist/webpack/server.mjs +63 -72
- package/dist/webpack/server.mjs.map +1 -1
- package/dist/webpack/utils.cjs +5 -21
- package/dist/webpack/utils.cjs.map +1 -1
- package/dist/webpack/utils.d.cts +6 -36
- package/dist/webpack/utils.d.cts.map +1 -1
- package/dist/webpack/utils.d.mts +6 -36
- package/dist/webpack/utils.d.mts.map +1 -1
- package/dist/webpack/utils.mjs +4 -18
- package/dist/webpack/utils.mjs.map +1 -1
- package/package.json +16 -40
- package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs +0 -10
- package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs.map +0 -1
- package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts +0 -4
- package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts.map +0 -1
- package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts +0 -4
- package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts.map +0 -1
- package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs +0 -8
- package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs.map +0 -1
- package/dist/commands/eval/__test__/browserify/good/snap.config.cjs +0 -10
- package/dist/commands/eval/__test__/browserify/good/snap.config.cjs.map +0 -1
- package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts +0 -4
- package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts.map +0 -1
- package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts +0 -4
- package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts.map +0 -1
- package/dist/commands/eval/__test__/browserify/good/snap.config.mjs +0 -8
- package/dist/commands/eval/__test__/browserify/good/snap.config.mjs.map +0 -1
- package/dist/utils/legacy.cjs +0 -53
- package/dist/utils/legacy.cjs.map +0 -1
- package/dist/utils/legacy.d.cts +0 -28
- package/dist/utils/legacy.d.cts.map +0 -1
- package/dist/utils/legacy.d.mts +0 -28
- package/dist/utils/legacy.d.mts.map +0 -1
- package/dist/utils/legacy.mjs +0 -47
- package/dist/utils/legacy.mjs.map +0 -1
- package/dist/webpack/loaders/browserify.cjs +0 -84
- package/dist/webpack/loaders/browserify.cjs.map +0 -1
- package/dist/webpack/loaders/browserify.d.cts +0 -18
- package/dist/webpack/loaders/browserify.d.cts.map +0 -1
- package/dist/webpack/loaders/browserify.d.mts +0 -18
- package/dist/webpack/loaders/browserify.d.mts.map +0 -1
- package/dist/webpack/loaders/browserify.mjs +0 -88
- package/dist/webpack/loaders/browserify.mjs.map +0 -1
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import builders from "../../builders.mjs";
|
|
2
1
|
import { manifestHandler } from "./manifest.mjs";
|
|
2
|
+
import builders from "../../builders.mjs";
|
|
3
3
|
const command = {
|
|
4
4
|
command: ['manifest', 'm'],
|
|
5
5
|
desc: 'Validate the snap.manifest.json file',
|
|
6
6
|
builder: (yarg) => {
|
|
7
|
-
// Browserify options. These are merged into the config object.
|
|
8
|
-
yarg.option('writeManifest', builders.writeManifest);
|
|
9
|
-
// Webpack options.
|
|
10
7
|
yarg.option('fix', builders.fix);
|
|
11
8
|
},
|
|
12
9
|
handler: async (argv) => manifestHandler(argv.context.config, { fix: argv.fix }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,uBAAmB;AAC7C,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC;IAC1B,IAAI,EAAE,sCAAsC;IAC5C,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;CAC1D,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { manifestHandler } from './manifest';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['manifest', 'm'],\n desc: 'Validate the snap.manifest.json file',\n builder: (yarg: yargs.Argv) => {\n yarg.option('fix', builders.fix);\n },\n handler: async (argv: YargsArgs) =>\n manifestHandler(argv.context.config, { fix: argv.fix }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.manifestHandler = void 0;
|
|
4
4
|
const node_1 = require("@metamask/snaps-utils/node");
|
|
5
|
+
const implementation_1 = require("./implementation.cjs");
|
|
5
6
|
const errors_1 = require("../../errors.cjs");
|
|
6
7
|
const utils_1 = require("../../utils/index.cjs");
|
|
7
|
-
const implementation_1 = require("./implementation.cjs");
|
|
8
8
|
const steps = [
|
|
9
9
|
{
|
|
10
10
|
name: 'Checking the input file.',
|
|
@@ -16,8 +16,8 @@ const steps = [
|
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
name: 'Validating the snap manifest.',
|
|
19
|
-
task: async ({ input,
|
|
20
|
-
const write = getWriteManifest(
|
|
19
|
+
task: async ({ input, options, spinner }) => {
|
|
20
|
+
const write = getWriteManifest(options);
|
|
21
21
|
const valid = await (0, implementation_1.manifest)(input, write, spinner);
|
|
22
22
|
if (valid) {
|
|
23
23
|
spinner.succeed('The snap manifest file is valid.');
|
|
@@ -28,15 +28,14 @@ const steps = [
|
|
|
28
28
|
/**
|
|
29
29
|
* Get whether to write the manifest to disk.
|
|
30
30
|
*
|
|
31
|
-
* @param config - The config object.
|
|
32
31
|
* @param options - The options object.
|
|
33
32
|
* @returns Whether to write the manifest to disk.
|
|
34
33
|
*/
|
|
35
|
-
function getWriteManifest(
|
|
34
|
+
function getWriteManifest(options) {
|
|
36
35
|
if (typeof options.fix === 'boolean') {
|
|
37
36
|
return options.fix;
|
|
38
37
|
}
|
|
39
|
-
return
|
|
38
|
+
return false;
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* Validates a snap.manifest.json file. Attempts to fix the manifest and write
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;
|
|
1
|
+
{"version":3,"file":"manifest.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD,yDAA4C;AAE5C,6CAA4C;AAE5C,iDAA2C;AAY3C,MAAM,KAAK,GAA2B;IACpC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,6BAA6B,KAAK,2DAA2D,CAC9F,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,+BAA+B;QACrC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC1C,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,IAAA,yBAAQ,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAEpD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;KACF;CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAwB;IAChD,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,OAAO,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,MAAuB,EACvB,OAAwB;IAExB,MAAM,IAAA,oBAAY,EAAC,KAAK,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC3B,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AATD,0CASC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport { manifest } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps } from '../../utils';\n\ntype ManifestOptions = {\n fix?: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n};\n\nconst steps: Steps<ManifestContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n throw new CommandError(\n `Manifest file not found: \"${input}\". Make sure that the \\`snap.manifest.json\\` file exists.`,\n );\n }\n },\n },\n {\n name: 'Validating the snap manifest.',\n task: async ({ input, options, spinner }) => {\n const write = getWriteManifest(options);\n const valid = await manifest(input, write, spinner);\n\n if (valid) {\n spinner.succeed('The snap manifest file is valid.');\n }\n },\n },\n];\n\n/**\n * Get whether to write the manifest to disk.\n *\n * @param options - The options object.\n * @returns Whether to write the manifest to disk.\n */\nfunction getWriteManifest(options: ManifestOptions) {\n if (typeof options.fix === 'boolean') {\n return options.fix;\n }\n\n return false;\n}\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function manifestHandler(\n config: ProcessedConfig,\n options: ManifestOptions,\n) {\n await executeSteps(steps, {\n input: config.manifest.path,\n config,\n options,\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAKpD,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AA8CF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,iBAOzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAKpD,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AA8CF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,iBAOzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFile } from "@metamask/snaps-utils/node";
|
|
2
|
+
import { manifest } from "./implementation.mjs";
|
|
2
3
|
import { CommandError } from "../../errors.mjs";
|
|
3
4
|
import { executeSteps } from "../../utils/index.mjs";
|
|
4
|
-
import { manifest } from "./implementation.mjs";
|
|
5
5
|
const steps = [
|
|
6
6
|
{
|
|
7
7
|
name: 'Checking the input file.',
|
|
@@ -13,8 +13,8 @@ const steps = [
|
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
name: 'Validating the snap manifest.',
|
|
16
|
-
task: async ({ input,
|
|
17
|
-
const write = getWriteManifest(
|
|
16
|
+
task: async ({ input, options, spinner }) => {
|
|
17
|
+
const write = getWriteManifest(options);
|
|
18
18
|
const valid = await manifest(input, write, spinner);
|
|
19
19
|
if (valid) {
|
|
20
20
|
spinner.succeed('The snap manifest file is valid.');
|
|
@@ -25,15 +25,14 @@ const steps = [
|
|
|
25
25
|
/**
|
|
26
26
|
* Get whether to write the manifest to disk.
|
|
27
27
|
*
|
|
28
|
-
* @param config - The config object.
|
|
29
28
|
* @param options - The options object.
|
|
30
29
|
* @returns Whether to write the manifest to disk.
|
|
31
30
|
*/
|
|
32
|
-
function getWriteManifest(
|
|
31
|
+
function getWriteManifest(options) {
|
|
33
32
|
if (typeof options.fix === 'boolean') {
|
|
34
33
|
return options.fix;
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return false;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Validates a snap.manifest.json file. Attempts to fix the manifest and write
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;
|
|
1
|
+
{"version":3,"file":"manifest.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AAEpD,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAE5C,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,YAAY,EAAE,8BAAoB;AAY3C,MAAM,KAAK,GAA2B;IACpC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CACpB,6BAA6B,KAAK,2DAA2D,CAC9F,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,+BAA+B;QACrC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YAC1C,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAEpD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;KACF;CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAwB;IAChD,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,OAAO,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAuB,EACvB,OAAwB;IAExB,MAAM,YAAY,CAAC,KAAK,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC3B,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport { manifest } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps } from '../../utils';\n\ntype ManifestOptions = {\n fix?: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n};\n\nconst steps: Steps<ManifestContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n throw new CommandError(\n `Manifest file not found: \"${input}\". Make sure that the \\`snap.manifest.json\\` file exists.`,\n );\n }\n },\n },\n {\n name: 'Validating the snap manifest.',\n task: async ({ input, options, spinner }) => {\n const write = getWriteManifest(options);\n const valid = await manifest(input, write, spinner);\n\n if (valid) {\n spinner.succeed('The snap manifest file is valid.');\n }\n },\n },\n];\n\n/**\n * Get whether to write the manifest to disk.\n *\n * @param options - The options object.\n * @returns Whether to write the manifest to disk.\n */\nfunction getWriteManifest(options: ManifestOptions) {\n if (typeof options.fix === 'boolean') {\n return options.fix;\n }\n\n return false;\n}\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function manifestHandler(\n config: ProcessedConfig,\n options: ManifestOptions,\n) {\n await executeSteps(steps, {\n input: config.manifest.path,\n config,\n options,\n });\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
const sandbox_1 = require("./sandbox.cjs");
|
|
7
|
+
const builders_1 = __importDefault(require("../../builders.cjs"));
|
|
8
|
+
const command = {
|
|
9
|
+
command: ['sandbox'],
|
|
10
|
+
desc: 'Start a sandbox server to interact with the Snap',
|
|
11
|
+
builder: (yarg) => {
|
|
12
|
+
yarg.option('build', builders_1.default.build);
|
|
13
|
+
},
|
|
14
|
+
handler: async (argv) => (0, sandbox_1.sandboxHandler)(argv.context.config, { build: argv.build }),
|
|
15
|
+
};
|
|
16
|
+
exports.default = command;
|
|
17
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/sandbox/index.ts"],"names":[],"mappings":";;;;;AAEA,2CAA2C;AAC3C,kEAAsC;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,IAAI,EAAE,kDAAkD;IACxD,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,kBAAQ,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,wBAAc,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;CAC7D,CAAC;AAEF,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { sandboxHandler } from './sandbox';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['sandbox'],\n desc: 'Start a sandbox server to interact with the Snap',\n builder: (yarg: yargs.Argv) => {\n yarg.option('build', builders.build);\n },\n handler: async (argv: YargsArgs) =>\n sandboxHandler(argv.context.config, { build: argv.build }),\n};\n\nexport default command;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type yargs from "yargs";
|
|
2
|
+
import type { YargsArgs } from "../../types/yargs.d.cjs";
|
|
3
|
+
declare const command: {
|
|
4
|
+
command: string[];
|
|
5
|
+
desc: string;
|
|
6
|
+
builder: (yarg: yargs.Argv) => void;
|
|
7
|
+
handler: (argv: YargsArgs) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export default command;
|
|
10
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/sandbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAEhC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type yargs from "yargs";
|
|
2
|
+
import type { YargsArgs } from "../../types/yargs.d.mjs";
|
|
3
|
+
declare const command: {
|
|
4
|
+
command: string[];
|
|
5
|
+
desc: string;
|
|
6
|
+
builder: (yarg: yargs.Argv) => void;
|
|
7
|
+
handler: (argv: YargsArgs) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export default command;
|
|
10
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/sandbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAEhC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { sandboxHandler } from "./sandbox.mjs";
|
|
2
|
+
import builders from "../../builders.mjs";
|
|
3
|
+
const command = {
|
|
4
|
+
command: ['sandbox'],
|
|
5
|
+
desc: 'Start a sandbox server to interact with the Snap',
|
|
6
|
+
builder: (yarg) => {
|
|
7
|
+
yarg.option('build', builders.build);
|
|
8
|
+
},
|
|
9
|
+
handler: async (argv) => sandboxHandler(argv.context.config, { build: argv.build }),
|
|
10
|
+
};
|
|
11
|
+
export default command;
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/sandbox/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,sBAAkB;AAC3C,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,IAAI,EAAE,kDAAkD;IACxD,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;CAC7D,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { sandboxHandler } from './sandbox';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['sandbox'],\n desc: 'Start a sandbox server to interact with the Snap',\n builder: (yarg: yargs.Argv) => {\n yarg.option('build', builders.build);\n },\n handler: async (argv: YargsArgs) =>\n sandboxHandler(argv.context.config, { build: argv.build }),\n};\n\nexport default command;\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sandboxHandler = void 0;
|
|
4
|
+
const server_1 = require("./server.cjs");
|
|
5
|
+
const utils_1 = require("../../utils/index.cjs");
|
|
6
|
+
const build_1 = require("../build/index.cjs");
|
|
7
|
+
const steps = [
|
|
8
|
+
...build_1.steps,
|
|
9
|
+
{
|
|
10
|
+
name: 'Running sandbox.',
|
|
11
|
+
task: async ({ config, spinner }) => {
|
|
12
|
+
const { port } = await (0, server_1.startSandbox)(config);
|
|
13
|
+
(0, utils_1.success)(`Sandbox running at http://localhost:${port}.`, spinner);
|
|
14
|
+
spinner.stop();
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Start the sandbox.
|
|
20
|
+
*
|
|
21
|
+
* @param config - The config object.
|
|
22
|
+
* @param options - The options object.
|
|
23
|
+
* @param options.build - Whether to build the Snap before starting the sandbox.
|
|
24
|
+
*/
|
|
25
|
+
async function sandboxHandler(config, { build = true }) {
|
|
26
|
+
await (0, utils_1.executeSteps)(steps, {
|
|
27
|
+
analyze: false,
|
|
28
|
+
build,
|
|
29
|
+
config,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.sandboxHandler = sandboxHandler;
|
|
33
|
+
//# sourceMappingURL=sandbox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.cjs","sourceRoot":"","sources":["../../../src/commands/sandbox/sandbox.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAGxC,iDAAoD;AACpD,8CAA+C;AAS/C,MAAM,KAAK,GAA0B;IACnC,GAAG,aAAU;IACb;QACE,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;YAC5C,IAAA,eAAO,EAAC,uCAAuC,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEjE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACF,CAAC;AAEF;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAClC,MAAuB,EACvB,EAAE,KAAK,GAAG,IAAI,EAAkB;IAEhC,MAAM,IAAA,oBAAY,EAAC,KAAK,EAAE;QACxB,OAAO,EAAE,KAAK;QACd,KAAK;QACL,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AATD,wCASC","sourcesContent":["import { startSandbox } from './server';\nimport type { ProcessedConfig } from '../../config';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps } from '../../utils';\nimport { steps as buildSteps } from '../build';\nimport type { BuildContext } from '../build/build';\n\ntype SandboxOptions = {\n build?: boolean;\n};\n\ntype SandboxContext = BuildContext;\n\nconst steps: Steps<SandboxContext> = [\n ...buildSteps,\n {\n name: 'Running sandbox.',\n task: async ({ config, spinner }) => {\n const { port } = await startSandbox(config);\n success(`Sandbox running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n];\n\n/**\n * Start the sandbox.\n *\n * @param config - The config object.\n * @param options - The options object.\n * @param options.build - Whether to build the Snap before starting the sandbox.\n */\nexport async function sandboxHandler(\n config: ProcessedConfig,\n { build = true }: SandboxOptions,\n) {\n await executeSteps(steps, {\n analyze: false,\n build,\n config,\n });\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProcessedConfig } from "../../config.cjs";
|
|
2
|
+
type SandboxOptions = {
|
|
3
|
+
build?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Start the sandbox.
|
|
7
|
+
*
|
|
8
|
+
* @param config - The config object.
|
|
9
|
+
* @param options - The options object.
|
|
10
|
+
* @param options.build - Whether to build the Snap before starting the sandbox.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sandboxHandler(config: ProcessedConfig, { build }: SandboxOptions): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=sandbox.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.cts","sourceRoot":"","sources":["../../../src/commands/sandbox/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAiBF;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,EAAE,KAAY,EAAE,EAAE,cAAc,iBAOjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProcessedConfig } from "../../config.mjs";
|
|
2
|
+
type SandboxOptions = {
|
|
3
|
+
build?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Start the sandbox.
|
|
7
|
+
*
|
|
8
|
+
* @param config - The config object.
|
|
9
|
+
* @param options - The options object.
|
|
10
|
+
* @param options.build - Whether to build the Snap before starting the sandbox.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sandboxHandler(config: ProcessedConfig, { build }: SandboxOptions): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=sandbox.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.mts","sourceRoot":"","sources":["../../../src/commands/sandbox/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAiBF;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,EAAE,KAAY,EAAE,EAAE,cAAc,iBAOjC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { startSandbox } from "./server.mjs";
|
|
2
|
+
import { success, executeSteps } from "../../utils/index.mjs";
|
|
3
|
+
import { steps as buildSteps } from "../build/index.mjs";
|
|
4
|
+
const steps = [
|
|
5
|
+
...buildSteps,
|
|
6
|
+
{
|
|
7
|
+
name: 'Running sandbox.',
|
|
8
|
+
task: async ({ config, spinner }) => {
|
|
9
|
+
const { port } = await startSandbox(config);
|
|
10
|
+
success(`Sandbox running at http://localhost:${port}.`, spinner);
|
|
11
|
+
spinner.stop();
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Start the sandbox.
|
|
17
|
+
*
|
|
18
|
+
* @param config - The config object.
|
|
19
|
+
* @param options - The options object.
|
|
20
|
+
* @param options.build - Whether to build the Snap before starting the sandbox.
|
|
21
|
+
*/
|
|
22
|
+
export async function sandboxHandler(config, { build = true }) {
|
|
23
|
+
await executeSteps(steps, {
|
|
24
|
+
analyze: false,
|
|
25
|
+
build,
|
|
26
|
+
config,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=sandbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.mjs","sourceRoot":"","sources":["../../../src/commands/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAiB;AAGxC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,8BAAoB;AACpD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,2BAAiB;AAS/C,MAAM,KAAK,GAA0B;IACnC,GAAG,UAAU;IACb;QACE,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;YAC5C,OAAO,CAAC,uCAAuC,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEjE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAuB,EACvB,EAAE,KAAK,GAAG,IAAI,EAAkB;IAEhC,MAAM,YAAY,CAAC,KAAK,EAAE;QACxB,OAAO,EAAE,KAAK;QACd,KAAK;QACL,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { startSandbox } from './server';\nimport type { ProcessedConfig } from '../../config';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps } from '../../utils';\nimport { steps as buildSteps } from '../build';\nimport type { BuildContext } from '../build/build';\n\ntype SandboxOptions = {\n build?: boolean;\n};\n\ntype SandboxContext = BuildContext;\n\nconst steps: Steps<SandboxContext> = [\n ...buildSteps,\n {\n name: 'Running sandbox.',\n task: async ({ config, spinner }) => {\n const { port } = await startSandbox(config);\n success(`Sandbox running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\n },\n },\n];\n\n/**\n * Start the sandbox.\n *\n * @param config - The config object.\n * @param options - The options object.\n * @param options.build - Whether to build the Snap before starting the sandbox.\n */\nexport async function sandboxHandler(\n config: ProcessedConfig,\n { build = true }: SandboxOptions,\n) {\n await executeSteps(steps, {\n analyze: false,\n build,\n config,\n });\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startSandbox = void 0;
|
|
4
|
+
const express_1 = require("express/index.js");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const webpack_1 = require("../../webpack/index.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* Start the sandbox.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The config object.
|
|
11
|
+
* @returns The server instance.
|
|
12
|
+
*/
|
|
13
|
+
async function startSandbox(config) {
|
|
14
|
+
const server = (0, webpack_1.getServer)(config, [
|
|
15
|
+
(app) => {
|
|
16
|
+
app.use('/__sandbox__', (0, express_1.static)((0, path_1.dirname)(require.resolve('@metamask/snaps-sandbox/dist/index.html'))));
|
|
17
|
+
app.get('/', (_request, response) => {
|
|
18
|
+
response.sendFile(require.resolve('@metamask/snaps-sandbox/dist/index.html'));
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
// If the `configPort` is `0`, the OS will choose a random port for us, so we
|
|
23
|
+
// need to get the port from the server after it starts.
|
|
24
|
+
return await server.listen(config.server.port);
|
|
25
|
+
}
|
|
26
|
+
exports.startSandbox = startSandbox;
|
|
27
|
+
//# sourceMappingURL=server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.cjs","sourceRoot":"","sources":["../../../src/commands/sandbox/server.ts"],"names":[],"mappings":";;;AAAA,8CAAkD;AAClD,+BAA+B;AAG/B,qDAA0C;AAE1C;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAAC,MAAuB;IACxD,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,MAAM,EAAE;QAC/B,CAAC,GAAG,EAAE,EAAE;YACN,GAAG,CAAC,GAAG,CACL,cAAc,EACd,IAAA,gBAAa,EACX,IAAA,cAAO,EAAC,OAAO,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC,CACpE,CACF,CAAC;YAEF,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;gBAClC,QAAQ,CAAC,QAAQ,CACf,OAAO,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAC3D,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AArBD,oCAqBC","sourcesContent":["import { static as expressStatic } from 'express';\nimport { dirname } from 'path';\n\nimport type { ProcessedConfig } from '../../config';\nimport { getServer } from '../../webpack';\n\n/**\n * Start the sandbox.\n *\n * @param config - The config object.\n * @returns The server instance.\n */\nexport async function startSandbox(config: ProcessedConfig) {\n const server = getServer(config, [\n (app) => {\n app.use(\n '/__sandbox__',\n expressStatic(\n dirname(require.resolve('@metamask/snaps-sandbox/dist/index.html')),\n ),\n );\n\n app.get('/', (_request, response) => {\n response.sendFile(\n require.resolve('@metamask/snaps-sandbox/dist/index.html'),\n );\n });\n },\n ]);\n\n // If the `configPort` is `0`, the OS will choose a random port for us, so we\n // need to get the port from the server after it starts.\n return await server.listen(config.server.port);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ProcessedConfig } from "../../config.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Start the sandbox.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The config object.
|
|
7
|
+
* @returns The server instance.
|
|
8
|
+
*/
|
|
9
|
+
export declare function startSandbox(config: ProcessedConfig): Promise<{
|
|
10
|
+
port: number;
|
|
11
|
+
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
12
|
+
close: () => Promise<void>;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=server.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.cts","sourceRoot":"","sources":["../../../src/commands/sandbox/server.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAGpD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,eAAe;;;;GAqBzD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ProcessedConfig } from "../../config.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Start the sandbox.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The config object.
|
|
7
|
+
* @returns The server instance.
|
|
8
|
+
*/
|
|
9
|
+
export declare function startSandbox(config: ProcessedConfig): Promise<{
|
|
10
|
+
port: number;
|
|
11
|
+
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
12
|
+
close: () => Promise<void>;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["../../../src/commands/sandbox/server.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAGpD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,eAAe;;;;GAqBzD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as $createRequire } from "module";
|
|
2
|
+
const $require = $createRequire(import.meta.url);
|
|
3
|
+
import { static as expressStatic } from "express/index.js";
|
|
4
|
+
import { dirname } from "path";
|
|
5
|
+
import { getServer } from "../../webpack/index.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Start the sandbox.
|
|
8
|
+
*
|
|
9
|
+
* @param config - The config object.
|
|
10
|
+
* @returns The server instance.
|
|
11
|
+
*/
|
|
12
|
+
export async function startSandbox(config) {
|
|
13
|
+
const server = getServer(config, [
|
|
14
|
+
(app) => {
|
|
15
|
+
app.use('/__sandbox__', expressStatic(dirname($require.resolve('@metamask/snaps-sandbox/dist/index.html'))));
|
|
16
|
+
app.get('/', (_request, response) => {
|
|
17
|
+
response.sendFile($require.resolve('@metamask/snaps-sandbox/dist/index.html'));
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
// If the `configPort` is `0`, the OS will choose a random port for us, so we
|
|
22
|
+
// need to get the port from the server after it starts.
|
|
23
|
+
return await server.listen(config.server.port);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["../../../src/commands/sandbox/server.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,yBAAgB;AAClD,OAAO,EAAE,OAAO,EAAE,aAAa;AAG/B,OAAO,EAAE,SAAS,EAAE,gCAAsB;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAuB;IACxD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE;QAC/B,CAAC,GAAG,EAAE,EAAE;YACN,GAAG,CAAC,GAAG,CACL,cAAc,EACd,aAAa,CACX,OAAO,kBAAiB,yCAAyC,EAAE,CACpE,CACF,CAAC;YAEF,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;gBAClC,QAAQ,CAAC,QAAQ,kBACC,yCAAyC,EAC1D,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { static as expressStatic } from 'express';\nimport { dirname } from 'path';\n\nimport type { ProcessedConfig } from '../../config';\nimport { getServer } from '../../webpack';\n\n/**\n * Start the sandbox.\n *\n * @param config - The config object.\n * @returns The server instance.\n */\nexport async function startSandbox(config: ProcessedConfig) {\n const server = getServer(config, [\n (app) => {\n app.use(\n '/__sandbox__',\n expressStatic(\n dirname(require.resolve('@metamask/snaps-sandbox/dist/index.html')),\n ),\n );\n\n app.get('/', (_request, response) => {\n response.sendFile(\n require.resolve('@metamask/snaps-sandbox/dist/index.html'),\n );\n });\n },\n ]);\n\n // If the `configPort` is `0`, the OS will choose a random port for us, so we\n // need to get the port from the server after it starts.\n return await server.listen(config.server.port);\n}\n"]}
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const builders_1 = __importDefault(require("../../builders.cjs"));
|
|
7
6
|
const serve_1 = require("./serve.cjs");
|
|
7
|
+
const builders_1 = __importDefault(require("../../builders.cjs"));
|
|
8
8
|
const command = {
|
|
9
9
|
command: ['serve', 's'],
|
|
10
10
|
desc: 'Locally serve Snap file(s) for testing',
|
|
11
11
|
builder: (yarg) => {
|
|
12
|
-
yarg.option('
|
|
12
|
+
yarg.option('port', builders_1.default.port);
|
|
13
13
|
},
|
|
14
14
|
handler: async (argv) => (0, serve_1.serveHandler)(argv.context.config, {
|
|
15
15
|
port: argv.port ?? argv.context.config.server.port,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":";;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":";;;;;AAEA,uCAAuC;AACvC,kEAAsC;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wCAAwC;IAC9C,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI;KACnD,CAAC;CACL,CAAC;AAEF,kBAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { serveHandler } from './serve';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['serve', 's'],\n desc: 'Locally serve Snap file(s) for testing',\n builder: (yarg: yargs.Argv) => {\n yarg.option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n serveHandler(argv.context.config, {\n port: argv.port ?? argv.context.config.server.port,\n }),\n};\n\nexport default command;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAIhC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAGJ,SAAS;CAIhC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import builders from "../../builders.mjs";
|
|
2
1
|
import { serveHandler } from "./serve.mjs";
|
|
2
|
+
import builders from "../../builders.mjs";
|
|
3
3
|
const command = {
|
|
4
4
|
command: ['serve', 's'],
|
|
5
5
|
desc: 'Locally serve Snap file(s) for testing',
|
|
6
6
|
builder: (yarg) => {
|
|
7
|
-
yarg.option('
|
|
7
|
+
yarg.option('port', builders.port);
|
|
8
8
|
},
|
|
9
9
|
handler: async (argv) => serveHandler(argv.context.config, {
|
|
10
10
|
port: argv.port ?? argv.context.config.server.port,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/commands/serve/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAgB;AACvC,OAAO,QAAQ,2BAAuB;AAGtC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,IAAI,EAAE,wCAAwC;IAC9C,OAAO,EAAE,CAAC,IAAgB,EAAE,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI;KACnD,CAAC;CACL,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import type yargs from 'yargs';\n\nimport { serveHandler } from './serve';\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\n\nconst command = {\n command: ['serve', 's'],\n desc: 'Locally serve Snap file(s) for testing',\n builder: (yarg: yargs.Argv) => {\n yarg.option('port', builders.port);\n },\n handler: async (argv: YargsArgs) =>\n serveHandler(argv.context.config, {\n port: argv.port ?? argv.context.config.server.port,\n }),\n};\n\nexport default command;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.watch = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
4
5
|
const path_1 = require("path");
|
|
5
6
|
const webpack_1 = require("../../webpack/index.cjs");
|
|
6
7
|
/**
|
|
@@ -30,6 +31,7 @@ async function watch(config, options) {
|
|
|
30
31
|
reject(watchError);
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
34
|
+
(0, utils_1.assert)(compiler.watching, 'Expected `compiler.watching` to be set.');
|
|
33
35
|
resolve(compiler.watching);
|
|
34
36
|
});
|
|
35
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":";;;AAAA,+BAAgC;AAKhC,qDAA4C;AAE5C;;;;;;;;;GASG;AACI,KAAK,UAAU,KAAK,
|
|
1
|
+
{"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,+BAAgC;AAKhC,qDAA4C;AAE5C;;;;;;;;;GASG;AACI,KAAK,UAAU,KAAK,CAAC,MAAuB,EAAE,OAAwB;IAC3E,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,QAAQ,CAAC,KAAK,CACZ;YACE,OAAO,EAAE;gBACP,sBAAsB;gBACtB,MAAM,IAAA,eAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;aAC1C;SACF,EACD,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,IAAA,cAAM,EAAC,QAAQ,CAAC,QAAQ,EAAE,yCAAyC,CAAC,CAAC;YACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,sBA0BC","sourcesContent":["import { assert } from '@metamask/utils';\nimport { basename } from 'path';\nimport type { Watching } from 'webpack';\n\nimport type { ProcessedConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle and watch for changes. This uses Webpack to build the\n * bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built for the first time.\n * The promise resolves with a Webpack watching instance that can be used to\n * close the watcher.\n */\nexport async function watch(config: ProcessedConfig, options?: WebpackOptions) {\n const compiler = await getCompiler(config, {\n evaluate: config.evaluate,\n watch: true,\n spinner: options?.spinner,\n });\n\n return new Promise<Watching>((resolve, reject) => {\n compiler.watch(\n {\n ignored: [\n '**/node_modules/**/*',\n `**/${basename(config.output.path)}/**/*`,\n ],\n },\n (watchError) => {\n if (watchError) {\n reject(watchError);\n return;\n }\n\n assert(compiler.watching, 'Expected `compiler.watching` to be set.');\n resolve(compiler.watching);\n },\n );\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Watching } from "webpack";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProcessedConfig } from "../../config.cjs";
|
|
3
3
|
import type { WebpackOptions } from "../../webpack/index.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* Build the snap bundle and watch for changes. This uses Webpack to build the
|
|
@@ -11,5 +11,5 @@ import type { WebpackOptions } from "../../webpack/index.cjs";
|
|
|
11
11
|
* The promise resolves with a Webpack watching instance that can be used to
|
|
12
12
|
* close the watcher.
|
|
13
13
|
*/
|
|
14
|
-
export declare function watch(config:
|
|
14
|
+
export declare function watch(config: ProcessedConfig, options?: WebpackOptions): Promise<Watching>;
|
|
15
15
|
//# sourceMappingURL=implementation.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBA0B5E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Watching } from "webpack";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProcessedConfig } from "../../config.mjs";
|
|
3
3
|
import type { WebpackOptions } from "../../webpack/index.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Build the snap bundle and watch for changes. This uses Webpack to build the
|
|
@@ -11,5 +11,5 @@ import type { WebpackOptions } from "../../webpack/index.mjs";
|
|
|
11
11
|
* The promise resolves with a Webpack watching instance that can be used to
|
|
12
12
|
* close the watcher.
|
|
13
13
|
*/
|
|
14
|
-
export declare function watch(config:
|
|
14
|
+
export declare function watch(config: ProcessedConfig, options?: WebpackOptions): Promise<Watching>;
|
|
15
15
|
//# sourceMappingURL=implementation.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/watch/implementation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,qBA0B5E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "@metamask/utils";
|
|
1
2
|
import { basename } from "path";
|
|
2
3
|
import { getCompiler } from "../../webpack/index.mjs";
|
|
3
4
|
/**
|
|
@@ -27,6 +28,7 @@ export async function watch(config, options) {
|
|
|
27
28
|
reject(watchError);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
31
|
+
assert(compiler.watching, 'Expected `compiler.watching` to be set.');
|
|
30
32
|
resolve(compiler.watching);
|
|
31
33
|
});
|
|
32
34
|
});
|