-
Notifications
You must be signed in to change notification settings - Fork 73
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
@oclif/core v4 #1059
Merged
Merged
@oclif/core v4 #1059
Conversation
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
* chore: bump major version * feat: slimmer ux module * test: no fancy-tests * chore(release): 4.0.0-v4.0 [skip ci] * chore: code review * chore(release): 4.0.0-v4.1 [skip ci] * chore(release): 4.0.0-beta.1 [skip ci] * chore: remove duplicate dep * test: windows unit tests * test: windows unit tests --------- Co-authored-by: svc-cli-bot <[email protected]>
feat: customizable logger
* feat: support rc files * chore: code review
* feat: improved PJSON type * feat: enable exactOptionalPropertyTypes * feat: theme can be object or file path * feat: support target and identifier for helpClass * chore: add jsdocs to Configuration type * fix: add back scope to pjson type * feat: top level exports * fix: simplify ux export * chore: cleanup * feat: export logger too
feat: remove support for `baseFlags`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Slimmer
ux
moduleAs described here, we're removing most of the methods in the
ux
module. We're simply unable to adequately support the feature set thatux
offers and think that most people would benefit from using dedicated libraries that are better supported.We are, however, keeping some of the functionality. The new
ux
module will contain the following:Unchanged
colorize
error
exit
action
- will be unchanged from previous version except that the spinner color will be configurable using themes.warn
Renamed
stdout
- rename ofux.log
stderr
- rename ofux.logToStderr
New
colorizeJson
- Apply color theme to arbitrary JSON.What you'll need to do
You will need to replace everything that
ux
was doing with dedicated libraries. Here are a few suggestions:Theme-able spinner and JSON output
The color of the spinner can now be customized using the
spinner
key in your theme.The JSON output can also now be customized with these keys:
Customizable Logger
In the current major version, we exclusively use debug for debug logs. In the next major, we're going to export a
Logger
interface that will allow you to provide a custom logger for@oclif/core
to use. This will be useful if you want all the@oclif/core
debug logs to go through your own logger.The default logger will continue to use
debug
under the hood. So if you choose to use the default, you can continue to use theDEBUG
environment variable to access the debug logs in the console. The only breaking change will be that the namespace for all the logs with be prefixed with a root namespace,oclif
.So if you're used to using
DEBUG=config:* my-cli do stuff
, you'll need to start doing this instead:DEBUG=oclif:config:* my-cli do stuff
Interface
Usage
You can also provide the logger to
Config
, in the event that you instantiateConfig
before callingrun
orexecute
Support for
rc
filesCurrently the configuration for oclif must live inside the
oclif
section of your CLI or plugin's package.json. This can be difficult if you have a large amount of configuration, you want to dynamically change the configuration, or want to ensure that your configuration is correctly typed.To solve this, we can now use cosmiconfig or lilconfig to read in a variety of rc files.
Despite being able to use an rc file,
@oclif/core
will still be dependent on your package.json to get thename
,version
, anddependencies
. We could ask that you put those value in your rc file, but duplicating that information across two files feels like something people would rather not do.If you choose to use an rc file, one thing you must consider is that there will be a slight performance hit due to needing to search for the rc file in addition to the package.json.
This is the list of supported files. Please feel free to create a PR to add support for other files
Top level exports
We'll have top level exports for:
args
command
config
errors
execute
flags
flush
handle
help
hooks
interfaces
logger
performance
run
settings
util/ids
ux
The current way of accessing these looks like this:
With top level exports, you could access those like this:
The benefit of this is that you'll be able to import those utilities without also importing everything else that
@oclif/core
exports.As a result of this change, deep imports (e.g.
import {Command} from '@oclif/core/lib/command.js
) will no longer work.Bundling support for custom help classes
In case you missed it, we introduced new command discovery strategies that make bundling possible. In order to do that, the location of commands and hooks needed to be configured using a
target
(i.e. a file or directory containing the commands or hooks) and anidentifier
(i.e. the name of the export inside thetarget
).This change originally only worked for commands and hooks but now also works for custom help classes so that those can be bundled as well.
exactOptionalPropertyTypes
We enabled
exactOptionalPropertyTypes
(fixes #960) for improved type safetyInterfaces
Interfaces.PJSON
Interfaces.PJSON
has now been simplified to a single type instead ofInterfaces.PJSON.CLI
andInterfaces.PJSON.Plugin
Interfaces.OclifConfiguration
There's a new
Interfaces.OclifConfiguration
that represents everything that could be added to theoclif
section of your package.json (or rc file). This is particularly helpful if you want to use a.oclifrc.ts
and ensure that your oclif configuration matches the expected type.Runtime auto-transpilation of linked ESM plugins with
tsx
If your ESM plugin has a devDependency on
tsx
, then you oclif can now auto-transpile the code at runtime