diff --git a/package.json b/package.json index e2430f20..d11281ad 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@salesforce/kit": "^3.0.15", "@salesforce/sf-plugins-core": "^5.0.3", "@salesforce/source-deploy-retrieve": "^10.0.2", - "@salesforce/source-tracking": "^5.0.1", + "@salesforce/source-tracking": "^5.1.0", "chalk": "^5.3.0" }, "devDependencies": { diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index 80f3ea33..fd7c43d7 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -263,7 +263,7 @@ export default class DeployMetadata extends SfCommand { } protected catch(error: Error | SfError): Promise { - if (error instanceof SourceConflictError) { + if (error instanceof SourceConflictError && error.data) { if (!this.jsonEnabled()) { writeConflictTable(error.data); // set the message and add plugin-specific actions diff --git a/src/commands/project/retrieve/start.ts b/src/commands/project/retrieve/start.ts index fef75887..fd419ab8 100644 --- a/src/commands/project/retrieve/start.ts +++ b/src/commands/project/retrieve/start.ts @@ -267,7 +267,7 @@ export default class RetrieveMetadata extends SfCommand { } protected catch(error: Error | SfError): Promise { - if (!this.jsonEnabled() && error instanceof SourceConflictError) { + if (!this.jsonEnabled() && error instanceof SourceConflictError && error.data) { writeConflictTable(error.data); // set the message and add plugin-specific actions return super.catch({ diff --git a/src/utils/progressBar.ts b/src/utils/progressBar.ts index 1a2de233..2a90907c 100644 --- a/src/utils/progressBar.ts +++ b/src/utils/progressBar.ts @@ -6,9 +6,10 @@ */ import { dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { envVars as env, EnvironmentVariable, Messages } from '@salesforce/core'; +import { envVars as env, EnvironmentVariable, Lifecycle, Messages } from '@salesforce/core'; import { MetadataApiDeploy, MetadataApiDeployStatus } from '@salesforce/source-deploy-retrieve'; import { Progress } from '@salesforce/sf-plugins-core'; +import { SourceMemberPollingEvent } from '@salesforce/source-tracking'; Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url))); const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'metadata.transfer'); @@ -20,7 +21,7 @@ const showBar = Boolean( export class DeployProgress extends Progress { private static OPTIONS = { title: 'Status', - format: `%s: {status} ${showBar ? '| {bar} ' : ''}| {value}/{total} Components (Errors:{errorCount}) {testInfo}`, + format: `%s: {status} ${showBar ? '| {bar} ' : ''}| {value}/{total} Components{errorInfo}{testInfo}{trackingInfo}`, barCompleteChar: '\u2588', barIncompleteChar: '\u2591', linewrap: true, @@ -28,13 +29,19 @@ export class DeployProgress extends Progress { // they won't get the "bar" but will get the remaining template bits this way noTTYOutput: true, }; + private lifecycle = Lifecycle.getInstance(); public constructor(private deploy: MetadataApiDeploy, jsonEnabled = false) { super(!jsonEnabled); } public start(): void { - super.start(0, { status: 'Waiting' }, DeployProgress.OPTIONS); + super.start(0, { status: 'Waiting', trackingInfo: '', testInfo: '' }, DeployProgress.OPTIONS); + + // for sourceMember polling events + this.lifecycle.on('sourceMemberPollingEvent', (event: SourceMemberPollingEvent) => + Promise.resolve(this.updateTrackingProgress(event)) + ); this.deploy.onUpdate((data) => this.updateProgress(data)); @@ -52,21 +59,32 @@ export class DeployProgress extends Progress { }); } + private updateTrackingProgress(data: SourceMemberPollingEvent): void { + const { remaining, original } = data; + this.update(0, { + status: 'Polling SourceMembers', + trackingInfo: ` | Tracking: ${original - remaining}/${original}`, + }); + } + private updateProgress(data: MetadataApiDeployStatus): void { // the numCompTot. isn't computed right away, wait to start until we know how many we have - const errorCount = data.numberComponentErrors ?? 0; - const testInfo = `| ${data.numberTestsCompleted ?? 0}/${data.numberTestsTotal ?? 0} Tests (Errors:${ - data.numberTestErrors - })`; + const testInfo = data.numberTestsTotal + ? ` | ${data.numberTestsCompleted ?? 0}/${data.numberTestsTotal ?? 0} Tests${ + data.numberTestErrors ? `(Errors:${data.numberTestErrors})` : '' + }` + : ''; + const errorInfo = data.numberComponentErrors > 0 ? ` | Errors: ${data.numberComponentErrors}` : ''; + if (data.numberComponentsTotal) { this.setTotal(data.numberComponentsTotal); this.update(data.numberComponentsDeployed, { - errorCount, + errorInfo: data.numberComponentErrors > 0 ? ` | Errors: ${data.numberComponentErrors}` : '', status: mdTransferMessages.getMessage(data.status), testInfo, }); } else { - this.update(0, { errorCount, testInfo, status: mdTransferMessages.getMessage(data.status) ?? 'Waiting' }); + this.update(0, { errorInfo, testInfo, status: mdTransferMessages.getMessage(data.status) ?? 'Waiting' }); } } } diff --git a/yarn.lock b/yarn.lock index 5cabd369..e3ba5909 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1200,15 +1200,15 @@ shelljs "^0.8.4" sinon "^10.0.0" -"@salesforce/source-tracking@^5.0.0", "@salesforce/source-tracking@^5.0.1": - version "5.0.1" - resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-5.0.1.tgz#3b54b2ed8eee9c7bc8506ca9b1c0e88f961b435a" - integrity sha512-9ckOvid03/J5Lvq83aW7GIlLm9HtJ9NMLwalppDMvSd4T/lyWe8y4bxh4LKbqTC7fhzHMxet8yYTpzub0t+DPA== +"@salesforce/source-tracking@^5.0.0", "@salesforce/source-tracking@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-5.1.0.tgz#c0d6336f0002a8c4abeae4ff3392de4adc169fd3" + integrity sha512-FTuDwLjERm1OR/xTy4a5oHThGOQvI0Rqs4ZqClQFUdgUKREcbxvO3UivSekgXA3az6nuSeNRmaTZGTC5gPjtKA== dependencies: "@oclif/core" "^3.10.8" - "@salesforce/core" "^6.1.3" + "@salesforce/core" "^6.2.0" "@salesforce/kit" "^3.0.15" - "@salesforce/source-deploy-retrieve" "^10.0.0" + "@salesforce/source-deploy-retrieve" "^10.0.2" "@salesforce/ts-types" "^2.0.9" fast-xml-parser "^4.2.5" graceful-fs "^4.2.11"