@metamask/snaps-cli 7.0.0 → 7.2.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 +22 -1
- package/README.md +1 -0
- package/dist/builders.cjs +9 -0
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +9 -0
- package/dist/builders.d.cts.map +1 -1
- package/dist/builders.d.mts +9 -0
- package/dist/builders.d.mts.map +1 -1
- package/dist/builders.mjs +9 -0
- package/dist/builders.mjs.map +1 -1
- package/dist/commands/build/build.cjs +12 -23
- package/dist/commands/build/build.cjs.map +1 -1
- package/dist/commands/build/build.d.cts +9 -0
- package/dist/commands/build/build.d.cts.map +1 -1
- package/dist/commands/build/build.d.mts +9 -0
- package/dist/commands/build/build.d.mts.map +1 -1
- package/dist/commands/build/build.mjs +11 -22
- 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.map +1 -1
- 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 +4 -2
- 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 +2 -2
- package/dist/commands/build/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/implementation.cjs +8 -4
- package/dist/commands/manifest/implementation.cjs.map +1 -1
- package/dist/commands/manifest/implementation.d.cts +2 -1
- package/dist/commands/manifest/implementation.d.cts.map +1 -1
- package/dist/commands/manifest/implementation.d.mts +2 -1
- package/dist/commands/manifest/implementation.d.mts.map +1 -1
- package/dist/commands/manifest/implementation.mjs +8 -4
- package/dist/commands/manifest/implementation.mjs.map +1 -1
- package/dist/commands/manifest/index.cjs +5 -1
- 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 +5 -1
- package/dist/commands/manifest/index.mjs.map +1 -1
- package/dist/commands/manifest/manifest.cjs +20 -4
- package/dist/commands/manifest/manifest.cjs.map +1 -1
- package/dist/commands/manifest/manifest.d.cts +1 -0
- package/dist/commands/manifest/manifest.d.cts.map +1 -1
- package/dist/commands/manifest/manifest.d.mts +1 -0
- package/dist/commands/manifest/manifest.d.mts.map +1 -1
- package/dist/commands/manifest/manifest.mjs +21 -5
- 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/watch/watch.cjs +1 -1
- package/dist/commands/watch/watch.cjs.map +1 -1
- package/dist/commands/watch/watch.mjs +1 -1
- package/dist/commands/watch/watch.mjs.map +1 -1
- package/dist/webpack/config.cjs +1 -1
- package/dist/webpack/config.cjs.map +1 -1
- package/dist/webpack/config.d.cts.map +1 -1
- package/dist/webpack/config.d.mts.map +1 -1
- package/dist/webpack/config.mjs +1 -1
- package/dist/webpack/config.mjs.map +1 -1
- package/dist/webpack/plugins.cjs +2 -2
- package/dist/webpack/plugins.cjs.map +1 -1
- package/dist/webpack/plugins.d.cts.map +1 -1
- package/dist/webpack/plugins.d.mts.map +1 -1
- package/dist/webpack/plugins.mjs +2 -2
- 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/package.json +11 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.manifest = void 0;
|
|
4
|
+
const snaps_rpc_methods_1 = require("@metamask/snaps-rpc-methods");
|
|
4
5
|
const node_1 = require("@metamask/snaps-utils/node");
|
|
5
6
|
const snaps_webpack_plugin_1 = require("@metamask/snaps-webpack-plugin");
|
|
6
7
|
const utils_1 = require("@metamask/utils");
|
|
@@ -15,11 +16,14 @@ const utils_2 = require("../../utils/index.cjs");
|
|
|
15
16
|
*
|
|
16
17
|
* @param path - The path to the manifest file.
|
|
17
18
|
* @param write - Whether to write the manifest to disk if it is invalid.
|
|
19
|
+
* @param exports - The exports to check in the manifest.
|
|
18
20
|
* @param spinner - An optional spinner to use for logging.
|
|
19
21
|
* @returns Whether the manifest is valid.
|
|
20
22
|
*/
|
|
21
|
-
async function manifest(path, write, spinner) {
|
|
23
|
+
async function manifest(path, write, exports, spinner) {
|
|
22
24
|
const { reports, updated } = await (0, node_1.checkManifest)((0, path_1.dirname)(path), {
|
|
25
|
+
exports,
|
|
26
|
+
handlerEndowments: snaps_rpc_methods_1.handlerEndowments,
|
|
23
27
|
updateAndWriteManifest: write,
|
|
24
28
|
writeFileFn: snaps_webpack_plugin_1.writeManifest,
|
|
25
29
|
});
|
|
@@ -40,7 +44,7 @@ async function manifest(path, write, spinner) {
|
|
|
40
44
|
}
|
|
41
45
|
if (errors.length > 0) {
|
|
42
46
|
const formattedErrors = errors.join('\n');
|
|
43
|
-
let message = `The
|
|
47
|
+
let message = `The Snap manifest file is invalid.\n\n${formattedErrors}`;
|
|
44
48
|
if (!write) {
|
|
45
49
|
message +=
|
|
46
50
|
'\n\nRun the command with the `--fix` flag to attempt to fix the manifest.';
|
|
@@ -49,11 +53,11 @@ async function manifest(path, write, spinner) {
|
|
|
49
53
|
}
|
|
50
54
|
if (write && updated) {
|
|
51
55
|
const formattedFixed = fixed.join('\n');
|
|
52
|
-
(0, utils_2.info)(`The
|
|
56
|
+
(0, utils_2.info)(`The Snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
|
|
53
57
|
}
|
|
54
58
|
if (warnings.length > 0) {
|
|
55
59
|
const formattedWarnings = warnings.join('\n');
|
|
56
|
-
(0, utils_2.warn)(`The
|
|
60
|
+
(0, utils_2.warn)(`The Snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
|
|
57
61
|
}
|
|
58
62
|
if (errors.length > 0) {
|
|
59
63
|
spinner?.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[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,IAAA,cAAM,EAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,IAAA,cAAM,EAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,yCAAyC,eAAe,EAAE,CAAC;QACzE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,2EAA2E,CAAC;QAChF,CAAC;QAED,IAAA,aAAK,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAA,YAAI,EACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAA,YAAI,EACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA/DD,4BA+DC","sourcesContent":["import { handlerEndowments } from '@metamask/snaps-rpc-methods';\nimport { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param exports - The exports to check in the manifest.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n exports?: string[],\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n exports,\n handlerEndowments,\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The Snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The Snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The Snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
|
|
@@ -7,8 +7,9 @@ import type { Ora } from "ora/index.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param path - The path to the manifest file.
|
|
9
9
|
* @param write - Whether to write the manifest to disk if it is invalid.
|
|
10
|
+
* @param exports - The exports to check in the manifest.
|
|
10
11
|
* @param spinner - An optional spinner to use for logging.
|
|
11
12
|
* @returns Whether the manifest is valid.
|
|
12
13
|
*/
|
|
13
|
-
export declare function manifest(path: string, write: boolean, spinner?: Ora): Promise<boolean>;
|
|
14
|
+
export declare function manifest(path: string, write: boolean, exports?: string[], spinner?: Ora): Promise<boolean>;
|
|
14
15
|
//# sourceMappingURL=implementation.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
|
|
@@ -7,8 +7,9 @@ import type { Ora } from "ora/index.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param path - The path to the manifest file.
|
|
9
9
|
* @param write - Whether to write the manifest to disk if it is invalid.
|
|
10
|
+
* @param exports - The exports to check in the manifest.
|
|
10
11
|
* @param spinner - An optional spinner to use for logging.
|
|
11
12
|
* @returns Whether the manifest is valid.
|
|
12
13
|
*/
|
|
13
|
-
export declare function manifest(path: string, write: boolean, spinner?: Ora): Promise<boolean>;
|
|
14
|
+
export declare function manifest(path: string, write: boolean, exports?: string[], spinner?: Ora): Promise<boolean>;
|
|
14
15
|
//# sourceMappingURL=implementation.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAK/B;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { handlerEndowments } from "@metamask/snaps-rpc-methods";
|
|
1
2
|
import { checkManifest, indent } from "@metamask/snaps-utils/node";
|
|
2
3
|
import { writeManifest } from "@metamask/snaps-webpack-plugin";
|
|
3
4
|
import { assert } from "@metamask/utils";
|
|
@@ -13,11 +14,14 @@ import { error, info, warn } from "../../utils/index.mjs";
|
|
|
13
14
|
*
|
|
14
15
|
* @param path - The path to the manifest file.
|
|
15
16
|
* @param write - Whether to write the manifest to disk if it is invalid.
|
|
17
|
+
* @param exports - The exports to check in the manifest.
|
|
16
18
|
* @param spinner - An optional spinner to use for logging.
|
|
17
19
|
* @returns Whether the manifest is valid.
|
|
18
20
|
*/
|
|
19
|
-
export async function manifest(path, write, spinner) {
|
|
21
|
+
export async function manifest(path, write, exports, spinner) {
|
|
20
22
|
const { reports, updated } = await checkManifest(dirname(path), {
|
|
23
|
+
exports,
|
|
24
|
+
handlerEndowments,
|
|
21
25
|
updateAndWriteManifest: write,
|
|
22
26
|
writeFileFn: writeManifest,
|
|
23
27
|
});
|
|
@@ -38,7 +42,7 @@ export async function manifest(path, write, spinner) {
|
|
|
38
42
|
}
|
|
39
43
|
if (errors.length > 0) {
|
|
40
44
|
const formattedErrors = errors.join('\n');
|
|
41
|
-
let message = `The
|
|
45
|
+
let message = `The Snap manifest file is invalid.\n\n${formattedErrors}`;
|
|
42
46
|
if (!write) {
|
|
43
47
|
message +=
|
|
44
48
|
'\n\nRun the command with the `--fix` flag to attempt to fix the manifest.';
|
|
@@ -47,11 +51,11 @@ export async function manifest(path, write, spinner) {
|
|
|
47
51
|
}
|
|
48
52
|
if (write && updated) {
|
|
49
53
|
const formattedFixed = fixed.join('\n');
|
|
50
|
-
info(`The
|
|
54
|
+
info(`The Snap manifest file has been updated.\n\n${formattedFixed}`, spinner);
|
|
51
55
|
}
|
|
52
56
|
if (warnings.length > 0) {
|
|
53
57
|
const formattedWarnings = warnings.join('\n');
|
|
54
|
-
warn(`The
|
|
58
|
+
warn(`The Snap manifest file has warnings.\n\n${formattedWarnings}`, spinner);
|
|
55
59
|
}
|
|
56
60
|
if (errors.length > 0) {
|
|
57
61
|
spinner?.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mCAAmC;AACnE,OAAO,EAAE,aAAa,EAAE,uCAAuC;AAC/D,OAAO,EAAE,MAAM,EAAE,wBAAwB;;;AAGzC,OAAO,EAAE,OAAO,EAAE,aAAa;AAE/B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,8BAAoB;AAEhD
|
|
1
|
+
{"version":3,"file":"implementation.mjs","sourceRoot":"","sources":["../../../src/commands/manifest/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oCAAoC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mCAAmC;AACnE,OAAO,EAAE,aAAa,EAAE,uCAAuC;AAC/D,OAAO,EAAE,MAAM,EAAE,wBAAwB;;;AAGzC,OAAO,EAAE,OAAO,EAAE,aAAa;AAE/B,OAAO,EAAE,KAAK,EAAE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AAI,OAAO,GAAG,yCAAyC,eAAe,EAAE,CAAC;QACzE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,2EAA2E,CAAC;QAChF,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CACF,+CAA+C,cAAc,EAAE,EAC/D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,CACF,2CAA2C,iBAAiB,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { handlerEndowments } from '@metamask/snaps-rpc-methods';\nimport { checkManifest, indent } from '@metamask/snaps-utils/node';\nimport { writeManifest } from '@metamask/snaps-webpack-plugin';\nimport { assert } from '@metamask/utils';\nimport { red, yellow, green } from 'chalk';\nimport type { Ora } from 'ora';\nimport { dirname } from 'path';\n\nimport { error, info, warn } from '../../utils';\n\n/**\n * Check the snap manifest file at the given path. If `write` is `true`, the\n * manifest will be written to disk if it is invalid. If `write` is `false`,\n * the manifest will not be written to disk, and the function will log any\n * errors and warnings to the console.\n *\n * @param path - The path to the manifest file.\n * @param write - Whether to write the manifest to disk if it is invalid.\n * @param exports - The exports to check in the manifest.\n * @param spinner - An optional spinner to use for logging.\n * @returns Whether the manifest is valid.\n */\nexport async function manifest(\n path: string,\n write: boolean,\n exports?: string[],\n spinner?: Ora,\n): Promise<boolean> {\n const { reports, updated } = await checkManifest(dirname(path), {\n exports,\n handlerEndowments,\n updateAndWriteManifest: write,\n writeFileFn: writeManifest,\n });\n\n const errors = [];\n const fixed = [];\n const warnings = [];\n\n for (const report of reports) {\n if (report.severity === 'error' && !report.wasFixed) {\n errors.push(indent(red(`• ${report.message}`)));\n } else if (report.wasFixed) {\n fixed.push(indent(yellow(`• ${report.message}`) + green(' (fixed)')));\n } else {\n assert(report.severity === 'warning');\n warnings.push(indent(yellow(`• ${report.message}`)));\n }\n }\n\n if (errors.length > 0) {\n const formattedErrors = errors.join('\\n');\n let message = `The Snap manifest file is invalid.\\n\\n${formattedErrors}`;\n if (!write) {\n message +=\n '\\n\\nRun the command with the `--fix` flag to attempt to fix the manifest.';\n }\n\n error(message, spinner);\n }\n\n if (write && updated) {\n const formattedFixed = fixed.join('\\n');\n info(\n `The Snap manifest file has been updated.\\n\\n${formattedFixed}`,\n spinner,\n );\n }\n\n if (warnings.length > 0) {\n const formattedWarnings = warnings.join('\\n');\n\n warn(\n `The Snap manifest file has warnings.\\n\\n${formattedWarnings}`,\n spinner,\n );\n }\n\n if (errors.length > 0) {\n spinner?.stop();\n process.exitCode = 1;\n return false;\n }\n\n return true;\n}\n"]}
|
|
@@ -24,8 +24,12 @@ const command = {
|
|
|
24
24
|
desc: 'Validate the snap.manifest.json file',
|
|
25
25
|
builder: (yarg) => {
|
|
26
26
|
yarg.option('fix', builders_1.default.fix);
|
|
27
|
+
yarg.option('eval', builders_1.default.eval);
|
|
27
28
|
},
|
|
28
|
-
handler: async (argv) => (0, manifest_1.manifestHandler)(argv.context.config, {
|
|
29
|
+
handler: async (argv) => (0, manifest_1.manifestHandler)(argv.context.config, {
|
|
30
|
+
fix: argv.fix,
|
|
31
|
+
eval: argv.eval ?? argv.context.config.evaluate,
|
|
32
|
+
}),
|
|
29
33
|
};
|
|
30
34
|
__exportStar(require("./implementation.cjs"), exports);
|
|
31
35
|
exports.default = command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,6CAA6C;AAC7C,kEAAsC;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,kBAAQ,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,6CAA6C;AAC7C,kEAAsC;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,kBAAQ,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,IAAA,0BAAe,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ;KAChD,CAAC;CACL,CAAC;AAEF,uDAAiC;AACjC,kBAAe,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 yarg.option('eval', builders.eval);\n },\n handler: async (argv: YargsArgs) =>\n manifestHandler(argv.context.config, {\n fix: argv.fix,\n eval: argv.eval ?? argv.context.config.evaluate,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAIJ,SAAS;CAKhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/commands/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAA0B;AAEnD,QAAA,MAAM,OAAO;;;oBAGK,MAAM,IAAI;oBAIJ,SAAS;CAKhC,CAAC;AAEF,qCAAiC;AACjC,eAAe,OAAO,CAAC"}
|
|
@@ -5,8 +5,12 @@ const command = {
|
|
|
5
5
|
desc: 'Validate the snap.manifest.json file',
|
|
6
6
|
builder: (yarg) => {
|
|
7
7
|
yarg.option('fix', builders.fix);
|
|
8
|
+
yarg.option('eval', builders.eval);
|
|
8
9
|
},
|
|
9
|
-
handler: async (argv) => manifestHandler(argv.context.config, {
|
|
10
|
+
handler: async (argv) => manifestHandler(argv.context.config, {
|
|
11
|
+
fix: argv.fix,
|
|
12
|
+
eval: argv.eval ?? argv.context.config.evaluate,
|
|
13
|
+
}),
|
|
10
14
|
};
|
|
11
15
|
export * from "./implementation.mjs";
|
|
12
16
|
export default command;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,CACjC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ;KAChD,CAAC;CACL,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 yarg.option('eval', builders.eval);\n },\n handler: async (argv: YargsArgs) =>\n manifestHandler(argv.context.config, {\n fix: argv.fix,\n eval: argv.eval ?? argv.context.config.evaluate,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
|
|
@@ -2,9 +2,11 @@
|
|
|
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 path_1 = require("path");
|
|
5
6
|
const implementation_1 = require("./implementation.cjs");
|
|
6
7
|
const errors_1 = require("../../errors.cjs");
|
|
7
8
|
const utils_1 = require("../../utils/index.cjs");
|
|
9
|
+
const eval_1 = require("../eval/index.cjs");
|
|
8
10
|
const steps = [
|
|
9
11
|
{
|
|
10
12
|
name: 'Checking the input file.',
|
|
@@ -15,12 +17,26 @@ const steps = [
|
|
|
15
17
|
},
|
|
16
18
|
},
|
|
17
19
|
{
|
|
18
|
-
name: '
|
|
19
|
-
|
|
20
|
+
name: 'Evaluating the Snap bundle.',
|
|
21
|
+
condition: ({ options }) => options.eval,
|
|
22
|
+
task: async (context) => {
|
|
23
|
+
const { config, spinner } = context;
|
|
24
|
+
const path = (0, path_1.resolve)(process.cwd(), config.output.path, config.output.filename);
|
|
25
|
+
const { exports } = await (0, eval_1.evaluate)(path);
|
|
26
|
+
(0, utils_1.info)(`Snap bundle evaluated successfully.`, spinner);
|
|
27
|
+
return {
|
|
28
|
+
...context,
|
|
29
|
+
exports,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Validating the Snap manifest.',
|
|
35
|
+
task: async ({ input, options, exports, spinner }) => {
|
|
20
36
|
const write = getWriteManifest(options);
|
|
21
|
-
const valid = await (0, implementation_1.manifest)(input, write, spinner);
|
|
37
|
+
const valid = await (0, implementation_1.manifest)(input, write, exports, spinner);
|
|
22
38
|
if (valid) {
|
|
23
|
-
spinner.succeed('The
|
|
39
|
+
spinner.succeed('The Snap manifest file is valid.');
|
|
24
40
|
}
|
|
25
41
|
},
|
|
26
42
|
},
|
|
@@ -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;AACpD,+BAA+B;AAE/B,yDAA4C;AAE5C,6CAA4C;AAE5C,iDAAiD;AACjD,4CAAmC;AAcnC,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,6BAA6B;QACnC,SAAS,EA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,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';\nimport { resolve } from 'path';\n\nimport { manifest } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { info, executeSteps } from '../../utils';\nimport { evaluate } from '../eval';\n\ntype ManifestOptions = {\n fix?: boolean;\n eval: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n exports?: string[];\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: 'Evaluating the Snap bundle.',\n condition: ({ options }) => options.eval,\n task: async (context) => {\n const { config, spinner } = context;\n const path = resolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n const { exports } = await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n\n return {\n ...context,\n exports,\n };\n },\n },\n {\n name: 'Validating the Snap manifest.',\n task: async ({ input, options, exports, spinner }) => {\n const write = getWriteManifest(options);\n const valid = await manifest(input, write, exports, 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":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAoEF;;;;;;;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":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAMpD,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAoEF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,iBAOzB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isFile } from "@metamask/snaps-utils/node";
|
|
2
|
+
import { resolve } from "path";
|
|
2
3
|
import { manifest } from "./implementation.mjs";
|
|
3
4
|
import { CommandError } from "../../errors.mjs";
|
|
4
|
-
import { executeSteps } from "../../utils/index.mjs";
|
|
5
|
+
import { info, executeSteps } from "../../utils/index.mjs";
|
|
6
|
+
import { evaluate } from "../eval/index.mjs";
|
|
5
7
|
const steps = [
|
|
6
8
|
{
|
|
7
9
|
name: 'Checking the input file.',
|
|
@@ -12,12 +14,26 @@ const steps = [
|
|
|
12
14
|
},
|
|
13
15
|
},
|
|
14
16
|
{
|
|
15
|
-
name: '
|
|
16
|
-
|
|
17
|
+
name: 'Evaluating the Snap bundle.',
|
|
18
|
+
condition: ({ options }) => options.eval,
|
|
19
|
+
task: async (context) => {
|
|
20
|
+
const { config, spinner } = context;
|
|
21
|
+
const path = resolve(process.cwd(), config.output.path, config.output.filename);
|
|
22
|
+
const { exports } = await evaluate(path);
|
|
23
|
+
info(`Snap bundle evaluated successfully.`, spinner);
|
|
24
|
+
return {
|
|
25
|
+
...context,
|
|
26
|
+
exports,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'Validating the Snap manifest.',
|
|
32
|
+
task: async ({ input, options, exports, spinner }) => {
|
|
17
33
|
const write = getWriteManifest(options);
|
|
18
|
-
const valid = await manifest(input, write, spinner);
|
|
34
|
+
const valid = await manifest(input, write, exports, spinner);
|
|
19
35
|
if (valid) {
|
|
20
|
-
spinner.succeed('The
|
|
36
|
+
spinner.succeed('The Snap manifest file is valid.');
|
|
21
37
|
}
|
|
22
38
|
},
|
|
23
39
|
},
|
|
@@ -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;AACpD,OAAO,EAAE,OAAO,EAAE,aAAa;AAE/B,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAE5C,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,IAAI,EAAE,YAAY,EA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AC,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';\nimport { resolve } from 'path';\n\nimport { manifest } from './implementation';\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { info, executeSteps } from '../../utils';\nimport { evaluate } from '../eval';\n\ntype ManifestOptions = {\n fix?: boolean;\n eval: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n exports?: string[];\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: 'Evaluating the Snap bundle.',\n condition: ({ options }) => options.eval,\n task: async (context) => {\n const { config, spinner } = context;\n const path = resolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n const { exports } = await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n\n return {\n ...context,\n exports,\n };\n },\n },\n {\n name: 'Validating the Snap manifest.',\n task: async ({ input, options, exports, spinner }) => {\n const write = getWriteManifest(options);\n const valid = await manifest(input, write, exports, 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
|