-
Notifications
You must be signed in to change notification settings - Fork 0
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
FEDX-812 Improve CLI ergonomics #6
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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,22 @@ | ||
# Contributing | ||
|
||
## Supported Dart Versions | ||
Currently, `dpx` is written to support Dart 2.19 and Dart 3. We will eventually | ||
drop support for Dart 2, but until then, all dependency ranges need to take this | ||
into account and all CI checks (static analysis and tests) should pass on both | ||
major versions of Dart. Additionally, language features that require Dart 3+ are | ||
not yet used. | ||
|
||
## Running Locally | ||
|
||
- Install dependencies: `dart pub get` | ||
- Analysis: `dart analyze` | ||
- Tests: `dart test` | ||
- Running: | ||
- `dart bin/dpx.dart` | ||
- `dart pub global activate -spath .` to activate and `dart pub global run dpx` | ||
to run (or just `dpx` if global Dart executables are added to your path). | ||
- Debugging: | ||
- In VS Code, use the `DPX CLI` launch configuration. This will start `dpx` in | ||
interactive mode and open a terminal where you can enter the args. This will | ||
let you use the debugger and set breakpoints. |
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 |
---|---|---|
|
@@ -2,9 +2,8 @@ | |
|
||
## Installation | ||
|
||
Until this is published to pub, you'll have to install via Git: | ||
```bash | ||
dart pub global activate -sgit [email protected]:Workiva/dpx.git | ||
dart pub global activate dpx | ||
``` | ||
|
||
For ease of use, [follow these instructions][dart run from path] to add the | ||
|
@@ -13,48 +12,33 @@ system cache `bin` directory to your path so that you can run `dpx` directly. | |
## Usage | ||
|
||
```bash | ||
# Execute a command from <pkg> with the same name as <pkg> | ||
dpx <pkg> [args...] | ||
|
||
# Execute <cmd> from <pkg>. | ||
# Use if there are multiple executables or if the executable name is different. | ||
dpx --package=<pkg> <cmd> [args...] | ||
dpx <package-spec>[:<package-executable>] [-e <executable>] [args...] | ||
``` | ||
|
||
## Command Running | ||
|
||
Once the necessary package is installed, dpx will attempt to run the command. | ||
First, dpx will globally activate the package specified by `<package-spec>`. | ||
Then it will run a command. | ||
|
||
First, it tries to run the command directly, assuming that it is available as an | ||
executable in the PATH. This works for Dart packages that declare an | ||
[executable in the pubspec][pubspec executable]. | ||
|
||
```yaml | ||
# pubspec.yaml | ||
name: webdev | ||
executables: | ||
webdev: | ||
``` | ||
If neither `:<package-executable>` nor `-e <executable>` are specified, dpx will | ||
run the default package executable from `<package>`. This is equivalent to: | ||
|
||
```bash | ||
# Installs and runs `webdev` executable in PATH | ||
dpx webdev | ||
dart pub global run <package> [args...] | ||
``` | ||
|
||
If that fails, dpx falls back to running the command with `dart pub global run`. | ||
The expected format of a command run this way is `<pkg>:<cmd>`, where `<pkg>` is | ||
the name of the Dart package and `<cmd>` is the name of the Dart file in `bin/`, | ||
minus the `.dart` extension. | ||
|
||
Dart lets you omit the `:<cmd>` portion if there's a file with the same name as | ||
the package. | ||
|
||
For other files, dpx lets you omit the `<pkg>` portion since it can be inferred. | ||
If `:<package-executable>` is specified, dpx will run that executable from the | ||
installed package. This is equivalent to: | ||
|
||
```bash | ||
dpx --package=build_runner :graph_inspector | ||
dart pub global run <package>:<package-executable> [args...] | ||
``` | ||
|
||
If `-e <executable>` is specified, dpx will run `<executable> [args...]` | ||
directly after installing the package. This allows you to opt-out of the default | ||
method that uses `dart pub global run`. This may be useful for Dart packages | ||
that declare an [executable in the pubspec][pubspec executable] that would be | ||
available in the PATH, or if other executables outside of the package need to be | ||
used. | ||
|
||
## Exit Status | ||
|
||
| Exit Code | Meaning | | ||
|
@@ -79,9 +63,9 @@ dpx webdev@^3.0.0 [args...] | |
|
||
# Install from custom pub server. | ||
# Syntax: | ||
dpx pub@<pub-server>:<pkg>[@<version-constraint] [args...] | ||
dpx pub@<pub-server>:<package>[@<version-constraint] [args...] | ||
# Example: | ||
dpx [email protected]:workiva_nullsafety_migrator@^1.0.0 | ||
dpx [email protected]:dart_null_tools@^1.0.0 | ||
|
||
# Install from a github repo. | ||
# Syntax: | ||
|
@@ -99,11 +83,11 @@ dpx github+ssh:<org>/<repo> [args...] | |
# - <path> if the package is not in the root of the repo | ||
# - <ref> to checkout a specific tag/branch/commit | ||
# Syntax: | ||
dpx <git-url>#path:sub/dir,ref:v1.0.2 [args...] | ||
dpx <git-url>#path=sub/dir,ref=v1.0.2 [args...] | ||
# Examples: | ||
dpx github:Workiva/dpx#ref:v0.0.0 --help | ||
dpx github:Workiva/dpx#path:example/hello | ||
dpx github:Workiva/dpx#path:example/hello,ref:v0.0.0 | ||
dpx github:Workiva/dpx#ref=v0.1.0 --help | ||
dpx github:Workiva/dpx#path=example/dpx_hello | ||
dpx github:Workiva/dpx#path=example/dpx_hello,ref=v0.1.0 | ||
``` | ||
|
||
## Troubleshooting | ||
|
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
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.
Doesn't look like dpx is on the public pub server yet
Is this change just in preparation for this to happen soon? or should we add
--hosted-url
on this line?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.
Yeah I was planning to open source and publish once this change lands 👍