-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat!: use current inquirer BREAKING CHANGE: ESM-only BREAKING CHANGE: removes cross-cloud hooks (deployer, deauthorizer, etc) BREAKING CHANGE: removes Prompter module BREAKING CHANGE: remove option to barrel-import from Ux * refactor: changes from live code review with Mike * chore: bump oclif/core * refactor: handing process error from QA * refactor: rename prompt stub for consistency * docs: prompts * chore: correct chalk types for esm/v5 * chore(release): 5.0.14-dev.0 [skip ci] * refactor: move prompts to ux and export * test: add plugin-settings for xnuts * chore(release): 5.0.14-dev.1 [skip ci] * refactor: restore exported namespace merge * chore(release): 5.0.14-dev.2 [skip ci] * docs: migration doc * docs: pr feedback * chore: set major version --------- Co-authored-by: svc-cli-bot <svc_cli_bot@salesforce.com>
- Loading branch information
1 parent
d0051fb
commit 77e33ab
Showing
45 changed files
with
656 additions
and
1,779 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"require": "test/init.js, ts-node/register, source-map-support/register", | ||
"require": "ts-node/register", | ||
"watch-extensions": ["ts", "md"], | ||
"watch-files": ["src", "test", "messages"], | ||
"recursive": true, | ||
"reporter": "spec", | ||
"timeout": 5000 | ||
"timeout": 5000, | ||
"node-option": ["loader=ts-node/esm"] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Migrating from v5 to v6 | ||
|
||
## ESM | ||
|
||
v6 is ESM-only, which can't be consumed by plugins written in cjs. Salesforce-owned plugins are ESM now and you can use them as a guide for the necessary changes. | ||
|
||
## Prompts | ||
|
||
This library uses [`inquirer`](https://github.com/SBoudrias/Inquirer.js) for interactivity. Inquirer made some large changes, including its own ESM rewrite. To take advantage of its improved performance and smaller dependency, we've upgraded. | ||
|
||
The API is completely different, resulting in changes to sf-plugins-core. The new philopsophy is | ||
|
||
1. provide limited, simplified prompts for common use cases | ||
2. plugins that need more advanced propting should import the parts of inquirer that they need | ||
|
||
### Changes | ||
|
||
The `Prompter` class is removed. | ||
|
||
SfCommand contains two prompt methods | ||
|
||
1. `confirm` provides boolean confirmation prompts | ||
2. `secretPrompt` takes masked string input from the user | ||
|
||
Unlike the inquirer base prompts (`confirm` and `password`, respectively) these have a built-in default timeout. Both take an object parameter that lets you change the timeout (confirm previously took a series of parameters) | ||
|
||
These methods are also built into the `stubPrompter` method for simplified test stubbing. | ||
|
||
If your command relies heavily on the old inquirer/prompt structure, it's possible to import that as a dependency. | ||
|
||
### Reorganized exports | ||
|
||
There are more "standalone" exports available. See package.json#exports for options that don't invole importing the entire library. | ||
|
||
Also removed is the "barrel of Ux". Import what you need. | ||
|
||
## Breaking type changes | ||
|
||
### SfCommand.project | ||
|
||
Project was typed as an `SfProject` but could be undefined when `requiresProject` wasn't set to true on a command. It's now typed as `SfProject | undefined`. If your command sets `requiresProject = true` you can safely assert `this.project!`. | ||
|
||
### SfCommand.catch | ||
|
||
Catch was previously typed to return an error, but it always threw the error. It's now properly typed as `never`. If you extended `catch`, your method should also return `never`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2023, 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 { Mode, Messages, envVars } from '@salesforce/core'; | ||
import type { ChalkInstance } from 'chalk'; | ||
import { StandardColors } from './ux/standardColors.js'; | ||
import { SfCommandError } from './types.js'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages'); | ||
|
||
/** | ||
* Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):', | ||
* When there are actions, we add 'Try this:' in blue | ||
* followed by each action in red on its own line. | ||
* If Error.code is present it is output last in parentheses | ||
* | ||
* @returns {string} Returns decorated messages. | ||
*/ | ||
|
||
/** | ||
* Utility function to format actions lines | ||
* | ||
* @param actions | ||
* @param options | ||
* @private | ||
*/ | ||
export const formatActions = ( | ||
actions: string[], | ||
options: { actionColor: ChalkInstance } = { actionColor: StandardColors.info } | ||
): string[] => | ||
actions.length | ||
? [ | ||
`\n${StandardColors.info(messages.getMessage('actions.tryThis'))}\n`, | ||
...actions.map((a) => `${options.actionColor(a)}`), | ||
] | ||
: []; | ||
|
||
export const formatError = (error: SfCommandError): string => | ||
[ | ||
`${formatErrorPrefix(error)} ${error.message}`, | ||
...formatActions(error.actions ?? []), | ||
error.stack && envVars.getString('SF_ENV') === Mode.DEVELOPMENT | ||
? StandardColors.info(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`) | ||
: [], | ||
].join('\n'); | ||
|
||
const formatErrorPrefix = (error: SfCommandError): string => | ||
`${StandardColors.error(messages.getMessage('error.prefix', [formatErrorCode(error)]))}`; | ||
|
||
const formatErrorCode = (error: SfCommandError): string => | ||
typeof error.code === 'string' || typeof error.code === 'number' ? ` (${error.code})` : ''; |
Oops, something went wrong.