@atlaspack/reporter-cli 2.15.1-canary.20 → 2.15.1-canary.201

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 CHANGED
@@ -1,5 +1,241 @@
1
1
  # @atlaspack/reporter-cli
2
2
 
3
+ ## 2.17.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
8
+
9
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
10
+ - @atlaspack/plugin@2.14.31
11
+ - @atlaspack/types@2.15.21
12
+ - @atlaspack/utils@2.19.3
13
+
14
+ ## 2.17.12
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies []:
19
+ - @atlaspack/utils@2.19.2
20
+ - @atlaspack/plugin@2.14.30
21
+ - @atlaspack/types@2.15.20
22
+
23
+ ## 2.17.11
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies []:
28
+ - @atlaspack/utils@2.19.1
29
+ - @atlaspack/plugin@2.14.29
30
+ - @atlaspack/types@2.15.19
31
+
32
+ ## 2.17.10
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
37
+ - @atlaspack/utils@2.19.0
38
+ - @atlaspack/plugin@2.14.28
39
+ - @atlaspack/types@2.15.18
40
+
41
+ ## 2.17.9
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies []:
46
+ - @atlaspack/utils@2.18.4
47
+ - @atlaspack/plugin@2.14.27
48
+ - @atlaspack/types@2.15.17
49
+
50
+ ## 2.17.8
51
+
52
+ ### Patch Changes
53
+
54
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
55
+
56
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
57
+ - @atlaspack/plugin@2.14.26
58
+ - @atlaspack/types@2.15.16
59
+ - @atlaspack/utils@2.18.3
60
+
61
+ ## 2.17.7
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies []:
66
+ - @atlaspack/utils@2.18.2
67
+ - @atlaspack/plugin@2.14.25
68
+ - @atlaspack/types@2.15.15
69
+
70
+ ## 2.17.6
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies []:
75
+ - @atlaspack/utils@2.18.1
76
+ - @atlaspack/plugin@2.14.24
77
+ - @atlaspack/types@2.15.14
78
+
79
+ ## 2.17.5
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
84
+ - @atlaspack/utils@2.18.0
85
+ - @atlaspack/types@2.15.13
86
+ - @atlaspack/plugin@2.14.23
87
+
88
+ ## 2.17.4
89
+
90
+ ### Patch Changes
91
+
92
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
93
+
94
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
95
+ - @atlaspack/plugin@2.14.22
96
+ - @atlaspack/types@2.15.12
97
+ - @atlaspack/utils@2.17.4
98
+
99
+ ## 2.17.3
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies []:
104
+ - @atlaspack/types@2.15.11
105
+ - @atlaspack/utils@2.17.3
106
+ - @atlaspack/plugin@2.14.21
107
+
108
+ ## 2.17.2
109
+
110
+ ### Patch Changes
111
+
112
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
113
+ - @atlaspack/plugin@2.14.20
114
+ - @atlaspack/utils@2.17.2
115
+ - @atlaspack/types@2.15.10
116
+
117
+ ## 2.17.1
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies []:
122
+ - @atlaspack/utils@2.17.1
123
+ - @atlaspack/types@2.15.9
124
+ - @atlaspack/plugin@2.14.19
125
+
126
+ ## 2.17.0
127
+
128
+ ### Minor Changes
129
+
130
+ - [#693](https://github.com/atlassian-labs/atlaspack/pull/693) [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417) Thanks [@mattcompiles](https://github.com/mattcompiles)! - These packages should have been bumped in [pull request 691](https://github.com/atlassian-labs/atlaspack/pull/691).
131
+
132
+ Rectifying by creating a new changeset now.
133
+
134
+ ### Patch Changes
135
+
136
+ - [#645](https://github.com/atlassian-labs/atlaspack/pull/645) [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3) Thanks [@alshdavid](https://github.com/alshdavid)! - Updated build system and added some extra test-specific code
137
+
138
+ - [#682](https://github.com/atlassian-labs/atlaspack/pull/682) [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56) Thanks [@alshdavid](https://github.com/alshdavid)! - Updating build system
139
+
140
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
141
+ - @atlaspack/utils@2.17.0
142
+ - @atlaspack/types@2.15.8
143
+ - @atlaspack/plugin@2.14.18
144
+
145
+ ## 2.16.1
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies []:
150
+ - @atlaspack/utils@2.16.1
151
+ - @atlaspack/types@2.15.7
152
+ - @atlaspack/plugin@2.14.17
153
+
154
+ ## 2.16.0
155
+
156
+ ### Minor Changes
157
+
158
+ - [#659](https://github.com/atlassian-labs/atlaspack/pull/659) [`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529) Thanks [@benjervis](https://github.com/benjervis)! - Add the `simple-cli-reporter` debug tool, which turns off the "print every bundle" output of the CLI reporter.
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
163
+ - @atlaspack/utils@2.16.0
164
+ - @atlaspack/types@2.15.6
165
+ - @atlaspack/plugin@2.14.16
166
+
167
+ ## 2.15.11
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies []:
172
+ - @atlaspack/utils@2.15.3
173
+ - @atlaspack/types@2.15.5
174
+ - @atlaspack/plugin@2.14.15
175
+
176
+ ## 2.15.10
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies []:
181
+ - @atlaspack/utils@2.15.2
182
+ - @atlaspack/types@2.15.4
183
+ - @atlaspack/plugin@2.14.14
184
+
185
+ ## 2.15.9
186
+
187
+ ### Patch Changes
188
+
189
+ - Updated dependencies []:
190
+ - @atlaspack/types@2.15.3
191
+ - @atlaspack/utils@2.15.1
192
+ - @atlaspack/plugin@2.14.13
193
+
194
+ ## 2.15.8
195
+
196
+ ### Patch Changes
197
+
198
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
199
+ - @atlaspack/utils@2.15.0
200
+ - @atlaspack/types@2.15.2
201
+ - @atlaspack/plugin@2.14.12
202
+
203
+ ## 2.15.7
204
+
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies []:
208
+ - @atlaspack/utils@2.14.11
209
+ - @atlaspack/types@2.15.1
210
+ - @atlaspack/plugin@2.14.11
211
+
212
+ ## 2.15.6
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
217
+ - @atlaspack/types@2.15.0
218
+ - @atlaspack/plugin@2.14.10
219
+ - @atlaspack/utils@2.14.10
220
+
221
+ ## 2.15.5
222
+
223
+ ### Patch Changes
224
+
225
+ - Updated dependencies []:
226
+ - @atlaspack/utils@2.14.9
227
+ - @atlaspack/types@2.14.9
228
+ - @atlaspack/plugin@2.14.9
229
+
230
+ ## 2.15.4
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies []:
235
+ - @atlaspack/utils@2.14.8
236
+ - @atlaspack/types@2.14.8
237
+ - @atlaspack/plugin@2.14.8
238
+
3
239
  ## 2.15.3
4
240
 
5
241
  ### Patch Changes
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports._report = _report;
40
+ const feature_flags_1 = require("@atlaspack/feature-flags");
41
+ const plugin_1 = require("@atlaspack/plugin");
42
+ const utils_1 = require("@atlaspack/utils");
43
+ const chalk_1 = __importDefault(require("chalk"));
44
+ const utils_2 = require("./utils");
45
+ const logLevels_1 = __importDefault(require("./logLevels"));
46
+ const bundleReport_1 = __importDefault(require("./bundleReport"));
47
+ const phaseReport_1 = __importDefault(require("./phaseReport"));
48
+ const render_1 = require("./render");
49
+ const emoji = __importStar(require("./emoji"));
50
+ // @ts-expect-error TS7016
51
+ const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
52
+ const THROTTLE_DELAY = 100;
53
+ const seenWarnings = new Set();
54
+ const seenPhases = new Set();
55
+ const seenPhasesGen = new Set();
56
+ let phaseStartTimes = {};
57
+ let pendingIncrementalBuild = false;
58
+ let packagingProgress = 0;
59
+ let updatePackageProgress = (completeBundles, totalBundles) => {
60
+ let updateThreshold = 0;
61
+ if (totalBundles > 5000) {
62
+ // If more than 5000 bundles, update every 5%
63
+ updateThreshold = 5;
64
+ }
65
+ else if (totalBundles > 1000) {
66
+ // If more than 1000 bundles, update every 10%
67
+ updateThreshold = 10;
68
+ }
69
+ else {
70
+ // othewise update every 25%
71
+ updateThreshold = 25;
72
+ }
73
+ let percent = Math.floor((completeBundles / totalBundles) * 100);
74
+ if (percent - packagingProgress >= updateThreshold) {
75
+ packagingProgress = percent;
76
+ (0, render_1.updateSpinner)((0, utils_1.getPackageProgressMessage)(completeBundles, totalBundles));
77
+ }
78
+ };
79
+ let statusThrottle = (0, utils_1.throttle)((message) => {
80
+ (0, render_1.updateSpinner)(message);
81
+ }, THROTTLE_DELAY);
82
+ const cacheWriteState = {
83
+ startTime: null,
84
+ };
85
+ // Exported only for test
86
+ async function _report(event, options) {
87
+ let logLevelFilter = logLevels_1.default[options.logLevel || 'info'];
88
+ switch (event.type) {
89
+ case 'buildStart': {
90
+ seenWarnings.clear();
91
+ seenPhases.clear();
92
+ if (logLevelFilter < logLevels_1.default.info) {
93
+ break;
94
+ }
95
+ // Clear any previous output
96
+ (0, render_1.resetWindow)();
97
+ if (options.serveOptions) {
98
+ (0, render_1.persistMessage)(chalk_1.default.blue.bold(`Server running at ${options.serveOptions.https ? 'https' : 'http'}://${options.serveOptions.host ?? 'localhost'}:${options.serveOptions.port}`));
99
+ }
100
+ break;
101
+ }
102
+ case 'buildProgress': {
103
+ if (logLevelFilter < logLevels_1.default.info) {
104
+ break;
105
+ }
106
+ if (pendingIncrementalBuild) {
107
+ pendingIncrementalBuild = false;
108
+ phaseStartTimes = {};
109
+ seenPhasesGen.clear();
110
+ seenPhases.clear();
111
+ }
112
+ if (!seenPhasesGen.has(event.phase)) {
113
+ phaseStartTimes[event.phase] = Date.now();
114
+ seenPhasesGen.add(event.phase);
115
+ }
116
+ if ((0, feature_flags_1.getFeatureFlag)('cliProgressReportingImprovements') &&
117
+ (event.phase === 'packaging' || event.phase === 'optimizing')) {
118
+ // If the flag is turned on, we ignore the old `packaging` and
119
+ // `optimizing` event types, and only consider `packagingAndOptimizing`
120
+ // events
121
+ break;
122
+ }
123
+ if (!render_1.isTTY && logLevelFilter != logLevels_1.default.verbose) {
124
+ if (event.phase == 'transforming' && !seenPhases.has('transforming')) {
125
+ (0, render_1.updateSpinner)('Building...');
126
+ }
127
+ else if (event.phase == 'bundling' && !seenPhases.has('bundling')) {
128
+ (0, render_1.updateSpinner)('Bundling...');
129
+ }
130
+ else if (event.phase === 'packagingAndOptimizing') {
131
+ updatePackageProgress(event.completeBundles, event.totalBundles);
132
+ }
133
+ else if ((event.phase == 'packaging' || event.phase == 'optimizing') &&
134
+ !seenPhases.has('packaging') &&
135
+ !seenPhases.has('optimizing')) {
136
+ (0, render_1.updateSpinner)('Packaging & Optimizing...');
137
+ }
138
+ seenPhases.add(event.phase);
139
+ break;
140
+ }
141
+ let message = (0, utils_1.getProgressMessage)(event);
142
+ if (message != null) {
143
+ if (render_1.isTTY) {
144
+ statusThrottle(chalk_1.default.gray.bold(message));
145
+ }
146
+ else {
147
+ (0, render_1.updateSpinner)(message);
148
+ }
149
+ }
150
+ break;
151
+ }
152
+ case 'buildSuccess':
153
+ if (logLevelFilter < logLevels_1.default.info) {
154
+ break;
155
+ }
156
+ phaseStartTimes['buildSuccess'] = Date.now();
157
+ (0, render_1.persistSpinner)('buildProgress', 'success', chalk_1.default.green.bold(`Built in ${(0, utils_1.prettifyTime)(event.buildTime)}`));
158
+ if (options.mode === 'production') {
159
+ if (utils_1.debugTools['simple-cli-reporter']) {
160
+ (0, render_1.writeOut)(`🛠️ Built ${event.bundleGraph.getBundles().length} bundles.`);
161
+ }
162
+ else {
163
+ await (0, bundleReport_1.default)(event.bundleGraph, options.outputFS, options.projectRoot, options.detailedReport?.assetsPerBundle);
164
+ }
165
+ }
166
+ else {
167
+ pendingIncrementalBuild = true;
168
+ }
169
+ if (process.env.ATLASPACK_SHOW_PHASE_TIMES) {
170
+ (0, phaseReport_1.default)(phaseStartTimes);
171
+ }
172
+ break;
173
+ case 'buildFailure':
174
+ if (logLevelFilter < logLevels_1.default.error) {
175
+ break;
176
+ }
177
+ (0, render_1.resetWindow)();
178
+ (0, render_1.persistSpinner)('buildProgress', 'error', chalk_1.default.red.bold('Build failed.'));
179
+ await writeDiagnostic(options, event.diagnostics, 'red', true);
180
+ break;
181
+ case 'cache':
182
+ if (event.size > 500000) {
183
+ switch (event.phase) {
184
+ case 'start':
185
+ (0, render_1.updateSpinner)('Writing cache to disk');
186
+ cacheWriteState.startTime = Date.now();
187
+ break;
188
+ case 'end':
189
+ (0, render_1.persistSpinner)('cache', 'success', chalk_1.default.grey.bold(`Cache written to disk in ${(0, utils_1.prettifyTime)(Date.now() - (cacheWriteState.startTime ?? 0))}`));
190
+ cacheWriteState.startTime = null;
191
+ break;
192
+ }
193
+ }
194
+ break;
195
+ case 'log': {
196
+ if (logLevelFilter < logLevels_1.default[event.level]) {
197
+ break;
198
+ }
199
+ switch (event.level) {
200
+ case 'success':
201
+ (0, render_1.writeOut)(chalk_1.default.green(event.message));
202
+ break;
203
+ case 'progress':
204
+ (0, render_1.writeOut)(event.message);
205
+ break;
206
+ case 'verbose':
207
+ case 'info':
208
+ await writeDiagnostic(options, event.diagnostics, 'blue');
209
+ break;
210
+ case 'warn':
211
+ if (event.diagnostics.some((diagnostic) => !seenWarnings.has(diagnostic.message))) {
212
+ await writeDiagnostic(options, event.diagnostics, 'yellow', true);
213
+ for (let diagnostic of event.diagnostics) {
214
+ seenWarnings.add(diagnostic.message);
215
+ }
216
+ }
217
+ break;
218
+ case 'error':
219
+ await writeDiagnostic(options, event.diagnostics, 'red', true);
220
+ break;
221
+ default:
222
+ // @ts-expect-error TS2339
223
+ throw new Error('Unknown log level ' + event.level);
224
+ }
225
+ }
226
+ }
227
+ }
228
+ async function writeDiagnostic(options, diagnostics,
229
+ // @ts-expect-error TS2749
230
+ color, isError = false) {
231
+ let columns = (0, utils_2.getTerminalWidth)().columns;
232
+ let indent = 2;
233
+ let spaceAfter = isError;
234
+ for (let diagnostic of diagnostics) {
235
+ let { message, stack, codeframe, hints, documentation } = await (0, utils_1.prettyDiagnostic)(diagnostic, options, columns - indent);
236
+ // @ts-expect-error TS7053
237
+ message = chalk_1.default[color](message);
238
+ if (spaceAfter) {
239
+ (0, render_1.writeOut)('');
240
+ }
241
+ if (message) {
242
+ (0, render_1.writeOut)(wrapWithIndent(message), isError);
243
+ }
244
+ if (stack || codeframe) {
245
+ (0, render_1.writeOut)('');
246
+ }
247
+ if (stack) {
248
+ (0, render_1.writeOut)(chalk_1.default.gray(wrapWithIndent(stack, indent)), isError);
249
+ }
250
+ if (codeframe) {
251
+ (0, render_1.writeOut)(indentString(codeframe, indent), isError);
252
+ }
253
+ if ((stack || codeframe) && (hints.length > 0 || documentation)) {
254
+ (0, render_1.writeOut)('');
255
+ }
256
+ // Write hints
257
+ let hintIndent = stack || codeframe ? indent : 0;
258
+ for (let hint of hints) {
259
+ (0, render_1.writeOut)(wrapWithIndent(`${emoji.hint} ${chalk_1.default.blue.bold(hint)}`, hintIndent + 3, hintIndent));
260
+ }
261
+ if (documentation) {
262
+ (0, render_1.writeOut)(wrapWithIndent(`${emoji.docs} ${chalk_1.default.magenta.bold(documentation)}`, hintIndent + 3, hintIndent));
263
+ }
264
+ // @ts-expect-error TS2322
265
+ spaceAfter = stack || codeframe || hints.length > 0 || documentation;
266
+ }
267
+ if (spaceAfter) {
268
+ (0, render_1.writeOut)('');
269
+ }
270
+ }
271
+ function wrapWithIndent(string, indent = 0, initialIndent = indent) {
272
+ let width = (0, utils_2.getTerminalWidth)().columns;
273
+ return indentString((0, wrap_ansi_1.default)(string.trimEnd(), width - indent, { trim: false }), indent, initialIndent);
274
+ }
275
+ // @ts-expect-error TS7006
276
+ function indentString(string, indent = 0, initialIndent = indent) {
277
+ return (' '.repeat(initialIndent) + string.replace(/\n/g, '\n' + ' '.repeat(indent)));
278
+ }
279
+ exports.default = new plugin_1.Reporter({
280
+ report({ event, options }) {
281
+ return _report(event, options);
282
+ },
283
+ });
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.default = bundleReport;
40
+ const utils_1 = require("@atlaspack/utils");
41
+ const filesize_1 = __importDefault(require("filesize"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const nullthrows_1 = __importDefault(require("nullthrows"));
44
+ const emoji = __importStar(require("./emoji"));
45
+ const render_1 = require("./render");
46
+ const utils_2 = require("./utils");
47
+ const LARGE_BUNDLE_SIZE = 1024 * 1024;
48
+ const COLUMNS = [
49
+ { align: 'left' }, // name
50
+ { align: 'right' }, // size
51
+ { align: 'right' }, // time
52
+ ];
53
+ async function bundleReport(bundleGraph, fs, projectRoot, assetCount = 0) {
54
+ let bundleList = bundleGraph.getBundles();
55
+ // Get a list of bundles sorted by size
56
+ let { bundles } = assetCount > 0
57
+ ? await (0, utils_1.generateBuildMetrics)(bundleList, fs, projectRoot)
58
+ : {
59
+ bundles: bundleList.map((b) => {
60
+ return {
61
+ filePath: (0, nullthrows_1.default)(b.filePath),
62
+ size: b.stats.size,
63
+ time: b.stats.time,
64
+ assets: [],
65
+ };
66
+ }),
67
+ };
68
+ let rows = [];
69
+ for (let bundle of bundles) {
70
+ // Add a row for the bundle
71
+ rows.push([
72
+ (0, utils_2.formatFilename)(bundle.filePath || '', chalk_1.default.cyan.bold),
73
+ chalk_1.default.bold(prettifySize(bundle.size, bundle.size > LARGE_BUNDLE_SIZE)),
74
+ chalk_1.default.green.bold((0, utils_1.prettifyTime)(bundle.time)),
75
+ ]);
76
+ if (assetCount > 0) {
77
+ let largestAssets = bundle.assets.slice(0, assetCount);
78
+ for (let asset of largestAssets) {
79
+ let columns = [
80
+ asset == largestAssets[largestAssets.length - 1] ? '└── ' : '├── ',
81
+ // @ts-expect-error TS2554
82
+ chalk_1.default.dim(prettifySize(asset.size)),
83
+ chalk_1.default.dim(chalk_1.default.green((0, utils_1.prettifyTime)(asset.time))),
84
+ ];
85
+ if (asset.filePath !== '') {
86
+ columns[0] += (0, utils_2.formatFilename)(asset.filePath, chalk_1.default.reset);
87
+ }
88
+ else {
89
+ columns[0] += 'Code from unknown sourcefiles';
90
+ }
91
+ // Add a row for the asset.
92
+ rows.push(columns);
93
+ }
94
+ if (bundle.assets.length > largestAssets.length) {
95
+ rows.push([
96
+ '└── ' +
97
+ chalk_1.default.dim(`+ ${bundle.assets.length - largestAssets.length} more assets`),
98
+ ]);
99
+ }
100
+ // If this isn't the last bundle, add an empty row before the next one
101
+ if (bundle !== bundles[bundles.length - 1]) {
102
+ rows.push([]);
103
+ }
104
+ }
105
+ }
106
+ // Render table
107
+ (0, render_1.writeOut)('');
108
+ // @ts-expect-error TS2345
109
+ (0, render_1.table)(COLUMNS, rows);
110
+ }
111
+ function prettifySize(size, isLarge) {
112
+ let res = (0, filesize_1.default)(size);
113
+ if (isLarge) {
114
+ return chalk_1.default.yellow(emoji.warning + ' ' + res);
115
+ }
116
+ return chalk_1.default.magenta(res);
117
+ }
package/dist/emoji.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.docs = exports.hint = exports.info = exports.warning = exports.error = exports.success = exports.progress = void 0;
4
+ // From https://github.com/sindresorhus/is-unicode-supported/blob/8f123916d5c25a87c4f966dcc248b7ca5df2b4ca/index.js
5
+ // This package is ESM-only so it has to be vendored
6
+ function isUnicodeSupported() {
7
+ if (process.platform !== 'win32') {
8
+ return process.env.TERM !== 'linux'; // Linux console (kernel)
9
+ }
10
+ return (Boolean(process.env.CI) ||
11
+ Boolean(process.env.WT_SESSION) || // Windows Terminal
12
+ process.env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
13
+ process.env.TERM_PROGRAM === 'vscode' ||
14
+ process.env.TERM === 'xterm-256color' ||
15
+ process.env.TERM === 'alacritty');
16
+ }
17
+ const supportsEmoji = isUnicodeSupported();
18
+ // Fallback symbols for Windows from https://en.wikipedia.org/wiki/Code_page_437
19
+ exports.progress = supportsEmoji ? '⏳' : '∞';
20
+ exports.success = supportsEmoji ? '✨' : '√';
21
+ exports.error = supportsEmoji ? '🚨' : '×';
22
+ exports.warning = supportsEmoji ? '⚠️' : '‼';
23
+ exports.info = supportsEmoji ? 'ℹ️' : 'ℹ';
24
+ exports.hint = supportsEmoji ? '💡' : 'ℹ';
25
+ exports.docs = supportsEmoji ? '📝' : 'ℹ';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const logLevels = {
4
+ none: 0,
5
+ error: 1,
6
+ warn: 2,
7
+ info: 3,
8
+ progress: 3,
9
+ success: 3,
10
+ verbose: 4,
11
+ };
12
+ exports.default = logLevels;