Skip to content

Commit 9e5ef50

Browse files
feat: devScripts update (#1203)
* chore: updates from devScripts * fix: remove oclif interface * refactor: use cli-progress directly * chore: remove unused constructor prop, break inheritance chain --------- Co-authored-by: mshanemc <shane.mclaughlin@salesforce.com>
1 parent a2b6272 commit 9e5ef50

File tree

12 files changed

+177
-155
lines changed

12 files changed

+177
-155
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^3.26.6",
8+
"@oclif/core": "^4",
99
"@salesforce/apex-node": "^6.0.0",
1010
"@salesforce/core": "^7.3.9",
1111
"@salesforce/kit": "^3.1.2",
12-
"@salesforce/sf-plugins-core": "^9.1.1",
12+
"@salesforce/sf-plugins-core": "^10.0.0",
1313
"@salesforce/source-deploy-retrieve": "^11.6.2",
1414
"@salesforce/source-tracking": "^6.3.3",
1515
"@salesforce/ts-types": "^2.0.9",
1616
"chalk": "^5.3.0",
17+
"cli-progress": "^3.12.0",
1718
"got": "^13.0.0",
1819
"proxy-agent": "^6.3.1"
1920
},
2021
"devDependencies": {
2122
"@oclif/plugin-command-snapshot": "^5.1.7",
2223
"@oclif/plugin-help": "^6.1.0",
2324
"@salesforce/cli-plugins-testkit": "^5.3.5",
24-
"@salesforce/dev-scripts": "^9.1.3",
25+
"@salesforce/dev-scripts": "^10.1.0",
2526
"@salesforce/plugin-command-reference": "^3.0.86",
2627
"@salesforce/source-testkit": "^2.2.23",
2728
"@salesforce/ts-sinon": "1.4.19",
2829
"@types/archiver": "^5.3.2",
30+
"@types/cli-progress": "^3.11.5",
2931
"archiver": "^5.3.2",
3032
"chai-each": "^0.0.1",
3133
"cross-env": "^7.0.3",

src/commands/force/mdapi/deploy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
} from '../../../deployCommand.js';
2626
import { DeployCommandAsyncResult } from '../../../formatters/source/deployAsyncResultFormatter.js';
2727
import { MdDeployResult, MdDeployResultFormatter } from '../../../formatters/mdapi/mdDeployResultFormatter.js';
28-
import { ProgressFormatter } from '../../../formatters/progressFormatter.js';
2928
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter.js';
3029
import { DeployProgressStatusFormatter } from '../../../formatters/deployProgressStatusFormatter.js';
3130
import { MdDeployAsyncResultFormatter } from '../../../formatters/mdapi/mdDeployAsyncResultFormatter.js';
@@ -205,8 +204,8 @@ export class Deploy extends DeployCommand {
205204

206205
if (!this.isAsync) {
207206
if (!this.jsonEnabled()) {
208-
const progressFormatter: ProgressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
209-
? new DeployProgressBarFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }))
207+
const progressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
208+
? new DeployProgressBarFormatter()
210209
: new DeployProgressStatusFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }));
211210
progressFormatter.progress(deploy);
212211
}

src/commands/force/mdapi/deploy/report.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
import { Interfaces } from '@oclif/core';
2020
import { MdDeployResult, MdDeployResultFormatter } from '../../../../formatters/mdapi/mdDeployResultFormatter.js';
2121
import { DeployCommand, getCoverageFormattersOptions, reportsFormatters } from '../../../../deployCommand.js';
22-
import { ProgressFormatter } from '../../../../formatters/progressFormatter.js';
2322
import { DeployProgressBarFormatter } from '../../../../formatters/deployProgressBarFormatter.js';
2423
import { DeployProgressStatusFormatter } from '../../../../formatters/deployProgressStatusFormatter.js';
2524

@@ -112,8 +111,8 @@ export class Report extends DeployCommand {
112111

113112
const deploy = this.createDeploy(this.org.getConnection(), deployId);
114113
if (!this.jsonEnabled()) {
115-
const progressFormatter: ProgressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
116-
? new DeployProgressBarFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }))
114+
const progressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
115+
? new DeployProgressBarFormatter()
117116
: new DeployProgressStatusFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }));
118117
progressFormatter.progress(deploy);
119118
}

src/commands/force/source/deploy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
DeployAsyncResultFormatter,
3030
DeployCommandAsyncResult,
3131
} from '../../../formatters/source/deployAsyncResultFormatter.js';
32-
import { ProgressFormatter } from '../../../formatters/progressFormatter.js';
3332
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter.js';
3433
import { DeployProgressStatusFormatter } from '../../../formatters/deployProgressStatusFormatter.js';
3534
import { filterConflictsByComponentSet, trackingSetup, updateTracking } from '../../../trackingFunctions.js';
@@ -283,8 +282,8 @@ export class Deploy extends DeployCommand {
283282
if (!this.isAsync) {
284283
// we're not print JSON output
285284
if (!this.jsonEnabled()) {
286-
const progressFormatter: ProgressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
287-
? new DeployProgressBarFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }))
285+
const progressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
286+
? new DeployProgressBarFormatter()
288287
: new DeployProgressStatusFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }), {
289288
verbose: this.flags.verbose,
290289
});

