1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.LightReport = void 0;
|
4 | const Report_1 = require("./Report");
|
5 | const StreamReport_1 = require("./StreamReport");
|
6 | class LightReport extends Report_1.Report {
|
7 | constructor({ configuration, stdout, suggestInstall = true }) {
|
8 | super();
|
9 | this.errorCount = 0;
|
10 | this.configuration = configuration;
|
11 | this.stdout = stdout;
|
12 | this.suggestInstall = suggestInstall;
|
13 | }
|
14 | static async start(opts, cb) {
|
15 | const report = new this(opts);
|
16 | try {
|
17 | await cb(report);
|
18 | }
|
19 | catch (error) {
|
20 | report.reportExceptionOnce(error);
|
21 | }
|
22 | finally {
|
23 | await report.finalize();
|
24 | }
|
25 | return report;
|
26 | }
|
27 | hasErrors() {
|
28 | return this.errorCount > 0;
|
29 | }
|
30 | exitCode() {
|
31 | return this.hasErrors() ? 1 : 0;
|
32 | }
|
33 | reportCacheHit(locator) {
|
34 | }
|
35 | reportCacheMiss(locator) {
|
36 | }
|
37 | startTimerSync(what, cb) {
|
38 | return cb();
|
39 | }
|
40 | async startTimerPromise(what, cb) {
|
41 | return await cb();
|
42 | }
|
43 | async startCacheReport(cb) {
|
44 | return await cb();
|
45 | }
|
46 | reportSeparator() {
|
47 | }
|
48 | reportInfo(name, text) {
|
49 | }
|
50 | reportWarning(name, text) {
|
51 | }
|
52 | reportError(name, text) {
|
53 | this.errorCount += 1;
|
54 | this.stdout.write(`${this.configuration.format(`➤`, `redBright`)} ${this.formatNameWithHyperlink(name)}: ${text}\n`);
|
55 | }
|
56 | reportProgress(progress) {
|
57 | const promise = Promise.resolve().then(async () => {
|
58 |
|
59 | for await (const {} of progress) {
|
60 |
|
61 | }
|
62 | });
|
63 | const stop = () => {
|
64 |
|
65 | };
|
66 | return { ...promise, stop };
|
67 | }
|
68 | reportJson(data) {
|
69 |
|
70 | }
|
71 | async finalize() {
|
72 | if (this.errorCount > 0) {
|
73 | this.stdout.write(`${this.configuration.format(`➤`, `redBright`)} Errors happened when preparing the environment required to run this command.\n`);
|
74 | if (this.suggestInstall) {
|
75 | this.stdout.write(`${this.configuration.format(`➤`, `redBright`)} This might be caused by packages being missing from the lockfile, in which case running "yarn install" might help.\n`);
|
76 | }
|
77 | }
|
78 | }
|
79 | formatNameWithHyperlink(name) {
|
80 | return StreamReport_1.formatNameWithHyperlink(name, {
|
81 | configuration: this.configuration,
|
82 | json: false,
|
83 | });
|
84 | }
|
85 | }
|
86 | exports.LightReport = LightReport;
|