@metamask/snaps-cli 6.6.1 → 6.7.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 +8 -1
- package/dist/builders.cjs +4 -1
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +117 -2
- package/dist/builders.d.cts.map +1 -1
- package/dist/builders.d.mts +117 -2
- package/dist/builders.d.mts.map +1 -1
- package/dist/builders.mjs +4 -1
- package/dist/builders.mjs.map +1 -1
- package/dist/commands/build/build.cjs +32 -6
- package/dist/commands/build/build.cjs.map +1 -1
- package/dist/commands/build/build.d.cts +2 -1
- package/dist/commands/build/build.d.cts.map +1 -1
- package/dist/commands/build/build.d.mts +2 -1
- package/dist/commands/build/build.d.mts.map +1 -1
- package/dist/commands/build/build.mjs +30 -4
- package/dist/commands/build/build.mjs.map +1 -1
- package/dist/commands/build/implementation.cjs +1 -1
- package/dist/commands/build/implementation.cjs.map +1 -1
- package/dist/commands/build/implementation.d.cts +2 -1
- package/dist/commands/build/implementation.d.cts.map +1 -1
- package/dist/commands/build/implementation.d.mts +2 -1
- package/dist/commands/build/implementation.d.mts.map +1 -1
- package/dist/commands/build/implementation.mjs +1 -1
- package/dist/commands/build/implementation.mjs.map +1 -1
- package/dist/commands/build/index.cjs +2 -1
- package/dist/commands/build/index.cjs.map +1 -1
- package/dist/commands/build/index.d.cts.map +1 -1
- package/dist/commands/build/index.d.mts.map +1 -1
- package/dist/commands/build/index.mjs +2 -1
- package/dist/commands/build/index.mjs.map +1 -1
- package/dist/commands/build/utils.cjs +25 -0
- package/dist/commands/build/utils.cjs.map +1 -0
- package/dist/commands/build/utils.d.cts +9 -0
- package/dist/commands/build/utils.d.cts.map +1 -0
- package/dist/commands/build/utils.d.mts +9 -0
- package/dist/commands/build/utils.d.mts.map +1 -0
- package/dist/commands/build/utils.mjs +21 -0
- package/dist/commands/build/utils.mjs.map +1 -0
- package/dist/utils/logging.cjs +16 -2
- package/dist/utils/logging.cjs.map +1 -1
- package/dist/utils/logging.d.cts +8 -1
- package/dist/utils/logging.d.cts.map +1 -1
- package/dist/utils/logging.d.mts +8 -1
- package/dist/utils/logging.d.mts.map +1 -1
- package/dist/utils/logging.mjs +15 -2
- package/dist/utils/logging.mjs.map +1 -1
- package/dist/utils/steps.cjs +11 -6
- package/dist/utils/steps.cjs.map +1 -1
- package/dist/utils/steps.d.cts +1 -1
- package/dist/utils/steps.d.cts.map +1 -1
- package/dist/utils/steps.d.mts +1 -1
- package/dist/utils/steps.d.mts.map +1 -1
- package/dist/utils/steps.mjs +11 -6
- package/dist/utils/steps.mjs.map +1 -1
- package/dist/webpack/config.cjs +7 -0
- package/dist/webpack/config.cjs.map +1 -1
- package/dist/webpack/config.d.cts +4 -0
- package/dist/webpack/config.d.cts.map +1 -1
- package/dist/webpack/config.d.mts +4 -0
- package/dist/webpack/config.d.mts.map +1 -1
- package/dist/webpack/config.mjs +7 -0
- package/dist/webpack/config.mjs.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.7.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `--analyze` flag to build command to enable bundle analyzer ([#3075](https://github.com/MetaMask/snaps/pull/3075))
|
|
15
|
+
|
|
10
16
|
## [6.6.1]
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -314,7 +320,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
314
320
|
- The version of the package no longer needs to match the version of all other
|
|
315
321
|
MetaMask Snaps packages.
|
|
316
322
|
|
|
317
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.
|
|
323
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.7.0...HEAD
|
|
324
|
+
[6.7.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.6.1...@metamask/snaps-cli@6.7.0
|
|
318
325
|
[6.6.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.6.0...@metamask/snaps-cli@6.6.1
|
|
319
326
|
[6.6.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.5.4...@metamask/snaps-cli@6.6.0
|
|
320
327
|
[6.5.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.5.3...@metamask/snaps-cli@6.5.4
|
package/dist/builders.cjs
CHANGED
|
@@ -8,7 +8,10 @@ var TranspilationModes;
|
|
|
8
8
|
TranspilationModes["None"] = "none";
|
|
9
9
|
})(TranspilationModes || (exports.TranspilationModes = TranspilationModes = {}));
|
|
10
10
|
const builders = {
|
|
11
|
-
|
|
11
|
+
analyze: {
|
|
12
|
+
describe: 'Analyze the Snap bundle',
|
|
13
|
+
type: 'boolean',
|
|
14
|
+
},
|
|
12
15
|
config: {
|
|
13
16
|
alias: 'c',
|
|
14
17
|
describe: 'Path to config file',
|
package/dist/builders.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.cjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mDAA6B,CAAA;IAC7B,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"builders.cjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mDAA6B,CAAA;IAC7B,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,MAAM,QA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KACjB;IAED,aAAa,EAAE;QACb,QAAQ,EAAE,kDAAkD;QAC5D,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,IAAI;KACjB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,wCAAwC;QAClD,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,IAAI;KACjB;CACmD,CAAC;AAEvD,kBAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\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} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
|
package/dist/builders.d.cts
CHANGED
|
@@ -1,9 +1,124 @@
|
|
|
1
|
-
import type { Options } from "yargs";
|
|
2
1
|
export declare enum TranspilationModes {
|
|
3
2
|
LocalAndDeps = "localAndDeps",
|
|
4
3
|
LocalOnly = "localOnly",
|
|
5
4
|
None = "none"
|
|
6
5
|
}
|
|
7
|
-
declare const builders:
|
|
6
|
+
declare const builders: {
|
|
7
|
+
readonly analyze: {
|
|
8
|
+
readonly describe: "Analyze the Snap bundle";
|
|
9
|
+
readonly type: "boolean";
|
|
10
|
+
};
|
|
11
|
+
readonly config: {
|
|
12
|
+
readonly alias: "c";
|
|
13
|
+
readonly describe: "Path to config file";
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly normalize: true;
|
|
16
|
+
};
|
|
17
|
+
readonly fix: {
|
|
18
|
+
readonly describe: "Attempt to fix snap.manifest.json";
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
};
|
|
21
|
+
readonly input: {
|
|
22
|
+
readonly alias: "i";
|
|
23
|
+
readonly describe: "Snap bundle file to evaluate";
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly normalize: true;
|
|
26
|
+
};
|
|
27
|
+
readonly bundle: {
|
|
28
|
+
readonly alias: "b";
|
|
29
|
+
readonly describe: "Snap bundle file";
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly normalize: true;
|
|
32
|
+
readonly deprecated: "Use --input instead.";
|
|
33
|
+
};
|
|
34
|
+
readonly dist: {
|
|
35
|
+
readonly alias: "d";
|
|
36
|
+
readonly describe: "Output directory";
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly normalize: true;
|
|
39
|
+
readonly deprecated: true;
|
|
40
|
+
};
|
|
41
|
+
readonly eval: {
|
|
42
|
+
readonly alias: "e";
|
|
43
|
+
readonly describe: "Attempt to evaluate Snap bundle in SES";
|
|
44
|
+
readonly type: "boolean";
|
|
45
|
+
readonly deprecated: true;
|
|
46
|
+
};
|
|
47
|
+
readonly manifest: {
|
|
48
|
+
readonly alias: "m";
|
|
49
|
+
readonly describe: "Validate snap.manifest.json";
|
|
50
|
+
readonly type: "boolean";
|
|
51
|
+
readonly deprecated: true;
|
|
52
|
+
};
|
|
53
|
+
readonly port: {
|
|
54
|
+
readonly alias: "p";
|
|
55
|
+
readonly describe: "Local server port for testing";
|
|
56
|
+
readonly type: "number";
|
|
57
|
+
readonly coerce: (arg: unknown) => number;
|
|
58
|
+
readonly deprecated: true;
|
|
59
|
+
};
|
|
60
|
+
readonly outfileName: {
|
|
61
|
+
readonly alias: "n";
|
|
62
|
+
readonly describe: "Output file name";
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
readonly deprecated: true;
|
|
65
|
+
};
|
|
66
|
+
readonly root: {
|
|
67
|
+
readonly alias: "r";
|
|
68
|
+
readonly describe: "Server root directory";
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
readonly normalize: true;
|
|
71
|
+
readonly deprecated: true;
|
|
72
|
+
};
|
|
73
|
+
readonly sourceMaps: {
|
|
74
|
+
readonly describe: "Whether builds include sourcemaps";
|
|
75
|
+
readonly type: "boolean";
|
|
76
|
+
readonly deprecated: true;
|
|
77
|
+
};
|
|
78
|
+
readonly src: {
|
|
79
|
+
readonly alias: "s";
|
|
80
|
+
readonly describe: "Source file";
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly normalize: true;
|
|
83
|
+
readonly deprecated: true;
|
|
84
|
+
};
|
|
85
|
+
readonly stripComments: {
|
|
86
|
+
readonly alias: "strip";
|
|
87
|
+
readonly describe: "Whether to remove code comments from the build output";
|
|
88
|
+
readonly type: "boolean";
|
|
89
|
+
readonly deprecated: true;
|
|
90
|
+
};
|
|
91
|
+
readonly suppressWarnings: {
|
|
92
|
+
readonly type: "boolean";
|
|
93
|
+
readonly describe: "Whether to suppress warnings";
|
|
94
|
+
readonly deprecated: true;
|
|
95
|
+
};
|
|
96
|
+
readonly transpilationMode: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly describe: "Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing";
|
|
99
|
+
readonly choices: TranspilationModes[];
|
|
100
|
+
readonly deprecated: true;
|
|
101
|
+
};
|
|
102
|
+
readonly depsToTranspile: {
|
|
103
|
+
readonly type: "array";
|
|
104
|
+
readonly describe: "Transpile only the listed dependencies.";
|
|
105
|
+
readonly deprecated: true;
|
|
106
|
+
};
|
|
107
|
+
readonly verboseErrors: {
|
|
108
|
+
readonly type: "boolean";
|
|
109
|
+
readonly describe: "Display original errors";
|
|
110
|
+
readonly deprecated: true;
|
|
111
|
+
};
|
|
112
|
+
readonly writeManifest: {
|
|
113
|
+
readonly describe: "Make necessary changes to the snap manifest file";
|
|
114
|
+
readonly type: "boolean";
|
|
115
|
+
readonly deprecated: true;
|
|
116
|
+
};
|
|
117
|
+
readonly serve: {
|
|
118
|
+
readonly describe: "Serve snap file(s) locally for testing";
|
|
119
|
+
readonly type: "boolean";
|
|
120
|
+
readonly deprecated: true;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
8
123
|
export default builders;
|
|
9
124
|
//# sourceMappingURL=builders.d.cts.map
|
package/dist/builders.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.cts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builders.d.cts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,oBAAY,kBAAkB;IAC5B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAED,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA4DI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoF6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
|
package/dist/builders.d.mts
CHANGED
|
@@ -1,9 +1,124 @@
|
|
|
1
|
-
import type { Options } from "yargs";
|
|
2
1
|
export declare enum TranspilationModes {
|
|
3
2
|
LocalAndDeps = "localAndDeps",
|
|
4
3
|
LocalOnly = "localOnly",
|
|
5
4
|
None = "none"
|
|
6
5
|
}
|
|
7
|
-
declare const builders:
|
|
6
|
+
declare const builders: {
|
|
7
|
+
readonly analyze: {
|
|
8
|
+
readonly describe: "Analyze the Snap bundle";
|
|
9
|
+
readonly type: "boolean";
|
|
10
|
+
};
|
|
11
|
+
readonly config: {
|
|
12
|
+
readonly alias: "c";
|
|
13
|
+
readonly describe: "Path to config file";
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly normalize: true;
|
|
16
|
+
};
|
|
17
|
+
readonly fix: {
|
|
18
|
+
readonly describe: "Attempt to fix snap.manifest.json";
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
};
|
|
21
|
+
readonly input: {
|
|
22
|
+
readonly alias: "i";
|
|
23
|
+
readonly describe: "Snap bundle file to evaluate";
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly normalize: true;
|
|
26
|
+
};
|
|
27
|
+
readonly bundle: {
|
|
28
|
+
readonly alias: "b";
|
|
29
|
+
readonly describe: "Snap bundle file";
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly normalize: true;
|
|
32
|
+
readonly deprecated: "Use --input instead.";
|
|
33
|
+
};
|
|
34
|
+
readonly dist: {
|
|
35
|
+
readonly alias: "d";
|
|
36
|
+
readonly describe: "Output directory";
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly normalize: true;
|
|
39
|
+
readonly deprecated: true;
|
|
40
|
+
};
|
|
41
|
+
readonly eval: {
|
|
42
|
+
readonly alias: "e";
|
|
43
|
+
readonly describe: "Attempt to evaluate Snap bundle in SES";
|
|
44
|
+
readonly type: "boolean";
|
|
45
|
+
readonly deprecated: true;
|
|
46
|
+
};
|
|
47
|
+
readonly manifest: {
|
|
48
|
+
readonly alias: "m";
|
|
49
|
+
readonly describe: "Validate snap.manifest.json";
|
|
50
|
+
readonly type: "boolean";
|
|
51
|
+
readonly deprecated: true;
|
|
52
|
+
};
|
|
53
|
+
readonly port: {
|
|
54
|
+
readonly alias: "p";
|
|
55
|
+
readonly describe: "Local server port for testing";
|
|
56
|
+
readonly type: "number";
|
|
57
|
+
readonly coerce: (arg: unknown) => number;
|
|
58
|
+
readonly deprecated: true;
|
|
59
|
+
};
|
|
60
|
+
readonly outfileName: {
|
|
61
|
+
readonly alias: "n";
|
|
62
|
+
readonly describe: "Output file name";
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
readonly deprecated: true;
|
|
65
|
+
};
|
|
66
|
+
readonly root: {
|
|
67
|
+
readonly alias: "r";
|
|
68
|
+
readonly describe: "Server root directory";
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
readonly normalize: true;
|
|
71
|
+
readonly deprecated: true;
|
|
72
|
+
};
|
|
73
|
+
readonly sourceMaps: {
|
|
74
|
+
readonly describe: "Whether builds include sourcemaps";
|
|
75
|
+
readonly type: "boolean";
|
|
76
|
+
readonly deprecated: true;
|
|
77
|
+
};
|
|
78
|
+
readonly src: {
|
|
79
|
+
readonly alias: "s";
|
|
80
|
+
readonly describe: "Source file";
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly normalize: true;
|
|
83
|
+
readonly deprecated: true;
|
|
84
|
+
};
|
|
85
|
+
readonly stripComments: {
|
|
86
|
+
readonly alias: "strip";
|
|
87
|
+
readonly describe: "Whether to remove code comments from the build output";
|
|
88
|
+
readonly type: "boolean";
|
|
89
|
+
readonly deprecated: true;
|
|
90
|
+
};
|
|
91
|
+
readonly suppressWarnings: {
|
|
92
|
+
readonly type: "boolean";
|
|
93
|
+
readonly describe: "Whether to suppress warnings";
|
|
94
|
+
readonly deprecated: true;
|
|
95
|
+
};
|
|
96
|
+
readonly transpilationMode: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly describe: "Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing";
|
|
99
|
+
readonly choices: TranspilationModes[];
|
|
100
|
+
readonly deprecated: true;
|
|
101
|
+
};
|
|
102
|
+
readonly depsToTranspile: {
|
|
103
|
+
readonly type: "array";
|
|
104
|
+
readonly describe: "Transpile only the listed dependencies.";
|
|
105
|
+
readonly deprecated: true;
|
|
106
|
+
};
|
|
107
|
+
readonly verboseErrors: {
|
|
108
|
+
readonly type: "boolean";
|
|
109
|
+
readonly describe: "Display original errors";
|
|
110
|
+
readonly deprecated: true;
|
|
111
|
+
};
|
|
112
|
+
readonly writeManifest: {
|
|
113
|
+
readonly describe: "Make necessary changes to the snap manifest file";
|
|
114
|
+
readonly type: "boolean";
|
|
115
|
+
readonly deprecated: true;
|
|
116
|
+
};
|
|
117
|
+
readonly serve: {
|
|
118
|
+
readonly describe: "Serve snap file(s) locally for testing";
|
|
119
|
+
readonly type: "boolean";
|
|
120
|
+
readonly deprecated: true;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
8
123
|
export default builders;
|
|
9
124
|
//# sourceMappingURL=builders.d.mts.map
|
package/dist/builders.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.mts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builders.d.mts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,oBAAY,kBAAkB;IAC5B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAED,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA4DI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoF6B,CAAC;AAEvD,eAAe,QAAQ,CAAC"}
|
package/dist/builders.mjs
CHANGED
|
@@ -5,7 +5,10 @@ export var TranspilationModes;
|
|
|
5
5
|
TranspilationModes["None"] = "none";
|
|
6
6
|
})(TranspilationModes || (TranspilationModes = {}));
|
|
7
7
|
const builders = {
|
|
8
|
-
|
|
8
|
+
analyze: {
|
|
9
|
+
describe: 'Analyze the Snap bundle',
|
|
10
|
+
type: 'boolean',
|
|
11
|
+
},
|
|
9
12
|
config: {
|
|
10
13
|
alias: 'c',
|
|
11
14
|
describe: 'Path to config file',
|
package/dist/builders.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mDAA6B,CAAA;IAC7B,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAED,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"builders.mjs","sourceRoot":"","s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EAAE,IAAI;KACjB;IAED,eAAe,EAAE;QACf,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,yCAAyC;QACnD,UAAU,EAAE,IAAI;KACjB;IAED,aAAa,EAAE;QACb,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,yBAAyB;QACnC,UAAU,EAAE,IAAI;KACjB;IAED,aAAa,EAAE;QACb,QAAQ,EAAE,kDAAkD;QAC5D,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,IAAI;KACjB;IAED,KAAK,EAAE;QACL,QAAQ,EAAE,wCAAwC;QAClD,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,IAAI;KACjB;CACmD,CAAC;AAEvD,eAAe,QAAQ,CAAC","sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders = {\n analyze: {\n describe: 'Analyze the Snap bundle',\n type: 'boolean',\n },\n\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} as const satisfies Record<string, Readonly<Options>>;\n\nexport default builders;\n"]}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildHandler = void 0;
|
|
4
4
|
const node_1 = require("@metamask/snaps-utils/node");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const errors_1 = require("../../errors.cjs");
|
|
7
|
-
const
|
|
8
|
+
const utils_2 = require("../../utils/index.cjs");
|
|
8
9
|
const eval_1 = require("../eval/index.cjs");
|
|
9
10
|
const implementation_1 = require("./implementation.cjs");
|
|
11
|
+
const utils_3 = require("./utils.cjs");
|
|
10
12
|
const steps = [
|
|
11
13
|
{
|
|
12
14
|
name: 'Checking the input file.',
|
|
@@ -19,10 +21,23 @@ const steps = [
|
|
|
19
21
|
},
|
|
20
22
|
{
|
|
21
23
|
name: 'Building the snap bundle.',
|
|
22
|
-
task: async ({ config, spinner }) => {
|
|
24
|
+
task: async ({ analyze, config, spinner }) => {
|
|
23
25
|
// We don't evaluate the bundle here, because it's done in a separate
|
|
24
26
|
// step.
|
|
25
|
-
|
|
27
|
+
const compiler = await (0, implementation_1.build)(config, {
|
|
28
|
+
analyze,
|
|
29
|
+
evaluate: false,
|
|
30
|
+
spinner,
|
|
31
|
+
});
|
|
32
|
+
if (analyze) {
|
|
33
|
+
return {
|
|
34
|
+
analyze,
|
|
35
|
+
config,
|
|
36
|
+
spinner,
|
|
37
|
+
port: await (0, utils_3.getBundleAnalyzerPort)(compiler),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
26
41
|
},
|
|
27
42
|
},
|
|
28
43
|
{
|
|
@@ -31,7 +46,16 @@ const steps = [
|
|
|
31
46
|
task: async ({ config, spinner }) => {
|
|
32
47
|
const path = (0, path_1.resolve)(process.cwd(), config.output.path, config.output.filename);
|
|
33
48
|
await (0, eval_1.evaluate)(path);
|
|
34
|
-
(0,
|
|
49
|
+
(0, utils_2.info)(`Snap bundle evaluated successfully.`, spinner);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'Running analyser.',
|
|
54
|
+
condition: ({ analyze }) => analyze,
|
|
55
|
+
task: async ({ spinner, port }) => {
|
|
56
|
+
(0, utils_1.assert)(port, 'Port is not defined.');
|
|
57
|
+
(0, utils_2.success)(`Bundle analyzer running at http://localhost:${port}.`, spinner);
|
|
58
|
+
spinner.stop();
|
|
35
59
|
},
|
|
36
60
|
},
|
|
37
61
|
];
|
|
@@ -42,11 +66,13 @@ const steps = [
|
|
|
42
66
|
* This creates the destination directory if it doesn't exist.
|
|
43
67
|
*
|
|
44
68
|
* @param config - The config object.
|
|
69
|
+
* @param analyze - Whether to analyze the bundle.
|
|
45
70
|
* @returns Nothing.
|
|
46
71
|
*/
|
|
47
|
-
async function buildHandler(config) {
|
|
48
|
-
return await (0,
|
|
72
|
+
async function buildHandler(config, analyze = false) {
|
|
73
|
+
return await (0, utils_2.executeSteps)(steps, {
|
|
49
74
|
config,
|
|
75
|
+
analyze,
|
|
50
76
|
});
|
|
51
77
|
}
|
|
52
78
|
exports.buildHandler = buildHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.cjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,+BAA8C;AAG9C,6CAA4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"build.cjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,2CAAyC;AACzC,+BAA8C;AAG9C,6CAA4C;AAE5C,iDAA0D;AAC1D,4CAAmC;AACnC,yDAAyC;AACzC,uCAAgD;AAQhD,MAAM,KAAK,GAAwB;IACjC;QACE,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YAEzB,IAAI,CAAC,CAAC,MAAM,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qBAAY,CACpB,0BAA0B,KAAK,qEAAqE,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3C,qEAAqE;YACrE,QAAQ;YACR,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAK,EAAC,MAAM,EAAE;gBACnC,OAA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,CAAC,CAAC;AACL,CAAC;AARD,oCAQC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\nimport { resolve as pathResolve } from 'path';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\n\ntype BuildContext = {\n analyze: boolean;\n config: ProcessedWebpackConfig;\n port?: number;\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 ({ analyze, config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n const compiler = await build(config, {\n analyze,\n evaluate: false,\n spinner,\n });\n\n if (analyze) {\n return {\n analyze,\n config,\n spinner,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\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 {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\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 * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n config,\n analyze,\n });\n}\n"]}
|
|
@@ -6,7 +6,8 @@ import type { ProcessedConfig } from "../../config.cjs";
|
|
|
6
6
|
* This creates the destination directory if it doesn't exist.
|
|
7
7
|
*
|
|
8
8
|
* @param config - The config object.
|
|
9
|
+
* @param analyze - Whether to analyze the bundle.
|
|
9
10
|
* @returns Nothing.
|
|
10
11
|
*/
|
|
11
|
-
export declare function buildHandler(config: ProcessedConfig): Promise<void>;
|
|
12
|
+
export declare function buildHandler(config: ProcessedConfig, analyze?: boolean): Promise<void>;
|
|
12
13
|
//# sourceMappingURL=build.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.cts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.cts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAA0B,yBAAqB;AA6E5E;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -6,7 +6,8 @@ import type { ProcessedConfig } from "../../config.mjs";
|
|
|
6
6
|
* This creates the destination directory if it doesn't exist.
|
|
7
7
|
*
|
|
8
8
|
* @param config - The config object.
|
|
9
|
+
* @param analyze - Whether to analyze the bundle.
|
|
9
10
|
* @returns Nothing.
|
|
10
11
|
*/
|
|
11
|
-
export declare function buildHandler(config: ProcessedConfig): Promise<void>;
|
|
12
|
+
export declare function buildHandler(config: ProcessedConfig, analyze?: boolean): Promise<void>;
|
|
12
13
|
//# sourceMappingURL=build.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.mts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.mts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAA0B,yBAAqB;AA6E5E;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isFile } from "@metamask/snaps-utils/node";
|
|
2
|
+
import { assert } from "@metamask/utils";
|
|
2
3
|
import { resolve as pathResolve } from "path";
|
|
3
4
|
import { CommandError } from "../../errors.mjs";
|
|
4
|
-
import { executeSteps, info } from "../../utils/index.mjs";
|
|
5
|
+
import { success, executeSteps, info } from "../../utils/index.mjs";
|
|
5
6
|
import { evaluate } from "../eval/index.mjs";
|
|
6
7
|
import { build } from "./implementation.mjs";
|
|
8
|
+
import { getBundleAnalyzerPort } from "./utils.mjs";
|
|
7
9
|
const steps = [
|
|
8
10
|
{
|
|
9
11
|
name: 'Checking the input file.',
|
|
@@ -16,10 +18,23 @@ const steps = [
|
|
|
16
18
|
},
|
|
17
19
|
{
|
|
18
20
|
name: 'Building the snap bundle.',
|
|
19
|
-
task: async ({ config, spinner }) => {
|
|
21
|
+
task: async ({ analyze, config, spinner }) => {
|
|
20
22
|
// We don't evaluate the bundle here, because it's done in a separate
|
|
21
23
|
// step.
|
|
22
|
-
|
|
24
|
+
const compiler = await build(config, {
|
|
25
|
+
analyze,
|
|
26
|
+
evaluate: false,
|
|
27
|
+
spinner,
|
|
28
|
+
});
|
|
29
|
+
if (analyze) {
|
|
30
|
+
return {
|
|
31
|
+
analyze,
|
|
32
|
+
config,
|
|
33
|
+
spinner,
|
|
34
|
+
port: await getBundleAnalyzerPort(compiler),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
23
38
|
},
|
|
24
39
|
},
|
|
25
40
|
{
|
|
@@ -31,6 +46,15 @@ const steps = [
|
|
|
31
46
|
info(`Snap bundle evaluated successfully.`, spinner);
|
|
32
47
|
},
|
|
33
48
|
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Running analyser.',
|
|
51
|
+
condition: ({ analyze }) => analyze,
|
|
52
|
+
task: async ({ spinner, port }) => {
|
|
53
|
+
assert(port, 'Port is not defined.');
|
|
54
|
+
success(`Bundle analyzer running at http://localhost:${port}.`, spinner);
|
|
55
|
+
spinner.stop();
|
|
56
|
+
},
|
|
57
|
+
},
|
|
34
58
|
];
|
|
35
59
|
/**
|
|
36
60
|
* Build all files in the given source directory to the given destination
|
|
@@ -39,11 +63,13 @@ const steps = [
|
|
|
39
63
|
* This creates the destination directory if it doesn't exist.
|
|
40
64
|
*
|
|
41
65
|
* @param config - The config object.
|
|
66
|
+
* @param analyze - Whether to analyze the bundle.
|
|
42
67
|
* @returns Nothing.
|
|
43
68
|
*/
|
|
44
|
-
export async function buildHandler(config) {
|
|
69
|
+
export async function buildHandler(config, analyze = false) {
|
|
45
70
|
return await executeSteps(steps, {
|
|
46
71
|
config,
|
|
72
|
+
analyze,
|
|
47
73
|
});
|
|
48
74
|
}
|
|
49
75
|
//# sourceMappingURL=build.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.mjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,aAAa;AAG9C,OAAO,EAAE,YAAY,EAAE,yBAAqB;AAE5C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAAoB;
|
|
1
|
+
{"version":3,"file":"build.mjs","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mCAAmC;AACpD,OAAO,EAAE,MAAM,EAAE,wBAAwB;AACzC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,aAAa;AAG9C,OAAO,EAAE,YAAY,EAAE,yBAAqB;AA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CAAC,MAAM,CAAC,IAAI,EAClB,MAAM,CAAC,MAAM,CAAC,QAAQ,CACvB,CAAC;YAEF,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;YAErB,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;KACF;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO;QACnC,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAChC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YACrC,OAAO,CAAC,+CAA+C,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;KACF;CACO,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,OAAO,GAAG,KAAK;IAEf,OAAO,MAAM,YAAY,CAAC,KAAK,EAAE;QAC/B,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\nimport { assert } from '@metamask/utils';\nimport { resolve as pathResolve } from 'path';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { success, executeSteps, info } from '../../utils';\nimport { evaluate } from '../eval';\nimport { build } from './implementation';\nimport { getBundleAnalyzerPort } from './utils';\n\ntype BuildContext = {\n analyze: boolean;\n config: ProcessedWebpackConfig;\n port?: number;\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 ({ analyze, config, spinner }) => {\n // We don't evaluate the bundle here, because it's done in a separate\n // step.\n const compiler = await build(config, {\n analyze,\n evaluate: false,\n spinner,\n });\n\n if (analyze) {\n return {\n analyze,\n config,\n spinner,\n port: await getBundleAnalyzerPort(compiler),\n };\n }\n\n return undefined;\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 {\n name: 'Running analyser.',\n condition: ({ analyze }) => analyze,\n task: async ({ spinner, port }) => {\n assert(port, 'Port is not defined.');\n success(`Bundle analyzer running at http://localhost:${port}.`, spinner);\n\n spinner.stop();\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 * @param analyze - Whether to analyze the bundle.\n * @returns Nothing.\n */\nexport async function buildHandler(\n config: ProcessedConfig,\n analyze = false,\n): Promise<void> {\n return await executeSteps(steps, {\n config,\n analyze,\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"implementation.cjs","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":";;;AAIA,qDAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,KAAK,CACzB,MAA8B,EAC9B,OAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC5B,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,UAAU,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,sBAsBC","sourcesContent":["import type { Compiler } from 'webpack';\n\nimport 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<Compiler>((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(compiler);\n });\n });\n });\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Compiler } from "webpack";
|
|
1
2
|
import type { ProcessedWebpackConfig } from "../../config.cjs";
|
|
2
3
|
import type { WebpackOptions } from "../../webpack/index.cjs";
|
|
3
4
|
/**
|
|
@@ -7,5 +8,5 @@ import type { WebpackOptions } from "../../webpack/index.cjs";
|
|
|
7
8
|
* @param options - The Webpack options.
|
|
8
9
|
* @returns A promise that resolves when the bundle is built.
|
|
9
10
|
*/
|
|
10
|
-
export declare function build(config: ProcessedWebpackConfig, options?: WebpackOptions): Promise<
|
|
11
|
+
export declare function build(config: ProcessedWebpackConfig, options?: WebpackOptions): Promise<Compiler>;
|
|
11
12
|
//# sourceMappingURL=implementation.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAqB;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"implementation.d.cts","sourceRoot":"","sources":["../../../src/commands/build/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAqB;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAsB;AAGpD;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,qBAoBzB"}
|