Skip to content

Commit

Permalink
feat: migrate messages/descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Sep 13, 2021
1 parent 3e4f119 commit 8fea6e5
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 16 deletions.
9 changes: 9 additions & 0 deletions messages/source_pull.json
@@ -0,0 +1,9 @@
{
"commandDescription": "pull source from the scratch org to the project",
"commandDescriptionLong": "Pulls changed source from the scratch org to your project to keep them in sync.",
"commandHelp": "If the command detects a conflict, it displays the conflicts but does not complete the process. After reviewing the conflict, rerun the command with the --forceoverwrite parameter.",
"forceoverwriteFlagDescription": "ignore conflict warnings and overwrite changes to the project",
"forceoverwriteFlagDescriptionLong": "Runs the pull command even if conflicts exist. Changes in the scratch org overwrite changes in the project.",
"waitFlagDescriptionLong": "The number of minutes to wait for the command to complete and display results to the terminal window. If the command continues to run after the wait period, the CLI returns control of the terminal window to you. The default is 33 minutes.",
"NonScratchOrgPull": "We can\"t retrieve your changes. \"force:source:pull\" is only available for orgs that have source tracking enabled. Use \"force:source:retrieve\" or \"force:mdapi:retrieve\" instead."
}
14 changes: 14 additions & 0 deletions messages/source_push.json
@@ -0,0 +1,14 @@
{
"pushCommandConflictMsg": "We couldn't complete the push operation due to conflicts. Verify that you want to keep the local versions, then run \"sfdx force:source:push -f\" with the --forceoverwrite (-f) option.",
"commandDescription": "push source to a scratch org from the project",
"commandDescriptionLong": "Pushes changed source from your project to a scratch org to keep them in sync.",
"commandHelp": "If the command detects a conflict, it displays the conflicts but does not complete the process. After reviewing the conflict, rerun the command with the --forceoverwrite parameter.",
"waitFlagDescriptionLong": "Number of minutes to wait for the command to complete and display results to the terminal window. If the command continues to run after the wait period, the CLI returns control of the terminal window to you. The default is 33 minutes.",
"forceoverwriteFlagDescription": "ignore conflict warnings and overwrite changes to scratch org",
"forceoverwriteFlagDescriptionLong": "Runs the push command even if conflicts exist. Changes in the project overwrite changes in the scratch org.",
"replacetokensFlagDescription": "replace tokens in source files prior to deployment",
"replacetokensFlagDescriptionLong": "Replaces tokens in source files prior to deployment.",
"ignorewarningsFlagDescription": "deploy changes even if warnings are generated",
"ignorewarningsFlagDescriptionLong": "Completes the deployment even if warnings are generated.",
"sourcepushFailed": "Push failed."
}
17 changes: 17 additions & 0 deletions messages/status.json
@@ -0,0 +1,17 @@
{
"statusCommandCliDescription": "list local changes and/or changes in a scratch org",
"statusCommandCliLongDescription": "Lists changes that have been made locally, in a scratch org, or both.",
"examples": [
"sfdx force:source:status -l",
"sfdx force:source:status -r",
"sfdx force:source:status -a",
"sfdx force:source:status -a -u me@example.com --json"
],
"statusCommandAllOptionDescription": "list all the changes that have been made",
"statusCommandAllOptionDescriptionLong": "Lists all the changes that have been made.",
"statusCommandLocalOptionDescription": "list the changes that have been made locally",
"statusCommandLocalOptionDescriptionLong": "Lists the changes that have been made locally.",
"statusCommandRemoteOptionDescription": "list the changes that have been made in the scratch org",
"statusCommandRemoteOptionDescriptionLong": "Lists the changes that have been made in the scratch org.",
"statusCommandHumanSuccess": "Source Status"
}
17 changes: 13 additions & 4 deletions src/commands/force/source/pull.ts
Expand Up @@ -7,19 +7,28 @@

import { FlagsConfig, flags, SfdxCommand } from '@salesforce/command';
import { Duration } from '@salesforce/kit';
import { SfdxProject, Org } from '@salesforce/core';
import { SfdxProject, Org, Messages } from '@salesforce/core';
import { writeConflictTable } from '../../../writeConflictTable';
import { SourceTracking } from '../../../sourceTracking';

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/source-tracking', 'source_pull');

