Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sh/api version updates #673

Merged
merged 4 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion messages/deployCommand.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"resultsDirMissing": "You must supply the --resultsdir parameter when choosing to produce code coverage or JUnit reports.",
"MissingDeployId": "No deploy ID was provided or found in deploy history.",
"invalidDeployId": "The provided ID is invalid, deploy IDs must start with '0Af'."
"invalidDeployId": "The provided ID is invalid, deploy IDs must start with '0Af'.",
"apiVersionMsgBasic": "Deploying metadata to %s using the v%s %s API",
"apiVersionMsgDetailed": "%s v%s metadata to %s using the v%s %s API"
}
3 changes: 2 additions & 1 deletion messages/retrieve.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"nothingToRetrieve": "Specify a source path, manifest, metadata, or package names to retrieve.",
"wantsToRetrieveCustomFields": "Because you're retrieving one or more CustomFields, we're also retrieving the CustomObject to which it's associated.",
"retrieveWontDelete": "You currently have files deleted in your org. The retrieve command will NOT delete them from your local project",
"retrieveTargetDirOverlapsPackage": "The retrieve target directory [%s] overlaps one of your package directories. Specify a different retrieve target directory and try again."
"retrieveTargetDirOverlapsPackage": "The retrieve target directory [%s] overlaps one of your package directories. Specify a different retrieve target directory and try again.",
"apiVersionMsgDetailed": "%s v%s metadata from %s using the v%s SOAP API"
}
2 changes: 1 addition & 1 deletion messages/spinner.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"retrieve": {
"main": "Retrieving metadata from %s",
"componentSetBuild": "Preparing retrieve request",
"sendingRequest": "Sending request to org (metadata API version %s)",
"sendingRequest": "Sending request to org",
"polling": "Waiting for the org to respond"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"@oclif/plugin-help": "^3.3.1",
"@salesforce/apex-node": "^1.4.0",
"@salesforce/command": "^5.2.27",
"@salesforce/core": "^3.32.5",
"@salesforce/core": "^3.32.8",
"@salesforce/kit": "^1.8.0",
"@salesforce/source-deploy-retrieve": "^7.5.13",
"@salesforce/source-tracking": "^2.2.14",
"@salesforce/source-deploy-retrieve": "^7.5.17",
"@salesforce/source-tracking": "^2.2.15",
"chalk": "^4.1.2",
"got": "^11.8.3",
"jsforce": "^2.0.0-beta.19",
Expand Down Expand Up @@ -188,4 +188,4 @@
"publishConfig": {
"access": "public"
}
}
}
21 changes: 9 additions & 12 deletions src/commands/force/mdapi/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ import { EOL } from 'os';
import { flags, FlagsConfig } from '@salesforce/command';
import { Duration, env } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import {
DeployCommand,
getCoverageFormattersOptions,
getVersionMessage,
reportsFormatters,
TestLevel,
} from '../../../deployCommand';
import { DeployVersionData, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import { DeployCommand, getCoverageFormattersOptions, reportsFormatters, TestLevel } from '../../../deployCommand';
import { DeployCommandAsyncResult } from '../../../formatters/source/deployAsyncResultFormatter';
import { MdDeployResult, MdDeployResultFormatter } from '../../../formatters/mdapi/mdDeployResultFormatter';
import { ProgressFormatter } from '../../../formatters/progressFormatter';
Expand All @@ -26,6 +20,7 @@ import { ResultFormatterOptions } from '../../../formatters/resultFormatter';

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

const xorFlags = ['zipfile', 'validateddeployrequestid', 'deploydir'];

Expand Down Expand Up @@ -140,10 +135,11 @@ export class Deploy extends DeployCommand {
const deploymentOptions = this.flags.zipfile
? { zipPath: this.flags.zipfile as string }
: { mdapiPath: this.flags.deploydir as string };
const username = this.org.getUsername();

// still here? we need to deploy a zip file then
const deploy = new MetadataApiDeploy({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
...deploymentOptions,
apiOptions: {
// properties that will always have values
Expand All @@ -162,13 +158,14 @@ export class Deploy extends DeployCommand {
...(this.getFlag<string[]>('runtests') ? { runTests: this.getFlag<string[]>('runtests') } : {}),
},
});
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionDeploy', async (apiData: DeployVersionData) => {
this.ux.log(deployMessages.getMessage('apiVersionMsgBasic', [username, apiData.apiVersion, apiData.webService]));
});
await deploy.start();
this.asyncDeployResult = { id: deploy.id };
this.updateDeployId(deploy.id);

// we might not know the source api version without unzipping a zip file, so we don't use componentSet
this.ux.log(getVersionMessage('Deploying', undefined, this.isRest));

if (!this.isAsync) {
if (!this.isJsonOutput()) {
const progressFormatter: ProgressFormatter = env.getBoolean('SFDX_USE_PROGRESS_BAR', true)
Expand Down
19 changes: 16 additions & 3 deletions src/commands/force/mdapi/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MetadataApiRetrieve,
RequestStatus,
RetrieveResult,
RetrieveVersionData,
} from '@salesforce/source-deploy-retrieve';
import { Optional } from '@salesforce/ts-types';
import { resolveZipFileName, SourceCommand } from '../../../sourceCommand';
Expand All @@ -27,6 +28,7 @@ import {
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'md.retrieve');
const spinnerMessages = Messages.loadMessages('@salesforce/plugin-source', 'spinner');
const retrieveMessages = Messages.load('@salesforce/plugin-source', 'retrieve', ['apiVersionMsgDetailed']);

export class Retrieve extends SourceCommand {
public static aliases = ['force:mdapi:beta:retrieve'];
Expand Down Expand Up @@ -142,11 +144,22 @@ export class Retrieve extends SourceCommand {
});

await this.lifecycle.emit('preretrieve', { packageXmlPath: manifest });

this.ux.setSpinnerStatus(spinnerMessages.getMessage('retrieve.sendingRequest', [this.componentSet.apiVersion]));
const username = this.org.getUsername();
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionRetrieve', async (apiData: RetrieveVersionData) => {
this.ux.log(
retrieveMessages.getMessage('apiVersionMsgDetailed', [
'Retrieving',
apiData.manifestVersion,
username,
apiData.apiVersion,
])
);
});
this.ux.setSpinnerStatus(spinnerMessages.getMessage('retrieve.sendingRequest'));

