@metamask/snaps-cli 0.10.5 → 0.11.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 +26 -2
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/cmds/build/buildHandler.js +7 -7
- package/dist/cmds/build/buildHandler.js.map +1 -1
- package/dist/cmds/build/bundle.js +3 -3
- package/dist/cmds/build/bundle.js.map +1 -1
- package/dist/cmds/build/index.js +2 -2
- package/dist/cmds/build/index.js.map +1 -1
- package/dist/cmds/build/utils.js +4 -4
- package/dist/cmds/build/utils.js.map +1 -1
- package/dist/cmds/eval/eval-worker.js +3 -3
- package/dist/cmds/eval/eval-worker.js.map +1 -1
- package/dist/cmds/eval/evalHandler.js +3 -3
- package/dist/cmds/eval/evalHandler.js.map +1 -1
- package/dist/cmds/eval/index.js +1 -1
- package/dist/cmds/eval/index.js.map +1 -1
- package/dist/cmds/eval/mock.js +3 -3
- package/dist/cmds/eval/mock.js.map +1 -1
- package/dist/cmds/init/index.js +3 -3
- package/dist/cmds/init/index.js.map +1 -1
- package/dist/cmds/init/init-template.json +1 -1
- package/dist/cmds/init/initHandler.js +12 -12
- package/dist/cmds/init/initHandler.js.map +1 -1
- package/dist/cmds/init/initUtils.js +26 -26
- package/dist/cmds/init/initUtils.js.map +1 -1
- package/dist/cmds/manifest/index.js +2 -2
- package/dist/cmds/manifest/index.js.map +1 -1
- package/dist/cmds/manifest/manifestHandler.js +6 -6
- package/dist/cmds/manifest/manifestHandler.js.map +1 -1
- package/dist/cmds/serve/index.js +5 -5
- package/dist/cmds/serve/index.js.map +1 -1
- package/dist/cmds/serve/serveUtils.js +2 -2
- package/dist/cmds/serve/serveUtils.js.map +1 -1
- package/dist/cmds/watch/index.js +2 -2
- package/dist/cmds/watch/index.js.map +1 -1
- package/dist/cmds/watch/watchHandler.js +9 -9
- package/dist/cmds/watch/watchHandler.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/utils/fs.js +1 -1
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/misc.js +1 -1
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/snap-config.js +5 -5
- package/dist/utils/snap-config.js.map +1 -1
- package/dist/utils/validate-fs.js +2 -2
- package/dist/utils/validate-fs.js.map +1 -1
- package/package.json +10 -8
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,yCAAuB;AACvB,6CAA2B;AAC3B,gDAA8B;AAC9B,gDAA8B","sourcesContent":["export * from './fs';\nexport * from './misc';\nexport * from './readline';\nexport * from './snap-config';\nexport * from './validate-fs';\n"]}
|
package/dist/utils/misc.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.trimPathString = exports.writeError = exports.logWarning = exports.logEr
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const rfdc_1 = __importDefault(require("rfdc"));
|
|
10
|
-
exports.deepClone = rfdc_1.default({ proto: false, circles: false });
|
|
10
|
+
exports.deepClone = (0, rfdc_1.default)({ proto: false, circles: false });
|
|
11
11
|
exports.permRequestKeys = [
|
|
12
12
|
'@context',
|
|
13
13
|
'id',
|
package/dist/utils/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA4C;AAC5C,gDAAwB;AACxB,gDAAwB;AAGX,QAAA,SAAS,GAAG,cAAI,
|
|
1
|
+
{"version":3,"file":"mis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O,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,IAAI,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;YACvC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;AACH,CAAC;AAPD,gCAOC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,GAAW,EACX,GAAU,EACV,YAAqB;IAErB,IAAI,eAAe,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,eAAe,IAAI,GAAG,CAAC;KACxB;IAED,QAAQ,CAAC,eAAe,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,IAAI;QACF,IAAI,YAAY,EAAE;YAChB,MAAM,aAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACvC;KACF;IAAC,OAAO,WAAW,EAAE;QACpB,QAAQ,CAAC,GAAG,eAAe,gCAAgC,EAAE,WAAW,CAAC,CAAC;KAC3E;IAED,qCAAqC;IACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE;QAC5B,0EAA0E;QAC1E,uEAAuE;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AA1BD,gCA0BC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC","sourcesContent":["import { promises as filesystem } from 'fs';\nimport path from 'path';\nimport rfdc from 'rfdc';\nimport { Arguments } from 'yargs';\n\nexport const deepClone = rfdc({ proto: false, circles: false });\n\nexport const permRequestKeys = [\n '@context',\n 'id',\n 'parentCapability',\n 'invoker',\n 'date',\n 'caveats',\n 'proof',\n];\n\nexport const CONFIG_FILE = 'snap.config.js';\n\n// CLI arguments whose values are file paths\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sets global variable snaps which tracks user settings:\n * watch mode activation, verbose errors messages, and whether to suppress warnings.\n *\n * @param argv - arguments as an object generated by yargs\n */\nexport function setSnapGlobals(argv: Arguments) {\n if (['w', 'watch'].includes(argv._[0] as string)) {\n global.snaps.isWatching = true;\n } else {\n global.snaps.isWatching = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(argv, 'verboseErrors')) {\n global.snaps.verboseErrors = booleanStringToBoolean(argv.verboseErrors);\n }\n\n if (Object.prototype.hasOwnProperty.call(argv, 'suppressWarnings')) {\n global.snaps.suppressWarnings = booleanStringToBoolean(\n argv.suppressWarnings,\n );\n }\n}\n\n/**\n * Attempts to convert a string to a boolean and throws if the value is invalid.\n *\n * @param value - The value to convert to a boolean.\n * @return `true` if the value is the string `\"true\"`, `false` if it is the\n * string `\"false\"`, the value if it is already a boolean, or an error\n * otherwise.\n */\nexport function booleanStringToBoolean(value: unknown): boolean {\n if (typeof value === 'boolean') {\n return value;\n } else if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n }\n\n throw new Error(\n `Expected a boolean or the strings \"true\" or \"false\". Received: \"${value}\"`,\n );\n}\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - arguments as an object generated by yargs\n */\nexport function sanitizeInputs(argv: Arguments) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Logs an error message to console. Logs original error if it exists and\n * the verboseErrors global is true.\n *\n * @param msg - The error message\n * @param err - The original error\n */\nexport function logError(msg: string, err?: Error): void {\n console.error(msg);\n if (err && global.snaps.verboseErrors) {\n console.error(err);\n }\n}\n\n/**\n * Logs a warning message to console.\n *\n * @param msg - The warning message\n */\nexport function logWarning(msg: string, error?: Error): void {\n if (msg && !global.snaps.suppressWarnings) {\n console.warn(msg);\n if (error && global.snaps.verboseErrors) {\n console.error(error);\n }\n }\n}\n\n/**\n * Logs an error, attempts to unlink the destination file, and exits.\n *\n * @param prefix - The message prefix\n * @param msg - The error message\n * @param err - The original error\n * @param destFilePath - The output file path\n */\nexport async function writeError(\n prefix: string,\n msg: string,\n err: Error,\n destFilePath?: string,\n): Promise<void> {\n let processedPrefix = prefix;\n if (!prefix.endsWith(' ')) {\n processedPrefix += ' ';\n }\n\n logError(processedPrefix + msg, err);\n try {\n if (destFilePath) {\n await filesystem.unlink(destFilePath);\n }\n } catch (unlinkError) {\n logError(`${processedPrefix}Failed to unlink mangled file.`, unlinkError);\n }\n\n // unless the watcher is active, exit\n if (!global.snaps.isWatching) {\n // TODO(ritave): Remove process exit and change into collapse of functions\n // https://github.com/MetaMask/snaps-skunkworks/issues/81\n process.exit(1);\n }\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns - The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n"]}
|
|
@@ -24,11 +24,11 @@ function loadConfig(cached = true) {
|
|
|
24
24
|
snapConfigCache = {};
|
|
25
25
|
return snapConfigCache;
|
|
26
26
|
}
|
|
27
|
-
misc_1.logError(`Error during parsing of ${misc_1.CONFIG_FILE}`, err);
|
|
27
|
+
(0, misc_1.logError)(`Error during parsing of ${misc_1.CONFIG_FILE}`, err);
|
|
28
28
|
return process.exit(1);
|
|
29
29
|
}
|
|
30
|
-
if (!snap_config___GENERATED__1.isSnapConfig(config)) {
|
|
31
|
-
misc_1.logError(`Can't validate ${misc_1.CONFIG_FILE}. Ensure it's a proper javascript file and abides with the structure of a snap configuration file`);
|
|
30
|
+
if (!(0, snap_config___GENERATED__1.isSnapConfig)(config)) {
|
|
31
|
+
(0, misc_1.logError)(`Can't validate ${misc_1.CONFIG_FILE}. Ensure it's a proper javascript file and abides with the structure of a snap configuration file`);
|
|
32
32
|
return process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
snapConfigCache = config;
|
|
@@ -60,7 +60,7 @@ function applyConfig(snapConfig, processArgv, yargsArgv, yargsInstance) {
|
|
|
60
60
|
// If we set args that aren't valid for the current command, yargs will error
|
|
61
61
|
// during validation.
|
|
62
62
|
const { alias: aliases, key: options } = yargsInstance.getOptions();
|
|
63
|
-
const parsedProcessArgv = yargs_parser_1.default(processArgv, {
|
|
63
|
+
const parsedProcessArgv = (0, yargs_parser_1.default)(processArgv, {
|
|
64
64
|
alias: aliases,
|
|
65
65
|
});
|
|
66
66
|
delete parsedProcessArgv._; // irrelevant yargs parser artifact
|
|
@@ -77,7 +77,7 @@ function applyConfig(snapConfig, processArgv, yargsArgv, yargsInstance) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
misc_1.logError(`Error: Encountered unrecognized config property "options.${key}" in config file "${misc_1.CONFIG_FILE}". Remove the property and try again.`);
|
|
80
|
+
(0, misc_1.logError)(`Error: Encountered unrecognized config property "options.${key}" in config file "${misc_1.CONFIG_FILE}". Remove the property and try again.`);
|
|
81
81
|
process.exit(1);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snap-config.js","sourceRoot":"","sources":["../../src/utils/snap-config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,gEAAsC;AAEtC,2DAAmC;AACnC,iCAA+C;AAC/C,0EAA2D;AAQ3D,IAAI,eAAuC,CAAC;AAE5C,SAAgB,UAAU,CAAC,MAAM,GAAG,IAAI;IACtC,IAAI,eAAe,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;QACpD,OAAO,eAAe,CAAC;KACxB;IAED,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ACrB,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;aAC3B;SACF;aAAM;YACL,IAAA,eAAQ,EACN,4DAA4D,GAAG,qBAAqB,kBAAW,uCAAuC,CACvI,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;KACF;AACH,CAAC;AAnDD,kCAmDC","sourcesContent":["import path from 'path';\nimport type browserify from 'browserify';\nimport { Arguments } from 'yargs';\nimport yargsParse from 'yargs-parser';\nimport yargs from 'yargs/yargs';\nimport builders from '../builders';\nimport { CONFIG_FILE, logError } from './misc';\nimport { isSnapConfig } from './snap-config.__GENERATED__';\n\n/** @see {isSnapConfig} ts-auto-guard:type-guard */\nexport type SnapConfig = {\n cliOptions?: Record<string, unknown>;\n bundlerCustomizer?: (bundler: browserify.BrowserifyObject) => void;\n};\n\nlet snapConfigCache: SnapConfig | undefined;\n\nexport function loadConfig(cached = true): SnapConfig {\n if (snapConfigCache !== undefined && cached === true) {\n return snapConfigCache;\n }\n\n let config: any;\n try {\n // eslint-disable-next-line node/global-require, import/no-dynamic-require, @typescript-eslint/no-require-imports\n config = require(path.resolve(process.cwd(), CONFIG_FILE));\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n snapConfigCache = {};\n return snapConfigCache;\n }\n logError(`Error during parsing of ${CONFIG_FILE}`, err);\n return process.exit(1);\n }\n\n if (!isSnapConfig(config)) {\n logError(\n `Can't validate ${CONFIG_FILE}. Ensure it's a proper javascript file and abides with the structure of a snap configuration file`,\n );\n return process.exit(1);\n }\n snapConfigCache = config;\n return config;\n}\n\n// Note that the below function is necessary because yarg's .config() function\n// leaves much to be desired.\n//\n// In particular, it will set all properties included in the config file\n// regardless of the command, which fails during validation.\n\n/**\n * Attempts to read configuration options for package.json and the config file,\n * and apply them to argv if they weren't already set.\n *\n * Arguments are only set per the snap-cli config file if they were not specified\n * on the command line.\n */\nexport function applyConfig(\n snapConfig: SnapConfig,\n processArgv: string[],\n yargsArgv: Arguments,\n yargsInstance: typeof yargs,\n): void {\n // Instances of yargs has a number of undocumented functions, including\n // getOptions. This function returns an object with properties \"key\" and\n // \"alias\", which specify the options associated with the current command and\n // their aliases, respectively.\n //\n // We leverage this to ensure that the config is only applied to args that are\n // valid for the current command, and that weren't specified by the user on\n // the command line.\n //\n // If we set args that aren't valid for the current command, yargs will error\n // during validation.\n const { alias: aliases, key: options } = (\n yargsInstance as any\n ).getOptions() as {\n alias: Record<string, string[]>;\n key: Record<string, unknown>;\n };\n\n const parsedProcessArgv = yargsParse(processArgv, {\n alias: aliases,\n }) as Record<string, unknown>;\n delete parsedProcessArgv._; // irrelevant yargs parser artifact\n\n const commandOptions = new Set(Object.keys(options));\n\n const shouldSetArg = (key: string): boolean => {\n return (\n commandOptions.has(key) &&\n !Object.prototype.hasOwnProperty.call(parsedProcessArgv, key)\n );\n };\n\n const cfg: Record<string, unknown> = snapConfig.cliOptions || {};\n for (const key of Object.keys(cfg)) {\n if (Object.hasOwnProperty.call(builders, key)) {\n if (shouldSetArg(key)) {\n yargsArgv[key] = cfg[key];\n }\n } else {\n logError(\n `Error: Encountered unrecognized config property \"options.${key}\" in config file \"${CONFIG_FILE}\". Remove the property and try again.`,\n );\n process.exit(1);\n }\n }\n}\n"]}
|
|
@@ -42,7 +42,7 @@ exports.validateOutfileName = validateOutfileName;
|
|
|
42
42
|
* @returns - True if validation succeeded
|
|
43
43
|
*/
|
|
44
44
|
async function validateFilePath(filePath) {
|
|
45
|
-
const exists = await fs_1.isFile(filePath);
|
|
45
|
+
const exists = await (0, fs_1.isFile)(filePath);
|
|
46
46
|
if (!exists) {
|
|
47
47
|
throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
|
|
48
48
|
}
|
|
@@ -58,7 +58,7 @@ exports.validateFilePath = validateFilePath;
|
|
|
58
58
|
* @returns - True if validation succeeded
|
|
59
59
|
*/
|
|
60
60
|
async function validateDirPath(dirName, createDir) {
|
|
61
|
-
const exists = await fs_1.isDirectory(dirName, createDir);
|
|
61
|
+
const exists = await (0, fs_1.isDirectory)(dirName, createDir);
|
|
62
62
|
if (!exists) {
|
|
63
63
|
throw new Error(`Invalid params: '${dirName}' is not a directory or could not be created.`);
|
|
64
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-fs.js","sourceRoot":"","sources":["../../src/utils/validate-fs.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA6B;AAC7B,6BAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,WAAmB;IAChE,OAAO,cAAS,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,IAAI,WAAW,CAAC,CAAC;AAC5D,CAAC;AAFD,wCAEC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,IACE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QACzB,QAAQ,KAAK,KAAK;QAClB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAC5B;QACA,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,sBAAsB,CAAC,CAAC;KAC1E;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AATD,kDASC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IACrD,MAAM,MAAM,GAAG,MAAM,WAAM,
|
|
1
|
+
{"version":3,"file":"validate-fs.js","sourceRoot":"","sources":["../../src/utils/validate-fs.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA6B;AAC7B,6BAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,WAAmB;IAChE,OAAO,cAAS,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,IAAI,WAAW,CAAC,CAAC;AAC5D,CAAC;AAFD,wCAEC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,IACE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QACzB,QAAQ,KAAK,KAAK;QAClB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAC5B;QACA,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,sBAAsB,CAAC,CAAC;KAC1E;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AATD,kDASC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IACrD,MAAM,MAAM,GAAG,MAAM,IAAA,WAAM,EAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,oBAAoB,QAAQ,oCAAoC,CACjE,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AARD,4CAQC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,SAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,IAAA,gBAAW,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,oBAAoB,OAAO,+CAA+C,CAC3E,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,0CAWC","sourcesContent":["import pathUtils from 'path';\nimport { isFile, isDirectory } from './fs';\n\n/**\n * Gets the complete out file path from the source file path and output\n * directory path.\n *\n * @param srcFilePath - The source file path\n * @param outDir - The out file directory\n * @returns - The complete out file path\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a js file name.\n * Throws on validation failure\n *\n * @param filename - The file name to validate\n * @returns - True if validation succeeded\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n filename.indexOf('/') !== -1\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path.\n * Throws on validation failure\n *\n * @param filePath - The file path to validate\n * @returns - True if validation succeeded\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path.\n * Throws on validation failure.\n *\n * @param dirPath - The directory path to validate\n * @param createDir - Whether to create the directory if it doesn't exist\n * @returns - True if validation succeeded\n */\nexport async function validateDirPath(\n dirName: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirName, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirName}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A CLI for developing MetaMask Snaps.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"build:watch": "tsc-watch --onSuccess 'yarn build:chmod'",
|
|
29
29
|
"clean": "rimraf dist/* src/**/*__GENERATED__*",
|
|
30
30
|
"test": "yarn build:init-template && jest",
|
|
31
|
+
"posttest": "jest-it-up",
|
|
31
32
|
"test:watch": "yarn test --watch",
|
|
32
33
|
"test:ci": "yarn test",
|
|
33
34
|
"lint:changelog": "yarn auto-changelog validate",
|
|
@@ -45,8 +46,8 @@
|
|
|
45
46
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
46
47
|
"@babel/plugin-transform-runtime": "^7.16.7",
|
|
47
48
|
"@babel/preset-env": "^7.16.7",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
49
|
+
"@chainsafe/strip-comments": "^1.0.5",
|
|
50
|
+
"@metamask/snap-controllers": "^0.11.0",
|
|
50
51
|
"babelify": "^10.0.0",
|
|
51
52
|
"browserify": "^17.0.0",
|
|
52
53
|
"chokidar": "^3.0.2",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"mkdirp": "^1.0.4",
|
|
57
58
|
"rfdc": "^1.3.0",
|
|
58
59
|
"serve-handler": "^6.1.1",
|
|
59
|
-
"ses": "^0.15.
|
|
60
|
+
"ses": "^0.15.15",
|
|
60
61
|
"slash": "^3.0.0",
|
|
61
62
|
"yargs": "^16.2.0",
|
|
62
63
|
"yargs-parser": "^20.2.2"
|
|
@@ -77,8 +78,8 @@
|
|
|
77
78
|
"@types/rimraf": "^3.0.0",
|
|
78
79
|
"@types/serve-handler": "^6.1.0",
|
|
79
80
|
"@types/yargs": "^15.0.12",
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
81
|
-
"@typescript-eslint/parser": "^
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
82
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
82
83
|
"clipboardy": "^2.3.0",
|
|
83
84
|
"eslint": "^7.30.0",
|
|
84
85
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"eslint-plugin-prettier": "^3.4.0",
|
|
89
90
|
"execa": "^5.1.1",
|
|
90
91
|
"jest": "^26.6.3",
|
|
92
|
+
"jest-it-up": "^2.0.0",
|
|
91
93
|
"patch-package": "^6.4.7",
|
|
92
94
|
"prettier": "^2.3.2",
|
|
93
95
|
"rimraf": "^3.0.2",
|
|
@@ -95,10 +97,10 @@
|
|
|
95
97
|
"ts-jest": "^26.5.6",
|
|
96
98
|
"ts-node": "^9.1.1",
|
|
97
99
|
"tsc-watch": "^4.5.0",
|
|
98
|
-
"typescript": "^4.
|
|
100
|
+
"typescript": "^4.4.0"
|
|
99
101
|
},
|
|
100
102
|
"engines": {
|
|
101
|
-
"node": ">=
|
|
103
|
+
"node": ">=14.0.0"
|
|
102
104
|
},
|
|
103
105
|
"publishConfig": {
|
|
104
106
|
"access": "public",
|