Skip to content

Commit

Permalink
Merge pull request #615 from oclif/mdonnalley/core-v4
Browse files Browse the repository at this point in the history
feat: use @oclif/core v4
  • Loading branch information
iowillhoit authored May 31, 2024
2 parents 169db12 + 9017488 commit 66dbd71
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-which/issues",
"dependencies": {
"@oclif/core": "^3.26.6"
"@oclif/core": "^4.0.0-beta.13",
"ansis": "^3.2.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^19",
Expand Down
24 changes: 20 additions & 4 deletions src/commands/which.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Command, Errors, toConfiguredId, ux} from '@oclif/core'
import {Command, toConfiguredId} from '@oclif/core'
import {bold, cyan} from 'ansis'

type WhichResult = {
aliasOf?: string
Expand All @@ -14,6 +15,18 @@ export default class Which extends Command {
command: '<%= config.bin %> <%= command.id %> help',
description: 'See which plugin the `help` command is in:',
},
{
command: '<%= config.bin %> <%= command.id %> foo:bar:baz',
description: 'Use colon separators.',
},
{
command: '<%= config.bin %> <%= command.id %> foo bar baz',
description: 'Use spaces as separators.',
},
{
command: '<%= config.bin %> <%= command.id %> "foo bar baz"',
description: 'Wrap command in quotes to use spaces as separators.',
},
]

static strict = false
Expand All @@ -22,7 +35,7 @@ export default class Which extends Command {
const {argv} = await this.parse(Which)

if (argv.length === 0) {
throw new Errors.CLIError('"which" expects a command name', {
this.error('"which" expects a command name', {
suggestions: [`Provide a command id like this, "${this.config.bin} which your:command:here"`],
})
}
Expand All @@ -46,8 +59,11 @@ export default class Which extends Command {
}

if (!this.jsonEnabled()) {
ux.styledHeader(commandParts.join(this.config.topicSeparator))
ux.styledObject(result)
this.log(bold(commandParts.join(this.config.topicSeparator)) + '\n')
this.log(`${cyan('plugin')}: ${result.plugin}`)
if (result.aliasOf) {
this.log(`${cyan('aliasOf')}: ${result.aliasOf}`)
}
}

return result
Expand Down
30 changes: 29 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,29 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^4.0.0-beta.13":
version "4.0.0-beta.13"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-4.0.0-beta.13.tgz#0e0a6431cfe612db77073d2f9ef361f14e4090b8"
integrity sha512-ug8CZUCJphgetSZVgd4HQgyewlYVGGG1LIeFXGxjgYsjZ/f5I3nSCj7xpAMEDqjVD/lwmSujtVwa7tvEgLGICw==
dependencies:
ansi-escapes "^4.3.2"
ansis "^3.0.1"
clean-stack "^3.0.1"
cli-spinners "^2.9.2"
cosmiconfig "^9.0.0"
debug "^4.3.4"
ejs "^3.1.10"
get-package-type "^0.1.0"
globby "^11.1.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
minimatch "^9.0.4"
string-width "^4.2.3"
supports-color "^9.4.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/plugin-help@^6", "@oclif/plugin-help@^6.0.21":
version "6.0.22"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-6.0.22.tgz#dca96ad1c28a68170e0bbf9f8f93f7dd171e4667"
Expand Down Expand Up @@ -2506,7 +2529,7 @@ ansicolors@~0.3.2:
resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979"
integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=

ansis@^3.2.0:
ansis@^3.0.1, ansis@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansis/-/ansis-3.2.0.tgz#0e050c5be94784f32ffdac4b84fccba064aeae4b"
integrity sha512-Yk3BkHH9U7oPyCN3gL5Tc7CpahG/+UFv/6UG03C311Vy9lzRmA5uoxDTpU9CO3rGHL6KzJz/pdDeXZCZ5Mu/Sg==
Expand Down Expand Up @@ -6058,6 +6081,11 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

supports-color@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-9.4.0.tgz#17bfcf686288f531db3dea3215510621ccb55954"
integrity sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==

supports-hyperlinks@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb"
Expand Down

0 comments on commit 66dbd71

Please sign in to comment.