@atlaspack/reporter-cli 2.15.1-canary.21 → 2.15.1-canary.211

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,252 @@
1
1
  # @atlaspack/reporter-cli
2
2
 
3
+ ## 2.17.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#793](https://github.com/atlassian-labs/atlaspack/pull/793) [`a4f887b`](https://github.com/atlassian-labs/atlaspack/commit/a4f887b8c45386b058650c41ad38ac675deee27d) Thanks [@benjervis](https://github.com/benjervis)! - Fixes the cliProgressReportingImprovements, which were previously being overwritten by the existing packaging messaging. With this fix, now only the progress messages are shown during packaging.
8
+
9
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
10
+ - @atlaspack/utils@3.0.0
11
+ - @atlaspack/plugin@2.14.32
12
+ - @atlaspack/types@2.15.22
13
+
14
+ ## 2.17.13
15
+
16
+ ### Patch Changes
17
+
18
+ - [#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.
19
+
20
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
21
+ - @atlaspack/plugin@2.14.31
22
+ - @atlaspack/types@2.15.21
23
+ - @atlaspack/utils@2.19.3
24
+
25
+ ## 2.17.12
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies []:
30
+ - @atlaspack/utils@2.19.2
31
+ - @atlaspack/plugin@2.14.30
32
+ - @atlaspack/types@2.15.20
33
+
34
+ ## 2.17.11
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies []:
39
+ - @atlaspack/utils@2.19.1
40
+ - @atlaspack/plugin@2.14.29
41
+ - @atlaspack/types@2.15.19
42
+
43
+ ## 2.17.10
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
48
+ - @atlaspack/utils@2.19.0
49
+ - @atlaspack/plugin@2.14.28
50
+ - @atlaspack/types@2.15.18
51
+
52
+ ## 2.17.9
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies []:
57
+ - @atlaspack/utils@2.18.4
58
+ - @atlaspack/plugin@2.14.27
59
+ - @atlaspack/types@2.15.17
60
+
61
+ ## 2.17.8
62
+
63
+ ### Patch Changes
64
+
65
+ - [#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
66
+
67
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
68
+ - @atlaspack/plugin@2.14.26
69
+ - @atlaspack/types@2.15.16
70
+ - @atlaspack/utils@2.18.3
71
+
72
+ ## 2.17.7
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies []:
77
+ - @atlaspack/utils@2.18.2
78
+ - @atlaspack/plugin@2.14.25
79
+ - @atlaspack/types@2.15.15
80
+
81
+ ## 2.17.6
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies []:
86
+ - @atlaspack/utils@2.18.1
87
+ - @atlaspack/plugin@2.14.24
88
+ - @atlaspack/types@2.15.14
89
+
90
+ ## 2.17.5
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
95
+ - @atlaspack/utils@2.18.0
96
+ - @atlaspack/types@2.15.13
97
+ - @atlaspack/plugin@2.14.23
98
+
99
+ ## 2.17.4
100
+
101
+ ### Patch Changes
102
+
103
+ - [#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
104
+
105
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
106
+ - @atlaspack/plugin@2.14.22
107
+ - @atlaspack/types@2.15.12
108
+ - @atlaspack/utils@2.17.4
109
+
110
+ ## 2.17.3
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies []:
115
+ - @atlaspack/types@2.15.11
116
+ - @atlaspack/utils@2.17.3
117
+ - @atlaspack/plugin@2.14.21
118
+
119
+ ## 2.17.2
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
124
+ - @atlaspack/plugin@2.14.20
125
+ - @atlaspack/utils@2.17.2
126
+ - @atlaspack/types@2.15.10
127
+
128
+ ## 2.17.1
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies []:
133
+ - @atlaspack/utils@2.17.1
134
+ - @atlaspack/types@2.15.9
135
+ - @atlaspack/plugin@2.14.19
136
+
137
+ ## 2.17.0
138
+
139
+ ### Minor Changes
140
+
141
+ - [#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).
142
+
143
+ Rectifying by creating a new changeset now.
144
+
145
+ ### Patch Changes
146
+
147
+ - [#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
148
+
149
+ - [#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
150
+
151
+ - 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)]:
152
+ - @atlaspack/utils@2.17.0
153
+ - @atlaspack/types@2.15.8
154
+ - @atlaspack/plugin@2.14.18
155
+
156
+ ## 2.16.1
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies []:
161
+ - @atlaspack/utils@2.16.1
162
+ - @atlaspack/types@2.15.7
163
+ - @atlaspack/plugin@2.14.17
164
+
165
+ ## 2.16.0
166
+
167
+ ### Minor Changes
168
+
169
+ - [#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.
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
174
+ - @atlaspack/utils@2.16.0
175
+ - @atlaspack/types@2.15.6
176
+ - @atlaspack/plugin@2.14.16
177
+
178
+ ## 2.15.11
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies []:
183
+ - @atlaspack/utils@2.15.3
184
+ - @atlaspack/types@2.15.5
185
+ - @atlaspack/plugin@2.14.15
186
+
187
+ ## 2.15.10
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies []:
192
+ - @atlaspack/utils@2.15.2
193
+ - @atlaspack/types@2.15.4
194
+ - @atlaspack/plugin@2.14.14
195
+
196
+ ## 2.15.9
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies []:
201
+ - @atlaspack/types@2.15.3
202
+ - @atlaspack/utils@2.15.1
203
+ - @atlaspack/plugin@2.14.13
204
+
205
+ ## 2.15.8
206
+
207
+ ### Patch Changes
208
+
209
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
210
+ - @atlaspack/utils@2.15.0
211
+ - @atlaspack/types@2.15.2
212
+ - @atlaspack/plugin@2.14.12
213
+
214
+ ## 2.15.7
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies []:
219
+ - @atlaspack/utils@2.14.11
220
+ - @atlaspack/types@2.15.1
221
+ - @atlaspack/plugin@2.14.11
222
+
223
+ ## 2.15.6
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
228
+ - @atlaspack/types@2.15.0
229
+ - @atlaspack/plugin@2.14.10
230
+ - @atlaspack/utils@2.14.10
231
+
232
+ ## 2.15.5
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies []:
237
+ - @atlaspack/utils@2.14.9
238
+ - @atlaspack/types@2.14.9
239
+ - @atlaspack/plugin@2.14.9
240
+
241
+ ## 2.15.4
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies []:
246
+ - @atlaspack/utils@2.14.8
247
+ - @atlaspack/types@2.14.8
248
+ - @atlaspack/plugin@2.14.8
249
+
3
250
  ## 2.15.3
4
251
 
5
252
  ### 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;