Skip to content

Commit

Permalink
fix: message formatting for GA
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Feb 22, 2022
1 parent fc9b92c commit 194ba4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion messages/compatibility.json
@@ -1,5 +1,5 @@
{
"sourceTrackingFileVersionMismatch": "This project uses the %s version of source tracking files.",
"clearSuggestion": "Clear the %s version of the tracking files by running '%s'",
"useOtherVersion": "Use the %s version of the command, '%s' to preserve the tracking files"
"useOtherVersion": "Use the %s version of the command, '%s' with your existing tracking files"
}
29 changes: 16 additions & 13 deletions src/compatibility.ts
Expand Up @@ -65,13 +65,16 @@ export const throwIfInvalid = ({

// We expected it to be the toolbelt version but it is using the new tracking files
if (toValidate === 'toolbelt') {
// some of the toolbelt commands aren't using SfdxCommand and the SfdxError actions won't be automatically displayed
throw new SfdxError(
messages.getMessage('sourceTrackingFileVersionMismatch', ['new']),
'SourceTrackingFileVersionMismatch',
[
messages.getMessage('useOtherVersion', ['new', replaceRenamedCommands(command)]),
messages.getMessage('clearSuggestion', ['new', replaceRenamedCommands('sfdx force:source:tracking:clear')]),
]
`${messages.getMessage('sourceTrackingFileVersionMismatch', ['new'])}\n\nTry this:\n${messages.getMessage(
'useOtherVersion',
['new', replaceRenamedCommands(command, true)]
)}.\n${messages.getMessage('clearSuggestion', [
'new',
replaceRenamedCommands('sfdx force:source:tracking:clear', true),
])}.`,
'SourceTrackingFileVersionMismatch'
);
}
// We expected it to be the plugin-source version but it is using the old tracking files
Expand All @@ -80,8 +83,8 @@ export const throwIfInvalid = ({
messages.getMessage('sourceTrackingFileVersionMismatch', ['old']),
'SourceTrackingFileVersionMismatch',
[
messages.getMessage('useOtherVersion', ['old', replaceRenamedCommands(command, true)]),
messages.getMessage('clearSuggestion', ['old', 'sfdx force:source:tracking:clear']),
messages.getMessage('useOtherVersion', ['old', replaceRenamedCommands(command)]),
messages.getMessage('clearSuggestion', ['old', replaceRenamedCommands('sfdx force:source:tracking:clear')]),
]
);
}
Expand All @@ -101,9 +104,9 @@ export const replaceRenamedCommands = (input: string, reverse = false): string =
};

const renames = new Map([
['force:source:status', 'force:source:beta:status'],
['force:source:push', 'force:source:beta:push'],
['force:source:pull', 'force:source:beta:pull'],
['force:source:tracking:reset', 'force:source:beta:tracking:reset'],
['force:source:tracking:clear', 'force:source:beta:tracking:clear'],
['force:source:status', 'force:source:legacy:status'],
['force:source:push', 'force:source:legacy:push'],
['force:source:pull', 'force:source:legacy:pull'],
['force:source:tracking:reset', 'force:source:legacy:tracking:reset'],
['force:source:tracking:clear', 'force:source:legacy:tracking:clear'],
]);

0 comments on commit 194ba4b

Please sign in to comment.