|
5 | 5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve'; |
9 |
| -import { once } from '@salesforce/kit'; |
10 |
| -import { ux as coreUx } from '@oclif/core'; |
11 |
| -import { Ux } from '@salesforce/sf-plugins-core'; |
12 |
| -import { ProgressFormatter } from './progressFormatter.js'; |
| 8 | +import { MetadataApiDeploy, MetadataApiDeployStatus } from '@salesforce/source-deploy-retrieve'; |
| 9 | +import { SingleBar } from 'cli-progress'; |
13 | 10 |
|
14 |
| -export class DeployProgressBarFormatter extends ProgressFormatter { |
15 |
| - protected progressBar = coreUx.progress({ |
| 11 | +export class DeployProgressBarFormatter { |
| 12 | + protected progressBar = new SingleBar({ |
16 | 13 | format: 'DEPLOY PROGRESS | {bar} | {value}/{total} Components',
|
17 | 14 | barCompleteChar: '\u2588',
|
18 | 15 | barIncompleteChar: '\u2591',
|
19 | 16 | linewrap: true,
|
| 17 | + noTTYOutput: Boolean(process.env.TERM === 'dumb' || !process.stdin.isTTY), |
20 | 18 | });
|
21 |
| - public constructor(ux: Ux) { |
22 |
| - super(ux); |
23 |
| - } |
| 19 | + |
| 20 | + public constructor() {} |
24 | 21 |
|
25 | 22 | // displays the progress of the Deployment
|
26 | 23 | public progress(deploy: MetadataApiDeploy): void {
|
27 |
| - const startProgressBar = once((componentTotal: number) => { |
28 |
| - this.progressBar.start(componentTotal, 0); |
29 |
| - }); |
30 |
| - |
31 |
| - deploy.onUpdate((data) => { |
32 |
| - // the numCompTot. isn't computed right away, wait to start until we know how many we have |
33 |
| - const total = data.numberComponentsTotal + data.numberTestsTotal; |
34 |
| - if (data.numberComponentsTotal) { |
35 |
| - startProgressBar(total); |
36 |
| - this.progressBar.update(data.numberComponentsDeployed + data.numberTestsCompleted); |
| 24 | + this.progressBar.start(0, 0); |
| 25 | + deploy.onUpdate( |
| 26 | + ({ |
| 27 | + numberComponentsTotal, |
| 28 | + numberTestsTotal, |
| 29 | + numberComponentsDeployed, |
| 30 | + numberTestsCompleted, |
| 31 | + }: MetadataApiDeployStatus) => { |
| 32 | + // the numberComponentsTotal isn't computed right away, wait to start until we know how many we have |
| 33 | + const total = numberComponentsTotal + numberTestsTotal; |
| 34 | + if (this.progressBar.getTotal() !== total) { |
| 35 | + this.progressBar.setTotal(total); |
| 36 | + } |
| 37 | + this.progressBar.update(numberComponentsDeployed + numberTestsCompleted); |
37 | 38 | }
|
38 |
| - |
39 |
| - // the numTestsTot. isn't computed until validated as tests by the server, update the PB once we know |
40 |
| - if (data.numberTestsTotal && data.numberComponentsTotal) { |
41 |
| - this.progressBar.setTotal(total); |
42 |
| - } |
43 |
| - }); |
| 39 | + ); |
44 | 40 |
|
45 | 41 | // any thing else should stop the progress bar
|
46 | 42 | deploy.onFinish((data) => {
|
|
0 commit comments