Skip to content

Commit

Permalink
fix: include correct username for deploy:report in async deploy (#392)
Browse files Browse the repository at this point in the history
Co-authored-by: Cristian Dominguez <[email protected]>
  • Loading branch information
WillieRuemmele and cristiand391 authored Jan 20, 2022
1 parent 428d398 commit f58ff25
Show file tree
Hide file tree
Showing 33 changed files with 118 additions and 77 deletions.
4 changes: 2 additions & 2 deletions messages/deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"deployCanceled": "The deployment has been canceled by %s.",
"deployFailed": "Deploy failed.",
"asyncDeployQueued": "Deploy has been queued.",
"asyncDeployCancel": "Run sfdx force:source:deploy:cancel -i %s to cancel the deploy.",
"asyncDeployReport": "Run sfdx force:source:deploy:report -i %s to get the latest status.",
"asyncDeployCancel": "Run sfdx force:source:deploy:cancel -i %s -u %s to cancel the deploy.",
"asyncDeployReport": "Run sfdx force:source:deploy:report -i %s -u %s to get the latest status.",
"invalidDeployId": "The provided ID is invalid, deploy IDs must start with '0Af'."
}
5 changes: 4 additions & 1 deletion messages/md.deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
"soapDeploy": "Deploy metadata with SOAP API instead of the default REST API. Because SOAP API has a lower .ZIP file size limit (400 MB uncompressed, 39 MB compressed), Salesforce recommends REST API deployment. This flag provides backwards compatibility with API version 50.0 and earlier when deploy used SOAP API by default."
},
"noRestDeploy": "REST deploy is not available for this org. This feature is currently for internal Salesforce use only.",
"deployFailed": "The metadata deploy operation failed."
"deployFailed": "The metadata deploy operation failed.",
"asyncDeployQueued": "Deploy has been queued.",
"asyncDeployCancel": "Run sfdx force:mdapi:deploy:cancel -i %s -u %s to cancel the deploy.",
"asyncDeployReport": "Run sfdx force:mdapi:beta:deploy:report -i %s -u %s to get the latest status."
}
11 changes: 5 additions & 6 deletions src/commands/force/mdapi/beta/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import { Duration, env } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import { DeployCommand, getVersionMessage, TestLevel } from '../../../../deployCommand';
import {
DeployAsyncResultFormatter,
DeployCommandAsyncResult,
} from '../../../../formatters/deployAsyncResultFormatter';
import { MdDeployResultFormatter, MdDeployResult } from '../../../../formatters/mdDeployResultFormatter';
import { DeployCommandAsyncResult } from '../../../../formatters/source/deployAsyncResultFormatter';
import { MdDeployResult, MdDeployResultFormatter } from '../../../../formatters/mdapi/mdDeployResultFormatter';
import { ProgressFormatter } from '../../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../../formatters/deployProgressBarFormatter';
import { DeployProgressStatusFormatter } from '../../../../formatters/deployProgressStatusFormatter';
import { MdDeployAsyncResultFormatter } from '../../../../formatters/mdapi/mdDeployAsyncResultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'md.deploy');
Expand Down Expand Up @@ -154,9 +152,10 @@ export class Deploy extends DeployCommand {
protected formatResult(): MdDeployResult | DeployCommandAsyncResult {
const formatterOptions = {
verbose: this.getFlag<boolean>('verbose', false),
username: this.org.getUsername(),
};
const formatter = this.isAsync
? new DeployAsyncResultFormatter(this.logger, this.ux, formatterOptions, this.asyncDeployResult)
? new MdDeployAsyncResultFormatter(this.logger, this.ux, formatterOptions, this.asyncDeployResult)
: new MdDeployResultFormatter(this.logger, this.ux, formatterOptions, this.deployResult);

// Only display results to console when JSON flag is unset.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/mdapi/beta/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { flags, FlagsConfig } from '@salesforce/command';
import { Duration, env } from '@salesforce/kit';
import { RequestStatus } from '@salesforce/source-deploy-retrieve';

import { MdDeployResult, MdDeployResultFormatter } from '../../../../../formatters/mdDeployResultFormatter';
import { MdDeployResult, MdDeployResultFormatter } from '../../../../../formatters/mdapi/mdDeployResultFormatter';
import { DeployCommand } from '../../../../../deployCommand';
import { ProgressFormatter } from '../../../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../../../formatters/deployProgressBarFormatter';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/source/beta/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { ChangeResult, replaceRenamedCommands, SourceTracking, throwIfInvalid } from '@salesforce/source-tracking';
import { processConflicts } from '../../../../formatters/conflicts';
import { SourceCommand } from '../../../../sourceCommand';
import { PullResponse, PullResultFormatter } from '../../../../formatters/pullFormatter';
import { PullResponse, PullResultFormatter } from '../../../../formatters/source/pullFormatter';

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/plugin-source', 'pull');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/source/beta/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ComponentStatus, DeployResult, RequestStatus } from '@salesforce/source
import { replaceRenamedCommands, SourceTracking, throwIfInvalid } from '@salesforce/source-tracking';
import { getBoolean } from '@salesforce/ts-types';
import { DeployCommand, getVersionMessage } from '../../../../deployCommand';
import { PushResponse, PushResultFormatter } from '../../../../formatters/pushResultFormatter';
import { PushResponse, PushResultFormatter } from '../../../../formatters/source/pushResultFormatter';
import { ProgressFormatter } from '../../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../../formatters/deployProgressBarFormatter';
import { DeployProgressStatusFormatter } from '../../../../formatters/deployProgressStatusFormatter';
Expand Down
10 changes: 5 additions & 5 deletions src/commands/force/source/beta/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
*/

import * as os from 'os';
import { FlagsConfig, flags, SfdxCommand } from '@salesforce/command';
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import {
SourceTracking,
throwIfInvalid,
replaceRenamedCommands,
ChangeResult,
replaceRenamedCommands,
SourceTracking,
StatusOutputRow,
throwIfInvalid,
} from '@salesforce/source-tracking';
import { StatusResult, StatusFormatter } from '../../../../formatters/statusFormatter';
import { StatusFormatter, StatusResult } from '../../../../formatters/source/statusFormatter';

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/plugin-source', 'status');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/source/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Duration, env } from '@salesforce/kit';
import { DeployCommand, TestLevel } from '../../../deployCommand';
import { ComponentSetBuilder } from '../../../componentSetBuilder';
import { DeployCommandResult, DeployResultFormatter } from '../../../formatters/deployResultFormatter';
import { DeleteResultFormatter } from '../../../formatters/deleteResultFormatter';
import { DeleteResultFormatter } from '../../../formatters/source/deleteResultFormatter';
import { ProgressFormatter } from '../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter';
import { DeployProgressStatusFormatter } from '../../../formatters/deployProgressStatusFormatter';
Expand Down
6 changes: 5 additions & 1 deletion src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { Duration, env } from '@salesforce/kit';
import { DeployCommand, getVersionMessage, TestLevel } from '../../../deployCommand';
import { ComponentSetBuilder } from '../../../componentSetBuilder';
import { DeployCommandResult, DeployResultFormatter } from '../../../formatters/deployResultFormatter';
import { DeployAsyncResultFormatter, DeployCommandAsyncResult } from '../../../formatters/deployAsyncResultFormatter';
import {
DeployAsyncResultFormatter,
DeployCommandAsyncResult,
} from '../../../formatters/source/deployAsyncResultFormatter';
import { ProgressFormatter } from '../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter';
import { DeployProgressStatusFormatter } from '../../../formatters/deployProgressStatusFormatter';
Expand Down Expand Up @@ -179,6 +182,7 @@ export class Deploy extends DeployCommand {
protected formatResult(): DeployCommandResult | DeployCommandAsyncResult {
const formatterOptions = {
verbose: this.getFlag<boolean>('verbose', false),
username: this.org.getUsername(),
};

const formatter = this.isAsync
Expand Down
6 changes: 3 additions & 3 deletions src/commands/force/source/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as fs from 'fs';
import * as open from 'open';
import { getString } from '@salesforce/ts-types';
import { flags, FlagsConfig } from '@salesforce/command';
import { Messages, sfdc, SfdxError, AuthInfo, SfdcUrl } from '@salesforce/core';
import { SourceComponent, MetadataResolver } from '@salesforce/source-deploy-retrieve';
import { OpenResultFormatter, OpenCommandResult } from '../../../formatters/openResultFormatter';
import { AuthInfo, Messages, sfdc, SfdcUrl, SfdxError } from '@salesforce/core';
import { MetadataResolver, SourceComponent } from '@salesforce/source-deploy-retrieve';
import { OpenCommandResult, OpenResultFormatter } from '../../../formatters/source/openResultFormatter';
import { SourceCommand } from '../../../sourceCommand';

Messages.importMessagesDirectory(__dirname);
Expand Down
34 changes: 34 additions & 0 deletions src/formatters/mdapi/mdDeployAsyncResultFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* 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 { EOL } from 'os';
import { UX } from '@salesforce/command';
import { Logger, Messages } from '@salesforce/core';
import { AsyncResult } from '@salesforce/source-deploy-retrieve';
import { ResultFormatterOptions } from '../resultFormatter';
import { DeployAsyncResultFormatter } from '../source/deployAsyncResultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'md.deploy');

export class MdDeployAsyncResultFormatter extends DeployAsyncResultFormatter {
protected result: AsyncResult;

public constructor(logger: Logger, ux: UX, options: ResultFormatterOptions, result: AsyncResult) {
super(logger, ux, options, result);
this.result = result;
}

/**
* Displays async deploy results in human format.
*/
public display(): void {
this.ux.log(messages.getMessage('asyncDeployQueued'), EOL);
this.ux.log(messages.getMessage('asyncDeployCancel', [this.result.id, this.options.username]));
this.ux.log(messages.getMessage('asyncDeployReport', [this.result.id, this.options.username]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MetadataApiDeployStatus,
RequestStatus,
} from '@salesforce/source-deploy-retrieve';
import { ResultFormatter, ResultFormatterOptions, toArray } from './resultFormatter';
import { ResultFormatter, ResultFormatterOptions, toArray } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'md.deploy');
Expand Down
3 changes: 2 additions & 1 deletion src/formatters/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import * as path from 'path';
import { UX } from '@salesforce/command';
import { Logger } from '@salesforce/core';
import { FileResponse, FileProperties, Failures, Successes } from '@salesforce/source-deploy-retrieve';
import { Failures, FileProperties, FileResponse, Successes } from '@salesforce/source-deploy-retrieve';
import { getNumber } from '@salesforce/ts-types';

export interface ResultFormatterOptions {
verbose?: boolean;
quiet?: boolean;
waitTime?: number;
concise?: boolean;
username?: string;
}

export function toArray<T>(entryOrArray: T | T[] | undefined): T[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { DeployMessage, DeployResult, FileResponse } from '@salesforce/source-de
import { UX } from '@salesforce/command';
import { Logger } from '@salesforce/core';
import * as chalk from 'chalk';
import { DeployCommandResult, DeployResultFormatter } from './deployResultFormatter';
import { ResultFormatterOptions, toArray } from './resultFormatter';
import { DeployCommandResult, DeployResultFormatter } from '../deployResultFormatter';
import { ResultFormatterOptions, toArray } from '../resultFormatter';

export class DeleteResultFormatter extends DeployResultFormatter {
public constructor(logger: Logger, ux: UX, options: ResultFormatterOptions, result?: DeployResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UX } from '@salesforce/command';
import { Logger, Messages } from '@salesforce/core';
import { cloneJson } from '@salesforce/kit';
import { AsyncResult } from '@salesforce/source-deploy-retrieve';
import { ResultFormatter, ResultFormatterOptions } from './resultFormatter';
import { ResultFormatter, ResultFormatterOptions } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'deploy');
Expand Down Expand Up @@ -63,7 +63,7 @@ export class DeployAsyncResultFormatter extends ResultFormatter {
*/
public display(): void {
this.ux.log(messages.getMessage('asyncDeployQueued'), EOL);
this.ux.log(messages.getMessage('asyncDeployCancel', [this.result.id]));
this.ux.log(messages.getMessage('asyncDeployReport', [this.result.id]));
this.ux.log(messages.getMessage('asyncDeployCancel', [this.result.id, this.options.username]));
this.ux.log(messages.getMessage('asyncDeployReport', [this.result.id, this.options.username]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { UX } from '@salesforce/command';
import { Logger, Messages, SfdxError } from '@salesforce/core';
import { ResultFormatter } from './resultFormatter';
import { ResultFormatter } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'open');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import { blue, yellow } from 'chalk';
import { UX } from '@salesforce/command';
import { Logger, Messages, SfdxError } from '@salesforce/core';
import { get, getString, getNumber } from '@salesforce/ts-types';
import { get, getNumber, getString } from '@salesforce/ts-types';
import {
RetrieveResult,
ComponentStatus,
FileResponse,
RequestStatus,
RetrieveMessage,
RetrieveResult,
} from '@salesforce/source-deploy-retrieve';
import { ResultFormatter, ResultFormatterOptions, toArray } from './resultFormatter';
import { ResultFormatter, ResultFormatterOptions, toArray } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'pull');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import * as chalk from 'chalk';
import { UX } from '@salesforce/command';
import { Logger, Messages, SfdxError } from '@salesforce/core';
import {
ComponentStatus,
DeployMessage,
DeployResult,
FileResponse,
DeployMessage,
ComponentStatus,
MetadataResolver,
VirtualTreeContainer,
SourceComponent,
VirtualTreeContainer,
} from '@salesforce/source-deploy-retrieve';
import { isString } from '@salesforce/ts-types';
import { ResultFormatter, ResultFormatterOptions, toArray } from './resultFormatter';
import { ResultFormatter, ResultFormatterOptions, toArray } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'push');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { UX } from '@salesforce/command';
import { Logger, Messages } from '@salesforce/core';
import { ResultFormatter, ResultFormatterOptions } from './resultFormatter';
import { ResultFormatter, ResultFormatterOptions } from '../resultFormatter';

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/plugin-source', 'status');
Expand Down
2 changes: 1 addition & 1 deletion test/commands/source/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DeployCommandResult, DeployResultFormatter } from '../../../src/formatt
import {
DeployAsyncResultFormatter,
DeployCommandAsyncResult,
} from '../../../src/formatters/deployAsyncResultFormatter';
} from '../../../src/formatters/source/deployAsyncResultFormatter';
import { ComponentSetBuilder, ComponentSetOptions } from '../../../src/componentSetBuilder';
import { DeployProgressBarFormatter } from '../../../src/formatters/deployProgressBarFormatter';
import { DeployProgressStatusFormatter } from '../../../src/formatters/deployProgressStatusFormatter';
Expand Down
6 changes: 3 additions & 3 deletions test/commands/source/open.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import * as fs from 'fs';
import { join } from 'path';
import * as sinon from 'sinon';
import { expect } from 'chai';
import { SourceComponent, MetadataResolver } from '@salesforce/source-deploy-retrieve';
import { MetadataResolver, SourceComponent } from '@salesforce/source-deploy-retrieve';
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
import { IConfig } from '@oclif/config';
import { AuthInfo, SfdxProject, Org, MyDomainResolver } from '@salesforce/core';
import { AuthInfo, MyDomainResolver, Org, SfdxProject } from '@salesforce/core';
import { Open } from '../../../src/commands/force/source/open';
import { OpenCommandResult } from '../../../src/formatters/openResultFormatter';
import { OpenCommandResult } from '../../../src/formatters/source/openResultFormatter';

describe('force:source:open', () => {
const sandbox = sinon.createSandbox();
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/mdDeployResultFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Logger } from '@salesforce/core';
import { UX } from '@salesforce/command';
import { stubInterface } from '@salesforce/ts-sinon';
import { getDeployResult } from '../commands/source/deployResponses';
import { MdDeployResultFormatter } from '../../src/formatters/mdDeployResultFormatter';
import { MdDeployResultFormatter } from '../../src/formatters/mdapi/mdDeployResultFormatter';

describe('mdDeployResultFormatter', () => {
const sandbox = sinon.createSandbox();
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/pushResultFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UX } from '@salesforce/command';
import * as sinon from 'sinon';
import { stubInterface } from '@salesforce/ts-sinon';
import { getDeployResult } from '../commands/source/deployResponses';
import { PushResultFormatter } from '../../src/formatters/pushResultFormatter';
import { PushResultFormatter } from '../../src/formatters/source/pushResultFormatter';

describe('PushResultFormatter', () => {
const logger = Logger.childFromRoot('deployTestLogger').useMemoryLogging();
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/statusResultFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UX } from '@salesforce/command';
import { stubInterface } from '@salesforce/ts-sinon';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { StatusResult, StatusFormatter } from '../../src/formatters/statusFormatter';
import { StatusFormatter, StatusResult } from '../../src/formatters/source/statusFormatter';

const fakeResult: StatusResult[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions test/nuts/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import * as fs from 'fs';
import * as path from 'path';
import { exec } from 'shelljs';
import { expect } from 'chai';
import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { ComponentSet, SourceComponent } from '@salesforce/source-deploy-retrieve';
import { DescribeMetadataResult } from 'jsforce';
import { create as createArchive } from 'archiver';
import { RetrieveCommandAsyncResult, RetrieveCommandResult } from 'src/formatters/mdapi/retrieveResultFormatter';
import { ConvertCommandResult } from '../../src/formatters/mdapi/convertResultFormatter';
import { DeployCancelCommandResult } from '../../src/formatters/deployCancelResultFormatter';
import { MdDeployResult } from '../../src/formatters/mdDeployResultFormatter';
import { MdDeployResult } from '../../src/formatters/mdapi/mdDeployResultFormatter';

let session: TestSession;

Expand Down
Loading

0 comments on commit f58ff25

Please sign in to comment.