@lde/pipeline-console-reporter 0.15.5 → 0.15.7

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.
@@ -1,16 +1,17 @@
1
1
  import type { Dataset, Distribution } from '@lde/dataset';
2
2
  import type { DistributionAnalysisResult, ProgressReporter, ValidationReport } from '@lde/pipeline';
3
3
  export declare class ConsoleReporter implements ProgressReporter {
4
- private stageSpinner?;
4
+ private activeSpinner?;
5
5
  private stageStartTime;
6
6
  private datasetStartTime;
7
7
  private datasetTotal;
8
8
  private datasetIndex;
9
- private importSpinner?;
10
9
  private importTimer?;
11
10
  private probeLines;
12
11
  /** Print a static succeed/fail line without starting a spinner animation. */
13
12
  private printLine;
13
+ /** Stop any active spinner and start a new one. */
14
+ private startSpinner;
14
15
  pipelineStart(_name: string): void;
15
16
  datasetsSelected(count: number, duration: number): void;
16
17
  datasetStart(dataset: Dataset): void;
@@ -18,7 +19,7 @@ export declare class ConsoleReporter implements ProgressReporter {
18
19
  importStarted(): void;
19
20
  importFailed(_distribution: Distribution, error: string): void;
20
21
  distributionSelected(_dataset: Dataset, distribution: Distribution, importedFrom?: Distribution, importDuration?: number, tripleCount?: number): void;
21
- private clearImportSpinner;
22
+ private clearImportTimer;
22
23
  stageStart(stage: string): void;
23
24
  stageProgress(update: {
24
25
  itemsProcessed: number;
@@ -1 +1 @@
1
- {"version":3,"file":"consoleReporter.d.ts","sourceRoot":"","sources":["../src/consoleReporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAUvB,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,OAAO,CAAC,YAAY,CAAC,CAAM;IAC3B,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,gBAAgB,CAAK;IAC7B,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AAY,CAAC,EAAE,YAAY,EAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,GACnB,IAAI;IA0CP,OAAO,CAAC,gBAAgB;IAOxB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK/B,aAAa,CAAC,MAAM,EAAE;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,IAAI;IAWR,aAAa,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE;QACN,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB,GACA,IAAI;IAUP,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAQ/C,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAc9D,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQlD,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IASxC,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIvD,gBAAgB,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAOrD"}
@@ -1,4 +1,5 @@
1
1
  import chalk from 'chalk';
2
+ import logSymbols from 'log-symbols';
2
3
  import ora from 'ora';
3
4
  import prettyMilliseconds from 'pretty-ms';
4
5
  const compactNumber = new Intl.NumberFormat('en', {
@@ -6,33 +7,38 @@ const compactNumber = new Intl.NumberFormat('en', {
6
7
  maximumFractionDigits: 1,
7
8
  });
8
9
  export class ConsoleReporter {
9
- stageSpinner;
10
+ activeSpinner;
10
11
  stageStartTime = 0;
11
12
  datasetStartTime = 0;
12
13
  datasetTotal = 0;
13
14
  datasetIndex = 0;
14
- importSpinner;
15
15
  importTimer;
16
16
  probeLines = [];
17
17
  /** Print a static succeed/fail line without starting a spinner animation. */
18
18
  printLine(method, text) {
19
- ora({ discardStdin: false })[method](text);
19
+ const symbol = method === 'succeed' ? logSymbols.success : logSymbols.error;
20
+ process.stderr.write(`${symbol} ${text}\n`);
21
+ }
22
+ /** Stop any active spinner and start a new one. */
23
+ startSpinner(text) {
24
+ this.activeSpinner?.stop();
25
+ this.clearImportTimer();
26
+ this.activeSpinner = ora({ discardStdin: false }).start(text);
27
+ return this.activeSpinner;
20
28
  }
21
29
  pipelineStart(_name) {
22
- this.stageSpinner = ora({
23
- discardStdin: false,
24
- text: 'Selecting datasets',
25
- }).start();
30
+ this.startSpinner('Selecting datasets');
26
31
  }
27
32
  datasetsSelected(count, duration) {
28
33
  this.datasetTotal = count;
29
- if (this.stageSpinner) {
30
- this.stageSpinner.text = `Selected datasets: found ${chalk.bold(count)} ${count === 1 ? 'dataset' : 'datasets'} in ${chalk.bold(prettyMilliseconds(duration))}`;
34
+ if (this.activeSpinner) {
35
+ this.activeSpinner.text = `Selected datasets: found ${chalk.bold(count)} ${count === 1 ? 'dataset' : 'datasets'} in ${chalk.bold(prettyMilliseconds(duration))}`;
31
36
  }
32
37
  }
33
38
  datasetStart(dataset) {
34
- this.stageSpinner?.succeed();
35
- this.stageSpinner = undefined;
39
+ this.activeSpinner?.succeed();
40
+ this.activeSpinner = undefined;
41
+ this.clearImportTimer();
36
42
  this.datasetStartTime = Date.now();
37
43
  this.probeLines = [];
38
44
  this.datasetIndex++;
@@ -66,37 +72,47 @@ export class ConsoleReporter {
66
72
  }
67
73
  importStarted() {
68
74
  const importStart = Date.now();
69
- this.importSpinner = ora({ discardStdin: false }).start('Importing\u2026');
75
+ const spinner = this.startSpinner('Importing\u2026');
70
76
  this.importTimer = setInterval(() => {
71
- if (this.importSpinner) {
72
- this.importSpinner.suffixText = prettyMilliseconds(Date.now() - importStart);
77
+ if (spinner.isSpinning) {
78
+ spinner.suffixText = prettyMilliseconds(Date.now() - importStart);
73
79
  }
74
80
  }, 1_000);
75
81
  }
76
82
  importFailed(_distribution, error) {
77
- const spinner = this.importSpinner ?? ora({ discardStdin: false });
78
- if (!this.importSpinner)
79
- spinner.start();
80
- spinner.text = `Import failed: ${error}`;
81
- spinner.suffixText = '';
82
- spinner.fail();
83
- this.clearImportSpinner();
83
+ if (this.activeSpinner) {
84
+ this.activeSpinner.text = `Import failed: ${error}`;
85
+ this.activeSpinner.suffixText = '';
86
+ this.activeSpinner.fail();
87
+ }
88
+ else {
89
+ this.printLine('fail', `Import failed: ${error}`);
90
+ }
91
+ this.clearImportTimer();
92
+ this.activeSpinner = undefined;
84
93
  }
85
94
  distributionSelected(_dataset, distribution, importedFrom, importDuration, tripleCount) {
86
95
  if (importedFrom) {
87
- const spinner = this.importSpinner ?? ora({ discardStdin: false }).start();
88
96
  const count = tripleCount !== undefined
89
97
  ? `${compactNumber.format(tripleCount)} triples, `
90
98
  : '';
91
99
  const duration = importDuration !== undefined
92
100
  ? ` in ${chalk.bold(prettyMilliseconds(importDuration))}`
93
101
  : '';
94
- spinner.text = `Imported ${importedFrom.accessUrl.toString()} (${count}to ${distribution.accessUrl.toString()})${duration}`;
95
- spinner.suffixText = '';
96
- spinner.succeed();
97
- this.clearImportSpinner();
102
+ const text = `Imported ${importedFrom.accessUrl.toString()} (${count}to ${distribution.accessUrl.toString()})${duration}`;
103
+ if (this.activeSpinner) {
104
+ this.activeSpinner.text = text;
105
+ this.activeSpinner.suffixText = '';
106
+ this.activeSpinner.succeed();
107
+ }
108
+ else {
109
+ this.printLine('succeed', text);
110
+ }
111
+ this.clearImportTimer();
112
+ this.activeSpinner = undefined;
98
113
  }
99
114
  else {
115
+ this.clearImportTimer(); // defensive — prevents leaks from a previous dataset
100
116
  const url = distribution.accessUrl.toString();
101
117
  const probe = this.probeLines.find((line) => line.url === url);
102
118
  const text = probe?.text || url;
@@ -116,36 +132,34 @@ export class ConsoleReporter {
116
132
  }
117
133
  }
118
134
  }
119
- clearImportSpinner() {
135
+ clearImportTimer() {
120
136
  if (this.importTimer) {
121
137
  clearInterval(this.importTimer);
122
138
  this.importTimer = undefined;
123
139
  }
124
- this.importSpinner = undefined;
125
140
  }
126
141
  stageStart(stage) {
127
142
  this.stageStartTime = Date.now();
128
- this.stageSpinner = ora({ discardStdin: false }).start();
129
- this.stageSpinner.text = `Stage ${chalk.bold(stage)}`;
143
+ this.startSpinner(`Stage ${chalk.bold(stage)}`);
130
144
  }
131
145
  stageProgress(update) {
132
- if (this.stageSpinner) {
146
+ if (this.activeSpinner) {
133
147
  const elapsed = prettyMilliseconds(Date.now() - this.stageStartTime);
134
- this.stageSpinner.suffixText = `${compactNumber.format(update.itemsProcessed)} items, ${compactNumber.format(update.quadsGenerated)} quads, ${elapsed}`;
148
+ this.activeSpinner.suffixText = `${compactNumber.format(update.itemsProcessed)} items, ${compactNumber.format(update.quadsGenerated)} quads, ${elapsed}`;
135
149
  }
136
150
  }
137
151
  stageComplete(_stage, result) {
138
- if (this.stageSpinner) {
139
- this.stageSpinner.suffixText = `took ${chalk.bold(prettyMilliseconds(result.duration))}`;
140
- this.stageSpinner.succeed();
141
- this.stageSpinner = undefined;
152
+ if (this.activeSpinner) {
153
+ this.activeSpinner.suffixText = `took ${chalk.bold(prettyMilliseconds(result.duration))}`;
154
+ this.activeSpinner.succeed();
155
+ this.activeSpinner = undefined;
142
156
  }
143
157
  }
144
158
  stageFailed(_stage, error) {
145
- if (this.stageSpinner) {
146
- this.stageSpinner.suffixText = chalk.red(error.message);
147
- this.stageSpinner.fail();
148
- this.stageSpinner = undefined;
159
+ if (this.activeSpinner) {
160
+ this.activeSpinner.suffixText = chalk.red(error.message);
161
+ this.activeSpinner.fail();
162
+ this.activeSpinner = undefined;
149
163
  }
150
164
  }
151
165
  stageValidated(_stage, report) {
@@ -157,10 +171,10 @@ export class ConsoleReporter {
157
171
  }
158
172
  }
159
173
  stageSkipped(_stage, reason) {
160
- if (this.stageSpinner) {
161
- this.stageSpinner.suffixText = `skipped: ${chalk.red(reason)}`;
162
- this.stageSpinner.fail();
163
- this.stageSpinner = undefined;
174
+ if (this.activeSpinner) {
175
+ this.activeSpinner.suffixText = `skipped: ${chalk.red(reason)}`;
176
+ this.activeSpinner.fail();
177
+ this.activeSpinner = undefined;
164
178
  }
165
179
  }
166
180
  datasetComplete(_dataset) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/pipeline-console-reporter",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "Console progress reporter for @lde/pipeline",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/ldelements/lde.git",
@@ -25,12 +25,13 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "chalk": "^5.4.1",
28
+ "log-symbols": "^7.0.0",
28
29
  "ora": "^9.3.0",
29
30
  "pretty-ms": "^9.3.0",
30
31
  "tslib": "^2.3.0"
31
32
  },
32
33
  "peerDependencies": {
33
- "@lde/dataset": "0.7.1",
34
- "@lde/pipeline": "0.24.3"
34
+ "@lde/dataset": "0.7.2",
35
+ "@lde/pipeline": "0.24.4"
35
36
  }
36
37
  }