@metamask-previews/wallet-cli 0.0.0-preview-bbd2df29f → 0.0.0-preview-ea5e7f6d0
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 +1 -4
- package/README.md +0 -41
- package/dist/daemon/daemon-entry.cjs +0 -4
- package/dist/daemon/daemon-entry.cjs.map +1 -1
- package/dist/daemon/daemon-entry.mjs +0 -4
- package/dist/daemon/daemon-entry.mjs.map +1 -1
- package/dist/daemon/daemon-spawn.cjs +25 -46
- package/dist/daemon/daemon-spawn.cjs.map +1 -1
- package/dist/daemon/daemon-spawn.d.cts.map +1 -1
- package/dist/daemon/daemon-spawn.d.mts.map +1 -1
- package/dist/daemon/daemon-spawn.mjs +26 -47
- package/dist/daemon/daemon-spawn.mjs.map +1 -1
- package/dist/daemon/socket-line.cjs +4 -8
- package/dist/daemon/socket-line.cjs.map +1 -1
- package/dist/daemon/socket-line.d.cts +0 -2
- package/dist/daemon/socket-line.d.cts.map +1 -1
- package/dist/daemon/socket-line.d.mts +0 -2
- package/dist/daemon/socket-line.d.mts.map +1 -1
- package/dist/daemon/socket-line.mjs +4 -8
- package/dist/daemon/socket-line.mjs.map +1 -1
- package/dist/daemon/stop-daemon.cjs +9 -23
- package/dist/daemon/stop-daemon.cjs.map +1 -1
- package/dist/daemon/stop-daemon.d.cts +7 -17
- package/dist/daemon/stop-daemon.d.cts.map +1 -1
- package/dist/daemon/stop-daemon.d.mts +7 -17
- package/dist/daemon/stop-daemon.d.mts.map +1 -1
- package/dist/daemon/stop-daemon.mjs +9 -23
- package/dist/daemon/stop-daemon.mjs.map +1 -1
- package/dist/daemon/utils.cjs +1 -52
- package/dist/daemon/utils.cjs.map +1 -1
- package/dist/daemon/utils.d.cts +0 -28
- package/dist/daemon/utils.d.cts.map +1 -1
- package/dist/daemon/utils.d.mts +0 -28
- package/dist/daemon/utils.d.mts.map +1 -1
- package/dist/daemon/utils.mjs +0 -48
- package/dist/daemon/utils.mjs.map +1 -1
- package/package.json +2 -5
- package/dist/commands/daemon/call.cjs +0 -79
- package/dist/commands/daemon/call.cjs.map +0 -1
- package/dist/commands/daemon/call.d.cts +0 -14
- package/dist/commands/daemon/call.d.cts.map +0 -1
- package/dist/commands/daemon/call.d.mts +0 -14
- package/dist/commands/daemon/call.d.mts.map +0 -1
- package/dist/commands/daemon/call.mjs +0 -77
- package/dist/commands/daemon/call.mjs.map +0 -1
- package/dist/commands/daemon/list.cjs +0 -48
- package/dist/commands/daemon/list.cjs.map +0 -1
- package/dist/commands/daemon/list.d.cts +0 -7
- package/dist/commands/daemon/list.d.cts.map +0 -1
- package/dist/commands/daemon/list.d.mts +0 -7
- package/dist/commands/daemon/list.d.mts.map +0 -1
- package/dist/commands/daemon/list.mjs +0 -46
- package/dist/commands/daemon/list.mjs.map +0 -1
- package/dist/commands/daemon/purge.cjs +0 -58
- package/dist/commands/daemon/purge.cjs.map +0 -1
- package/dist/commands/daemon/purge.d.cts +0 -10
- package/dist/commands/daemon/purge.d.cts.map +0 -1
- package/dist/commands/daemon/purge.d.mts +0 -10
- package/dist/commands/daemon/purge.d.mts.map +0 -1
- package/dist/commands/daemon/purge.mjs +0 -56
- package/dist/commands/daemon/purge.mjs.map +0 -1
- package/dist/commands/daemon/start.cjs +0 -48
- package/dist/commands/daemon/start.cjs.map +0 -1
- package/dist/commands/daemon/start.d.cts +0 -12
- package/dist/commands/daemon/start.d.cts.map +0 -1
- package/dist/commands/daemon/start.d.mts +0 -12
- package/dist/commands/daemon/start.d.mts.map +0 -1
- package/dist/commands/daemon/start.mjs +0 -46
- package/dist/commands/daemon/start.mjs.map +0 -1
- package/dist/commands/daemon/status.cjs +0 -59
- package/dist/commands/daemon/status.cjs.map +0 -1
- package/dist/commands/daemon/status.d.cts +0 -7
- package/dist/commands/daemon/status.d.cts.map +0 -1
- package/dist/commands/daemon/status.d.mts +0 -7
- package/dist/commands/daemon/status.d.mts.map +0 -1
- package/dist/commands/daemon/status.mjs +0 -57
- package/dist/commands/daemon/status.mjs.map +0 -1
- package/dist/commands/daemon/stop.cjs +0 -26
- package/dist/commands/daemon/stop.cjs.map +0 -1
- package/dist/commands/daemon/stop.d.cts +0 -7
- package/dist/commands/daemon/stop.d.cts.map +0 -1
- package/dist/commands/daemon/stop.d.mts +0 -7
- package/dist/commands/daemon/stop.d.mts.map +0 -1
- package/dist/commands/daemon/stop.mjs +0 -24
- package/dist/commands/daemon/stop.mjs.map +0 -1
- package/dist/test/run-command.cjs +0 -73
- package/dist/test/run-command.cjs.map +0 -1
- package/dist/test/run-command.d.cts +0 -27
- package/dist/test/run-command.d.cts.map +0 -1
- package/dist/test/run-command.d.mts +0 -27
- package/dist/test/run-command.d.mts.map +0 -1
- package/dist/test/run-command.mjs +0 -69
- package/dist/test/run-command.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.d.mts","sourceRoot":"","sources":["../../src/test/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB;AAC1C,OAAO,EAAE,QAAQ,EAAE,2BAA2B;AAE9C,KAAK,WAAW,GAAG,KACjB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,KACX,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9B,CAAC;AAKF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAC9B,YAAY,EAAE,WAAW,EACzB,IAAI,GAAE,MAAM,EAAO,GAClB,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC7B,CAAC,CAkDD"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
import { CLIError } from "@oclif/core/errors";
|
|
3
|
-
const TEST_DATA_DIR = '/tmp/mm-cli-test-data';
|
|
4
|
-
const TEST_PACKAGE_ROOT = '/tmp/mm-cli-test-root';
|
|
5
|
-
/**
|
|
6
|
-
* Invoke an oclif command class with the given argv and return the captured
|
|
7
|
-
* stdout/stderr/error so tests can assert on them.
|
|
8
|
-
*
|
|
9
|
-
* Bypasses `Command.run`'s static plugin-loading path (which requires a real
|
|
10
|
-
* `Config.load`) by constructing the command instance directly with a
|
|
11
|
-
* hand-rolled `Config` and invoking the protected `_run`. Spies on the
|
|
12
|
-
* Command prototype so `this.log` and `this.error` go to local buffers
|
|
13
|
-
* instead of stdout/stderr.
|
|
14
|
-
*
|
|
15
|
-
* @param CommandClass - The command class (a subclass of `@oclif/core` Command).
|
|
16
|
-
* @param argv - Command-line tokens (flags + positional args).
|
|
17
|
-
* @returns Captured stdout, stderr, and any `this.error()` payload.
|
|
18
|
-
*/
|
|
19
|
-
export async function runCommand(CommandClass, argv = []) {
|
|
20
|
-
let stdout = '';
|
|
21
|
-
let stderr = '';
|
|
22
|
-
let error;
|
|
23
|
-
const fakeConfig = {
|
|
24
|
-
dataDir: TEST_DATA_DIR,
|
|
25
|
-
root: TEST_PACKAGE_ROOT,
|
|
26
|
-
bin: 'mm',
|
|
27
|
-
name: '@metamask/wallet-cli',
|
|
28
|
-
version: '0.0.0-test',
|
|
29
|
-
pjson: { name: '@metamask/wallet-cli', version: '0.0.0-test' },
|
|
30
|
-
findCommand: () => undefined,
|
|
31
|
-
runHook: async () => ({ successes: [], failures: [] }),
|
|
32
|
-
scopedEnvVar: () => undefined,
|
|
33
|
-
scopedEnvVarKey: () => '',
|
|
34
|
-
scopedEnvVarKeys: () => [],
|
|
35
|
-
scopedEnvVarTrue: () => false,
|
|
36
|
-
plugins: new Map(),
|
|
37
|
-
flexibleTaxonomy: false,
|
|
38
|
-
};
|
|
39
|
-
const logSpy = jest
|
|
40
|
-
.spyOn(Command.prototype, 'log')
|
|
41
|
-
.mockImplementation((message = '') => {
|
|
42
|
-
stdout += `${String(message)}\n`;
|
|
43
|
-
});
|
|
44
|
-
const errorSpy = jest
|
|
45
|
-
.spyOn(Command.prototype, 'error')
|
|
46
|
-
.mockImplementation((input) => {
|
|
47
|
-
const message = typeof input === 'string' ? input : input.message;
|
|
48
|
-
throw new CLIError(message);
|
|
49
|
-
});
|
|
50
|
-
try {
|
|
51
|
-
const instance = new CommandClass(argv, fakeConfig);
|
|
52
|
-
await instance._run();
|
|
53
|
-
}
|
|
54
|
-
catch (caught) {
|
|
55
|
-
if (caught instanceof CLIError) {
|
|
56
|
-
error = caught;
|
|
57
|
-
stderr += `${caught.message}\n`;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw caught;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
logSpy.mockRestore();
|
|
65
|
-
errorSpy.mockRestore();
|
|
66
|
-
}
|
|
67
|
-
return { stdout, stderr, error };
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=run-command.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.mjs","sourceRoot":"","sources":["../../src/test/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB;AAEtC,OAAO,EAAE,QAAQ,EAAE,2BAA2B;AAS9C,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAC9C,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,YAAyB,EACzB,OAAiB,EAAE;IAMnB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,KAA2B,CAAC;IAEhC,MAAM,UAAU,GAAG;QACjB,OAAO,EAAE,aAAa;QACtB,IAAI,EAAE,iBAAiB;QACvB,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,sBAA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B,IAAI,MAAM,YAAY,QAAQ,EAAE,CAAC;YAC/B,KAAK,GAAG,MAAM,CAAC;YACf,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,IAAI,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CAAC;QACf,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACrB,QAAQ,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { Command } from '@oclif/core';\nimport type { Config } from '@oclif/core';\nimport { CLIError } from '@oclif/core/errors';\n\ntype CommandCtor = new (\n argv: string[],\n config: Config,\n) => Command & {\n _run: () => Promise<unknown>;\n};\n\nconst TEST_DATA_DIR = '/tmp/mm-cli-test-data';\nconst TEST_PACKAGE_ROOT = '/tmp/mm-cli-test-root';\n\n/**\n * Invoke an oclif command class with the given argv and return the captured\n * stdout/stderr/error so tests can assert on them.\n *\n * Bypasses `Command.run`'s static plugin-loading path (which requires a real\n * `Config.load`) by constructing the command instance directly with a\n * hand-rolled `Config` and invoking the protected `_run`. Spies on the\n * Command prototype so `this.log` and `this.error` go to local buffers\n * instead of stdout/stderr.\n *\n * @param CommandClass - The command class (a subclass of `@oclif/core` Command).\n * @param argv - Command-line tokens (flags + positional args).\n * @returns Captured stdout, stderr, and any `this.error()` payload.\n */\nexport async function runCommand(\n CommandClass: CommandCtor,\n argv: string[] = [],\n): Promise<{\n stdout: string;\n stderr: string;\n error: CLIError | undefined;\n}> {\n let stdout = '';\n let stderr = '';\n let error: CLIError | undefined;\n\n const fakeConfig = {\n dataDir: TEST_DATA_DIR,\n root: TEST_PACKAGE_ROOT,\n bin: 'mm',\n name: '@metamask/wallet-cli',\n version: '0.0.0-test',\n pjson: { name: '@metamask/wallet-cli', version: '0.0.0-test' },\n findCommand: () => undefined,\n runHook: async () => ({ successes: [], failures: [] }),\n scopedEnvVar: () => undefined,\n scopedEnvVarKey: () => '',\n scopedEnvVarKeys: () => [],\n scopedEnvVarTrue: () => false,\n plugins: new Map(),\n flexibleTaxonomy: false,\n } as unknown as Config;\n\n const logSpy = jest\n .spyOn(Command.prototype, 'log')\n .mockImplementation((message: unknown = '') => {\n stdout += `${String(message)}\\n`;\n });\n const errorSpy = jest\n .spyOn(Command.prototype, 'error')\n .mockImplementation((input: string | Error) => {\n const message = typeof input === 'string' ? input : input.message;\n throw new CLIError(message);\n });\n\n try {\n const instance = new CommandClass(argv, fakeConfig);\n await instance._run();\n } catch (caught: unknown) {\n if (caught instanceof CLIError) {\n error = caught;\n stderr += `${caught.message}\\n`;\n } else {\n throw caught;\n }\n } finally {\n logSpy.mockRestore();\n errorSpy.mockRestore();\n }\n\n return { stdout, stderr, error };\n}\n"]}
|