Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Dec 19, 2024
2 parents 108c060 + c3f126c commit 71f9f1a
Show file tree
Hide file tree
Showing 7 changed files with 2,270 additions and 1,783 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [3.16.1](https://github.com/salesforcecli/plugin-deploy-retrieve/compare/3.16.0...3.16.1) (2024-12-19)

### Bug Fixes

- bump SDR ([#1246](https://github.com/salesforcecli/plugin-deploy-retrieve/issues/1246)) ([cb51d1e](https://github.com/salesforcecli/plugin-deploy-retrieve/commit/cb51d1e18850a51f227c483d76d17a66ded323e1))

# [3.16.0](https://github.com/salesforcecli/plugin-deploy-retrieve/compare/3.15.22...3.16.0) (2024-12-16)

### Features

- render test failure counter ([#1215](https://github.com/salesforcecli/plugin-deploy-retrieve/issues/1215)) ([e05b983](https://github.com/salesforcecli/plugin-deploy-retrieve/commit/e05b983bf478f29fa8dcb83f44c66079138e2c2c))

## [3.15.22](https://github.com/salesforcecli/plugin-deploy-retrieve/compare/3.15.21...3.15.22) (2024-12-14)

### Bug Fixes

- **deps:** bump @oclif/core from 4.0.34 to 4.0.37 ([75c0f0b](https://github.com/salesforcecli/plugin-deploy-retrieve/commit/75c0f0b980dfb0b06aed2285855a5f0d007c8031))

## [3.15.21](https://github.com/salesforcecli/plugin-deploy-retrieve/compare/3.15.20...3.15.21) (2024-12-14)

### Bug Fixes

- **deps:** bump @salesforce/sf-plugins-core from 12.0.11 to 12.1.1 ([7dea591](https://github.com/salesforcecli/plugin-deploy-retrieve/commit/7dea59160acc64f2111e6eadc16285e53248fa61))

## [3.15.20](https://github.com/salesforcecli/plugin-deploy-retrieve/compare/3.15.19...3.15.20) (2024-12-07)

### Bug Fixes
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ FLAG DESCRIPTIONS
If you specify this flag, don’t specify --metadata or --source-dir.
```

_See code: [src/commands/project/convert/mdapi.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/convert/mdapi.ts)_
_See code: [src/commands/project/convert/mdapi.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/convert/mdapi.ts)_

## `sf project convert source`

Expand Down Expand Up @@ -214,7 +214,7 @@ FLAG DESCRIPTIONS
Override the api version used for api requests made by this command
```

_See code: [src/commands/project/convert/source.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/convert/source.ts)_
_See code: [src/commands/project/convert/source.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/convert/source.ts)_

## `sf project convert source-behavior`

Expand Down Expand Up @@ -272,7 +272,7 @@ EXAMPLES
$ sf project convert source-behavior --behavior decomposePermissionSetBeta --dry-run --preserve-temp-dir
```

_See code: [src/commands/project/convert/source-behavior.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/convert/source-behavior.ts)_
_See code: [src/commands/project/convert/source-behavior.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/convert/source-behavior.ts)_

## `sf project delete source`

Expand Down Expand Up @@ -412,7 +412,7 @@ FLAG DESCRIPTIONS
- Separate the test names with spaces: --tests Test1 Test2 "Test With Space"
```

_See code: [src/commands/project/delete/source.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/delete/source.ts)_
_See code: [src/commands/project/delete/source.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/delete/source.ts)_

## `sf project delete tracking`

Expand Down Expand Up @@ -449,7 +449,7 @@ EXAMPLES
$ sf project delete tracking --target-org my-scratch
```

_See code: [src/commands/project/delete/tracking.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/delete/tracking.ts)_
_See code: [src/commands/project/delete/tracking.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/delete/tracking.ts)_

## `sf project deploy cancel`

Expand Down Expand Up @@ -521,7 +521,7 @@ FLAG DESCRIPTIONS
project deploy report".
```

_See code: [src/commands/project/deploy/cancel.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/cancel.ts)_
_See code: [src/commands/project/deploy/cancel.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/cancel.ts)_

## `sf project deploy preview`

Expand Down Expand Up @@ -604,7 +604,7 @@ FLAG DESCRIPTIONS
All child components are included. If you specify this flag, don’t specify --metadata or --source-dir.
```

_See code: [src/commands/project/deploy/preview.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/preview.ts)_
_See code: [src/commands/project/deploy/preview.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/preview.ts)_

## `sf project deploy quick`

Expand Down Expand Up @@ -688,7 +688,7 @@ FLAG DESCRIPTIONS
deploy report".
```

_See code: [src/commands/project/deploy/quick.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/quick.ts)_
_See code: [src/commands/project/deploy/quick.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/quick.ts)_

## `sf project deploy report`

Expand Down Expand Up @@ -780,7 +780,7 @@ FLAG DESCRIPTIONS
--coverage-formatters lcov --coverage-formatters clover
```

_See code: [src/commands/project/deploy/report.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/report.ts)_
_See code: [src/commands/project/deploy/report.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/report.ts)_

## `sf project deploy resume`

Expand Down Expand Up @@ -865,7 +865,7 @@ FLAG DESCRIPTIONS
--coverage-formatters lcov --coverage-formatters clover
```

_See code: [src/commands/project/deploy/resume.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/resume.ts)_
_See code: [src/commands/project/deploy/resume.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/resume.ts)_

## `sf project deploy start`

Expand Down Expand Up @@ -1101,7 +1101,7 @@ FLAG DESCRIPTIONS
--coverage-formatters lcov --coverage-formatters clover
```

_See code: [src/commands/project/deploy/start.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/start.ts)_
_See code: [src/commands/project/deploy/start.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/start.ts)_

## `sf project deploy validate`

Expand Down Expand Up @@ -1274,7 +1274,7 @@ FLAG DESCRIPTIONS
--coverage-formatters lcov --coverage-formatters clover
```

_See code: [src/commands/project/deploy/validate.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/deploy/validate.ts)_
_See code: [src/commands/project/deploy/validate.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/deploy/validate.ts)_

## `sf project generate manifest`

Expand Down Expand Up @@ -1351,7 +1351,7 @@ EXAMPLES
$ sf project generate manifest --from-org [email protected] --include-packages unlocked
```

_See code: [src/commands/project/generate/manifest.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/generate/manifest.ts)_
_See code: [src/commands/project/generate/manifest.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/generate/manifest.ts)_

## `sf project list ignored`

Expand Down Expand Up @@ -1393,7 +1393,7 @@ EXAMPLES
$ sf project list ignored --source-dir package.xml
```

_See code: [src/commands/project/list/ignored.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/list/ignored.ts)_
_See code: [src/commands/project/list/ignored.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/list/ignored.ts)_

## `sf project reset tracking`

Expand Down Expand Up @@ -1442,7 +1442,7 @@ EXAMPLES
$ sf project reset tracking --revision 30
```

_See code: [src/commands/project/reset/tracking.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/reset/tracking.ts)_
_See code: [src/commands/project/reset/tracking.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/reset/tracking.ts)_

## `sf project retrieve preview`

Expand Down Expand Up @@ -1496,7 +1496,7 @@ FLAG DESCRIPTIONS
production orgs.
```

_See code: [src/commands/project/retrieve/preview.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/retrieve/preview.ts)_
_See code: [src/commands/project/retrieve/preview.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/retrieve/preview.ts)_

## `sf project retrieve start`

Expand Down Expand Up @@ -1665,6 +1665,6 @@ FLAG DESCRIPTIONS
If you specify this flag, don’t specify --metadata or --source-dir.
```

_See code: [src/commands/project/retrieve/start.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.15.20/src/commands/project/retrieve/start.ts)_
_See code: [src/commands/project/retrieve/start.ts](https://github.com/salesforcecli/plugin-deploy-retrieve/blob/3.16.1/src/commands/project/retrieve/start.ts)_

<!-- commandsstop -->
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@salesforce/plugin-deploy-retrieve",
"description": "deploy and retrieve commands for sf",
"version": "3.15.20",
"version": "3.16.1",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^4.0.34",
"@oclif/multi-stage-output": "^0.7.15",
"@oclif/core": "^4.0.37",
"@oclif/multi-stage-output": "^0.8.0",
"@salesforce/apex-node": "^8.1.18",
"@salesforce/core": "^8.6.4",
"@salesforce/kit": "^3.2.3",
"@salesforce/plugin-info": "^3.4.23",
"@salesforce/sf-plugins-core": "^12.0.11",
"@salesforce/sf-plugins-core": "^12.1.1",
"@salesforce/source-deploy-retrieve": "12.10.4-dev-17431548.0",
"@salesforce/source-tracking": "^7.1.17",
"@salesforce/ts-types": "^2.0.12",
Expand All @@ -22,13 +22,13 @@
"@oclif/plugin-command-snapshot": "^5.2.22",
"@salesforce/cli-plugins-testkit": "^5.3.38",
"@salesforce/dev-scripts": "^10.2.11",
"@salesforce/plugin-command-reference": "^3.1.34",
"@salesforce/plugin-command-reference": "^3.1.37",
"@salesforce/schemas": "^1.9.0",
"@salesforce/source-testkit": "^2.2.90",
"@salesforce/ts-sinon": "^1.4.30",
"cross-env": "^7.0.3",
"eslint-plugin-sf-plugin": "^1.20.13",
"oclif": "^4.16.0",
"oclif": "^4.16.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
Expand Down
11 changes: 8 additions & 3 deletions src/formatters/testResultsFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ensureArray } from '@salesforce/kit';
import { TestLevel, Verbosity } from '../utils/types.js';
import { tableHeader, error, success, check } from '../utils/output.js';
import { coverageOutput } from '../utils/coverage.js';
import { isCI } from '../utils/deployStages.js';

const ux = new Ux();

Expand All @@ -45,10 +46,14 @@ export class TestResultsFormatter {
return;
}

displayVerboseTestFailures(this.result.response);
if (!isCI()) {
displayVerboseTestFailures(this.result.response);
}

if (this.verbosity === 'verbose') {
displayVerboseTestSuccesses(this.result.response.details.runTestResult?.successes);
if (!isCI()) {
displayVerboseTestSuccesses(this.result.response.details.runTestResult?.successes);
}
displayVerboseTestCoverage(this.result.response.details.runTestResult?.codeCoverage);
}

Expand Down Expand Up @@ -122,7 +127,7 @@ const displayVerboseTestCoverage = (coverage?: CodeCoverage | CodeCoverage[]): v
}
};

const testResultSort = <T extends Successes | Failures>(a: T, b: T): number =>
export const testResultSort = <T extends Successes | Failures>(a: T, b: T): number =>
a.methodName === b.methodName ? a.name.localeCompare(b.name) : a.methodName.localeCompare(b.methodName);

const coverageSort = (a: CodeCoverage, b: CodeCoverage): number =>
Expand Down
87 changes: 85 additions & 2 deletions src/utils/deployStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import os from 'node:os';
import { MultiStageOutput } from '@oclif/multi-stage-output';
import { Lifecycle, Messages } from '@salesforce/core';
import { MetadataApiDeploy, MetadataApiDeployStatus, RequestStatus } from '@salesforce/source-deploy-retrieve';
import {
Failures,
MetadataApiDeploy,
MetadataApiDeployStatus,
RequestStatus,
} from '@salesforce/source-deploy-retrieve';
import { SourceMemberPollingEvent } from '@salesforce/source-tracking';
import terminalLink from 'terminal-link';
import ansis from 'ansis';
import { testResultSort } from '../formatters/testResultsFormatter.js';
import { getZipFileSize } from './output.js';
import { isTruthy } from './types.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'metadata.transfer');
Expand Down Expand Up @@ -47,8 +56,14 @@ function formatProgress(current: number, total: number): string {

export class DeployStages {
private mso: MultiStageOutput<Data>;
/**
* Set of Apex test failures that were already rendered in the `Running Tests` block.
* This is used in the `Failed` stage block for CI output to ensure test failures aren't duplicated when rendering new failures on polling.
*/
private printedApexTestFailures: Set<string>;

public constructor({ title, jsonEnabled }: Options) {
this.printedApexTestFailures = new Set();
this.mso = new MultiStageOutput<Data>({
title,
stages: [
Expand Down Expand Up @@ -129,14 +144,51 @@ export class DeployStages {
type: 'dynamic-key-value',
},
{
label: 'Tests',
label: 'Successful',
get: (data): string | undefined =>
data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestsCompleted
? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal)
: undefined,
stage: 'Running Tests',
type: 'dynamic-key-value',
},
{
label: 'Failed',
alwaysPrintInCI: true,
get: (data): string | undefined => {
let testFailures: Failures[] = [];

// only render new test failures
if (isCI() && Array.isArray(data?.mdapiDeploy.details.runTestResult?.failures)) {
// skip failure counter/progress info if there's no new failures to render.
if (
this.printedApexTestFailures.size > 0 &&
data.mdapiDeploy.numberTestErrors === this.printedApexTestFailures.size
) {
return undefined;
}

testFailures = data.mdapiDeploy.details.runTestResult?.failures.filter(
(f) => !this.printedApexTestFailures.has(`${f.name}.${f.methodName}`)
);

data?.mdapiDeploy.details.runTestResult?.failures.forEach((f) =>
this.printedApexTestFailures.add(`${f.name}.${f.methodName}`)
);

return data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors
? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) +
(isCI() ? os.EOL + formatTestFailures(testFailures) : '')
: undefined;
}

return data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors
? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal)
: undefined;
},
stage: 'Running Tests',
type: 'dynamic-key-value',
},
{
label: 'Members',
get: (data): string | undefined =>
Expand Down Expand Up @@ -232,3 +284,34 @@ export class DeployStages {
this.mso.skipTo('Done', data);
}
}

function formatTestFailures(failuresData: Failures[]): string {
const failures = failuresData.sort(testResultSort);

let output = '';

for (const test of failures) {
const testName = ansis.underline(`${test.name}.${test.methodName}`);
output += ` • ${testName}${os.EOL}`;
output += ` message: ${test.message}${os.EOL}`;
if (test.stackTrace) {
const stackTrace = test.stackTrace.replace(/\n/g, `${os.EOL} `);
output += ` stacktrace:${os.EOL} ${stackTrace}${os.EOL}${os.EOL}`;
}
}

// remove last EOL char
return output.slice(0, -1);
}

export function isCI(): boolean {
if (
isTruthy(process.env.CI) &&
('CI' in process.env ||
'CONTINUOUS_INTEGRATION' in process.env ||
Object.keys(process.env).some((key) => key.startsWith('CI_')))
)
return true;

return false;
}
4 changes: 4 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ export const isFileResponseDeleted = (fileResponse: FileResponseSuccess): boolea
fileResponse.state === ComponentStatus.Deleted;

export const isDefined = <T>(value?: T): value is T => value !== undefined;

export function isTruthy(value: string | undefined): boolean {
return value !== '0' && value !== 'false';
}
Loading

0 comments on commit 71f9f1a

Please sign in to comment.