export default class SourcePull extends SfdxCommand {
public static description = 'get local changes';
public static description = messages.getMessage('commandDescription');
protected static readonly flagsConfig: FlagsConfig = {
forceoverwrite: flags.boolean({ char: 'f', description: 'overwrite files without prompting' }),
forceoverwrite: flags.boolean({
char: 'f',
description: messages.getMessage('forceoverwriteFlagDescription'),
longDescription: messages.getMessage('forceoverwriteFlagDescriptionLong'),
}),
// TODO: use shared flags from plugin-source
wait: flags.minutes({
char: 'w',
default: Duration.minutes(33),
min: Duration.minutes(0), // wait=0 means deploy is asynchronous
description: 'tbd',
description: messages.getMessage('waitFlagDescriptionLong'),
longDescription: messages.getMessage('waitFlagDescriptionLong'),
}),
};
protected static requiresUsername = true;
Expand Down
25 changes: 18 additions & 7 deletions src/commands/force/source/push.ts
Expand Up @@ -7,24 +7,35 @@

import { FlagsConfig, flags, SfdxCommand } from '@salesforce/command';
import { Duration } from '@salesforce/kit';
import { SfdxProject, Org } from '@salesforce/core';
import { SfdxProject, Org, Messages } from '@salesforce/core';
import { PushPullResponse } from '../../../shared/types';
import { SourceTracking } from '../../../sourceTracking';
import { writeConflictTable } from '../../../writeConflictTable';

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/source-tracking', 'source_push');

export default class SourcePush extends SfdxCommand {
public static description = 'get local changes';
public static description = messages.getMessage('commandDescription');
public static help = messages.getMessage('commandHelp');
protected static readonly flagsConfig: FlagsConfig = {
forceoverwrite: flags.boolean({ char: 'f', description: 'overwrite files without prompting' }),
// TODO: use shared flags from plugin-source
forceoverwrite: flags.boolean({
char: 'f',
description: messages.getMessage('forceoverwriteFlagDescription'),
longDescription: messages.getMessage('forceoverwriteFlagDescriptionLong'),
}),
// TODO: use shared flags from plugin-source?
wait: flags.minutes({
char: 'w',
default: Duration.minutes(33),
min: Duration.minutes(0), // wait=0 means deploy is asynchronous
description: 'tbd',
description: messages.getMessage('waitFlagDescriptionLong'),
longDescription: messages.getMessage('waitFlagDescriptionLongLong'),
}),
ignorewarnings: flags.boolean({
char: 'g',
description: 'tbd',
description: messages.getMessage('ignorewarningsFlagDescription'),
longDescription: messages.getMessage('ignorewarningsFlagDescriptionLong'),
}),
};

Expand All @@ -45,7 +56,7 @@ export default class SourcePush extends SfdxCommand {
const conflicts = await tracking.getConflicts();
if (conflicts.length > 0) {
writeConflictTable(conflicts, this.ux);
throw new Error('conflicts detected');
throw new Error(messages.getMessage('pushCommandConflictMsg'));
}
}
const deployResult = await tracking.deployLocalChanges({
Expand Down
28 changes: 23 additions & 5 deletions src/commands/force/source/status.ts
Expand Up @@ -5,8 +5,9 @@
* 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 { FlagsConfig, flags, SfdxCommand } from '@salesforce/command';
import { SfdxProject, Org } from '@salesforce/core';
import { SfdxProject, Org, Messages } from '@salesforce/core';
import { getKeyFromStrings } from '../../..';

import { ChangeResult, SourceTracking, getKeyFromObject } from '../../../sourceTracking';
Expand All @@ -17,12 +18,28 @@ export interface StatusResult {
filePath?: string;
}

Messages.importMessagesDirectory(__dirname);
const messages: Messages = Messages.loadMessages('@salesforce/source-tracking', 'source_push');

export default class SourceStatus extends SfdxCommand {
public static description = 'get local changes';
public static description = messages.getMessage('statusCommandCliDescription');
public static readonly examples = messages.getMessage('examples').split(EOL);
protected static flagsConfig: FlagsConfig = {
all: flags.boolean({ char: 'a', description: 'tbd' }),
local: flags.boolean({ char: 'l', description: 'tbd' }),
remote: flags.boolean({ char: 'r', description: 'tbd' }),
all: flags.boolean({
char: 'a',
description: messages.getMessage('statusCommandAllOptionDescription'),
longDescription: messages.getMessage('statusCommandAllOptionDescriptionLong'),
}),
local: flags.boolean({
char: 'l',
description: messages.getMessage('statusCommandLocalOptionDescription'),
longDescription: messages.getMessage('statusCommandLocalOptionDescriptionLong'),
}),
remote: flags.boolean({
char: 'r',
description: messages.getMessage('statusCommandRemoteOptionDescription'),
longDescription: messages.getMessage('statusCommandRemoteOptionDescriptionLong'),
}),
};
protected static requiresUsername = true;
protected static requiresProject = true;
Expand Down Expand Up @@ -102,6 +119,7 @@ export default class SourceStatus extends SfdxCommand {
}
return a.state.toLowerCase() < b.state.toLowerCase() ? -1 : 1;
});
this.ux.log(messages.getMessage('statusCommandHumanSuccess'));
this.ux.table(outputRows, {
columns: [
{ label: 'STATE', key: 'state' },
Expand Down

0 comments on commit 8fea6e5

Please sign in to comment.