@metamask/snaps-cli 0.11.0 → 0.13.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 +16 -1
- package/dist/cli.js +1 -4
- package/dist/cli.js.map +1 -1
- package/dist/cmds/build/bundle.d.ts +1 -0
- package/dist/cmds/build/bundle.js +5 -1
- package/dist/cmds/build/bundle.js.map +1 -1
- package/dist/cmds/build/utils.d.ts +2 -18
- package/dist/cmds/build/utils.js +4 -66
- package/dist/cmds/build/utils.js.map +1 -1
- package/dist/cmds/eval/mock.d.ts +1 -0
- package/dist/cmds/eval/mock.js +4 -3
- package/dist/cmds/eval/mock.js.map +1 -1
- package/dist/cmds/init/initUtils.js +1 -0
- package/dist/cmds/init/initUtils.js.map +1 -1
- package/dist/utils/readline.d.ts +1 -0
- package/dist/utils/readline.js +5 -1
- package/dist/utils/readline.js.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.13.0]
|
|
10
|
+
### Changed
|
|
11
|
+
- No changes this release.
|
|
12
|
+
|
|
13
|
+
## [0.12.0]
|
|
14
|
+
### Changed
|
|
15
|
+
- No changes this release.
|
|
16
|
+
|
|
17
|
+
## [0.11.1]
|
|
18
|
+
### Changed
|
|
19
|
+
- No changes this release.
|
|
20
|
+
|
|
9
21
|
## [0.11.0]
|
|
10
22
|
### Added
|
|
11
23
|
- Add self to mock endowments ([#341](https://github.com/MetaMask/snaps-skunkworks/pull/341))
|
|
@@ -161,7 +173,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
161
173
|
- Example snaps ([#72](https://github.com/MetaMask/snaps-skunkworks/pull/72))
|
|
162
174
|
- The examples now live in their own package, [`@metamask/snap-examples`](https://npmjs.com/package/@metamask/snap-examples).
|
|
163
175
|
|
|
164
|
-
[Unreleased]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.
|
|
176
|
+
[Unreleased]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.13.0...HEAD
|
|
177
|
+
[0.13.0]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.12.0...v0.13.0
|
|
178
|
+
[0.12.0]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.11.1...v0.12.0
|
|
179
|
+
[0.11.1]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.11.0...v0.11.1
|
|
165
180
|
[0.11.0]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.10.7...v0.11.0
|
|
166
181
|
[0.10.7]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.10.6...v0.10.7
|
|
167
182
|
[0.10.6]: https://github.com/MetaMask/snaps-skunkworks/compare/v0.10.5...v0.10.6
|
package/dist/cli.js
CHANGED
|
@@ -32,10 +32,7 @@ function cli(argv, commands) {
|
|
|
32
32
|
(0, utils_1.sanitizeInputs)(yargsArgv);
|
|
33
33
|
}), true)
|
|
34
34
|
.fail((msg, err, _yargs) => {
|
|
35
|
-
|
|
36
|
-
if ((err === null || err === void 0 ? void 0 : err.stack) && global.snaps.verboseErrors) {
|
|
37
|
-
console.error(err.stack);
|
|
38
|
-
}
|
|
35
|
+
(0, utils_1.logError)(msg, err);
|
|
39
36
|
process.exitCode = 1;
|
|
40
37
|
})
|
|
41
38
|
.demandCommand(1, 'You must specify at least one command.')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyC;AAEzC,0DAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyC;AAEzC,0DAAkC;AAClC,mCAMiB;AAEjB,SAAgB,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N,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;AAC7B,CAAC;AApDD,kBAoDC","sourcesContent":["import yargs, { Arguments } from 'yargs';\nimport yargsType from 'yargs/yargs';\nimport builders from './builders';\nimport {\n applyConfig,\n loadConfig,\n sanitizeInputs,\n setSnapGlobals,\n logError,\n} from './utils';\n\nexport function cli(argv: string[], commands: any): void {\n const rawArgv = argv.slice(2);\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs(rawArgv)\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 init', `\\tInitialize a snap project in the current directory`)\n .example(\n '$0 build -s src/index.js -d out',\n `\\tBuild 'src/index.js' as './out/bundle.js'`,\n )\n .example(\n '$0 build -s src/index.js -d out -n snap.js',\n `\\tBuild 'src/index.js' as './out/snap.js'`,\n )\n .example('$0 serve -r out', `\\tServe files in './out' on port 8080`)\n .example('$0 serve -r out -p 9000', `\\tServe files in './out' on port 9000`)\n .example(\n '$0 watch -s src/index.js -d out',\n `\\tRebuild './out/bundle.js' on changes to files in 'src/index.js' parent and child directories`,\n )\n\n .command(commands)\n\n .option('verboseErrors', builders.verboseErrors)\n\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n // Typecast: The @types/yargs type for .middleware is incorrect.\n // yargs middleware functions receive the yargs instance as a second parameter.\n // ref: https://yargs.js.org/docs/#api-reference-middlewarecallbacks-applybeforevalidation\n .middleware(\n ((yargsArgv: Arguments, yargsInstance: typeof yargsType) => {\n applyConfig(loadConfig(), rawArgv, yargsArgv, yargsInstance);\n setSnapGlobals(yargsArgv);\n sanitizeInputs(yargsArgv);\n }) as any,\n true,\n )\n\n .fail((msg: string, err: Error, _yargs) => {\n logError(msg, err);\n process.exitCode = 1;\n })\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .help()\n .alias('help', 'h').argv;\n}\n"]}
|
|
@@ -9,5 +9,6 @@ import { YargsArgs } from '../../types/yargs';
|
|
|
9
9
|
* @param argv.sourceMaps - Whether to output sourcemaps.
|
|
10
10
|
* @param argv.stripComments - Whether to remove comments from code.
|
|
11
11
|
* @param argv.transpilationMode - The Babel transpilation mode.
|
|
12
|
+
* @param bundlerTransform
|
|
12
13
|
*/
|
|
13
14
|
export declare function bundle(src: string, dest: string, argv: YargsArgs, bundlerTransform?: (bundler: BrowserifyObject) => void): Promise<boolean>;
|
|
@@ -19,6 +19,7 @@ const utils_1 = require("./utils");
|
|
|
19
19
|
* @param argv.sourceMaps - Whether to output sourcemaps.
|
|
20
20
|
* @param argv.stripComments - Whether to remove comments from code.
|
|
21
21
|
* @param argv.transpilationMode - The Babel transpilation mode.
|
|
22
|
+
* @param bundlerTransform
|
|
22
23
|
*/
|
|
23
24
|
function bundle(src, dest, argv, bundlerTransform) {
|
|
24
25
|
const { sourceMaps: debug, transpilationMode } = argv;
|
|
@@ -44,13 +45,16 @@ function bundle(src, dest, argv, bundlerTransform) {
|
|
|
44
45
|
] }, babelifyOptions));
|
|
45
46
|
}
|
|
46
47
|
bundlerTransform === null || bundlerTransform === void 0 ? void 0 : bundlerTransform(bundler);
|
|
48
|
+
bundler.plugin('@metamask/snaps-browserify-plugin', {
|
|
49
|
+
stripComments: argv.stripComments,
|
|
50
|
+
transformHtmlComments: argv.transformHtmlComments,
|
|
51
|
+
});
|
|
47
52
|
bundler.bundle(async (bundleError, bundleBuffer) => await (0, utils_1.writeBundleFile)({
|
|
48
53
|
bundleError,
|
|
49
54
|
bundleBuffer,
|
|
50
55
|
src,
|
|
51
56
|
dest,
|
|
52
57
|
resolve,
|
|
53
|
-
argv,
|
|
54
58
|
}));
|
|
55
59
|
});
|
|
56
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/cmds/build/bundle.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA0D;AAC1D,6CAAoD;AAEpD,mCAA+D;AAE/D,+EAA+E;AAC/E,mEAAmE;AACn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mC,EAAE;YAClD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CACZ,KAAK,EAAE,WAAW,EAAE,YAAoB,EAAE,EAAE,CAC1C,MAAM,IAAA,uBAAe,EAAC;YACpB,WAAW;YACX,YAAY;YACZ,GAAG;YACH,IAAI;YACJ,OAAO;SACR,CAAC,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AArDD,wBAqDC","sourcesContent":["import browserify, { BrowserifyObject } from 'browserify';\nimport { TranspilationModes } from '../../builders';\nimport { YargsArgs } from '../../types/yargs';\nimport { processDependencies, writeBundleFile } from './utils';\n\n// We need to statically import all Browserify transforms and all Babel presets\n// and plugins, and calling `require` is the sanest way to do that.\n/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, node/global-require */\n\n/**\n * Builds a Snap bundle JS file from its JavaScript source.\n *\n * @param src - The source file path.\n * @param dest - The destination file path.\n * @param argv - arguments as an object generated by yargs.\n * @param argv.sourceMaps - Whether to output sourcemaps.\n * @param argv.stripComments - Whether to remove comments from code.\n * @param argv.transpilationMode - The Babel transpilation mode.\n * @param bundlerTransform\n */\nexport function bundle(\n src: string,\n dest: string,\n argv: YargsArgs,\n bundlerTransform?: (bundler: BrowserifyObject) => void,\n): Promise<boolean> {\n const { sourceMaps: debug, transpilationMode } = argv;\n const babelifyOptions = processDependencies(argv as any);\n return new Promise((resolve, _reject) => {\n const bundler = browserify(src, { debug });\n\n if (transpilationMode !== TranspilationModes.none) {\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.localAndDeps,\n presets: [\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: ['chrome >= 66', 'firefox >= 68'],\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-proposal-class-properties'),\n require('@babel/plugin-proposal-object-rest-spread'),\n require('@babel/plugin-proposal-optional-chaining'),\n require('@babel/plugin-proposal-nullish-coalescing-operator'),\n ],\n ...(babelifyOptions as any),\n });\n }\n\n bundlerTransform?.(bundler);\n\n bundler.plugin('@metamask/snaps-browserify-plugin', {\n stripComments: argv.stripComments,\n transformHtmlComments: argv.transformHtmlComments,\n });\n\n bundler.bundle(\n async (bundleError, bundleBuffer: Buffer) =>\n await writeBundleFile({\n bundleError,\n bundleBuffer,\n src,\n dest,\n resolve,\n }),\n );\n });\n}\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { YargsArgs } from '../../types/yargs';
|
|
3
3
|
declare type WriteBundleFileArgs = {
|
|
4
4
|
bundleError: Error;
|
|
5
5
|
bundleBuffer: Buffer;
|
|
6
6
|
src: string;
|
|
7
7
|
dest: string;
|
|
8
8
|
resolve: (value: boolean) => void;
|
|
9
|
-
argv: YargsArgs;
|
|
10
9
|
};
|
|
11
10
|
/**
|
|
12
11
|
* Performs postprocessing on the bundle contents and writes them to disk.
|
|
@@ -21,23 +20,8 @@ declare type WriteBundleFileArgs = {
|
|
|
21
20
|
* @param options.dest - The destination file path.
|
|
22
21
|
* @param options.resolve - A {@link Promise} resolution function, so that we
|
|
23
22
|
* can use promises and `async`/`await` even though Browserify uses callbacks.
|
|
24
|
-
* @param options.argv - The Yargs `argv` object.
|
|
25
23
|
*/
|
|
26
|
-
export declare function writeBundleFile({ bundleError, bundleBuffer, src, dest, resolve,
|
|
27
|
-
/**
|
|
28
|
-
* Postprocesses a JavaScript bundle string such that it can be evaluated in SES.
|
|
29
|
-
* Currently:
|
|
30
|
-
* - converts certain dot notation to string notation (for indexing)
|
|
31
|
-
* - makes all direct calls to eval indirect
|
|
32
|
-
* - wraps original bundle in anonymous function
|
|
33
|
-
* - handles certain Babel-related edge cases
|
|
34
|
-
*
|
|
35
|
-
* @param bundleString - The bundle string
|
|
36
|
-
* @param options - post process options
|
|
37
|
-
* @param options.stripComments
|
|
38
|
-
* @returns - The postprocessed bundle string
|
|
39
|
-
*/
|
|
40
|
-
export declare function postProcess(bundleString: string | null, options?: Partial<Option>): string | null;
|
|
24
|
+
export declare function writeBundleFile({ bundleError, bundleBuffer, src, dest, resolve, }: WriteBundleFileArgs): Promise<void>;
|
|
41
25
|
/**
|
|
42
26
|
* Processes dependencies and updates argv with an options object
|
|
43
27
|
* @param argv
|
package/dist/cmds/build/utils.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.processInvalidTranspilation = exports.sanitizeDependencyPaths = exports.getDependencyRegExp = exports.processDependencies = exports.
|
|
3
|
+
exports.processInvalidTranspilation = exports.sanitizeDependencyPaths = exports.getDependencyRegExp = exports.processDependencies = exports.writeBundleFile = void 0;
|
|
7
4
|
const fs_1 = require("fs");
|
|
8
|
-
const strip_comments_1 = __importDefault(require("@chainsafe/strip-comments"));
|
|
9
5
|
const misc_1 = require("../../utils/misc");
|
|
10
6
|
const builders_1 = require("../../builders");
|
|
11
7
|
/**
|
|
@@ -21,20 +17,14 @@ const builders_1 = require("../../builders");
|
|
|
21
17
|
* @param options.dest - The destination file path.
|
|
22
18
|
* @param options.resolve - A {@link Promise} resolution function, so that we
|
|
23
19
|
* can use promises and `async`/`await` even though Browserify uses callbacks.
|
|
24
|
-
* @param options.argv - The Yargs `argv` object.
|
|
25
20
|
*/
|
|
26
|
-
async function writeBundleFile({ bundleError, bundleBuffer, src, dest, resolve,
|
|
21
|
+
async function writeBundleFile({ bundleError, bundleBuffer, src, dest, resolve, }) {
|
|
27
22
|
if (bundleError) {
|
|
28
23
|
await (0, misc_1.writeError)('Build error:', bundleError.message, bundleError);
|
|
29
24
|
}
|
|
30
25
|
try {
|
|
31
|
-
await fs_1.promises.writeFile(dest,
|
|
32
|
-
|
|
33
|
-
transformHtmlComments: argv.transformHtmlComments,
|
|
34
|
-
}));
|
|
35
|
-
if (bundleBuffer) {
|
|
36
|
-
console.log(`Build success: '${src}' bundled as '${dest}'!`);
|
|
37
|
-
}
|
|
26
|
+
await fs_1.promises.writeFile(dest, bundleBuffer === null || bundleBuffer === void 0 ? void 0 : bundleBuffer.toString());
|
|
27
|
+
console.log(`Build success: '${src}' bundled as '${dest}'!`);
|
|
38
28
|
resolve(true);
|
|
39
29
|
}
|
|
40
30
|
catch (error) {
|
|
@@ -42,58 +32,6 @@ async function writeBundleFile({ bundleError, bundleBuffer, src, dest, resolve,
|
|
|
42
32
|
}
|
|
43
33
|
}
|
|
44
34
|
exports.writeBundleFile = writeBundleFile;
|
|
45
|
-
/**
|
|
46
|
-
* Postprocesses a JavaScript bundle string such that it can be evaluated in SES.
|
|
47
|
-
* Currently:
|
|
48
|
-
* - converts certain dot notation to string notation (for indexing)
|
|
49
|
-
* - makes all direct calls to eval indirect
|
|
50
|
-
* - wraps original bundle in anonymous function
|
|
51
|
-
* - handles certain Babel-related edge cases
|
|
52
|
-
*
|
|
53
|
-
* @param bundleString - The bundle string
|
|
54
|
-
* @param options - post process options
|
|
55
|
-
* @param options.stripComments
|
|
56
|
-
* @returns - The postprocessed bundle string
|
|
57
|
-
*/
|
|
58
|
-
function postProcess(bundleString, options = {}) {
|
|
59
|
-
if (typeof bundleString !== 'string') {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
let processedString = bundleString.trim();
|
|
63
|
-
if (options.stripComments) {
|
|
64
|
-
processedString = (0, strip_comments_1.default)(processedString);
|
|
65
|
-
}
|
|
66
|
-
// Break up tokens that could be parsed as HTML comment terminators.
|
|
67
|
-
// The regular expressions below are written strangely so as to avoid the
|
|
68
|
-
// appearance of such tokens in our source code.
|
|
69
|
-
// Ref: https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
|
|
70
|
-
// This aggressive hack may change the behavior of programs that contain HTML
|
|
71
|
-
// comment terminators in string literals.
|
|
72
|
-
if (options.transformHtmlComments) {
|
|
73
|
-
processedString = processedString.replace(new RegExp(`<!${'--'}`, 'gu'), '< !--');
|
|
74
|
-
processedString = processedString.replace(new RegExp(`${'--'}>`, 'gu'), '-- >');
|
|
75
|
-
}
|
|
76
|
-
// stuff.eval(otherStuff) => (1, stuff.eval)(otherStuff)
|
|
77
|
-
processedString = processedString.replace(/((?:\b[\w\d]*[\])]?\.)+eval)(\([^)]*\))/gu, '(1, $1)$2');
|
|
78
|
-
// If we don't do the above, the below causes syntax errors if it encounters
|
|
79
|
-
// things of the form: "something.eval(stuff)"
|
|
80
|
-
// eval(stuff) => (1, eval)(stuff)
|
|
81
|
-
processedString = processedString.replace(/(\b)(eval)(\([^)]*\))/gu, '$1(1, $2)$3');
|
|
82
|
-
// Browserify provides the Buffer global as an argument to modules that use
|
|
83
|
-
// it, but this does not work in SES. Since we pass in Buffer as an endowment,
|
|
84
|
-
// we can simply remove the argument.
|
|
85
|
-
processedString = processedString.replace(/^\(function \(Buffer\)\{$/gmu, '(function (){');
|
|
86
|
-
if (processedString.length === 0) {
|
|
87
|
-
throw new Error(`Bundled code is empty after postprocessing.`);
|
|
88
|
-
}
|
|
89
|
-
// handle some cases by declaring missing globals
|
|
90
|
-
// Babel regeneratorRuntime
|
|
91
|
-
if (processedString.indexOf('regeneratorRuntime') !== -1) {
|
|
92
|
-
processedString = `var regeneratorRuntime;\n${processedString}`;
|
|
93
|
-
}
|
|
94
|
-
return processedString;
|
|
95
|
-
}
|
|
96
|
-
exports.postProcess = postProcess;
|
|
97
35
|
/**
|
|
98
36
|
* Processes dependencies and updates argv with an options object
|
|
99
37
|
* @param argv
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cmds/build/utils.ts"],"names":[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MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACvE,OAAO,MAAM,CAAC;KACf;IACD,MAAM,KAAK,GAAa,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC9D,MAAM,GAAG,oBAAoB,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAC7C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC;AAVD,kDAUC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,YAAsB;IAC5D,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QACrC,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,0DAIC;AAED,SAAgB,2BAA2B,CAAC,IAAe;IACzD,IACE,IAAI,CAAC,eAAe;QACpB,IAAI,CAAC,iBAAiB,KAAK,6BAAkB,CAAC,YAAY,EAC1D;QACA,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;KACH;AACH,CAAC;AATD,kEASC","sourcesContent":["import { promises as fs } from 'fs';\nimport { writeError } from '../../utils/misc';\nimport { YargsArgs } from '../../types/yargs';\nimport { TranspilationModes } from '../../builders';\n\ntype WriteBundleFileArgs = {\n bundleError: Error;\n bundleBuffer: Buffer;\n src: string;\n dest: string;\n resolve: (value: boolean) => void;\n};\n\n/**\n * Performs postprocessing on the bundle contents and writes them to disk.\n * Intended to be used in the callback passed to the Browserify `.bundle()`\n * call.\n *\n * @param options - Options bag.\n * @param options.bundleError - Any error received from Browserify.\n * @param options.bundleBuffer - The {@link Buffer} with the bundle contents\n * from Browserify.\n * @param options.src - The source file path.\n * @param options.dest - The destination file path.\n * @param options.resolve - A {@link Promise} resolution function, so that we\n * can use promises and `async`/`await` even though Browserify uses callbacks.\n */\nexport async function writeBundleFile({\n bundleError,\n bundleBuffer,\n src,\n dest,\n resolve,\n}: WriteBundleFileArgs) {\n if (bundleError) {\n await writeError('Build error:', bundleError.message, bundleError);\n }\n\n try {\n await fs.writeFile(dest, bundleBuffer?.toString());\n console.log(`Build success: '${src}' bundled as '${dest}'!`);\n resolve(true);\n } catch (error) {\n await writeError('Write error:', error.message, error, dest);\n }\n}\n\n/**\n * Processes dependencies and updates argv with an options object\n * @param argv\n */\nexport function processDependencies(argv: YargsArgs) {\n const { depsToTranspile, transpilationMode } = argv;\n const babelifyOptions: Record<string, any> = {};\n if (transpilationMode === TranspilationModes.localAndDeps) {\n const regexpStr = getDependencyRegExp(depsToTranspile as string[]);\n if (regexpStr !== null) {\n babelifyOptions.ignore = [regexpStr];\n }\n }\n return babelifyOptions;\n}\n\n/**\n * Processes a string of space delimited dependencies into one regex string\n * @param dependencies\n * @returns a regexp string\n */\nexport function getDependencyRegExp(dependencies: string[]): RegExp | null {\n let regexp: string | null = null;\n if (!dependencies || dependencies.includes('.') || !dependencies.length) {\n return regexp;\n }\n const paths: string[] = sanitizeDependencyPaths(dependencies);\n regexp = `/node_modules/(?!${paths.shift()}`;\n paths.forEach((path) => (regexp += `|${path}`));\n regexp += '/)';\n return RegExp(regexp, 'u');\n}\n\n/**\n * Helper function remove any leading and trailing slashes from dependency list\n * @param dependencies\n * @returns an array of sanitized paths\n */\nexport function sanitizeDependencyPaths(dependencies: string[]): string[] {\n return dependencies.map((dependency) => {\n return dependency.replace(/^[/\\\\]+/u, '').replace(/[/\\\\]+$/u, '');\n });\n}\n\nexport function processInvalidTranspilation(argv: YargsArgs) {\n if (\n argv.depsToTranspile &&\n argv.transpilationMode !== TranspilationModes.localAndDeps\n ) {\n throw new Error(\n '\"depsToTranspile\" can only be specified if \"transpilationMode\" is set to \"localAndDeps\" .',\n );\n }\n}\n"]}
|
package/dist/cmds/eval/mock.d.ts
CHANGED
package/dist/cmds/eval/mock.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
exports.generateMockEndowments = exports.ALL_APIS = void 0;
|
|
6
|
+
exports.generateMockEndowments = exports.isConstructor = exports.ALL_APIS = void 0;
|
|
7
7
|
const events_1 = __importDefault(require("events"));
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
9
|
const snap_controllers_1 = require("@metamask/snap-controllers");
|
|
@@ -16,6 +16,7 @@ function getMockSnapProvider() {
|
|
|
16
16
|
return mockProvider;
|
|
17
17
|
}
|
|
18
18
|
const isConstructor = (value) => { var _a, _b; return Boolean(typeof ((_b = (_a = value === null || value === void 0 ? void 0 : value.prototype) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'string'); };
|
|
19
|
+
exports.isConstructor = isConstructor;
|
|
19
20
|
const mockFunction = () => true;
|
|
20
21
|
class MockClass {
|
|
21
22
|
}
|
|
@@ -37,7 +38,7 @@ const mockWindow = {
|
|
|
37
38
|
SubtleCrypto: MockClass,
|
|
38
39
|
};
|
|
39
40
|
const generateMockEndowment = (key) => {
|
|
40
|
-
const globalValue =
|
|
41
|
+
const globalValue = globalThis[key];
|
|
41
42
|
// Default exposed APIs don't need to be mocked
|
|
42
43
|
if (globalValue && snap_controllers_1.DEFAULT_ENDOWMENTS.includes(key)) {
|
|
43
44
|
return globalValue;
|
|
@@ -46,7 +47,7 @@ const generateMockEndowment = (key) => {
|
|
|
46
47
|
const globalOrMocked = globalValue !== null && globalValue !== void 0 ? globalValue : mockWindow[key];
|
|
47
48
|
const type = typeof globalOrMocked;
|
|
48
49
|
const isFunction = type === 'function';
|
|
49
|
-
if (isFunction && isConstructor(globalOrMocked)) {
|
|
50
|
+
if (isFunction && (0, exports.isConstructor)(globalOrMocked)) {
|
|
50
51
|
return generateMockClass(globalOrMocked);
|
|
51
52
|
}
|
|
52
53
|
else if (isFunction || !globalOrMocked) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../../src/cmds/eval/mock.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAkC;AAClC,oDAA4B;AAC5B,iEAAgE;AAEhE,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE/B,QAAA,QAAQ,GAAa,CAAC,GAAG,qCAAkB,EAAE,GAAG,YAAY,CAAC,CAAC;AAO3E,SAAS,mBAAmB;IAC1B,MAAM,YAAY,GAAG,IAAI,gBAAY,EAA+B,CAAC;IACrE,YAAY,CAAC,yBAAyB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IACpD,YAAY,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;IACxC,OAAO,YAAgC,CAAC;AAC1C,CAAC;
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../../src/cmds/eval/mock.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAkC;AAClC,oDAA4B;AAC5B,iEAAgE;AAEhE,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE/B,QAAA,QAAQ,GAAa,CAAC,GAAG,qCAAkB,EAAE,GAAG,YAAY,CAAC,CAAC;AAO3E,SAAS,mBAAmB;IAC1B,MAAM,YAAY,GAAG,IAAI,gBAAY,EAA+B,CAAC;IACrE,YAAY,CAAC,yBAAyB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IACpD,YAAY,CAAC,OAAO,GAA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IAAI,GAAG,OAAO,cAAc,CAAC;IACnC,MAAM,UAAU,GAAG,IAAI,KAAK,UAAU,CAAC;IACvC,IAAI,UAAU,IAAI,IAAA,qBAAa,EAAC,cAAc,CAAC,EAAE;QAC/C,OAAO,iBAAiB,CAAC,cAAc,CAAC,CAAC;KAC1C;SAAM,IAAI,UAAU,IAAI,CAAC,cAAc,EAAE;QACxC,qCAAqC;QACrC,OAAO,YAAY,CAAC;KACrB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEK,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,OAAO,gBAAQ,CAAC,MAAM,CACpB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,GAAG,CAAC,EAAE,qBAAqB,CAAC,GAAG,CAAC,IAAG,EAC7D,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,CAClC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC","sourcesContent":["import EventEmitter from 'events';\nimport crypto from 'crypto';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snap-controllers';\n\nconst NETWORK_APIS = ['fetch', 'WebSocket'];\n\nexport const ALL_APIS: string[] = [...DEFAULT_ENDOWMENTS, ...NETWORK_APIS];\n\ntype MockSnapProvider = EventEmitter & {\n registerRpcMessageHandler: () => any;\n request: () => Promise<any>;\n};\n\nfunction getMockSnapProvider(): MockSnapProvider {\n const mockProvider = new EventEmitter() as Partial<MockSnapProvider>;\n mockProvider.registerRpcMessageHandler = () => true;\n mockProvider.request = async () => true;\n return mockProvider as MockSnapProvider;\n}\n\nexport const isConstructor = (value: any) =>\n Boolean(typeof value?.prototype?.constructor?.name === 'string');\n\nconst mockFunction = () => true;\nclass MockClass {}\n\nconst handler = {\n construct(Target: any, args: any[]): any {\n return new Proxy(new Target(...args), handler);\n },\n get(_target: any, _prop: any) {\n return mockFunction;\n },\n};\n\nconst generateMockClass = (value: any) => {\n return new Proxy(value, handler);\n};\n\n// Things not currently auto-mocked because of NodeJS, by adding them here we have types for them and can use that to generate mocks if needed\nconst mockWindow = {\n WebSocket: MockClass,\n crypto,\n SubtleCrypto: MockClass,\n};\n\nconst generateMockEndowment = (key: string) => {\n const globalValue = (globalThis as any)[key];\n\n // Default exposed APIs don't need to be mocked\n if (globalValue && DEFAULT_ENDOWMENTS.includes(key)) {\n return globalValue;\n }\n\n // Fall back to mockWindow for certain APIs not exposed in global in Node.JS\n const globalOrMocked = globalValue ?? (mockWindow as any)[key];\n\n const type = typeof globalOrMocked;\n const isFunction = type === 'function';\n if (isFunction && isConstructor(globalOrMocked)) {\n return generateMockClass(globalOrMocked);\n } else if (isFunction || !globalOrMocked) {\n // Fall back to function mock for now\n return mockFunction;\n }\n return globalOrMocked;\n};\n\nexport const generateMockEndowments = () => {\n return ALL_APIS.reduce<Record<string, any>>(\n (acc, cur) => ({ ...acc, [cur]: generateMockEndowment(cur) }),\n { wallet: getMockSnapProvider() },\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initUtils.js","sourceRoot":"","sources":["../../../src/cmds/init/initUtils.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAChD,gDAA6B;AAC7B,iEAM+C;AAC/C,0EAAgD;AAChD,oDAA4B;AAC5B,kDAA0B;AAE1B,uCAQqB;AAErB;;GAEG;AACH,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAE1E,MAAM,uBAAuB,GAAG,4BAA4B,CAAC;AAE7D;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB;IAGpC,IAAI,IAAA,eAAU,EAAC,wBAAgB,CAAC,WAAW,CAAC,EAAE;QAC5C,OAAO,CAAC,GAAG,CACT,qCAAqC,wBAAgB,CAAC,WAAW,MAAM,CACxE,CAAC;QAEF,IAAI;YACF,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAY,EAAC,wBAAgB,CAAC,WAAW,CAAC,CAAC;YACrE,IAAA,4B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CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC7C;KACF;AACH,CAAC;AA1BD,0DA0BC","sourcesContent":["import { existsSync, promises as fs } from 'fs';\nimport pathUtils from 'path';\nimport {\n NpmSnapFileNames,\n NpmSnapPackageJson,\n PROPOSED_NAME_REGEX,\n SnapManifest,\n validateSnapJsonFile,\n} from '@metamask/snap-controllers/dist/snaps';\nimport initPackageJson from 'init-package-json';\nimport mkdirp from 'mkdirp';\nimport slash from 'slash';\nimport { YargsArgs } from '../../types/yargs';\nimport {\n CONFIG_FILE,\n deepClone,\n logError,\n logWarning,\n prompt,\n readJsonFile,\n trimPathString,\n} from '../../utils';\n\n/**\n * This is a placeholder shasum that will be replaced at the end of the init command.\n */\nconst PLACEHOLDER_SHASUM = '2QqUxo5joo4kKKr7yiCjdYsZOZcIFBnIBEdwU9Yx7+M=';\n\nconst NPM_PUBLIC_REGISTRY_URL = 'https://registry.npmjs.org';\n\n/**\n * Initializes a `package.json` file for a Snap project. Will attempt to read\n * and parse the existing file if it already exists, otherwise will intialize\n * a brand new one.\n *\n * @returns The contents of the `package.json` file.\n */\nexport async function asyncPackageInit(): Promise<\n Readonly<NpmSnapPackageJson>\n> {\n if (existsSync(NpmSnapFileNames.PackageJson)) {\n console.log(\n `Init: Attempting to use existing '${NpmSnapFileNames.PackageJson}'...`,\n );\n\n try {\n const packageJson = await readJsonFile(NpmSnapFileNames.PackageJson);\n validateSnapJsonFile(NpmSnapFileNames.PackageJson, packageJson);\n\n console.log(\n `Init: Successfully parsed '${NpmSnapFileNames.PackageJson}'!`,\n );\n return packageJson as NpmSnapPackageJson;\n } catch (error) {\n logError(\n `Init Error: Could not parse '${NpmSnapFileNames.PackageJson}'. Please verify that the file is correctly formatted and try again.`,\n error,\n );\n throw error;\n }\n }\n\n // Exit if yarn.lock is found, or we'll be in trouble\n if (existsSync('yarn.lock')) {\n logError(\n `Init Error: Found a 'yarn.lock' file but no '${NpmSnapFileNames.PackageJson}'. Please run 'yarn init' and try again.`,\n );\n throw new Error('Already existing yarn.lock file found');\n }\n\n // Run 'npm init'\n return new Promise((resolve, reject) => {\n initPackageJson(process.cwd(), '', {}, (err, data) => {\n if (err) {\n reject(err);\n } else {\n resolve(data);\n }\n });\n });\n}\n\nconst YES = 'yes';\nconst YES_VALUES = new Set([YES, 'y']);\n\nfunction isYes(userInput: string | undefined) {\n return userInput && YES_VALUES.has(userInput.toLowerCase());\n}\n\nconst DEFAULT_PERMISSION_KEY = 'snap_confirm';\nconst getDefaultPermissions = () => {\n return { [DEFAULT_PERMISSION_KEY]: {} };\n};\n\n/**\n * Interactively constructs a Snap manifest file by prompting the user.\n *\n * @param argv - The `yargs` `argv` object.\n * @param packageJson - The `package.json` object.\n * @param shasum - The shasum of the Snap source file.\n * @returns A tuple of the resulting Snap manifest object and a new `argv` object\n * with properties to match the manifest.\n */\nexport async function buildSnapManifest(\n argv: YargsArgs,\n packageJson: NpmSnapPackageJson,\n): Promise<[SnapManifest, { dist: string; outfileName: string; src: string }]> {\n const { outfileName } = argv;\n let { dist } = argv;\n let initialPermissions: Record<string, unknown> = getDefaultPermissions();\n let { description, name: proposedName } = packageJson;\n\n if (!description) {\n description = `The ${proposedName} Snap.`;\n }\n\n try {\n const userInput = await prompt({\n question: `Use default Snap manifest values?`,\n defaultValue: YES,\n shouldClose: false,\n });\n\n if (isYes(userInput)) {\n console.log('Using default values...');\n try {\n await mkdirp(dist);\n } catch (err) {\n logError(\n `Init Error: Could not write default 'dist' '${dist}'. Maybe check your local ${CONFIG_FILE} file?`,\n );\n throw err;\n }\n return endSnapManifest();\n }\n } catch (err) {\n logError(`Init Error: ${err.message}`, err);\n throw err;\n }\n\n let invalidProposedName = true;\n while (invalidProposedName) {\n // eslint-disable-next-line require-atomic-updates\n proposedName = await prompt({\n question: `Proposed Snap name:`,\n defaultValue: proposedName,\n });\n\n if (\n proposedName.length > 0 &&\n proposedName.length <= 214 &&\n PROPOSED_NAME_REGEX.test(proposedName)\n ) {\n invalidProposedName = false;\n } else {\n logError(\n `The proposed name must adhere to npm package naming conventions, except that capital letters are allowed. For details, see: https://docs.npmjs.com/cli/v6/configuring-npm/package-json#name`,\n );\n }\n }\n\n let invalidDescription = true;\n while (invalidDescription) {\n // eslint-disable-next-line require-atomic-updates\n description = await prompt({\n question: `Description:`,\n defaultValue: description,\n });\n\n if (description.length === 0 || description.length <= 280) {\n invalidDescription = false;\n } else {\n logError(\n `The description must be a non-empty string less than or equal to 280 characters.`,\n );\n }\n }\n\n let invalidDist = true;\n while (invalidDist) {\n // eslint-disable-next-line require-atomic-updates\n dist = await prompt({ question: `Output directory:`, defaultValue: dist });\n try {\n dist = trimPathString(dist);\n await mkdirp(dist);\n invalidDist = false;\n } catch (distError) {\n logError(\n `Unable to create directory '${dist}'. Ensure that the path is valid and try again.`,\n distError,\n );\n }\n }\n\n let invalidPermissions = true;\n while (invalidPermissions) {\n const inputPermissions = await prompt({\n // We add the parenthetical default value ourselves\n question: `Initial permissions: [perm1 perm2 ...] ([snap_confirm])`,\n });\n\n if (\n !inputPermissions ||\n inputPermissions.trim() === DEFAULT_PERMISSION_KEY\n ) {\n break;\n }\n\n try {\n initialPermissions = inputPermissions\n .split(' ')\n .reduce((allPermissions, permission) => {\n if (\n typeof permission === 'string' &&\n permission.match(/^[\\w\\d_:]+$/iu)\n ) {\n allPermissions[permission] = {};\n } else {\n throw new Error(`Invalid permission: ${permission}`);\n }\n return allPermissions;\n }, {} as Record<string, unknown>);\n\n invalidPermissions = false;\n } catch (err) {\n logError(\n `Invalid permissions '${inputPermissions}'.\\nThe permissions must be specified as a space-separated list of strings with only characters, digits, underscores ('_'), and colons (':').`,\n err,\n );\n }\n }\n\n return endSnapManifest();\n\n function endSnapManifest(): [\n SnapManifest,\n {\n dist: string;\n outfileName: string;\n src: string;\n },\n ] {\n const manifest = {\n version: packageJson.version,\n description,\n proposedName,\n repository: packageJson.repository\n ? deepClone(packageJson.repository)\n : null,\n source: {\n shasum: PLACEHOLDER_SHASUM,\n location: {\n npm: {\n filePath: slash(pathUtils.join(dist, outfileName)),\n packageName: packageJson.name,\n registry: NPM_PUBLIC_REGISTRY_URL,\n } as const,\n },\n },\n initialPermissions,\n manifestVersion: '0.1' as const,\n };\n\n try {\n validateSnapJsonFile(NpmSnapFileNames.Manifest, manifest);\n } catch (error) {\n /* istanbul ignore next */\n throw new Error(\n `Internal Error: Validation of constructed manifest failed. This is a bug, please report it. Reason:\\n${error.message}`,\n );\n }\n\n return [\n manifest,\n { dist, outfileName, src: packageJson.main || 'src/index.js' },\n ];\n }\n}\n\nconst INIT_FILE_NAMES = new Set([\n 'src',\n 'index.html',\n CONFIG_FILE,\n 'dist',\n NpmSnapFileNames.Manifest,\n]);\n\n/**\n * Checks whether any files in the current working directory will be overwritten\n * by the initialization process, and asks the user whether to continue if so.\n */\nexport async function prepareWorkingDirectory(): Promise<void> {\n const existingFiles = (await fs.readdir(process.cwd())).filter((item) =>\n INIT_FILE_NAMES.has(item.toString()),\n );\n\n if (existingFiles.length > 0) {\n logWarning(\n `\\nInit Warning: Existing files and/or directories may be overwritten:\\n${existingFiles.reduce(\n (message, currentFile) => {\n return `${message}\\t${currentFile}\\n`;\n },\n '',\n )}`,\n );\n\n const continueInput = await prompt({\n question: `Continue?`,\n defaultValue: YES,\n });\n const shouldContinue = continueInput && isYes(continueInput);\n\n if (!shouldContinue) {\n console.log(`Init: Exiting...`);\n throw new Error('User refused to continue');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"initUtils.js","sourceRoot":"","sources":["../../../src/cmds/init/initUtils.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAChD,gDAA6B;AAC7B,iEAM+C;AAC/C,0EAAgD;AAChD,oDAA4B;AAC5B,kDAA0B;AAE1B,uCAQqB;AAErB;;GAEG;AACH,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAE1E,MAAM,uBAAuB,GAAG,4BAA4B,CAAC;AAE7D;;;;;;GAMG;AACI,KAA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,EACD,EAAE,CACH,EAAE,CACJ,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAA,cAAM,EAAC;YACjC,QAAQ,EAAE,WAAW;YACrB,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QACH,MAAM,cAAc,GAAG,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QAE7D,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC7C;KACF;AACH,CAAC;AA1BD,0DA0BC","sourcesContent":["import { existsSync, promises as fs } from 'fs';\nimport pathUtils from 'path';\nimport {\n NpmSnapFileNames,\n NpmSnapPackageJson,\n PROPOSED_NAME_REGEX,\n SnapManifest,\n validateSnapJsonFile,\n} from '@metamask/snap-controllers/dist/snaps';\nimport initPackageJson from 'init-package-json';\nimport mkdirp from 'mkdirp';\nimport slash from 'slash';\nimport { YargsArgs } from '../../types/yargs';\nimport {\n CONFIG_FILE,\n deepClone,\n logError,\n logWarning,\n prompt,\n readJsonFile,\n trimPathString,\n} from '../../utils';\n\n/**\n * This is a placeholder shasum that will be replaced at the end of the init command.\n */\nconst PLACEHOLDER_SHASUM = '2QqUxo5joo4kKKr7yiCjdYsZOZcIFBnIBEdwU9Yx7+M=';\n\nconst NPM_PUBLIC_REGISTRY_URL = 'https://registry.npmjs.org';\n\n/**\n * Initializes a `package.json` file for a Snap project. Will attempt to read\n * and parse the existing file if it already exists, otherwise will intialize\n * a brand new one.\n *\n * @returns The contents of the `package.json` file.\n */\nexport async function asyncPackageInit(): Promise<\n Readonly<NpmSnapPackageJson>\n> {\n if (existsSync(NpmSnapFileNames.PackageJson)) {\n console.log(\n `Init: Attempting to use existing '${NpmSnapFileNames.PackageJson}'...`,\n );\n\n try {\n const packageJson = await readJsonFile(NpmSnapFileNames.PackageJson);\n validateSnapJsonFile(NpmSnapFileNames.PackageJson, packageJson);\n\n console.log(\n `Init: Successfully parsed '${NpmSnapFileNames.PackageJson}'!`,\n );\n return packageJson as NpmSnapPackageJson;\n } catch (error) {\n logError(\n `Init Error: Could not parse '${NpmSnapFileNames.PackageJson}'. Please verify that the file is correctly formatted and try again.`,\n error,\n );\n throw error;\n }\n }\n\n // Exit if yarn.lock is found, or we'll be in trouble\n if (existsSync('yarn.lock')) {\n logError(\n `Init Error: Found a 'yarn.lock' file but no '${NpmSnapFileNames.PackageJson}'. Please run 'yarn init' and try again.`,\n );\n throw new Error('Already existing yarn.lock file found');\n }\n\n // Run 'npm init'\n return new Promise((resolve, reject) => {\n initPackageJson(process.cwd(), '', {}, (err, data) => {\n if (err) {\n reject(err);\n } else {\n resolve(data);\n }\n });\n });\n}\n\nconst YES = 'yes';\nconst YES_VALUES = new Set([YES, 'y']);\n\nfunction isYes(userInput: string | undefined) {\n return userInput && YES_VALUES.has(userInput.toLowerCase());\n}\n\nconst DEFAULT_PERMISSION_KEY = 'snap_confirm';\nconst getDefaultPermissions = () => {\n return { [DEFAULT_PERMISSION_KEY]: {} };\n};\n\n/**\n * Interactively constructs a Snap manifest file by prompting the user.\n *\n * @param argv - The `yargs` `argv` object.\n * @param packageJson - The `package.json` object.\n * @param shasum - The shasum of the Snap source file.\n * @returns A tuple of the resulting Snap manifest object and a new `argv` object\n * with properties to match the manifest.\n */\nexport async function buildSnapManifest(\n argv: YargsArgs,\n packageJson: NpmSnapPackageJson,\n): Promise<[SnapManifest, { dist: string; outfileName: string; src: string }]> {\n const { outfileName } = argv;\n let { dist } = argv;\n let initialPermissions: Record<string, unknown> = getDefaultPermissions();\n let { description, name: proposedName } = packageJson;\n\n if (!description) {\n description = `The ${proposedName} Snap.`;\n }\n\n try {\n const userInput = await prompt({\n question: `Use default Snap manifest values?`,\n defaultValue: YES,\n shouldClose: false,\n });\n\n if (isYes(userInput)) {\n console.log('Using default values...');\n try {\n await mkdirp(dist);\n } catch (err) {\n logError(\n `Init Error: Could not write default 'dist' '${dist}'. Maybe check your local ${CONFIG_FILE} file?`,\n );\n throw err;\n }\n return endSnapManifest();\n }\n } catch (err) {\n logError(`Init Error: ${err.message}`, err);\n throw err;\n }\n\n let invalidProposedName = true;\n while (invalidProposedName) {\n // eslint-disable-next-line require-atomic-updates\n proposedName = await prompt({\n question: `Proposed Snap name:`,\n defaultValue: proposedName,\n });\n\n if (\n proposedName.length > 0 &&\n proposedName.length <= 214 &&\n PROPOSED_NAME_REGEX.test(proposedName)\n ) {\n invalidProposedName = false;\n } else {\n logError(\n `The proposed name must adhere to npm package naming conventions, except that capital letters are allowed. For details, see: https://docs.npmjs.com/cli/v6/configuring-npm/package-json#name`,\n );\n }\n }\n\n let invalidDescription = true;\n while (invalidDescription) {\n // eslint-disable-next-line require-atomic-updates\n description = await prompt({\n question: `Description:`,\n defaultValue: description,\n });\n\n if (description.length === 0 || description.length <= 280) {\n invalidDescription = false;\n } else {\n logError(\n `The description must be a non-empty string less than or equal to 280 characters.`,\n );\n }\n }\n\n let invalidDist = true;\n while (invalidDist) {\n // eslint-disable-next-line require-atomic-updates\n dist = await prompt({ question: `Output directory:`, defaultValue: dist });\n try {\n dist = trimPathString(dist);\n await mkdirp(dist);\n invalidDist = false;\n } catch (distError) {\n logError(\n `Unable to create directory '${dist}'. Ensure that the path is valid and try again.`,\n distError,\n );\n }\n }\n\n let invalidPermissions = true;\n while (invalidPermissions) {\n const inputPermissions = await prompt({\n // We add the parenthetical default value ourselves\n question: `Initial permissions: [perm1 perm2 ...] ([snap_confirm])`,\n });\n\n if (\n !inputPermissions ||\n inputPermissions.trim() === DEFAULT_PERMISSION_KEY\n ) {\n break;\n }\n\n try {\n initialPermissions = inputPermissions\n .split(' ')\n .reduce((allPermissions, permission) => {\n if (\n typeof permission === 'string' &&\n permission.match(/^[\\w\\d_:]+$/iu)\n ) {\n allPermissions[permission] = {};\n } else {\n throw new Error(`Invalid permission: ${permission}`);\n }\n return allPermissions;\n }, {} as Record<string, unknown>);\n\n invalidPermissions = false;\n } catch (err) {\n logError(\n `Invalid permissions '${inputPermissions}'.\\nThe permissions must be specified as a space-separated list of strings with only characters, digits, underscores ('_'), and colons (':').`,\n err,\n );\n }\n }\n\n return endSnapManifest();\n\n function endSnapManifest(): [\n SnapManifest,\n {\n dist: string;\n outfileName: string;\n src: string;\n },\n ] {\n const manifest = {\n version: packageJson.version,\n description,\n proposedName,\n repository: packageJson.repository\n ? deepClone(packageJson.repository)\n : null,\n source: {\n shasum: PLACEHOLDER_SHASUM,\n location: {\n npm: {\n filePath: slash(pathUtils.join(dist, outfileName)),\n packageName: packageJson.name,\n registry: NPM_PUBLIC_REGISTRY_URL,\n iconPath: 'icon.svg',\n } as const,\n },\n },\n initialPermissions,\n manifestVersion: '0.1' as const,\n };\n\n try {\n validateSnapJsonFile(NpmSnapFileNames.Manifest, manifest);\n } catch (error) {\n /* istanbul ignore next */\n throw new Error(\n `Internal Error: Validation of constructed manifest failed. This is a bug, please report it. Reason:\\n${error.message}`,\n );\n }\n\n return [\n manifest,\n { dist, outfileName, src: packageJson.main || 'src/index.js' },\n ];\n }\n}\n\nconst INIT_FILE_NAMES = new Set([\n 'src',\n 'index.html',\n CONFIG_FILE,\n 'dist',\n NpmSnapFileNames.Manifest,\n]);\n\n/**\n * Checks whether any files in the current working directory will be overwritten\n * by the initialization process, and asks the user whether to continue if so.\n */\nexport async function prepareWorkingDirectory(): Promise<void> {\n const existingFiles = (await fs.readdir(process.cwd())).filter((item) =>\n INIT_FILE_NAMES.has(item.toString()),\n );\n\n if (existingFiles.length > 0) {\n logWarning(\n `\\nInit Warning: Existing files and/or directories may be overwritten:\\n${existingFiles.reduce(\n (message, currentFile) => {\n return `${message}\\t${currentFile}\\n`;\n },\n '',\n )}`,\n );\n\n const continueInput = await prompt({\n question: `Continue?`,\n defaultValue: YES,\n });\n const shouldContinue = continueInput && isYes(continueInput);\n\n if (!shouldContinue) {\n console.log(`Init: Exiting...`);\n throw new Error('User refused to continue');\n }\n }\n}\n"]}
|
package/dist/utils/readline.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare type PromptArgs = {
|
|
|
6
6
|
shouldClose?: boolean;
|
|
7
7
|
readlineInterface?: readline.Interface;
|
|
8
8
|
};
|
|
9
|
+
export declare function openPrompt(): void;
|
|
9
10
|
export declare function prompt({ question, defaultValue, shouldClose, readlineInterface, }: PromptArgs): Promise<string>;
|
|
10
11
|
export declare function closePrompt(readlineInterface?: readline.Interface): void;
|
|
11
12
|
export {};
|
package/dist/utils/readline.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
exports.closePrompt = exports.prompt = void 0;
|
|
6
|
+
exports.closePrompt = exports.prompt = exports.openPrompt = void 0;
|
|
7
7
|
const readline_1 = __importDefault(require("readline"));
|
|
8
8
|
let singletonReadlineInterface;
|
|
9
9
|
function openPrompt() {
|
|
@@ -12,6 +12,7 @@ function openPrompt() {
|
|
|
12
12
|
output: process.stdout,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
exports.openPrompt = openPrompt;
|
|
15
16
|
function prompt({ question, defaultValue, shouldClose, readlineInterface = singletonReadlineInterface, }) {
|
|
16
17
|
let _readlineInterface = readlineInterface;
|
|
17
18
|
if (!_readlineInterface) {
|
|
@@ -41,6 +42,9 @@ function closePrompt(readlineInterface = singletonReadlineInterface) {
|
|
|
41
42
|
if (readlineInterface) {
|
|
42
43
|
readlineInterface.close();
|
|
43
44
|
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error('You are attempting to close a non existent prompt.');
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
exports.closePrompt = closePrompt;
|
|
46
50
|
//# sourceMappingURL=readline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readline.js","sourceRoot":"","sources":["../../src/utils/readline.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAEhC,IAAI,0BAA8C,CAAC;AASnD,
|
|
1
|
+
{"version":3,"file":"readline.js","sourceRoot":"","sources":["../../src/utils/readline.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAEhC,IAAI,0BAA8C,CAAC;AASnD,SAAgB,UAAU;IACxB,0BAA0B,GAAG,kBAAQ,CAAC,eAAe,CAAC;QACpD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC;AALD,gCAKC;AAED,SAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,iBAAiB,GAAG,0BAA0B,GACnC;IACX,IAAI,kBAAkB,GAAG,iBAAiB,CAAC;IAC3C,IAAI,CAAC,kBAAkB,EAAE;QACvB,UAAU,EAAE,CAAC;QACb,kBAAkB,GAAG,0BAA0B,CAAC;KACjD;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,IAAI,WAAW,GAAG,GAAG,QAAQ,GAAG,CAAC;QACjC,IAAI,YAAY,EAAE;YAChB,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC;SACrC;QAED,kBAAkB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAc,EAAE,EAAE;YAC1D,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;gBAC7B,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC9B,OAAO,CAAC,YAAY,CAAC,CAAC;iBACvB;aACF;YACD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACvB,IAAI,WAAW,EAAE;gBACf,kBAAkB,CAAC,KAAK,EAAE,CAAC;aAC5B;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA9BD,wBA8BC;AAED,SAAgB,WAAW,CACzB,iBAAiB,GAAG,0BAA0B;IAE9C,IAAI,iBAAiB,EAAE;QACrB,iBAAiB,CAAC,KAAK,EAAE,CAAC;KAC3B;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACvE;AACH,CAAC;AARD,kCAQC","sourcesContent":["import readline from 'readline';\n\nlet singletonReadlineInterface: readline.Interface;\n\ntype PromptArgs = {\n question: string;\n defaultValue?: string;\n shouldClose?: boolean;\n readlineInterface?: readline.Interface;\n};\n\nexport function openPrompt(): void {\n singletonReadlineInterface = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n}\n\nexport function prompt({\n question,\n defaultValue,\n shouldClose,\n readlineInterface = singletonReadlineInterface,\n}: PromptArgs): Promise<string> {\n let _readlineInterface = readlineInterface;\n if (!_readlineInterface) {\n openPrompt();\n _readlineInterface = singletonReadlineInterface;\n }\n\n return new Promise((resolve, _reject) => {\n let queryString = `${question} `;\n if (defaultValue) {\n queryString += `(${defaultValue}) `;\n }\n\n _readlineInterface.question(queryString, (answer: string) => {\n if (!answer || !answer.trim()) {\n if (defaultValue !== undefined) {\n resolve(defaultValue);\n }\n }\n resolve(answer.trim());\n if (shouldClose) {\n _readlineInterface.close();\n }\n });\n });\n}\n\nexport function closePrompt(\n readlineInterface = singletonReadlineInterface,\n): void {\n if (readlineInterface) {\n readlineInterface.close();\n } else {\n throw new Error('You are attempting to close a non existent prompt.');\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A CLI for developing MetaMask Snaps.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"@babel/plugin-transform-runtime": "^7.16.7",
|
|
48
48
|
"@babel/preset-env": "^7.16.7",
|
|
49
49
|
"@chainsafe/strip-comments": "^1.0.5",
|
|
50
|
-
"@metamask/snap-controllers": "^0.
|
|
50
|
+
"@metamask/snap-controllers": "^0.13.0",
|
|
51
|
+
"@metamask/snaps-browserify-plugin": "^0.13.0",
|
|
51
52
|
"babelify": "^10.0.0",
|
|
52
53
|
"browserify": "^17.0.0",
|
|
53
54
|
"chokidar": "^3.0.2",
|