-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat: final v3 features #779
Merged
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
66a69ea
feat: add charAliases
mdonnalley b525246
feat: add Flags.option
mdonnalley 292b4b1
fix: undo default options
mdonnalley d64d915
fix: allow bin/dev.js to auto-transpile ESM plugin
mdonnalley f6291f2
chore: update execute examples
mdonnalley f25c4cb
fix: update tsnode skip logic
mdonnalley d3446a2
chore: test debugging
mdonnalley f02bce2
fix: ts-node skip logic
mdonnalley ef1319f
fix: ts-node skip logic
mdonnalley a28e277
feat: cache relativePath and isESM in manifest
mdonnalley 3273513
fix: calculate id permutations at runtime to support backwards compat…
mdonnalley 15f8177
perf: avoid findLegacyRoot for linked plugins
mdonnalley 4f1a889
chore: remove env var
mdonnalley e2f37ce
fix: improve perf metrics
mdonnalley 2618f14
perf: improve perf debug output
mdonnalley 13115a6
perf: more debug improvements
mdonnalley 15b8f75
test: compilation errors
mdonnalley eaec901
fix: make relativePath OS safe
mdonnalley a89267e
test: use sf esm branch
mdonnalley 7882ce7
perf: give full hook path
mdonnalley 3efa804
chore: test debugging
mdonnalley 0c607e5
chore: test debugging
mdonnalley 7e9505f
chore: test debugging
mdonnalley e6d5b35
test: set shell for e2e tests
mdonnalley 70f07e4
fix: flag types respect defaults
mdonnalley 0fdc986
feat: node protocol
mdonnalley cac1dbd
test: move windows sf integration tests into separate job
mdonnalley d05c513
test: update assertion on plugins install test
mdonnalley c8d1c61
test: use correct file path
mdonnalley f13e29c
test: use -Force
mdonnalley 540fc32
test: use bash shell
mdonnalley 160e6c2
test: clean up
mdonnalley 6fcd2a6
test: remove shell option
mdonnalley 86d0ded
test: oclif/config, core v1, and core v2 interop tests
mdonnalley 970d04b
chore: drop node 16
mdonnalley 7a03f8f
test: remove lts/-1
mdonnalley 3f8c63e
chore: code review
mdonnalley 9b949fb
chore: add pre core migration guide
mdonnalley 49b7315
refactor: break up ModuleLoader
mdonnalley c00d998
chore: remove unicorn/consistent-function-scoping
mdonnalley a75e37c
chore: remove unicorn/no-missing-imports
mdonnalley 836d7e7
chore: remove @typescript-eslint/no-empty-function
mdonnalley 037e224
chore: remove ban-ts-comment and ban-ts-ignore
mdonnalley 9e9b677
chore: add sort-import rule
mdonnalley 023fe3d
fix: throw error if non-multiple flag provided more than once
mdonnalley 9d66bc9
test: mutliples of non-multiple flag test
mdonnalley 6c2145c
test: ut for charAliases (#791)
mshanemc 8cb414b
test: duplicate aliases tests
mdonnalley 0f65a1c
test: extend timeout
mdonnalley efbafd9
test: split windows esm-cjs tests
mdonnalley c579b4f
test: parallelize linux interop tests too
mdonnalley c62f427
test: typo
mdonnalley be392d0
test: use right executor
mdonnalley a4887b5
test: use right executor for clean up
mdonnalley 11b3ed4
chore: update eslint libs (#792)
mdonnalley 1c9104b
chore: replaceAll
mdonnalley d5fc535
fix: error exit codes
mdonnalley 4ff3245
fix: use es2021
mdonnalley f83d639
feat: use ES2022
mdonnalley 24fcc62
fix: use ES2021 again
mdonnalley 748fe7c
test: incorporate flags and args in esm-cjs tests
mdonnalley 91665b1
test: use correct expected values
mdonnalley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,14 @@ | ||
{ | ||
"extends": [ | ||
"oclif", | ||
"oclif-typescript" | ||
], | ||
"rules": { | ||
"sort-imports": "error", | ||
"unicorn/prefer-module": "off", | ||
"unicorn/import-style": "error", | ||
"unicorn/no-array-reduce": "off", | ||
"unicorn/prefer-array-some": "off", | ||
"no-useless-constructor": "off" | ||
} | ||
} |
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 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,182 @@ | ||
Migrating to @oclif/core from deprecated libraries | ||
============== | ||
|
||
Migrating to `@oclif/core` from the deprecated oclif libraries (`@oclif/config`, `@oclif/command`, `@oclif/error`, `@oclif/parser`) is relatively straight forward. | ||
|
||
- [Migrating to @oclif/core from deprecated libraries](#migrating-to-oclifcore-from-deprecated-libraries) | ||
- [Update Imports](#update-imports) | ||
- [Update your bin scripts](#update-your-bin-scripts) | ||
- [Add `main` to your package.json](#add-main-to-your-packagejson) | ||
- [Restore `-h`, `-v`, and `version`](#restore--h--v-and-version) | ||
- [Configure the `topicSeparator`](#configure-the-topicseparator) | ||
- [Update `this.parse` to `await this.parse`](#update-thisparse-to-await-thisparse) | ||
- [Update `default` property on flag definitions](#update-default-property-on-flag-definitions) | ||
- [Replace cli-ux library with `ux`](#replace-cli-ux-library-with-ux) | ||
- [Single command CLIs](#single-command-clis) | ||
|
||
## Update Imports | ||
|
||
Replace imports from the old libraries with `@oclif/core`. For example, | ||
|
||
```typescript | ||
import Help from '@oclif/plugin-help'; | ||
import {Topic} from '@oclif/config'; | ||
import {Command, Flags} from '@oclif/command' | ||
``` | ||
|
||
With this import: | ||
|
||
```typescript | ||
import {Command, Flags, Topic, Help} from '@oclif/core'; | ||
``` | ||
|
||
## Update your bin scripts | ||
|
||
`@oclif/core` now supports separate bin scripts for production and development. | ||
|
||
You can copy these new bin scripts directly from our [example repository](https://github.com/oclif/hello-world/tree/main/bin). | ||
|
||
## Add `main` to your package.json | ||
|
||
We recommend that all oclif plugins specify the `main` field in their package.json so that we can begin working on supporting Yarn v2. | ||
|
||
```json | ||
{ | ||
"main": "lib/index.js" | ||
} | ||
``` | ||
|
||
All plugins will be required to have this field in the next major version of `@oclif/core`. | ||
|
||
## Restore `-h`, `-v`, and `version` | ||
|
||
`@oclif/config` automatically added `-h` as a short flag for `--help`, `-v` as a short flag for `--version`, and `version` as an alias for `--version`. | ||
|
||
`@oclif/core` removes these so you can now use those flags for whatever you want! However, we've added a way to restore that functionality if you want to keep it. | ||
|
||
Simply add the `additionalHelpFlags` and `additionalVersionFlags` properties to the oclif section of your package.json: | ||
|
||
```json | ||
{ | ||
"oclif": { | ||
"additionalHelpFlags": ["-h"], | ||
"additionalVersionFlags": ["-v"] | ||
} | ||
} | ||
``` | ||
|
||
To get the `version` command, install `@oclif/plugin-version` into your CLI: | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"@oclif/plugin-version": "^3" | ||
}, | ||
"oclif": { | ||
"plugins": [ | ||
"@oclif/plugin-version" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## Configure the `topicSeparator` | ||
|
||
By default, the `topicSeparator` is set to a colon (`:`) to maintain backwards compatibility with existing CLIs. If you prefer, you can now set it to a space. | ||
|
||
For colons: | ||
```json | ||
{ | ||
"oclif": { | ||
"topicSeparator": ":" | ||
} | ||
} | ||
``` | ||
|
||
For spaces: | ||
```json | ||
{ | ||
"oclif": { | ||
"topicSeparator": " " | ||
} | ||
} | ||
``` | ||
|
||
**NOTE: Using colons always works, even if you set the `topicSeparator` to spaces.** This means that you can enable spaces in your CLI without introducing a breaking change to your users. | ||
|
||
## Update `this.parse` to `await this.parse` | ||
|
||
The `parse` method on `Command` is now asynchronous (more [here](https://oclif.io/blog/#async-command-parsing)). So you'll now need to `await` any calls to `this.parse`: | ||
|
||
`const { args, flags } = this.parse(MyCommand)` => `const { args, flags } = await this.parse(MyCommand)` | ||
|
||
## Update `default` property on flag definitions | ||
|
||
The `default` property on flag definitions is now asynchronous. So you'll now need to await those. | ||
|
||
Example: | ||
|
||
```typescript | ||
import {Command, Flags} from '@oclif/core' | ||
import {readFile} from 'fs/promises' | ||
|
||
function getTeam(): Promise<string> { | ||
return readFile('team.txt', 'utf-8') | ||
} | ||
|
||
export const team = Flags.build({ | ||
char: 't', | ||
description: 'team to use', | ||
default: () => getTeam(), | ||
}) | ||
|
||
export class MyCLI extends Command { | ||
static flags = { | ||
team: team(), | ||
} | ||
|
||
async run() { | ||
const {flags} = this.parse(MyCLI) | ||
if (flags.team) console.log(`--team is ${flags.team}`) | ||
} | ||
} | ||
``` | ||
|
||
## Replace cli-ux library with `ux` | ||
|
||
The [`cli-ux` library](https://github.com/oclif/cli-ux) has also been moved into `@oclif/core` in order to break a complex circular dependency between the two projects. | ||
|
||
All the exports that were available from `cli-ux` are now available under the `ux` namespace, with the exception of the `cli` export which was identical to the `ux` export. | ||
|
||
Old: | ||
|
||
```typescript | ||
import { cli } from 'cli-ux` | ||
|
||
cli.log('hello world') | ||
cli.action.start('doing things') | ||
cli.action.stop() | ||
``` | ||
|
||
New: | ||
|
||
```typescript | ||
import { ux } from '@oclif/core` | ||
|
||
ux.log('hello world') | ||
ux.action.start('doing things') | ||
ux.action.stop() | ||
``` | ||
|
||
## Single command CLIs | ||
|
||
Single command CLIs now are configured in a different way. To ensure your migrated CLI work as before, you have to add the following to your `oclif` configuration in the `package.json`: | ||
|
||
```json | ||
"oclif": { | ||
"default": ".", | ||
"commands": "./lib" | ||
} | ||
``` | ||
|
||
Where `./lib` points to the folder in which your `tsconfig.json` is configured to output to (if you are using TypeScript), and your single command CLI entrypoint `index.(ts|js)` is located. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is your branch required just temporarily?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. The sf integration tests fail since there are breaking changes. I have a note to switch this back to main once salesforcecli/cli#1094 is merged