@atlaspack/reporter-cli 2.17.3 → 2.17.4-typescript-17c3d1dec.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/LICENSE +201 -0
- package/lib/CLIReporter.d.ts +5 -0
- package/lib/CLIReporter.js +11 -2
- package/lib/bundleReport.d.ts +3 -0
- package/lib/bundleReport.js +4 -1
- package/lib/emoji.d.ts +7 -0
- package/lib/logLevels.d.ts +10 -0
- package/lib/phaseReport.d.ts +3 -0
- package/lib/render.d.ts +14 -0
- package/lib/render.js +3 -3
- package/lib/utils.d.ts +5 -0
- package/package.json +15 -10
- package/src/{CLIReporter.js → CLIReporter.ts} +13 -9
- package/src/{bundleReport.js → bundleReport.ts} +4 -3
- package/src/{emoji.js → emoji.ts} +0 -2
- package/src/{logLevels.js → logLevels.ts} +1 -3
- package/src/{phaseReport.js → phaseReport.ts} +2 -3
- package/src/{render.js → render.ts} +7 -7
- package/src/{utils.js → utils.ts} +0 -1
- package/test/{CLIReporter.test.js → CLIReporter.test.ts} +15 -14
- package/tsconfig.json +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2024 Atlassian US., Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReporterEvent, PluginOptions } from '@atlaspack/types';
|
|
2
|
+
import { Reporter } from '@atlaspack/plugin';
|
|
3
|
+
export declare function _report(event: ReporterEvent, options: PluginOptions): Promise<void>;
|
|
4
|
+
declare const _default: Reporter;
|
|
5
|
+
export default _default;
|
package/lib/CLIReporter.js
CHANGED
|
@@ -49,6 +49,8 @@ function _wrapAnsi() {
|
|
|
49
49
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
50
50
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
51
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
52
|
+
// @ts-expect-error TS7016
|
|
53
|
+
|
|
52
54
|
const THROTTLE_DELAY = 100;
|
|
53
55
|
const seenWarnings = new Set();
|
|
54
56
|
const seenPhases = new Set();
|
|
@@ -208,12 +210,15 @@ async function _report(event, options) {
|
|
|
208
210
|
await writeDiagnostic(options, event.diagnostics, 'red', true);
|
|
209
211
|
break;
|
|
210
212
|
default:
|
|
213
|
+
// @ts-expect-error TS2339
|
|
211
214
|
throw new Error('Unknown log level ' + event.level);
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
|
-
async function writeDiagnostic(options, diagnostics,
|
|
219
|
+
async function writeDiagnostic(options, diagnostics,
|
|
220
|
+
// @ts-expect-error TS2749
|
|
221
|
+
color, isError = false) {
|
|
217
222
|
let columns = (0, _utils2.getTerminalWidth)().columns;
|
|
218
223
|
let indent = 2;
|
|
219
224
|
let spaceAfter = isError;
|
|
@@ -225,7 +230,7 @@ async function writeDiagnostic(options, diagnostics, color, isError = false) {
|
|
|
225
230
|
hints,
|
|
226
231
|
documentation
|
|
227
232
|
} = await (0, _utils().prettyDiagnostic)(diagnostic, options, columns - indent);
|
|
228
|
-
//
|
|
233
|
+
// @ts-expect-error TS7053
|
|
229
234
|
message = _chalk().default[color](message);
|
|
230
235
|
if (spaceAfter) {
|
|
231
236
|
(0, _render.writeOut)('');
|
|
@@ -254,6 +259,8 @@ async function writeDiagnostic(options, diagnostics, color, isError = false) {
|
|
|
254
259
|
if (documentation) {
|
|
255
260
|
(0, _render.writeOut)(wrapWithIndent(`${emoji.docs} ${_chalk().default.magenta.bold(documentation)}`, hintIndent + 3, hintIndent));
|
|
256
261
|
}
|
|
262
|
+
|
|
263
|
+
// @ts-expect-error TS2322
|
|
257
264
|
spaceAfter = stack || codeframe || hints.length > 0 || documentation;
|
|
258
265
|
}
|
|
259
266
|
if (spaceAfter) {
|
|
@@ -266,6 +273,8 @@ function wrapWithIndent(string, indent = 0, initialIndent = indent) {
|
|
|
266
273
|
trim: false
|
|
267
274
|
}), indent, initialIndent);
|
|
268
275
|
}
|
|
276
|
+
|
|
277
|
+
// @ts-expect-error TS7006
|
|
269
278
|
function indentString(string, indent = 0, initialIndent = indent) {
|
|
270
279
|
return ' '.repeat(initialIndent) + string.replace(/\n/g, '\n' + ' '.repeat(indent));
|
|
271
280
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BundleGraph, FilePath, PackagedBundle } from '@atlaspack/types';
|
|
2
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
3
|
+
export default function bundleReport(bundleGraph: BundleGraph<PackagedBundle>, fs: FileSystem, projectRoot: FilePath, assetCount?: number): Promise<void>;
|
package/lib/bundleReport.js
CHANGED
|
@@ -75,7 +75,9 @@ async function bundleReport(bundleGraph, fs, projectRoot, assetCount = 0) {
|
|
|
75
75
|
if (assetCount > 0) {
|
|
76
76
|
let largestAssets = bundle.assets.slice(0, assetCount);
|
|
77
77
|
for (let asset of largestAssets) {
|
|
78
|
-
let columns = [asset == largestAssets[largestAssets.length - 1] ? '└── ' : '├── ',
|
|
78
|
+
let columns = [asset == largestAssets[largestAssets.length - 1] ? '└── ' : '├── ',
|
|
79
|
+
// @ts-expect-error TS2554
|
|
80
|
+
_chalk().default.dim(prettifySize(asset.size)), _chalk().default.dim(_chalk().default.green((0, _utils().prettifyTime)(asset.time)))];
|
|
79
81
|
if (asset.filePath !== '') {
|
|
80
82
|
columns[0] += (0, _utils2.formatFilename)(asset.filePath, _chalk().default.reset);
|
|
81
83
|
} else {
|
|
@@ -98,6 +100,7 @@ async function bundleReport(bundleGraph, fs, projectRoot, assetCount = 0) {
|
|
|
98
100
|
|
|
99
101
|
// Render table
|
|
100
102
|
(0, _render.writeOut)('');
|
|
103
|
+
// @ts-expect-error TS2345
|
|
101
104
|
(0, _render.table)(COLUMNS, rows);
|
|
102
105
|
}
|
|
103
106
|
function prettifySize(size, isLarge) {
|
package/lib/emoji.d.ts
ADDED
package/lib/render.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Writable } from 'stream';
|
|
2
|
+
import type { PadAlign } from './utils';
|
|
3
|
+
type ColumnType = {
|
|
4
|
+
align: PadAlign;
|
|
5
|
+
};
|
|
6
|
+
export declare const isTTY: any | boolean | true;
|
|
7
|
+
export declare function _setStdio(stdoutLike: Writable, stderrLike: Writable): void;
|
|
8
|
+
export declare function writeOut(message: string, isError?: boolean): void;
|
|
9
|
+
export declare function persistMessage(message: string): void;
|
|
10
|
+
export declare function updateSpinner(message: string): void;
|
|
11
|
+
export declare function persistSpinner(name: string, status: 'success' | 'error', message: string): void;
|
|
12
|
+
export declare function resetWindow(): void;
|
|
13
|
+
export declare function table(columns: Array<ColumnType>, table: Array<Array<string>>): void;
|
|
14
|
+
export {};
|
package/lib/render.js
CHANGED
|
@@ -37,9 +37,7 @@ var emoji = _interopRequireWildcard(require("./emoji"));
|
|
|
37
37
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
38
38
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
const isTTY = exports.isTTY =
|
|
41
|
-
// $FlowFixMe
|
|
42
|
-
process.env.NODE_ENV !== 'test' && process.stdout.isTTY;
|
|
40
|
+
const isTTY = exports.isTTY = process.env.NODE_ENV !== 'test' && process.stdout.isTTY;
|
|
43
41
|
let stdout = process.stdout;
|
|
44
42
|
let stderr = process.stderr;
|
|
45
43
|
|
|
@@ -55,7 +53,9 @@ let lineCount = 0;
|
|
|
55
53
|
let errorLineCount = 0;
|
|
56
54
|
let statusPersisted = false;
|
|
57
55
|
function _setStdio(stdoutLike, stderrLike) {
|
|
56
|
+
// @ts-expect-error TS2322
|
|
58
57
|
stdout = stdoutLike;
|
|
58
|
+
// @ts-expect-error TS2322
|
|
59
59
|
stderr = stderrLike;
|
|
60
60
|
}
|
|
61
61
|
let spinner = (0, _ora().default)({
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type PadAlign = 'left' | 'right';
|
|
2
|
+
export declare function getTerminalWidth(): any;
|
|
3
|
+
export declare function pad(text: string, length: number, align?: PadAlign): string;
|
|
4
|
+
export declare function formatFilename(filename: string, color?: (s: string) => string): string;
|
|
5
|
+
export declare function countLines(message: string): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/reporter-cli",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.4-typescript-17c3d1dec.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/CLIReporter.js",
|
|
13
|
-
"source": "src/CLIReporter.
|
|
12
|
+
"main": "./lib/CLIReporter.js",
|
|
13
|
+
"source": "./src/CLIReporter.ts",
|
|
14
|
+
"types": "./lib/CLIReporter.d.ts",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
16
17
|
},
|
|
@@ -26,19 +27,23 @@
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@atlaspack/plugin": "2.14.
|
|
30
|
-
"@atlaspack/types": "2.15.
|
|
31
|
-
"@atlaspack/utils": "2.17.
|
|
30
|
+
"@atlaspack/plugin": "2.14.22-typescript-17c3d1dec.0",
|
|
31
|
+
"@atlaspack/types": "2.15.12-typescript-17c3d1dec.0",
|
|
32
|
+
"@atlaspack/utils": "2.17.4-typescript-17c3d1dec.0",
|
|
32
33
|
"chalk": "^4.1.0",
|
|
33
|
-
"term-size": "^2.2.1",
|
|
34
34
|
"filesize": "^6.1.0",
|
|
35
35
|
"nullthrows": "^1.1.1",
|
|
36
36
|
"ora": "^5.2.0",
|
|
37
37
|
"string-width": "^4.2.0",
|
|
38
|
+
"term-size": "^2.2.1",
|
|
38
39
|
"wrap-ansi": "^7.0.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@atlaspack/feature-flags": "2.20.0"
|
|
42
|
+
"@atlaspack/feature-flags": "2.20.1-typescript-17c3d1dec.0"
|
|
43
|
+
},
|
|
44
|
+
"type": "commonjs",
|
|
45
|
+
"scripts": {
|
|
46
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
42
47
|
},
|
|
43
|
-
"
|
|
44
|
-
}
|
|
48
|
+
"gitHead": "17c3d1decf641e688fcfe3ca985e80e9897b7573"
|
|
49
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {ReporterEvent, PluginOptions} from '@atlaspack/types';
|
|
3
2
|
import type {Diagnostic} from '@atlaspack/diagnostic';
|
|
4
3
|
import type {Color} from 'chalk';
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
persistMessage,
|
|
29
28
|
} from './render';
|
|
30
29
|
import * as emoji from './emoji';
|
|
30
|
+
// @ts-expect-error TS7016
|
|
31
31
|
import wrapAnsi from 'wrap-ansi';
|
|
32
32
|
|
|
33
33
|
const THROTTLE_DELAY = 100;
|
|
@@ -35,7 +35,7 @@ const seenWarnings = new Set();
|
|
|
35
35
|
const seenPhases = new Set();
|
|
36
36
|
const seenPhasesGen = new Set();
|
|
37
37
|
|
|
38
|
-
let phaseStartTimes = {};
|
|
38
|
+
let phaseStartTimes: Record<string, any> = {};
|
|
39
39
|
let pendingIncrementalBuild = false;
|
|
40
40
|
let packagingProgress = 0;
|
|
41
41
|
|
|
@@ -63,9 +63,9 @@ let statusThrottle = throttle((message: string) => {
|
|
|
63
63
|
updateSpinner(message);
|
|
64
64
|
}, THROTTLE_DELAY);
|
|
65
65
|
|
|
66
|
-
const cacheWriteState: {
|
|
67
|
-
startTime: number | null
|
|
68
|
-
|
|
66
|
+
const cacheWriteState: {
|
|
67
|
+
startTime: number | null;
|
|
68
|
+
} = {
|
|
69
69
|
startTime: null,
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -247,6 +247,7 @@ export async function _report(
|
|
|
247
247
|
await writeDiagnostic(options, event.diagnostics, 'red', true);
|
|
248
248
|
break;
|
|
249
249
|
default:
|
|
250
|
+
// @ts-expect-error TS2339
|
|
250
251
|
throw new Error('Unknown log level ' + event.level);
|
|
251
252
|
}
|
|
252
253
|
}
|
|
@@ -256,6 +257,7 @@ export async function _report(
|
|
|
256
257
|
async function writeDiagnostic(
|
|
257
258
|
options: PluginOptions,
|
|
258
259
|
diagnostics: Array<Diagnostic>,
|
|
260
|
+
// @ts-expect-error TS2749
|
|
259
261
|
color: Color,
|
|
260
262
|
isError: boolean = false,
|
|
261
263
|
) {
|
|
@@ -265,7 +267,7 @@ async function writeDiagnostic(
|
|
|
265
267
|
for (let diagnostic of diagnostics) {
|
|
266
268
|
let {message, stack, codeframe, hints, documentation} =
|
|
267
269
|
await prettyDiagnostic(diagnostic, options, columns - indent);
|
|
268
|
-
//
|
|
270
|
+
// @ts-expect-error TS7053
|
|
269
271
|
message = chalk[color](message);
|
|
270
272
|
|
|
271
273
|
if (spaceAfter) {
|
|
@@ -314,6 +316,7 @@ async function writeDiagnostic(
|
|
|
314
316
|
);
|
|
315
317
|
}
|
|
316
318
|
|
|
319
|
+
// @ts-expect-error TS2322
|
|
317
320
|
spaceAfter = stack || codeframe || hints.length > 0 || documentation;
|
|
318
321
|
}
|
|
319
322
|
|
|
@@ -322,7 +325,7 @@ async function writeDiagnostic(
|
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
327
|
|
|
325
|
-
function wrapWithIndent(string, indent = 0, initialIndent = indent) {
|
|
328
|
+
function wrapWithIndent(string: string, indent = 0, initialIndent = indent) {
|
|
326
329
|
let width = getTerminalWidth().columns;
|
|
327
330
|
return indentString(
|
|
328
331
|
wrapAnsi(string.trimEnd(), width - indent, {trim: false}),
|
|
@@ -331,14 +334,15 @@ function wrapWithIndent(string, indent = 0, initialIndent = indent) {
|
|
|
331
334
|
);
|
|
332
335
|
}
|
|
333
336
|
|
|
337
|
+
// @ts-expect-error TS7006
|
|
334
338
|
function indentString(string, indent = 0, initialIndent = indent) {
|
|
335
339
|
return (
|
|
336
340
|
' '.repeat(initialIndent) + string.replace(/\n/g, '\n' + ' '.repeat(indent))
|
|
337
341
|
);
|
|
338
342
|
}
|
|
339
343
|
|
|
340
|
-
export default
|
|
344
|
+
export default new Reporter({
|
|
341
345
|
report({event, options}) {
|
|
342
346
|
return _report(event, options);
|
|
343
347
|
},
|
|
344
|
-
})
|
|
348
|
+
}) as Reporter;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {BundleGraph, FilePath, PackagedBundle} from '@atlaspack/types';
|
|
3
2
|
import type {FileSystem} from '@atlaspack/fs';
|
|
4
3
|
|
|
@@ -40,7 +39,7 @@ export default async function bundleReport(
|
|
|
40
39
|
};
|
|
41
40
|
}),
|
|
42
41
|
};
|
|
43
|
-
let rows = [];
|
|
42
|
+
let rows: Array<Array<string>> = [];
|
|
44
43
|
|
|
45
44
|
for (let bundle of bundles) {
|
|
46
45
|
// Add a row for the bundle
|
|
@@ -55,6 +54,7 @@ export default async function bundleReport(
|
|
|
55
54
|
for (let asset of largestAssets) {
|
|
56
55
|
let columns: Array<string> = [
|
|
57
56
|
asset == largestAssets[largestAssets.length - 1] ? '└── ' : '├── ',
|
|
57
|
+
// @ts-expect-error TS2554
|
|
58
58
|
chalk.dim(prettifySize(asset.size)),
|
|
59
59
|
chalk.dim(chalk.green(prettifyTime(asset.time))),
|
|
60
60
|
];
|
|
@@ -87,10 +87,11 @@ export default async function bundleReport(
|
|
|
87
87
|
|
|
88
88
|
// Render table
|
|
89
89
|
writeOut('');
|
|
90
|
+
// @ts-expect-error TS2345
|
|
90
91
|
table(COLUMNS, rows);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
function prettifySize(size, isLarge) {
|
|
94
|
+
function prettifySize(size: number, isLarge: undefined | boolean) {
|
|
94
95
|
let res = filesize(size);
|
|
95
96
|
if (isLarge) {
|
|
96
97
|
return chalk.yellow(emoji.warning + ' ' + res);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {prettifyTime} from '@atlaspack/utils';
|
|
3
2
|
import chalk from 'chalk';
|
|
4
3
|
import {writeOut} from './render';
|
|
5
4
|
import invariant from 'assert';
|
|
6
5
|
|
|
7
|
-
export default function phaseReport(phaseStartTimes: {[string]: number}) {
|
|
8
|
-
let phaseTimes = {};
|
|
6
|
+
export default function phaseReport(phaseStartTimes: {[key: string]: number}) {
|
|
7
|
+
let phaseTimes: Record<string, any> = {};
|
|
9
8
|
if (phaseStartTimes['transforming'] && phaseStartTimes['bundling']) {
|
|
10
9
|
phaseTimes['Transforming'] =
|
|
11
10
|
phaseStartTimes['bundling'] - phaseStartTimes['transforming'];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {Writable} from 'stream';
|
|
3
2
|
|
|
4
3
|
import readline from 'readline';
|
|
@@ -9,12 +8,11 @@ import type {PadAlign} from './utils';
|
|
|
9
8
|
import {pad, countLines} from './utils';
|
|
10
9
|
import * as emoji from './emoji';
|
|
11
10
|
|
|
12
|
-
type ColumnType = {
|
|
13
|
-
align: PadAlign
|
|
14
|
-
|
|
11
|
+
type ColumnType = {
|
|
12
|
+
align: PadAlign;
|
|
13
|
+
};
|
|
15
14
|
|
|
16
15
|
export const isTTY: any | boolean | true =
|
|
17
|
-
// $FlowFixMe
|
|
18
16
|
process.env.NODE_ENV !== 'test' && process.stdout.isTTY;
|
|
19
17
|
|
|
20
18
|
let stdout = process.stdout;
|
|
@@ -33,7 +31,9 @@ let errorLineCount = 0;
|
|
|
33
31
|
let statusPersisted = false;
|
|
34
32
|
|
|
35
33
|
export function _setStdio(stdoutLike: Writable, stderrLike: Writable) {
|
|
34
|
+
// @ts-expect-error TS2322
|
|
36
35
|
stdout = stdoutLike;
|
|
36
|
+
// @ts-expect-error TS2322
|
|
37
37
|
stderr = stderrLike;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ let spinner = ora({
|
|
|
42
42
|
stream: stdout,
|
|
43
43
|
discardStdin: false,
|
|
44
44
|
});
|
|
45
|
-
let persistedMessages = [];
|
|
45
|
+
let persistedMessages: Array<string> = [];
|
|
46
46
|
|
|
47
47
|
export function writeOut(message: string, isError: boolean = false) {
|
|
48
48
|
let processedMessage = message + '\n';
|
|
@@ -132,7 +132,7 @@ export function resetWindow() {
|
|
|
132
132
|
|
|
133
133
|
export function table(columns: Array<ColumnType>, table: Array<Array<string>>) {
|
|
134
134
|
// Measure column widths
|
|
135
|
-
let colWidths = [];
|
|
135
|
+
let colWidths: Array<number> = [];
|
|
136
136
|
for (let row of table) {
|
|
137
137
|
let i = 0;
|
|
138
138
|
for (let item of row) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
import sinon from 'sinon';
|
|
5
3
|
import {PassThrough} from 'stream';
|
|
@@ -39,13 +37,13 @@ const EMPTY_OPTIONS = {
|
|
|
39
37
|
assetsPerBundle: 10,
|
|
40
38
|
},
|
|
41
39
|
featureFlags: DEFAULT_FEATURE_FLAGS,
|
|
42
|
-
};
|
|
40
|
+
} as const;
|
|
43
41
|
|
|
44
42
|
describe('CLIReporter', () => {
|
|
45
|
-
let originalStdout;
|
|
46
|
-
let originalStderr;
|
|
47
|
-
let stdoutOutput;
|
|
48
|
-
let stderrOutput;
|
|
43
|
+
let originalStdout: any;
|
|
44
|
+
let originalStderr: any;
|
|
45
|
+
let stdoutOutput: any;
|
|
46
|
+
let stderrOutput: any;
|
|
49
47
|
|
|
50
48
|
beforeEach(async () => {
|
|
51
49
|
// Stub these out to avoid writing noise to real stdio and to read from these
|
|
@@ -57,9 +55,15 @@ describe('CLIReporter', () => {
|
|
|
57
55
|
stderrOutput = '';
|
|
58
56
|
|
|
59
57
|
let mockStdout = new PassThrough();
|
|
60
|
-
mockStdout.on(
|
|
58
|
+
mockStdout.on(
|
|
59
|
+
'data',
|
|
60
|
+
(d: any) => (stdoutOutput += stripAnsi(d.toString())),
|
|
61
|
+
);
|
|
61
62
|
let mockStderr = new PassThrough();
|
|
62
|
-
mockStderr.on(
|
|
63
|
+
mockStderr.on(
|
|
64
|
+
'data',
|
|
65
|
+
(d: any) => (stderrOutput += stripAnsi(d.toString())),
|
|
66
|
+
);
|
|
63
67
|
_setStdio(mockStdout, mockStderr);
|
|
64
68
|
|
|
65
69
|
await _report(
|
|
@@ -200,7 +204,6 @@ describe('CLIReporter', () => {
|
|
|
200
204
|
// emit a buildSuccess event to reset the timings and seen phases
|
|
201
205
|
// from the previous test
|
|
202
206
|
process.env['ATLASPACK_SHOW_PHASE_TIMES'] = undefined;
|
|
203
|
-
// $FlowFixMe
|
|
204
207
|
await _report({type: 'buildSuccess'}, EMPTY_OPTIONS);
|
|
205
208
|
|
|
206
209
|
process.env['ATLASPACK_SHOW_PHASE_TIMES'] = 'true';
|
|
@@ -210,17 +213,16 @@ describe('CLIReporter', () => {
|
|
|
210
213
|
);
|
|
211
214
|
await _report({type: 'buildProgress', phase: 'bundling'}, EMPTY_OPTIONS);
|
|
212
215
|
await _report(
|
|
213
|
-
// $FlowFixMe
|
|
214
216
|
{
|
|
215
217
|
type: 'buildProgress',
|
|
216
218
|
phase: 'packaging',
|
|
219
|
+
|
|
217
220
|
bundle: {
|
|
218
221
|
displayName: 'test',
|
|
219
222
|
},
|
|
220
223
|
},
|
|
221
224
|
EMPTY_OPTIONS,
|
|
222
225
|
);
|
|
223
|
-
// $FlowFixMe
|
|
224
226
|
await _report({type: 'buildSuccess'}, EMPTY_OPTIONS);
|
|
225
227
|
const expected =
|
|
226
228
|
/Building...\nBundling...\nPackaging & Optimizing...\nTransforming finished in [0-9]ms\nBundling finished in [0-9]ms\nPackaging & Optimizing finished in [0-9]ms/;
|
|
@@ -235,17 +237,16 @@ describe('CLIReporter', () => {
|
|
|
235
237
|
);
|
|
236
238
|
await _report({type: 'buildProgress', phase: 'bundling'}, EMPTY_OPTIONS);
|
|
237
239
|
await _report(
|
|
238
|
-
// $FlowFixMe
|
|
239
240
|
{
|
|
240
241
|
type: 'buildProgress',
|
|
241
242
|
phase: 'packaging',
|
|
243
|
+
|
|
242
244
|
bundle: {
|
|
243
245
|
displayName: 'test',
|
|
244
246
|
},
|
|
245
247
|
},
|
|
246
248
|
EMPTY_OPTIONS,
|
|
247
249
|
);
|
|
248
|
-
// $FlowFixMe
|
|
249
250
|
await _report({type: 'buildSuccess'}, EMPTY_OPTIONS);
|
|
250
251
|
|
|
251
252
|
assert.equal(
|
package/tsconfig.json
ADDED