src/commands/force/source/deploy/report.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
DeployReportCommandResult,
2424
DeployReportResultFormatter,
2525
} from '../../../../formatters/deployReportResultFormatter.js';
26-
import { ProgressFormatter } from '../../../../formatters/progressFormatter.js';
2726
import { DeployProgressBarFormatter } from '../../../../formatters/deployProgressBarFormatter.js';
2827
import { DeployProgressStatusFormatter } from '../../../../formatters/deployProgressStatusFormatter.js';
2928
import { ResultFormatterOptions } from '../../../../formatters/resultFormatter.js';
@@ -112,8 +111,8 @@ export class Report extends DeployCommand {
112111
const waitDuration = this.flags.wait;
113112
const deploy = this.createDeploy(this.flags['target-org'].getConnection(), deployId);
114113
if (!this.jsonEnabled()) {
115-
const progressFormatter: ProgressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
116-
? new DeployProgressBarFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }))
114+
const progressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
115+
? new DeployProgressBarFormatter()
117116
: new DeployProgressStatusFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }));
118117
progressFormatter.progress(deploy);
119118
}

src/commands/force/source/push.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
import { Interfaces } from '@oclif/core';
2121
import { DeployCommand } from '../../../deployCommand.js';
2222
import { PushResponse, PushResultFormatter } from '../../../formatters/source/pushResultFormatter.js';
23-
import { ProgressFormatter } from '../../../formatters/progressFormatter.js';
2423
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter.js';
2524
import { DeployProgressStatusFormatter } from '../../../formatters/deployProgressStatusFormatter.js';
2625
import { trackingSetup, updateTracking } from '../../../trackingFunctions.js';
@@ -149,8 +148,8 @@ export default class Push extends DeployCommand {
149148

150149
// we're not print JSON output
151150
if (!this.jsonEnabled()) {
152-
const progressFormatter: ProgressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
153-
? new DeployProgressBarFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }))
151+
const progressFormatter = env.getBoolean('SF_USE_PROGRESS_BAR', true)
152+
? new DeployProgressBarFormatter()
154153
: new DeployProgressStatusFormatter(new Ux({ jsonEnabled: this.jsonEnabled() }));
155154
progressFormatter.progress(deploy);
156155
}

src/commands/force/source/retrieve.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
requiredOrgFlagWithDeprecations,
2929
Ux,
3030
} from '@salesforce/sf-plugins-core';
31-
import { AlphabetLowercase } from '@oclif/core/lib/interfaces';
3231
import { SourceCommand } from '../../../sourceCommand.js';
3332
import {
3433
PackageRetrieval,
@@ -57,8 +56,7 @@ export class Retrieve extends SourceCommand {
5756
message: messages.getMessage('deprecation', [replacement]),
5857
};
5958
public static readonly flags = {
60-
// I have no idea why 'a' isn't matching the type AlphabetLowercase automatically
61-
'api-version': { ...orgApiVersionFlagWithDeprecations, char: 'a' as AlphabetLowercase },
59+
'api-version': { ...orgApiVersionFlagWithDeprecations, char: 'a' as const },
6260
loglevel,
6361
'target-org': requiredOrgFlagWithDeprecations,
6462
retrievetargetdir: Flags.directory({

src/formatters/deployProgressBarFormatter.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,38 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

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';
1310

14-
export class DeployProgressBarFormatter extends ProgressFormatter {
15-
protected progressBar = coreUx.progress({
11+
export class DeployProgressBarFormatter {
12+
protected progressBar = new SingleBar({
1613
format: 'DEPLOY PROGRESS | {bar} | {value}/{total} Components',
1714
barCompleteChar: '\u2588',
1815
barIncompleteChar: '\u2591',
1916
linewrap: true,
17+
noTTYOutput: Boolean(process.env.TERM === 'dumb' || !process.stdin.isTTY),
2018
});
21-
public constructor(ux: Ux) {
22-
super(ux);
23-
}
19+
20+
public constructor() {}
2421

2522
// displays the progress of the Deployment
2623
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);
3738
}
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+
);
4440

4541
// any thing else should stop the progress bar
4642
deploy.onFinish((data) => {

src/sourceCommand.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ import fs from 'node:fs';
1111
import { Messages, SfError } from '@salesforce/core';
1212
import { ComponentSet } from '@salesforce/source-deploy-retrieve';
1313
import { getString, Optional } from '@salesforce/ts-types';
14-
import { ux } from '@oclif/core';
14+
import { SingleBar } from 'cli-progress';
1515
import { SfCommand } from '@salesforce/sf-plugins-core';
16-
import { EnsureFsFlagOptions, FsError, ProgressBar } from './types.js';
16+
import { EnsureFsFlagOptions, FsError } from './types.js';
1717

1818
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1919
const messages = Messages.loadMessages('@salesforce/plugin-source', 'flags.validation');
2020

2121
export abstract class SourceCommand extends SfCommand<unknown> {
2222
public static readonly DEFAULT_WAIT_MINUTES = 33;
2323

24-
protected progressBar?: ProgressBar;
24+
protected progressBar?: SingleBar;
2525
protected componentSet?: ComponentSet;
2626

2727
protected initProgressBar(): void {
2828
this.debug('initializing progress bar');
29-
this.progressBar = ux.progress({
29+
this.progressBar = new SingleBar({
3030
format: 'SOURCE PROGRESS | {bar} | {value}/{total} Components',
3131
barCompleteChar: '\u2588',
3232
barIncompleteChar: '\u2591',
3333
linewrap: true,
34-
}) as ProgressBar;
34+
});
3535
}
3636

3737
/**

src/types.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@
77

88
export type FsError = {
99
code: string;
10-
} & Error
10+
} & Error;
1111

1212
export type EnsureFsFlagOptions = {
1313
flagName: string;
1414
path?: string;
1515
type: 'dir' | 'file' | 'any';
1616
throwOnENOENT?: boolean;
17-
}
18-
19-
export type ProgressBar = {
20-
total?: number;
21-
value?: number;
22-
start: (total: number, startValue: number, payload?: object) => void;
23-
update: (num: number, payload?: object) => void;
24-
setTotal: (num: number) => void;
25-
stop: () => void;
2617
};

0 commit comments

Comments
 (0)