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