@metamask/snaps-cli 0.37.1-flask.1 → 0.38.1-flask.1
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/.browserslistrc +3 -0
- package/CHANGELOG.md +19 -425
- package/README.md +539 -63
- package/dist/cjs/builders.js +40 -41
- package/dist/cjs/builders.js.map +1 -1
- package/dist/cjs/cli.js +14 -14
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/build/build.js +54 -0
- package/dist/cjs/commands/build/build.js.map +1 -0
- package/dist/cjs/commands/build/implementation.js +31 -0
- package/dist/cjs/commands/build/implementation.js.map +1 -0
- package/dist/cjs/{cmds → commands}/build/index.js +18 -5
- package/dist/cjs/commands/build/index.js.map +1 -0
- package/dist/cjs/commands/eval/eval.js +57 -0
- package/dist/cjs/commands/eval/eval.js.map +1 -0
- package/dist/cjs/commands/eval/implementation.js +27 -0
- package/dist/cjs/commands/eval/implementation.js.map +1 -0
- package/dist/cjs/commands/eval/index.js +50 -0
- package/dist/cjs/commands/eval/index.js.map +1 -0
- package/dist/cjs/commands/index.js.map +1 -0
- package/dist/cjs/commands/manifest/implementation.js +34 -0
- package/dist/cjs/commands/manifest/implementation.js.map +1 -0
- package/dist/cjs/commands/manifest/index.js +50 -0
- package/dist/cjs/commands/manifest/index.js.map +1 -0
- package/dist/cjs/commands/manifest/manifest.js +55 -0
- package/dist/cjs/commands/manifest/manifest.js.map +1 -0
- package/dist/cjs/{cmds → commands}/serve/index.js +4 -2
- package/dist/cjs/commands/serve/index.js.map +1 -0
- package/dist/cjs/commands/serve/serve.js +21 -0
- package/dist/cjs/commands/serve/serve.js.map +1 -0
- package/dist/cjs/commands/watch/implementation.js +35 -0
- package/dist/cjs/commands/watch/implementation.js.map +1 -0
- package/dist/cjs/{cmds → commands}/watch/index.js +19 -4
- package/dist/cjs/commands/watch/index.js.map +1 -0
- package/dist/cjs/commands/watch/watch.js +51 -0
- package/dist/cjs/commands/watch/watch.js.map +1 -0
- package/dist/cjs/config.js +290 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/errors.js +37 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +28 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main.js +6 -7
- package/dist/cjs/main.js.map +1 -1
- package/dist/cjs/utils/cli.js +61 -0
- package/dist/cjs/utils/cli.js.map +1 -0
- package/dist/cjs/utils/errors.js +42 -0
- package/dist/cjs/utils/errors.js.map +1 -0
- package/dist/cjs/utils/index.js +6 -2
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/legacy.js +48 -0
- package/dist/cjs/utils/legacy.js.map +1 -0
- package/dist/cjs/utils/logging.js +46 -0
- package/dist/cjs/utils/logging.js.map +1 -0
- package/dist/cjs/utils/path.js +16 -0
- package/dist/cjs/utils/path.js.map +1 -0
- package/dist/cjs/utils/steps.js +52 -0
- package/dist/cjs/utils/steps.js.map +1 -0
- package/dist/cjs/webpack/compiler.js +96 -0
- package/dist/cjs/webpack/compiler.js.map +1 -0
- package/dist/cjs/webpack/config.js +234 -0
- package/dist/cjs/webpack/config.js.map +1 -0
- package/dist/cjs/webpack/index.js +22 -0
- package/dist/cjs/webpack/index.js.map +1 -0
- package/dist/cjs/webpack/loaders/browserify.js +97 -0
- package/dist/cjs/webpack/loaders/browserify.js.map +1 -0
- package/dist/cjs/webpack/loaders/wasm.js +36 -0
- package/dist/cjs/webpack/loaders/wasm.js.map +1 -0
- package/dist/cjs/webpack/plugins.js +340 -0
- package/dist/cjs/webpack/plugins.js.map +1 -0
- package/dist/cjs/webpack/utils.js +133 -0
- package/dist/cjs/webpack/utils.js.map +1 -0
- package/dist/esm/builders.js +40 -41
- package/dist/esm/builders.js.map +1 -1
- package/dist/esm/cli.js +15 -15
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/build/build.js +51 -0
- package/dist/esm/commands/build/build.js.map +1 -0
- package/dist/esm/commands/build/implementation.js +27 -0
- package/dist/esm/commands/build/implementation.js.map +1 -0
- package/dist/esm/{cmds → commands}/build/index.js +5 -5
- package/dist/esm/commands/build/index.js.map +1 -0
- package/dist/esm/commands/eval/eval.js +54 -0
- package/dist/esm/commands/eval/eval.js.map +1 -0
- package/dist/esm/commands/eval/implementation.js +24 -0
- package/dist/esm/commands/eval/implementation.js.map +1 -0
- package/dist/esm/commands/eval/index.js +22 -0
- package/dist/esm/commands/eval/index.js.map +1 -0
- package/dist/esm/commands/index.js +15 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/commands/manifest/implementation.js +33 -0
- package/dist/esm/commands/manifest/implementation.js.map +1 -0
- package/dist/esm/commands/manifest/index.js +22 -0
- package/dist/esm/commands/manifest/index.js.map +1 -0
- package/dist/esm/commands/manifest/manifest.js +52 -0
- package/dist/esm/commands/manifest/manifest.js.map +1 -0
- package/dist/esm/{cmds → commands}/serve/index.js +4 -2
- package/dist/esm/commands/serve/index.js.map +1 -0
- package/dist/esm/commands/serve/serve.js +17 -0
- package/dist/esm/commands/serve/serve.js.map +1 -0
- package/dist/esm/commands/watch/implementation.js +34 -0
- package/dist/esm/commands/watch/implementation.js.map +1 -0
- package/dist/esm/{cmds → commands}/watch/index.js +6 -4
- package/dist/esm/commands/watch/index.js.map +1 -0
- package/dist/esm/commands/watch/watch.js +50 -0
- package/dist/esm/commands/watch/watch.js.map +1 -0
- package/dist/esm/config.js +294 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/errors.js +30 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/main.js +6 -7
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/utils/cli.js +43 -0
- package/dist/esm/utils/cli.js.map +1 -0
- package/dist/esm/utils/errors.js +43 -0
- package/dist/esm/utils/errors.js.map +1 -0
- package/dist/esm/utils/index.js +6 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/legacy.js +47 -0
- package/dist/esm/utils/legacy.js.map +1 -0
- package/dist/esm/utils/logging.js +40 -0
- package/dist/esm/utils/logging.js.map +1 -0
- package/dist/esm/utils/path.js +13 -0
- package/dist/esm/utils/path.js.map +1 -0
- package/dist/esm/utils/steps.js +43 -0
- package/dist/esm/utils/steps.js.map +1 -0
- package/dist/esm/webpack/compiler.js +89 -0
- package/dist/esm/webpack/compiler.js.map +1 -0
- package/dist/esm/webpack/config.js +236 -0
- package/dist/esm/webpack/config.js.map +1 -0
- package/dist/esm/webpack/index.js +5 -0
- package/dist/esm/webpack/index.js.map +1 -0
- package/dist/esm/webpack/loaders/browserify.js +82 -0
- package/dist/esm/webpack/loaders/browserify.js.map +1 -0
- package/dist/esm/webpack/loaders/wasm.js +26 -0
- package/dist/esm/webpack/loaders/wasm.js.map +1 -0
- package/dist/esm/webpack/plugins.js +343 -0
- package/dist/esm/webpack/plugins.js.map +1 -0
- package/dist/esm/webpack/utils.js +160 -0
- package/dist/esm/webpack/utils.js.map +1 -0
- package/dist/types/__fixtures__/configs/cjs.d.ts +1 -0
- package/dist/types/__fixtures__/configs/esm.d.ts +3 -0
- package/dist/types/__fixtures__/configs/invalid.d.ts +3 -0
- package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
- package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +3 -0
- package/dist/types/builders.d.ts +2 -21
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/commands/build/build.d.ts +10 -0
- package/dist/types/commands/build/implementation.d.ts +10 -0
- package/dist/types/{cmds/eval → commands/build}/index.d.ts +1 -0
- package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +3 -0
- package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +3 -0
- package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +3 -0
- package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +3 -0
- package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +3 -0
- package/dist/types/commands/eval/eval.d.ts +14 -0
- package/dist/types/commands/eval/implementation.d.ts +9 -0
- package/dist/types/{cmds/serve → commands/eval}/index.d.ts +1 -0
- package/dist/types/commands/manifest/implementation.d.ts +12 -0
- package/dist/types/{cmds → commands}/manifest/index.d.ts +1 -0
- package/dist/types/commands/manifest/manifest.d.ts +14 -0
- package/dist/types/commands/serve/serve.d.ts +16 -0
- package/dist/types/commands/watch/implementation.d.ts +14 -0
- package/dist/types/commands/watch/index.d.ts +10 -0
- package/dist/types/commands/watch/watch.d.ts +19 -0
- package/dist/types/config.d.ts +626 -0
- package/dist/types/errors.d.ts +25 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/utils/cli.d.ts +17 -0
- package/dist/types/utils/errors.d.ts +23 -0
- package/dist/types/utils/index.d.ts +6 -2
- package/dist/types/utils/legacy.d.ts +27 -0
- package/dist/types/utils/logging.d.ts +22 -0
- package/dist/types/utils/path.d.ts +9 -0
- package/dist/types/utils/steps.d.ts +17 -0
- package/dist/types/webpack/compiler.d.ts +29 -0
- package/dist/types/webpack/config.d.ts +37 -0
- package/dist/types/webpack/index.d.ts +3 -0
- package/dist/types/webpack/loaders/browserify.d.ts +16 -0
- package/dist/types/webpack/loaders/wasm.d.ts +20 -0
- package/dist/types/webpack/plugins.d.ts +147 -0
- package/dist/types/webpack/utils.d.ts +156 -0
- package/package.json +15 -7
- package/dist/cjs/cmds/build/buildHandler.js +0 -36
- package/dist/cjs/cmds/build/buildHandler.js.map +0 -1
- package/dist/cjs/cmds/build/bundle.js +0 -83
- package/dist/cjs/cmds/build/bundle.js.map +0 -1
- package/dist/cjs/cmds/build/index.js.map +0 -1
- package/dist/cjs/cmds/build/utils.js +0 -79
- package/dist/cjs/cmds/build/utils.js.map +0 -1
- package/dist/cjs/cmds/eval/evalHandler.js +0 -24
- package/dist/cjs/cmds/eval/evalHandler.js.map +0 -1
- package/dist/cjs/cmds/eval/index.js +0 -31
- package/dist/cjs/cmds/eval/index.js.map +0 -1
- package/dist/cjs/cmds/index.js.map +0 -1
- package/dist/cjs/cmds/manifest/index.js +0 -44
- package/dist/cjs/cmds/manifest/index.js.map +0 -1
- package/dist/cjs/cmds/manifest/manifestHandler.js +0 -47
- package/dist/cjs/cmds/manifest/manifestHandler.js.map +0 -1
- package/dist/cjs/cmds/serve/index.js.map +0 -1
- package/dist/cjs/cmds/serve/serveHandler.js +0 -62
- package/dist/cjs/cmds/serve/serveHandler.js.map +0 -1
- package/dist/cjs/cmds/serve/serveUtils.js +0 -37
- package/dist/cjs/cmds/serve/serveUtils.js.map +0 -1
- package/dist/cjs/cmds/watch/index.js.map +0 -1
- package/dist/cjs/cmds/watch/watchHandler.js +0 -91
- package/dist/cjs/cmds/watch/watchHandler.js.map +0 -1
- package/dist/cjs/utils/misc.js +0 -142
- package/dist/cjs/utils/misc.js.map +0 -1
- package/dist/cjs/utils/snap-config.js +0 -104
- package/dist/cjs/utils/snap-config.js.map +0 -1
- package/dist/esm/cmds/build/buildHandler.js +0 -36
- package/dist/esm/cmds/build/buildHandler.js.map +0 -1
- package/dist/esm/cmds/build/bundle.js +0 -81
- package/dist/esm/cmds/build/bundle.js.map +0 -1
- package/dist/esm/cmds/build/index.js.map +0 -1
- package/dist/esm/cmds/build/utils.js +0 -88
- package/dist/esm/cmds/build/utils.js.map +0 -1
- package/dist/esm/cmds/eval/evalHandler.js +0 -20
- package/dist/esm/cmds/eval/evalHandler.js.map +0 -1
- package/dist/esm/cmds/eval/index.js +0 -16
- package/dist/esm/cmds/eval/index.js.map +0 -1
- package/dist/esm/cmds/index.js +0 -15
- package/dist/esm/cmds/index.js.map +0 -1
- package/dist/esm/cmds/manifest/index.js +0 -29
- package/dist/esm/cmds/manifest/index.js.map +0 -1
- package/dist/esm/cmds/manifest/manifestHandler.js +0 -44
- package/dist/esm/cmds/manifest/manifestHandler.js.map +0 -1
- package/dist/esm/cmds/serve/index.js.map +0 -1
- package/dist/esm/cmds/serve/serveHandler.js +0 -54
- package/dist/esm/cmds/serve/serveHandler.js.map +0 -1
- package/dist/esm/cmds/serve/serveUtils.js +0 -30
- package/dist/esm/cmds/serve/serveUtils.js.map +0 -1
- package/dist/esm/cmds/watch/index.js.map +0 -1
- package/dist/esm/cmds/watch/watchHandler.js +0 -87
- package/dist/esm/cmds/watch/watchHandler.js.map +0 -1
- package/dist/esm/utils/misc.js +0 -139
- package/dist/esm/utils/misc.js.map +0 -1
- package/dist/esm/utils/snap-config.js +0 -107
- package/dist/esm/utils/snap-config.js.map +0 -1
- package/dist/types/cmds/build/buildHandler.d.ts +0 -13
- package/dist/types/cmds/build/bundle.d.ts +0 -15
- package/dist/types/cmds/build/utils.d.ts +0 -56
- package/dist/types/cmds/eval/evalHandler.d.ts +0 -9
- package/dist/types/cmds/manifest/manifestHandler.d.ts +0 -10
- package/dist/types/cmds/serve/serveHandler.d.ts +0 -10
- package/dist/types/cmds/serve/serveUtils.d.ts +0 -22
- package/dist/types/cmds/watch/index.d.ts +0 -9
- package/dist/types/cmds/watch/watchHandler.d.ts +0 -14
- package/dist/types/utils/misc.d.ts +0 -53
- package/dist/types/utils/snap-config.d.ts +0 -48
- /package/dist/cjs/{cmds → commands}/index.js +0 -0
- /package/dist/types/{cmds → commands}/index.d.ts +0 -0
- /package/dist/types/{cmds/build → commands/serve}/index.d.ts +0 -0
package/dist/cjs/builders.js
CHANGED
|
@@ -23,125 +23,124 @@ var TranspilationModes;
|
|
|
23
23
|
TranspilationModes["None"] = 'none';
|
|
24
24
|
})(TranspilationModes || (TranspilationModes = {}));
|
|
25
25
|
const builders = {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
config: {
|
|
28
|
+
alias: 'c',
|
|
29
|
+
describe: 'Path to config file',
|
|
30
|
+
type: 'string',
|
|
31
|
+
normalize: true
|
|
32
|
+
},
|
|
33
|
+
fix: {
|
|
34
|
+
describe: 'Attempt to fix snap.manifest.json',
|
|
35
|
+
type: 'boolean'
|
|
36
|
+
},
|
|
37
|
+
input: {
|
|
38
|
+
alias: 'i',
|
|
39
|
+
describe: 'Snap bundle file to evaluate',
|
|
40
|
+
type: 'string',
|
|
41
|
+
normalize: true
|
|
42
|
+
},
|
|
43
|
+
// Deprecated Browserify options.
|
|
26
44
|
bundle: {
|
|
27
45
|
alias: 'b',
|
|
28
46
|
describe: 'Snap bundle file',
|
|
29
47
|
type: 'string',
|
|
30
|
-
demandOption: true,
|
|
31
48
|
normalize: true,
|
|
32
|
-
|
|
49
|
+
deprecated: 'Use --input instead.'
|
|
33
50
|
},
|
|
34
51
|
dist: {
|
|
35
52
|
alias: 'd',
|
|
36
53
|
describe: 'Output directory',
|
|
37
54
|
type: 'string',
|
|
38
|
-
demandOption: true,
|
|
39
55
|
normalize: true,
|
|
40
|
-
|
|
56
|
+
deprecated: true
|
|
41
57
|
},
|
|
42
58
|
eval: {
|
|
43
59
|
alias: 'e',
|
|
44
60
|
describe: 'Attempt to evaluate Snap bundle in SES',
|
|
45
61
|
type: 'boolean',
|
|
46
|
-
|
|
47
|
-
default: true
|
|
62
|
+
deprecated: true
|
|
48
63
|
},
|
|
49
64
|
manifest: {
|
|
50
65
|
alias: 'm',
|
|
51
66
|
describe: 'Validate snap.manifest.json',
|
|
52
67
|
type: 'boolean',
|
|
53
|
-
|
|
54
|
-
default: true
|
|
68
|
+
deprecated: true
|
|
55
69
|
},
|
|
56
70
|
port: {
|
|
57
71
|
alias: 'p',
|
|
58
72
|
describe: 'Local server port for testing',
|
|
59
73
|
type: 'number',
|
|
60
|
-
demandOption: true,
|
|
61
|
-
default: 8081,
|
|
62
74
|
coerce: (arg)=>{
|
|
63
75
|
const port = Number.parseInt(String(arg), 10);
|
|
64
76
|
if (Number.isNaN(port)) {
|
|
65
|
-
throw new Error(`Invalid port: ${String(arg)}
|
|
77
|
+
throw new Error(`Invalid port: "${String(arg)}".`);
|
|
66
78
|
}
|
|
67
79
|
return port;
|
|
68
|
-
}
|
|
80
|
+
},
|
|
81
|
+
deprecated: true
|
|
69
82
|
},
|
|
70
83
|
outfileName: {
|
|
71
84
|
alias: 'n',
|
|
72
85
|
describe: 'Output file name',
|
|
73
86
|
type: 'string',
|
|
74
|
-
|
|
75
|
-
default: 'bundle.js'
|
|
87
|
+
deprecated: true
|
|
76
88
|
},
|
|
77
89
|
root: {
|
|
78
90
|
alias: 'r',
|
|
79
91
|
describe: 'Server root directory',
|
|
80
92
|
type: 'string',
|
|
81
|
-
demandOption: true,
|
|
82
93
|
normalize: true,
|
|
83
|
-
|
|
94
|
+
deprecated: true
|
|
84
95
|
},
|
|
85
96
|
sourceMaps: {
|
|
86
97
|
describe: 'Whether builds include sourcemaps',
|
|
87
98
|
type: 'boolean',
|
|
88
|
-
|
|
89
|
-
default: false
|
|
99
|
+
deprecated: true
|
|
90
100
|
},
|
|
91
101
|
src: {
|
|
92
102
|
alias: 's',
|
|
93
103
|
describe: 'Source file',
|
|
94
104
|
type: 'string',
|
|
95
|
-
demandOption: true,
|
|
96
105
|
normalize: true,
|
|
97
|
-
|
|
106
|
+
deprecated: true
|
|
98
107
|
},
|
|
99
108
|
stripComments: {
|
|
100
109
|
alias: 'strip',
|
|
101
110
|
describe: 'Whether to remove code comments from the build output',
|
|
102
111
|
type: 'boolean',
|
|
103
|
-
|
|
104
|
-
default: true
|
|
112
|
+
deprecated: true
|
|
105
113
|
},
|
|
106
114
|
suppressWarnings: {
|
|
107
115
|
type: 'boolean',
|
|
108
116
|
describe: 'Whether to suppress warnings',
|
|
109
|
-
|
|
110
|
-
default: false
|
|
117
|
+
deprecated: true
|
|
111
118
|
},
|
|
112
119
|
transpilationMode: {
|
|
113
120
|
type: 'string',
|
|
114
|
-
describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
choices: Object.values(TranspilationModes)
|
|
121
|
+
describe: 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',
|
|
122
|
+
choices: Object.values(TranspilationModes),
|
|
123
|
+
deprecated: true
|
|
118
124
|
},
|
|
119
125
|
depsToTranspile: {
|
|
120
126
|
type: 'array',
|
|
121
127
|
describe: 'Transpile only the listed dependencies.',
|
|
122
|
-
|
|
128
|
+
deprecated: true
|
|
123
129
|
},
|
|
124
130
|
verboseErrors: {
|
|
125
131
|
type: 'boolean',
|
|
126
132
|
describe: 'Display original errors',
|
|
127
|
-
|
|
128
|
-
default: true
|
|
133
|
+
deprecated: true
|
|
129
134
|
},
|
|
130
135
|
writeManifest: {
|
|
131
|
-
describe: 'Make necessary changes to the
|
|
136
|
+
describe: 'Make necessary changes to the snap manifest file',
|
|
132
137
|
type: 'boolean',
|
|
133
|
-
|
|
134
|
-
default: true
|
|
138
|
+
deprecated: true
|
|
135
139
|
},
|
|
136
140
|
serve: {
|
|
137
|
-
describe: 'Serve
|
|
141
|
+
describe: 'Serve snap file(s) locally for testing',
|
|
138
142
|
type: 'boolean',
|
|
139
|
-
|
|
140
|
-
default: true
|
|
141
|
-
},
|
|
142
|
-
directory: {
|
|
143
|
-
describe: 'the directory to use',
|
|
144
|
-
type: 'string'
|
|
143
|
+
deprecated: true
|
|
145
144
|
}
|
|
146
145
|
};
|
|
147
146
|
const _default = builders;
|
package/dist/cjs/builders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/builders.ts"],"sourcesContent":["import type { Options
|
|
1
|
+
{"version":3,"sources":["../../src/builders.ts"],"sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders: Record<string, Readonly<Options>> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n // Deprecated Browserify options.\n bundle: {\n alias: 'b',\n describe: 'Snap bundle file',\n type: 'string',\n normalize: true,\n deprecated: 'Use --input instead.',\n },\n\n dist: {\n alias: 'd',\n describe: 'Output directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n eval: {\n alias: 'e',\n describe: 'Attempt to evaluate Snap bundle in SES',\n type: 'boolean',\n deprecated: true,\n },\n\n manifest: {\n alias: 'm',\n describe: 'Validate snap.manifest.json',\n type: 'boolean',\n deprecated: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n deprecated: true,\n },\n\n outfileName: {\n alias: 'n',\n describe: 'Output file name',\n type: 'string',\n deprecated: true,\n },\n\n root: {\n alias: 'r',\n describe: 'Server root directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n sourceMaps: {\n describe: 'Whether builds include sourcemaps',\n type: 'boolean',\n deprecated: true,\n },\n\n src: {\n alias: 's',\n describe: 'Source file',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n stripComments: {\n alias: 'strip',\n describe: 'Whether to remove code comments from the build output',\n type: 'boolean',\n deprecated: true,\n },\n\n suppressWarnings: {\n type: 'boolean',\n describe: 'Whether to suppress warnings',\n deprecated: true,\n },\n\n transpilationMode: {\n type: 'string',\n describe:\n 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',\n choices: Object.values(TranspilationModes),\n deprecated: true,\n },\n\n depsToTranspile: {\n type: 'array',\n describe: 'Transpile only the listed dependencies.',\n deprecated: true,\n },\n\n verboseErrors: {\n type: 'boolean',\n describe: 'Display original errors',\n deprecated: true,\n },\n\n writeManifest: {\n describe: 'Make necessary changes to the snap manifest file',\n type: 'boolean',\n deprecated: true,\n },\n\n serve: {\n describe: 'Serve snap file(s) locally for testing',\n type: 'boolean',\n deprecated: true,\n },\n};\n\nexport default builders;\n"],"names":["TranspilationModes","LocalAndDeps","LocalOnly","None","builders","config","alias","describe","type","normalize","fix","input","bundle","deprecated","dist","eval","manifest","port","coerce","arg","Number","parseInt","String","isNaN","Error","outfileName","root","sourceMaps","src","stripComments","suppressWarnings","transpilationMode","choices","Object","values","depsToTranspile","verboseErrors","writeManifest","serve"],"mappings":";;;;;;;;;;;;;;IAsJA,OAAwB;eAAxB;;;IApJO;UAAKA,kBAAkB;IAAlBA,mBACVC,kBAAe;IADLD,mBAEVE,eAAY;IAFFF,mBAGVG,UAAO;GAHGH,uBAAAA;AAMZ,MAAMI,WAA8C;IAClD,gEAAgE;IAChEC,QAAQ;QACNC,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEAC,KAAK;QACHH,UAAU;QACVC,MAAM;IACR;IAEAG,OAAO;QACLL,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;IACb;IAEA,iCAAiC;IACjCG,QAAQ;QACNN,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAC,MAAM;QACJR,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAE,MAAM;QACJT,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAG,UAAU;QACRV,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAI,MAAM;QACJX,OAAO;QACPC,UAAU;QACVC,MAAM;QACNU,QAAQ,CAACC;YACP,MAAMF,OAAOG,OAAOC,QAAQ,CAACC,OAAOH,MAAM;YAC1C,IAAIC,OAAOG,KAAK,CAACN,OAAO;gBACtB,MAAM,IAAIO,MAAM,CAAC,eAAe,EAAEF,OAAOH,KAAK,EAAE,CAAC;YACnD;YAEA,OAAOF;QACT;QACAJ,YAAY;IACd;IAEAY,aAAa;QACXnB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAa,MAAM;QACJpB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAc,YAAY;QACVpB,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAe,KAAK;QACHtB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNC,WAAW;QACXI,YAAY;IACd;IAEAgB,eAAe;QACbvB,OAAO;QACPC,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAiB,kBAAkB;QAChBtB,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAkB,mBAAmB;QACjBvB,MAAM;QACND,UACE;QACFyB,SAASC,OAAOC,MAAM,CAAClC;QACvBa,YAAY;IACd;IAEAsB,iBAAiB;QACf3B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAuB,eAAe;QACb5B,MAAM;QACND,UAAU;QACVM,YAAY;IACd;IAEAwB,eAAe;QACb9B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;IAEAyB,OAAO;QACL/B,UAAU;QACVC,MAAM;QACNK,YAAY;IACd;AACF;MAEA,WAAeT"}
|
package/dist/cjs/cli.js
CHANGED
|
@@ -9,27 +9,27 @@ Object.defineProperty(exports, "cli", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _yargs = /*#__PURE__*/ _interop_require_default(require("yargs"));
|
|
12
|
+
const _helpers = require("yargs/helpers");
|
|
12
13
|
const _builders = /*#__PURE__*/ _interop_require_default(require("./builders"));
|
|
14
|
+
const _config = require("./config");
|
|
13
15
|
const _utils = require("./utils");
|
|
14
16
|
function _interop_require_default(obj) {
|
|
15
17
|
return obj && obj.__esModule ? obj : {
|
|
16
18
|
default: obj
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
|
-
function cli(argv, commands) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(0, _utils.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
process.exitCode = 1;
|
|
32
|
-
}).demandCommand(1, 'You must specify at least one command.').help().alias('help', 'h').argv;
|
|
21
|
+
async function cli(argv, commands) {
|
|
22
|
+
await (0, _yargs.default)((0, _helpers.hideBin)(argv)).scriptName('mm-snap').usage('Usage: $0 <command> [options]').example('$0 build', `Build './src/index.js' as './dist/bundle.js'`).example('$0 build --config ./snap.config.build.ts', `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`).example('$0 manifest --fix', `Check the snap manifest, and fix any errors`).example('$0 watch --port 8000', `The snap input file for changes, and serve it on port 8000`).example('$0 serve --port 8000', `Serve the snap bundle on port 8000`).command(commands).option('config', _builders.default.config).option('verboseErrors', _builders.default.verboseErrors).option('suppressWarnings', _builders.default.suppressWarnings).strict().middleware(async (args)=>{
|
|
23
|
+
// eslint-disable-next-line require-atomic-updates
|
|
24
|
+
args.context = {
|
|
25
|
+
config: await (0, _config.getConfigByArgv)(args)
|
|
26
|
+
};
|
|
27
|
+
(0, _utils.sanitizeInputs)(args);
|
|
28
|
+
}, false).demandCommand(1, 'You must specify at least one command.').fail((message, failure)=>{
|
|
29
|
+
(0, _utils.error)((0, _utils.getYargsErrorMessage)(message, failure));
|
|
30
|
+
// eslint-disable-next-line n/no-process-exit
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}).help().alias('help', 'h').parseAsync();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//# sourceMappingURL=cli.js.map
|
package/dist/cjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport builders from './builders';\nimport { getConfigByArgv } from './config';\nimport { error, getYargsErrorMessage, sanitizeInputs } from './utils';\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport async function cli(argv: string[], commands: any) {\n await yargs(hideBin(argv))\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 build', `Build './src/index.js' as './dist/bundle.js'`)\n .example(\n '$0 build --config ./snap.config.build.ts',\n `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`,\n )\n .example('$0 manifest --fix', `Check the snap manifest, and fix any errors`)\n .example(\n '$0 watch --port 8000',\n `The snap input file for changes, and serve it on port 8000`,\n )\n .example('$0 serve --port 8000', `Serve the snap bundle on port 8000`)\n\n .command(commands)\n\n .option('config', builders.config)\n .option('verboseErrors', builders.verboseErrors)\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n .middleware(async (args: any) => {\n // eslint-disable-next-line require-atomic-updates\n args.context = {\n config: await getConfigByArgv(args),\n };\n\n sanitizeInputs(args);\n }, false)\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .fail((message, failure) => {\n error(getYargsErrorMessage(message, failure));\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n })\n\n .help()\n .alias('help', 'h')\n .parseAsync();\n}\n"],"names":["cli","argv","commands","yargs","hideBin","scriptName","usage","example","command","option","builders","config","verboseErrors","suppressWarnings","strict","middleware","args","context","getConfigByArgv","sanitizeInputs","demandCommand","fail","message","failure","error","getYargsErrorMessage","process","exit","help","alias","parseAsync"],"mappings":";;;;+BAcsBA;;;eAAAA;;;8DAdJ;yBACM;iEAEH;wBACW;uBAC4B;;;;;;AASrD,eAAeA,IAAIC,IAAc,EAAEC,QAAa;IACrD,MAAMC,IAAAA,cAAK,EAACC,IAAAA,gBAAO,EAACH,OACjBI,UAAU,CAAC,WACXC,KAAK,CAAC,iCAENC,OAAO,CAAC,YAAY,CAAC,4CAA4C,CAAC,EAClEA,OAAO,CACN,4CACA,CAAC,yFAAyF,CAAC,EAE5FA,OAAO,CAAC,qBAAqB,CAAC,2CAA2C,CAAC,EAC1EA,OAAO,CACN,wBACA,CAAC,0DAA0D,CAAC,EAE7DA,OAAO,CAAC,wBAAwB,CAAC,kCAAkC,CAAC,EAEpEC,OAAO,CAACN,UAERO,MAAM,CAAC,UAAUC,iBAAQ,CAACC,MAAM,EAChCF,MAAM,CAAC,iBAAiBC,iBAAQ,CAACE,aAAa,EAC9CH,MAAM,CAAC,oBAAoBC,iBAAQ,CAACG,gBAAgB,EAEpDC,MAAM,GAENC,UAAU,CAAC,OAAOC;QACjB,kDAAkD;QAClDA,KAAKC,OAAO,GAAG;YACbN,QAAQ,MAAMO,IAAAA,uBAAe,EAACF;QAChC;QAEAG,IAAAA,qBAAc,EAACH;IACjB,GAAG,OAEFI,aAAa,CAAC,GAAG,0CAEjBC,IAAI,CAAC,CAACC,SAASC;QACdC,IAAAA,YAAK,EAACC,IAAAA,2BAAoB,EAACH,SAASC;QACpC,6CAA6C;QAC7CG,QAAQC,IAAI,CAAC;IACf,GAECC,IAAI,GACJC,KAAK,CAAC,QAAQ,KACdC,UAAU;AACf"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "buildHandler", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return buildHandler;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _snapsutils = require("@metamask/snaps-utils");
|
|
12
|
+
const _path = require("path");
|
|
13
|
+
const _errors = require("../../errors");
|
|
14
|
+
const _utils = require("../../utils");
|
|
15
|
+
const _eval = require("../eval");
|
|
16
|
+
const _implementation = require("./implementation");
|
|
17
|
+
const steps = [
|
|
18
|
+
{
|
|
19
|
+
name: 'Checking the input file.',
|
|
20
|
+
task: async ({ config })=>{
|
|
21
|
+
const { input } = config;
|
|
22
|
+
if (!await (0, _snapsutils.isFile)(input)) {
|
|
23
|
+
throw new _errors.CommandError(`Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'Building the snap bundle.',
|
|
29
|
+
task: async ({ config, spinner })=>{
|
|
30
|
+
// We don't evaluate the bundle here, because it's done in a separate
|
|
31
|
+
// step.
|
|
32
|
+
return await (0, _implementation.build)(config, {
|
|
33
|
+
evaluate: false,
|
|
34
|
+
spinner
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Evaluating the snap bundle.',
|
|
40
|
+
condition: ({ config })=>config.evaluate,
|
|
41
|
+
task: async ({ config, spinner })=>{
|
|
42
|
+
const path = (0, _path.resolve)(process.cwd(), config.output.path, config.output.filename);
|
|
43
|
+
await (0, _eval.evaluate)(path);
|
|
44
|
+
(0, _utils.info)(`Snap bundle evaluated successfully.`, spinner);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
async function buildHandler(config) {
|
|
49
|
+
return await (0, _utils.executeSteps)(steps, {
|
|
50
|
+
config
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/build/build.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve as pathResolve } from 'path';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\nimport { build } from './implementation';\n\ntype BuildContext = {\n config: ProcessedWebpackConfig;\n};\n\nconst steps: Steps<BuildContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n return await build(config, { evaluate: false, spinner });\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n condition: ({ config }) => config.evaluate,\n task: async ({ config, spinner }) => {\n const path = pathResolve(\n process.cwd(),\n config.output.path,\n config.output.filename,\n );\n\n await evaluate(path);\n\n info(`Snap bundle evaluated successfully.`, spinner);\n },\n },\n] as const;\n\n/**\n * Build all files in the given source directory to the given destination\n * directory.\n *\n * This creates the destination directory if it doesn't exist.\n *\n * @param config - The config object.\n */\nexport async function buildHandler(config: ProcessedConfig): Promise<void> {\n return await executeSteps(steps, {\n config,\n });\n}\n"],"names":["buildHandler","steps","name","task","config","input","isFile","CommandError","spinner","build","evaluate","condition","path","pathResolve","process","cwd","output","filename","info","executeSteps"],"mappings":";;;;+BA4DsBA;;;eAAAA;;;4BA5DC;sBACgB;wBAGV;uBAEM;sBACV;gCACH;AAMtB,MAAMC,QAA6B;IACjC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAE;YACrB,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAElB,IAAI,CAAE,MAAME,IAAAA,kBAAM,EAACD,QAAS;gBAC1B,MAAM,IAAIE,oBAAY,CACpB,CAAC,uBAAuB,EAAEF,MAAM,mEAAmE,CAAC;YAExG;QACF;IACF;IACA;QACEH,MAAM;QACNC,MAAM,OAAO,EAAEC,MAAM,EAAEI,OAAO,EAAE;YAC9B,qEAAqE;YACrE,QAAQ;YACR,OAAO,MAAMC,IAAAA,qBAAK,EAACL,QAAQ;gBAAEM,UAAU;gBAAOF;YAAQ;QACxD;IACF;IACA;QACEN,MAAM;QACNS,WAAW,CAAC,EAAEP,MAAM,EAAE,GAAKA,OAAOM,QAAQ;QAC1CP,MAAM,OAAO,EAAEC,MAAM,EAAEI,OAAO,EAAE;YAC9B,MAAMI,OAAOC,IAAAA,aAAW,EACtBC,QAAQC,GAAG,IACXX,OAAOY,MAAM,CAACJ,IAAI,EAClBR,OAAOY,MAAM,CAACC,QAAQ;YAGxB,MAAMP,IAAAA,cAAQ,EAACE;YAEfM,IAAAA,WAAI,EAAC,CAAC,mCAAmC,CAAC,EAAEV;QAC9C;IACF;CACD;AAUM,eAAeR,aAAaI,MAAuB;IACxD,OAAO,MAAMe,IAAAA,mBAAY,EAAClB,OAAO;QAC/BG;IACF;AACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "build", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return build;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _webpack = require("../../webpack");
|
|
12
|
+
async function build(config, options) {
|
|
13
|
+
const compiler = await (0, _webpack.getCompiler)(config, options);
|
|
14
|
+
return await new Promise((resolve, reject)=>{
|
|
15
|
+
compiler.run((runError)=>{
|
|
16
|
+
if (runError) {
|
|
17
|
+
reject(runError);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
compiler.close((closeError)=>{
|
|
21
|
+
if (closeError) {
|
|
22
|
+
reject(closeError);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
resolve();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/build/implementation.ts"],"sourcesContent":["import type { ProcessedWebpackConfig } from '../../config';\nimport type { WebpackOptions } from '../../webpack';\nimport { getCompiler } from '../../webpack';\n\n/**\n * Build the snap bundle. This uses Webpack to build the bundle.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns A promise that resolves when the bundle is built.\n */\nexport async function build(\n config: ProcessedWebpackConfig,\n options?: WebpackOptions,\n) {\n const compiler = await getCompiler(config, options);\n return await new Promise<void>((resolve, reject) => {\n compiler.run((runError) => {\n if (runError) {\n reject(runError);\n return;\n }\n\n compiler.close((closeError) => {\n if (closeError) {\n reject(closeError);\n return;\n }\n\n resolve();\n });\n });\n });\n}\n"],"names":["build","config","options","compiler","getCompiler","Promise","resolve","reject","run","runError","close","closeError"],"mappings":";;;;+BAWsBA;;;eAAAA;;;yBATM;AASrB,eAAeA,MACpBC,MAA8B,EAC9BC,OAAwB;IAExB,MAAMC,WAAW,MAAMC,IAAAA,oBAAW,EAACH,QAAQC;IAC3C,OAAO,MAAM,IAAIG,QAAc,CAACC,SAASC;QACvCJ,SAASK,GAAG,CAAC,CAACC;YACZ,IAAIA,UAAU;gBACZF,OAAOE;gBACP;YACF;YAEAN,SAASO,KAAK,CAAC,CAACC;gBACd,IAAIA,YAAY;oBACdJ,OAAOI;oBACP;gBACF;gBAEAL;YACF;QACF;IACF;AACF"}
|
|
@@ -9,8 +9,21 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const _build = require("./build");
|
|
13
|
+
_export_star(require("./implementation"), exports);
|
|
14
|
+
function _export_star(from, to) {
|
|
15
|
+
Object.keys(from).forEach(function(k) {
|
|
16
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
17
|
+
Object.defineProperty(to, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return from[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return from;
|
|
26
|
+
}
|
|
14
27
|
function _interop_require_default(obj) {
|
|
15
28
|
return obj && obj.__esModule ? obj : {
|
|
16
29
|
default: obj
|
|
@@ -21,11 +34,11 @@ const command = {
|
|
|
21
34
|
'build',
|
|
22
35
|
'b'
|
|
23
36
|
],
|
|
24
|
-
desc: 'Build
|
|
37
|
+
desc: 'Build snap from source',
|
|
25
38
|
builder: (yarg)=>{
|
|
26
|
-
yarg.option('dist', _builders.default.dist).option('eval', _builders.default.eval).option('manifest', _builders.default.manifest).option('outfileName', _builders.default.outfileName).option('sourceMaps', _builders.default.sourceMaps).option('src', _builders.default.src).option('stripComments', _builders.default.stripComments).option('transpilationMode', _builders.default.transpilationMode).option('depsToTranspile', _builders.default.depsToTranspile).option('writeManifest', _builders.default.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode')
|
|
39
|
+
yarg.option('dist', _builders.default.dist).option('eval', _builders.default.eval).option('manifest', _builders.default.manifest).option('outfileName', _builders.default.outfileName).option('sourceMaps', _builders.default.sourceMaps).option('src', _builders.default.src).option('stripComments', _builders.default.stripComments).option('transpilationMode', _builders.default.transpilationMode).option('depsToTranspile', _builders.default.depsToTranspile).option('writeManifest', _builders.default.writeManifest).implies('writeManifest', 'manifest').implies('depsToTranspile', 'transpilationMode');
|
|
27
40
|
},
|
|
28
|
-
handler: async (argv)=>(0,
|
|
41
|
+
handler: async (argv)=>(0, _build.buildHandler)(argv.context.config)
|
|
29
42
|
};
|
|
30
43
|
const _default = command;
|
|
31
44
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/build/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { buildHandler } from './build';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('dist', builders.dist)\n .option('eval', builders.eval)\n .option('manifest', builders.manifest)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('src', builders.src)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('writeManifest', builders.writeManifest)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) => buildHandler(argv.context.config),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["command","desc","builder","yarg","option","builders","dist","eval","manifest","outfileName","sourceMaps","src","stripComments","transpilationMode","depsToTranspile","writeManifest","implies","handler","argv","buildHandler","context","config"],"mappings":";;;;+BA4BA;;;eAAA;;;iEA1BqB;uBAEQ;qBAuBf;;;;;;;;;;;;;;;;;;;AArBd,MAAMA,UAAU;IACdA,SAAS;QAAC;QAAS;KAAI;IACvBC,MAAM;IACNC,SAAS,CAACC;QACRA,KACGC,MAAM,CAAC,QAAQC,iBAAQ,CAACC,IAAI,EAC5BF,MAAM,CAAC,QAAQC,iBAAQ,CAACE,IAAI,EAC5BH,MAAM,CAAC,YAAYC,iBAAQ,CAACG,QAAQ,EACpCJ,MAAM,CAAC,eAAeC,iBAAQ,CAACI,WAAW,EAC1CL,MAAM,CAAC,cAAcC,iBAAQ,CAACK,UAAU,EACxCN,MAAM,CAAC,OAAOC,iBAAQ,CAACM,GAAG,EAC1BP,MAAM,CAAC,iBAAiBC,iBAAQ,CAACO,aAAa,EAC9CR,MAAM,CAAC,qBAAqBC,iBAAQ,CAACQ,iBAAiB,EACtDT,MAAM,CAAC,mBAAmBC,iBAAQ,CAACS,eAAe,EAClDV,MAAM,CAAC,iBAAiBC,iBAAQ,CAACU,aAAa,EAC9CC,OAAO,CAAC,iBAAiB,YACzBA,OAAO,CAAC,mBAAmB;IAChC;IACAC,SAAS,OAAOC,OAAoBC,IAAAA,mBAAY,EAACD,KAAKE,OAAO,CAACC,MAAM;AACtE;MAGA,WAAerB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "evaluateHandler", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return evaluateHandler;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _snapsutils = require("@metamask/snaps-utils");
|
|
12
|
+
const _path = require("path");
|
|
13
|
+
const _errors = require("../../errors");
|
|
14
|
+
const _utils = require("../../utils");
|
|
15
|
+
const _implementation = require("./implementation");
|
|
16
|
+
const steps = [
|
|
17
|
+
{
|
|
18
|
+
name: 'Checking the input file.',
|
|
19
|
+
task: async ({ input })=>{
|
|
20
|
+
if (!await (0, _snapsutils.isFile)(input)) {
|
|
21
|
+
const relativePath = (0, _utils.getRelativePath)(input);
|
|
22
|
+
throw new _errors.CommandError(`Input file not found: "${relativePath}". Make sure that the "input" field in your snap config or the specified input file is correct.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Evaluating the snap bundle.',
|
|
28
|
+
task: async ({ input, spinner })=>{
|
|
29
|
+
await (0, _implementation.evaluate)(input);
|
|
30
|
+
spinner.succeed('Snap bundle evaluated successfully.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* Returns the path to the bundle, based on the config and options.
|
|
36
|
+
*
|
|
37
|
+
* - If `options.input` is specified, it is used as the bundle path.
|
|
38
|
+
* - Otherwise, the bundle path is resolved from the config's output path and
|
|
39
|
+
* filename.
|
|
40
|
+
*
|
|
41
|
+
* @param config - The processed config object.
|
|
42
|
+
* @param options - The eval options.
|
|
43
|
+
* @returns The path to the bundle.
|
|
44
|
+
*/ function getBundlePath(config, options) {
|
|
45
|
+
if (options.input) {
|
|
46
|
+
return (0, _path.resolve)(process.cwd(), options.input);
|
|
47
|
+
}
|
|
48
|
+
return (0, _path.resolve)(config.output.path, config.output.filename);
|
|
49
|
+
}
|
|
50
|
+
async function evaluateHandler(config, options = {}) {
|
|
51
|
+
const input = getBundlePath(config, options);
|
|
52
|
+
await (0, _utils.executeSteps)(steps, {
|
|
53
|
+
input
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=eval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/eval/eval.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils';\nimport { resolve } from 'path';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, getRelativePath } from '../../utils';\nimport { evaluate } from './implementation';\n\nexport type EvalOptions = {\n input?: string;\n};\n\nexport type EvalContext = Required<EvalOptions>;\n\nconst steps: Steps<EvalContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n const relativePath = getRelativePath(input);\n throw new CommandError(\n `Input file not found: \"${relativePath}\". Make sure that the \"input\" field in your snap config or the specified input file is correct.`,\n );\n }\n },\n },\n {\n name: 'Evaluating the snap bundle.',\n task: async ({ input, spinner }) => {\n await evaluate(input);\n spinner.succeed('Snap bundle evaluated successfully.');\n },\n },\n];\n\n/**\n * Returns the path to the bundle, based on the config and options.\n *\n * - If `options.input` is specified, it is used as the bundle path.\n * - Otherwise, the bundle path is resolved from the config's output path and\n * filename.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns The path to the bundle.\n */\nfunction getBundlePath(config: ProcessedConfig, options: EvalOptions): string {\n if (options.input) {\n return resolve(process.cwd(), options.input);\n }\n\n return resolve(config.output.path, config.output.filename);\n}\n\n/**\n * Runs the snap in a worker, to ensure SES compatibility.\n *\n * @param config - The processed config object.\n * @param options - The eval options.\n * @returns A promise that resolves once the eval has finished.\n * @throws If the eval failed.\n */\nexport async function evaluateHandler(\n config: ProcessedConfig,\n options: EvalOptions = {},\n): Promise<void> {\n const input = getBundlePath(config, options);\n await executeSteps(steps, { input });\n}\n"],"names":["evaluateHandler","steps","name","task","input","isFile","relativePath","getRelativePath","CommandError","spinner","evaluate","succeed","getBundlePath","config","options","resolve","process","cwd","output","path","filename","executeSteps"],"mappings":";;;;+BA+DsBA;;;eAAAA;;;4BA/DC;sBACC;wBAGK;uBAEiB;gCACrB;AAQzB,MAAMC,QAA4B;IAChC;QACEC,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAE;YACpB,IAAI,CAAE,MAAMC,IAAAA,kBAAM,EAACD,QAAS;gBAC1B,MAAME,eAAeC,IAAAA,sBAAe,EAACH;gBACrC,MAAM,IAAII,oBAAY,CACpB,CAAC,uBAAuB,EAAEF,aAAa,+FAA+F,CAAC;YAE3I;QACF;IACF;IACA;QACEJ,MAAM;QACNC,MAAM,OAAO,EAAEC,KAAK,EAAEK,OAAO,EAAE;YAC7B,MAAMC,IAAAA,wBAAQ,EAACN;YACfK,QAAQE,OAAO,CAAC;QAClB;IACF;CACD;AAED;;;;;;;;;;CAUC,GACD,SAASC,cAAcC,MAAuB,EAAEC,OAAoB;IAClE,IAAIA,QAAQV,KAAK,EAAE;QACjB,OAAOW,IAAAA,aAAO,EAACC,QAAQC,GAAG,IAAIH,QAAQV,KAAK;IAC7C;IAEA,OAAOW,IAAAA,aAAO,EAACF,OAAOK,MAAM,CAACC,IAAI,EAAEN,OAAOK,MAAM,CAACE,QAAQ;AAC3D;AAUO,eAAepB,gBACpBa,MAAuB,EACvBC,UAAuB,CAAC,CAAC;IAEzB,MAAMV,QAAQQ,cAAcC,QAAQC;IACpC,MAAMO,IAAAA,mBAAY,EAACpB,OAAO;QAAEG;IAAM;AACpC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "evaluate", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return evaluate;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _snapsutils = require("@metamask/snaps-utils");
|
|
12
|
+
const _chalk = require("chalk");
|
|
13
|
+
const _errors = require("../../errors");
|
|
14
|
+
async function evaluate(path) {
|
|
15
|
+
try {
|
|
16
|
+
return await (0, _snapsutils.evalBundle)(path);
|
|
17
|
+
} catch (evalError) {
|
|
18
|
+
if (evalError instanceof _snapsutils.SnapEvalError) {
|
|
19
|
+
throw new _errors.CommandError(`Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\nReceived the following error from the SES environment:\n\n${(0, _snapsutils.indent)((0, _chalk.red)(evalError.output.stderr), 2)}`);
|
|
20
|
+
}
|
|
21
|
+
// If the error is not a `SnapEvalError`, we don't know what it is, so
|
|
22
|
+
// we just throw it.
|
|
23
|
+
throw evalError;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/eval/implementation.ts"],"sourcesContent":["import { evalBundle, SnapEvalError, indent } from '@metamask/snaps-utils';\nimport { red } from 'chalk';\n\nimport { CommandError } from '../../errors';\n\n/**\n * Evaluate the given bundle in the SES environment. This is a wrapper around\n * {@link evalBundle} that throws a {@link CommandError} if the bundle cannot be\n * evaluated.\n *\n * @param path - The path to the bundle.\n * @throws If the bundle cannot be evaluated.\n */\nexport async function evaluate(path: string) {\n try {\n return await evalBundle(path);\n } catch (evalError) {\n if (evalError instanceof SnapEvalError) {\n throw new CommandError(\n `Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap.\\nReceived the following error from the SES environment:\\n\\n${indent(\n red(evalError.output.stderr),\n 2,\n )}`,\n );\n }\n\n // If the error is not a `SnapEvalError`, we don't know what it is, so\n // we just throw it.\n throw evalError;\n }\n}\n"],"names":["evaluate","path","evalBundle","evalError","SnapEvalError","CommandError","indent","red","output","stderr"],"mappings":";;;;+BAasBA;;;eAAAA;;;4BAb4B;uBAC9B;wBAES;AAUtB,eAAeA,SAASC,IAAY;IACzC,IAAI;QACF,OAAO,MAAMC,IAAAA,sBAAU,EAACD;IAC1B,EAAE,OAAOE,WAAW;QAClB,IAAIA,qBAAqBC,yBAAa,EAAE;YACtC,MAAM,IAAIC,oBAAY,CACpB,CAAC,kLAAkL,EAAEC,IAAAA,kBAAM,EACzLC,IAAAA,UAAG,EAACJ,UAAUK,MAAM,CAACC,MAAM,GAC3B,GACA,CAAC;QAEP;QAEA,sEAAsE;QACtE,oBAAoB;QACpB,MAAMN;IACR;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _builders = /*#__PURE__*/ _interop_require_default(require("../../builders"));
|
|
12
|
+
const _eval = require("./eval");
|
|
13
|
+
_export_star(require("./implementation"), exports);
|
|
14
|
+
function _export_star(from, to) {
|
|
15
|
+
Object.keys(from).forEach(function(k) {
|
|
16
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
17
|
+
Object.defineProperty(to, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return from[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return from;
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_default(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const command = {
|
|
33
|
+
command: [
|
|
34
|
+
'eval',
|
|
35
|
+
'e'
|
|
36
|
+
],
|
|
37
|
+
desc: 'Attempt to evaluate snap bundle in SES',
|
|
38
|
+
builder: (yarg)=>{
|
|
39
|
+
// Browserify options. These are merged into the config object.
|
|
40
|
+
yarg.option('bundle', _builders.default.bundle);
|
|
41
|
+
// Webpack options.
|
|
42
|
+
yarg.option('input', _builders.default.input);
|
|
43
|
+
},
|
|
44
|
+
handler: async (argv)=>(0, _eval.evaluateHandler)(argv.context.config, {
|
|
45
|
+
input: argv.input
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
const _default = command;
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/eval/index.ts"],"sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { evaluateHandler } from './eval';\n\nconst command = {\n command: ['eval', 'e'],\n desc: 'Attempt to evaluate snap bundle in SES',\n builder: (yarg: yargs.Argv) => {\n // Browserify options. These are merged into the config object.\n yarg.option('bundle', builders.bundle);\n\n // Webpack options.\n yarg.option('input', builders.input);\n },\n handler: async (argv: YargsArgs) =>\n evaluateHandler(argv.context.config, { input: argv.input }),\n};\n\nexport * from './implementation';\nexport default command;\n"],"names":["command","desc","builder","yarg","option","builders","bundle","input","handler","argv","evaluateHandler","context","config"],"mappings":";;;;+BAqBA;;;eAAA;;;iEAnBqB;sBAEW;qBAgBlB;;;;;;;;;;;;;;;;;;;AAdd,MAAMA,UAAU;IACdA,SAAS;QAAC;QAAQ;KAAI;IACtBC,MAAM;IACNC,SAAS,CAACC;QACR,+DAA+D;QAC/DA,KAAKC,MAAM,CAAC,UAAUC,iBAAQ,CAACC,MAAM;QAErC,mBAAmB;QACnBH,KAAKC,MAAM,CAAC,SAASC,iBAAQ,CAACE,KAAK;IACrC;IACAC,SAAS,OAAOC,OACdC,IAAAA,qBAAe,EAACD,KAAKE,OAAO,CAACC,MAAM,EAAE;YAAEL,OAAOE,KAAKF,KAAK;QAAC;AAC7D;MAGA,WAAeP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/index.ts"],"sourcesContent":["import buildCommand from './build';\nimport evaluateCommand from './eval';\nimport manifestCommand from './manifest';\nimport serveCommand from './serve';\nimport watchCommand from './watch';\n\nconst commands = [\n buildCommand,\n evaluateCommand,\n manifestCommand,\n serveCommand,\n watchCommand,\n];\n\nexport default commands;\n"],"names":["commands","buildCommand","evaluateCommand","manifestCommand","serveCommand","watchCommand"],"mappings":";;;;+BAcA;;;eAAA;;;8DAdyB;6DACG;iEACA;8DACH;8DACA;;;;;;AAEzB,MAAMA,WAAW;IACfC,cAAY;IACZC,aAAe;IACfC,iBAAe;IACfC,cAAY;IACZC,cAAY;CACb;MAED,WAAeL"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "manifest", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return manifest;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _snapsutils = require("@metamask/snaps-utils");
|
|
12
|
+
const _chalk = require("chalk");
|
|
13
|
+
const _path = require("path");
|
|
14
|
+
const _utils = require("../../utils");
|
|
15
|
+
async function manifest(path, write, spinner) {
|
|
16
|
+
const { warnings, errors, updated } = await (0, _snapsutils.checkManifest)((0, _path.dirname)(path), write);
|
|
17
|
+
if (write && updated) {
|
|
18
|
+
(0, _utils.info)('The snap manifest file has been updated.', spinner);
|
|
19
|
+
}
|
|
20
|
+
if (!write && errors.length > 0) {
|
|
21
|
+
const formattedErrors = errors.map((manifestError)=>(0, _snapsutils.indent)((0, _chalk.red)(`• ${manifestError}`))).join('\n');
|
|
22
|
+
(0, _utils.error)(`The snap manifest file is invalid.\n\n${formattedErrors}\n\nRun the command with the \`--fix\` flag to attempt to fix the manifest.`, spinner);
|
|
23
|
+
spinner?.stop();
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (warnings.length > 0) {
|
|
28
|
+
const formattedWarnings = warnings.map((manifestWarning)=>(0, _snapsutils.indent)((0, _chalk.yellow)(`• ${manifestWarning}`)));
|
|
29
|
+
(0, _utils.warn)(`The snap manifest file has warnings.\n\n${formattedWarnings.join('\n')}`, spinner);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=implementation.js.map
|