Skip to content

Commit

Permalink
fix: revert MSO changes (#1147)
Browse files Browse the repository at this point in the history
* Revert "fix: prevent NaN in stage output (#1139)"

This reverts commit e426bf5.

* Revert "Merge pull request #1123 from salesforcecli/mdonnalley/ink"

This reverts commit c4f1cff, reversing
changes made to 2098219.
  • Loading branch information
mdonnalley authored Aug 26, 2024
1 parent eb014af commit afb625e
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 591 deletions.
12 changes: 12 additions & 0 deletions messages/retrieve.start.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ Extract all files from the retrieved zip file.

File name to use for the retrieved zip file.

# spinner.start

Preparing retrieve request

# spinner.sending

Sending request to org

# spinner.polling

Waiting for the org to respond

# error.Conflicts

There are changes in your local files that conflict with the org changes you're trying to retrieve.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^4.0.18",
"@oclif/multi-stage-output": "^0.3.1",
"@salesforce/apex-node": "^8.1.3",
"@salesforce/core": "^8.4.0",
"@salesforce/kit": "^3.2.1",
Expand Down
12 changes: 3 additions & 9 deletions src/commands/project/delete/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
requiredOrgFlagWithDeprecations,
SfCommand,
} from '@salesforce/sf-plugins-core';
import { DeployStages } from '../../../utils/deployStages.js';
import { writeConflictTable } from '../../../utils/conflicts.js';
import { isNonDecomposedCustomLabel, isNonDecomposedCustomLabelsOrCustomLabel } from '../../../utils/metadataTypes.js';
import { getFileResponseSuccessProps, tableHeader } from '../../../utils/output.js';
Expand All @@ -42,6 +41,7 @@ import { getPackageDirs, getSourceApiVersion } from '../../../utils/project.js';
import { resolveApi, validateTests } from '../../../utils/deploy.js';
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
import { DeleteResultFormatter } from '../../../formatters/deleteResultFormatter.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { DeployCache } from '../../../utils/deployCache.js';
import { testLevelFlag, testsFlag } from '../../../utils/flags.js';
const testFlags = 'Test';
Expand Down Expand Up @@ -244,14 +244,8 @@ export class Source extends SfCommand<DeleteSourceJson> {

// fire predeploy event for the delete
await Lifecycle.getInstance().emit('predeploy', this.components);

const stages = new DeployStages({
title: 'Deleting Metadata',
jsonEnabled: this.jsonEnabled(),
});

const isRest = (await resolveApi()) === API['REST'];
stages.update({ message: `Deleting with ${isRest ? 'REST' : 'SOAP'} API` });
this.log(`*** Deleting with ${isRest ? 'REST' : 'SOAP'} API ***`);

const deploy = await this.componentSet.deploy({
usernameOrConnection: this.org.getUsername() as string,
Expand All @@ -263,7 +257,7 @@ export class Source extends SfCommand<DeleteSourceJson> {
},
});

stages.start({ deploy, username: this.org.getUsername() });
new DeployProgress(deploy, this.jsonEnabled()).start();
this.deployResult = await deploy.pollStatus({ timeout: this.flags.wait });
if (!deploy.id) {
throw new SfError('The deploy id is not available.');
Expand Down
9 changes: 3 additions & 6 deletions src/commands/project/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { Messages, Org, SfProject } from '@salesforce/core';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { ComponentSet, DeployResult, MetadataApiDeploy, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { DeployStages } from '../../../utils/deployStages.js';
import { buildComponentSet } from '../../../utils/deploy.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { DeployCache } from '../../../utils/deployCache.js';
import { DeployReportResultFormatter } from '../../../formatters/deployReportResultFormatter.js';
import { API, DeployResultJson } from '../../../utils/types.js';
Expand Down Expand Up @@ -70,7 +70,7 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
const jobId = cache.resolveLatest(flags['use-most-recent'], flags['job-id'], false);

const deployOpts = cache.maybeGet(jobId);
const { wait } = flags;
const wait = flags['wait'];
const org = deployOpts?.['target-org']
? await Org.create({ aliasOrUsername: deployOpts['target-org'] })
: flags['target-org'];
Expand Down Expand Up @@ -124,10 +124,7 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
if (wait) {
// poll for deploy results
try {
new DeployStages({
title: 'Deploying Metadata',
jsonEnabled: this.jsonEnabled(),
}).start({ deploy: mdapiDeploy, username: org.getUsername() });
new DeployProgress(mdapiDeploy, this.jsonEnabled()).start();
result = await mdapiDeploy.pollStatus(500, wait.seconds);
} catch (error) {
if (error instanceof Error && error.message.includes('The client has timed out')) {
Expand Down
10 changes: 4 additions & 6 deletions src/commands/project/deploy/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import ansis from 'ansis';
import { EnvironmentVariable, Messages, Org, SfError } from '@salesforce/core';
import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core';
import { DeployResult, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import { Duration } from '@salesforce/kit';
import { DeployStages } from '../../../utils/deployStages.js';
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { API, DeployResultJson } from '../../../utils/types.js';
import { buildComponentSet, determineExitCode, executeDeploy, isNotResumable } from '../../../utils/deploy.js';
import { DeployCache } from '../../../utils/deployCache.js';
Expand Down Expand Up @@ -123,11 +124,8 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {
jobId
);

new DeployStages({
title: 'Resuming Deploy',
jsonEnabled: this.jsonEnabled(),
}).start({ deploy, username: deployOpts['target-org'] });

this.log(`Deploy ID: ${ansis.bold(jobId)}`);
new DeployProgress(deploy, this.jsonEnabled()).start();
result = await deploy.pollStatus(500, wait.seconds);

if (!deploy.id) {
Expand Down
63 changes: 21 additions & 42 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { MultiStageOutput } from '@oclif/multi-stage-output';
import ansis from 'ansis';
import { EnvironmentVariable, Lifecycle, Messages, OrgConfigProperties, SfError } from '@salesforce/core';
import { DeployVersionData, MetadataApiDeployStatus } from '@salesforce/source-deploy-retrieve';
import { DeployVersionData } from '@salesforce/source-deploy-retrieve';
import { Duration } from '@salesforce/kit';
import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core';
import { SourceConflictError, SourceMemberPollingEvent } from '@salesforce/source-tracking';
import { DeployStages } from '../../../utils/deployStages.js';
import { SourceConflictError } from '@salesforce/source-tracking';
import { AsyncDeployResultFormatter } from '../../../formatters/asyncDeployResultFormatter.js';
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { DeployResultJson, TestLevel } from '../../../utils/types.js';
import { executeDeploy, resolveApi, validateTests, determineExitCode } from '../../../utils/deploy.js';
import { DeployCache } from '../../../utils/deployCache.js';
Expand Down Expand Up @@ -176,16 +176,6 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {

public static errorCodes = toHelpSection('ERROR CODES', DEPLOY_STATUS_CODES_DESCRIPTIONS);

protected ms!: MultiStageOutput<{
mdapiDeploy: MetadataApiDeployStatus;
sourceMemberPolling: SourceMemberPollingEvent;
status: string;
apiData: DeployVersionData;
targetOrg: string;
}>;

protected stages!: DeployStages;

public async run(): Promise<DeployResultJson> {
const { flags } = await this.parse(DeployMetadata);
const project = await getOptionalProject();
Expand All @@ -207,30 +197,23 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {

const api = await resolveApi(this.configAggregator);
const username = flags['target-org'].getUsername();
const title = flags['dry-run'] ? 'Deploying Metadata (dry-run)' : 'Deploying Metadata';
const action = flags['dry-run'] ? 'Deploying (dry-run)' : 'Deploying';

this.stages = new DeployStages({
title,
jsonEnabled: this.jsonEnabled(),
// eslint-disable-next-line @typescript-eslint/require-await
Lifecycle.getInstance().on('apiVersionDeploy', async (apiData: DeployVersionData) => {
this.log(
messages.getMessage('apiVersionMsgDetailed', [
action,
// technically manifestVersion can be undefined, but only on raw mdapi deployments.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
flags['metadata-dir'] ? '<version specified in manifest>' : `v${apiData.manifestVersion}`,
username,
apiData.apiVersion,
apiData.webService,
])
);
});

const lifecycle = Lifecycle.getInstance();
lifecycle.on('apiVersionDeploy', async (apiData: DeployVersionData) =>
Promise.resolve(
this.stages.update({
message: messages.getMessage('apiVersionMsgDetailed', [
flags['dry-run'] ? 'Deploying (dry-run)' : 'Deploying',
// technically manifestVersion can be undefined, but only on raw mdapi deployments.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
flags['metadata-dir'] ? '<version specified in manifest>' : `v${apiData.manifestVersion}`,
username,
apiData.apiVersion,
apiData.webService,
]),
})
)
);

const { deploy } = await executeDeploy(
{
...flags,
Expand All @@ -241,20 +224,16 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
);

if (!deploy) {
this.stages.stop();
this.log('No changes to deploy');
return { status: 'Nothing to deploy', files: [] };
}

if (!deploy.id) {
throw new SfError('The deploy id is not available.');
}

this.stages.start({ username, deploy });
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);

if (flags.async) {
this.stages.done({ status: 'Queued', username });
this.stages.stop();
if (flags['coverage-formatters']) {
this.warn(messages.getMessage('asyncCoverageJunitWarning'));
}
Expand All @@ -263,6 +242,8 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
return asyncFormatter.getJson();
}

new DeployProgress(deploy, this.jsonEnabled()).start();

const result = await deploy.pollStatus({ timeout: flags.wait });
process.exitCode = determineExitCode(result);
const formatter = new DeployResultFormatter(result, flags);
Expand All @@ -280,8 +261,6 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
protected catch(error: Error | SfError): Promise<never> {
if (error instanceof SourceConflictError && error.data) {
if (!this.jsonEnabled()) {
this.stages.update({ status: 'Failed' });
this.stages.stop(error);
writeConflictTable(error.data);
// set the message and add plugin-specific actions
return super.catch({
Expand Down
9 changes: 3 additions & 6 deletions src/commands/project/deploy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { EnvironmentVariable, Lifecycle, Messages, OrgConfigProperties, SfError
import { CodeCoverageWarnings, DeployVersionData, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { Duration, ensureArray } from '@salesforce/kit';
import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core';
import { DeployStages } from '../../../utils/deployStages.js';
import { AsyncDeployResultFormatter } from '../../../formatters/asyncDeployResultFormatter.js';
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { DeployResultJson, TestLevel } from '../../../utils/types.js';
import { executeDeploy, resolveApi, determineExitCode, validateTests } from '../../../utils/deploy.js';
import { DEPLOY_STATUS_CODES_DESCRIPTIONS } from '../../../utils/errorCodes.js';
Expand Down Expand Up @@ -195,18 +195,15 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
if (!deploy.id) {
throw new SfError('The deploy id is not available.');
}
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);

if (flags.async) {
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);
const asyncFormatter = new AsyncDeployResultFormatter(deploy.id);
if (!this.jsonEnabled()) asyncFormatter.display();
return asyncFormatter.getJson();
}

new DeployStages({
title: 'Validating Deployment',
jsonEnabled: this.jsonEnabled(),
}).start({ deploy, username });
new DeployProgress(deploy, this.jsonEnabled()).start();

const result = await deploy.pollStatus(500, flags.wait?.seconds);
process.exitCode = determineExitCode(result);
Expand Down
Loading

0 comments on commit afb625e

Please sign in to comment.