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

Prerelease/v4 #394

Merged
merged 20 commits into from
Oct 4, 2023
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: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/sf-plugins-core",
"version": "3.1.28",
"version": "4.0.0-beta.5",
"description": "Utils for writing Salesforce CLI plugins",
"main": "lib/exported",
"types": "lib/exported.d.ts",
Expand Down Expand Up @@ -35,7 +35,7 @@
"node": ">=16.0.0"
},
"dependencies": {
"@oclif/core": "^2.15.0",
"@oclif/core": "^3.0.0",
"@salesforce/core": "^5.3.1",
"@salesforce/kit": "^3.0.13",
"@salesforce/ts-types": "^2.0.7",
Expand Down
24 changes: 8 additions & 16 deletions src/flags/orgFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ export const getHubOrThrow = async (aliasOrUsername?: string): Promise<Org> => {
*/
export const optionalOrgFlag = Flags.custom({
char: 'o',
noCacheDefault: true,
parse: async (input: string | undefined) => maybeGetOrg(input),
default: async () => maybeGetOrg(),
defaultHelp: async (context, isWritingManifest) => {
if (isWritingManifest) {
return undefined;
}
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
return org.getUsername();
Expand Down Expand Up @@ -139,12 +137,10 @@ export const optionalOrgFlag = Flags.custom({
export const requiredOrgFlag = Flags.custom({
char: 'o',
summary: messages.getMessage('flags.targetOrg.summary'),
noCacheDefault: true,
parse: async (input: string | undefined) => getOrgOrThrow(input),
default: async () => getOrgOrThrow(),
defaultHelp: async (context, isWritingManifest) => {
if (isWritingManifest) {
return undefined;
}
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
return org.getUsername();
Expand Down Expand Up @@ -179,12 +175,10 @@ export const requiredOrgFlag = Flags.custom({
export const requiredHubFlag = Flags.custom({
char: 'v',
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
noCacheDefault: true,
parse: async (input: string | undefined) => getHubOrThrow(input),
default: async () => getHubOrThrow(),
defaultHelp: async (context, isWritingManifest) => {
if (isWritingManifest) {
return undefined;
}
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
return org.getUsername();
Expand Down Expand Up @@ -218,12 +212,10 @@ export const requiredHubFlag = Flags.custom({
export const optionalHubFlag = Flags.custom({
char: 'v',
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
noCacheDefault: true,
parse: async (input: string | undefined) => maybeGetHub(input),
default: async () => maybeGetHub(),
defaultHelp: async (context, isWritingManifest) => {
if (isWritingManifest) {
return undefined;
}
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
return org.getUsername();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ux/spinner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Spinner', () => {
const spinner = new Spinner(true);
spinner.start('Doing things');
spinner.stop('Finished');
expect(writeStub.firstCall.args).to.deep.equal(['stderr', 'Doing things...\n']);
expect(writeStub.firstCall.args).to.deep.equal(['stderr', 'Doing things...']);
Copy link
Contributor Author

@mdonnalley mdonnalley Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run these tests individually withyarn mocha test/unit/ux/spinner.test.ts they expect the \n but if you run it from yarn test (which uses wireit) it doesn't think the \n should be there.

There's a check in oclif/core for process.stderr.isTTY. If it's undefined or false, it uses the simple spinner (src/cli-ux/action/simple.ts), otherwise it uses the default spinner (src/cli-ux/action/spinner.ts)

The defaults spinner passes in the message with the \n, whereas the simple spinner doesn't.

oclif/core v2 wrongly imported the simple spinner: https://github.com/oclif/core/blob/2.15.0/src/cli-ux/config.ts#L3-L4

import spinner from './action/spinner'
import simple from './action/spinner'

v3 updates the simple spinner to the correct import, which is why this test now needs to be updated.

});

it('should not log anything if output is not enabled', () => {
Expand All @@ -45,7 +45,7 @@ describe('Spinner', () => {
spinner.start('Doing things');
spinner.pause(() => {});
spinner.stop('Finished');
expect(writeStub.firstCall.args).to.deep.equal(['stderr', 'Doing things...\n']);
expect(writeStub.firstCall.args).to.deep.equal(['stderr', 'Doing things...']);
});

it('should not log anything if output is not enabled', () => {
Expand Down
31 changes: 31 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,37 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.0.tgz#9326d1cbd036ce20a1cda5e1854c1ec4d50dd717"
integrity sha512-zFHDOizZxRmmuPe6Jba3lLPXpjBxDNWIWSiV87E5DdSbzBPiUsWgXUNfDQENP2EL1vdRIPOeTPmFyob7K1tbBg==
dependencies:
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
cardinal "^2.1.1"
chalk "^4.1.2"
clean-stack "^3.0.1"
cli-progress "^3.12.0"
debug "^4.3.4"
ejs "^3.1.8"
get-package-type "^0.1.0"
globby "^11.1.0"
hyperlinker "^1.0.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
js-yaml "^3.14.1"
natural-orderby "^2.0.3"
object-treeify "^1.1.33"
password-prompt "^1.1.2"
slice-ansi "^4.0.0"
string-width "^4.2.3"
strip-ansi "^6.0.1"
supports-color "^8.1.1"
supports-hyperlinks "^2.2.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/test@^2.5.6":
version "2.5.6"
resolved "https://registry.yarnpkg.com/@oclif/test/-/test-2.5.6.tgz#454ae74260123f1436babbda8f93223079f3b66c"
Expand Down
Loading