this.mdapiRetrieve = await this.componentSet.retrieve({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
output: this.retrieveTargetDir,
packageOptions: this.getFlag<string[]>('packagenames'),
format: 'metadata',
Expand Down
27 changes: 17 additions & 10 deletions src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ import { flags, FlagsConfig } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { Duration, env } from '@salesforce/kit';
import { SourceTracking } from '@salesforce/source-tracking';
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
import {
DeployCommand,
getCoverageFormattersOptions,
getVersionMessage,
reportsFormatters,
TestLevel,
} from '../../../deployCommand';
import { ComponentSetBuilder, DeployVersionData } from '@salesforce/source-deploy-retrieve';
import { DeployCommand, getCoverageFormattersOptions, reportsFormatters, TestLevel } from '../../../deployCommand';
import { DeployCommandResult, DeployResultFormatter } from '../../../formatters/deployResultFormatter';
import {
DeployAsyncResultFormatter,
Expand All @@ -30,6 +24,7 @@ import { ResultFormatterOptions } from '../../../formatters/resultFormatter';

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

// One of these flags must be specified for a valid deploy.
const xorFlags = ['manifest', 'metadata', 'sourcepath', 'validateddeployrequestid'];
Expand Down Expand Up @@ -209,10 +204,22 @@ export class Deploy extends DeployCommand {
}
// fire predeploy event for sync and async deploys
await this.lifecycle.emit('predeploy', this.componentSet.toArray());
this.ux.log(getVersionMessage('Deploying', this.componentSet, this.isRest));
const username = this.org.getUsername();
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionDeploy', async (apiData: DeployVersionData) => {
this.ux.log(
deployMessages.getMessage('apiVersionMsgDetailed', [
'Deploying',
apiData.manifestVersion,
username,
apiData.apiVersion,
apiData.webService,
])
);
});

const deploy = await this.componentSet.deploy({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
apiOptions: {
...{
purgeOnDelete: this.getFlag<boolean>('purgeondelete', false),
Expand Down
23 changes: 21 additions & 2 deletions src/commands/force/source/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import { flags, FlagsConfig } from '@salesforce/command';
import { Duration } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
import { FileResponse, RequestStatus, RetrieveResult, SourceComponent } from '@salesforce/source-deploy-retrieve';
import {
FileResponse,
RequestStatus,
RetrieveVersionData,
RetrieveResult,
SourceComponent,
} from '@salesforce/source-deploy-retrieve';
import { SourceTracking } from '@salesforce/source-tracking';
import { SourceCommand } from '../../../sourceCommand';
import { PullResponse, PullResultFormatter } from '../../../formatters/source/pullFormatter';
Expand All @@ -21,6 +27,7 @@ const messages = Messages.load('@salesforce/plugin-source', 'pull', [
'help',
'flags.waitLong',
]);
const retrieveMessages = Messages.load('@salesforce/plugin-source', 'retrieve', ['apiVersionMsgDetailed']);

export default class Pull extends SourceCommand {
public static aliases = ['force:source:beta:pull'];
Expand Down Expand Up @@ -94,9 +101,21 @@ export default class Pull extends SourceCommand {
if (this.getFlag<string>('apiversion')) {
componentSet.apiVersion = this.getFlag<string>('apiversion');
}
const username = this.org.getUsername();
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionRetrieve', async (apiData: RetrieveVersionData) => {
this.ux.log(
retrieveMessages.getMessage('apiVersionMsgDetailed', [
'Pulling',
apiData.manifestVersion,
username,
apiData.apiVersion,
])
);
});

const mdapiRetrieve = await componentSet.retrieve({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
merge: true,
output: this.project.getDefaultPackage().fullPath,
});
Expand Down
34 changes: 23 additions & 11 deletions src/commands/force/source/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { flags, FlagsConfig } from '@salesforce/command';
import { Duration, env } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
import { DeployResult, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { DeployResult, DeployVersionData, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { SourceTracking } from '@salesforce/source-tracking';
import { getBoolean } from '@salesforce/ts-types';
import { DeployCommand, getVersionMessage } from '../../../deployCommand';
import { DeployCommand } from '../../../deployCommand';
import { PushResponse, PushResultFormatter } from '../../../formatters/source/pushResultFormatter';
import { ProgressFormatter } from '../../../formatters/progressFormatter';
import { DeployProgressBarFormatter } from '../../../formatters/deployProgressBarFormatter';
Expand All @@ -20,6 +20,7 @@ import { trackingSetup, updateTracking } from '../../../trackingFunctions';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'push');
const deployMessages = Messages.loadMessages('@salesforce/plugin-source', 'deployCommand');

export default class Push extends DeployCommand {
public static aliases = ['force:source:beta:push'];
Expand Down Expand Up @@ -105,10 +106,22 @@ export default class Push extends DeployCommand {
// fire predeploy event for sync and async deploys
await this.lifecycle.emit('predeploy', componentSet.toArray());

this.ux.log(getVersionMessage('Pushing', componentSet, isRest));
const username = this.org.getUsername();
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionDeploy', async (apiData: DeployVersionData) => {
this.ux.log(
deployMessages.getMessage('apiVersionMsgDetailed', [
'Pushing',
apiData.manifestVersion,
username,
apiData.apiVersion,
apiData.webService,
])
);
});

const deploy = await componentSet.deploy({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
apiOptions: {
ignoreWarnings: this.getFlag<boolean>('ignorewarnings', false),
rest: isRest,
Expand Down Expand Up @@ -175,13 +188,12 @@ export default class Push extends DeployCommand {
return this.setExitCode(69);
}

const isSuccessLike = (result: DeployResult): boolean => (
result.response.status === RequestStatus.Succeeded ||
// successful-ish (only warnings about deleted things that are already deleted)
(result.response.status === RequestStatus.Failed &&
result.getFileResponses().every((fr) => fr.state !== 'Failed') &&
!result.response.errorMessage)
);
const isSuccessLike = (result: DeployResult): boolean =>
result.response.status === RequestStatus.Succeeded ||
// successful-ish (only warnings about deleted things that are already deleted)
(result.response.status === RequestStatus.Failed &&
result.getFileResponses().every((fr) => fr.state !== 'Failed') &&
!result.response.errorMessage);
// all successes
if (this.deployResults.every((result) => isSuccessLike(result))) {
return this.setExitCode(0);
Expand Down
29 changes: 22 additions & 7 deletions src/commands/force/source/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import * as fs from 'fs';
import { flags, FlagsConfig } from '@salesforce/command';
import { Messages, SfError, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { ComponentSet, ComponentSetBuilder, RequestStatus, RetrieveResult } from '@salesforce/source-deploy-retrieve';
import {
ComponentSet,
ComponentSetBuilder,
RequestStatus,
RetrieveVersionData,
RetrieveResult,
} from '@salesforce/source-deploy-retrieve';
import { SourceTracking } from '@salesforce/source-tracking';
import { SourceCommand } from '../../../sourceCommand';
import {
Expand All @@ -25,6 +31,7 @@ import { promisesQueue } from '../../../promiseQueue';
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-source', 'retrieve');
const spinnerMessages = Messages.loadMessages('@salesforce/plugin-source', 'spinner');
const retrieveMessages = Messages.load('@salesforce/plugin-source', 'retrieve', ['apiVersionMsgDetailed']);

export class Retrieve extends SourceCommand {
public static readonly description = messages.getMessage('description');
Expand Down Expand Up @@ -123,6 +130,18 @@ export class Retrieve extends SourceCommand {
}

protected async retrieve(): Promise<void> {
const username = this.org.getUsername();
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.on('apiVersionRetrieve', async (apiData: RetrieveVersionData) => {
this.ux.log(
retrieveMessages.getMessage('apiVersionMsgDetailed', [
'Retrieving',
apiData.manifestVersion,
username,
apiData.apiVersion,
])
);
});
this.ux.startSpinner(spinnerMessages.getMessage('retrieve.componentSetBuild'));
this.componentSet = await ComponentSetBuilder.build({
apiversion: this.getFlag<string>('apiversion'),
Expand Down Expand Up @@ -163,13 +182,9 @@ export class Retrieve extends SourceCommand {

await this.lifecycle.emit('preretrieve', this.componentSet.toArray());

this.ux.setSpinnerStatus(
spinnerMessages.getMessage('retrieve.sendingRequest', [
this.componentSet.sourceApiVersion || this.componentSet.apiVersion,
])
);
this.ux.setSpinnerStatus(spinnerMessages.getMessage('retrieve.sendingRequest'));
const mdapiRetrieve = await this.componentSet.retrieve({
usernameOrConnection: this.org.getUsername(),
usernameOrConnection: username,
merge: true,
output: this.resolvedTargetDir || this.project.getDefaultPackage().fullPath,
packageOptions: this.getFlag<string[]>('packagenames'),
Expand Down
Loading