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

Improve help output UX and DX #10090

Merged
merged 33 commits into from Jun 29, 2023
Merged

Improve help output UX and DX #10090

merged 33 commits into from Jun 29, 2023

Conversation

Ethan-Arrowood
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood commented Jun 9, 2023

This PR adds a new utility for generating help output for CLI commands. Backed by a JSON data structure that represents the commands, this utility uses deterministic functions for generating the different output sections (such as options and examples). This change will let contributor easily add/modify command details. The data structure is also used by the CLI to generate the args parsing structure for the deploy command. Optimistically, this same data structure can be used to generate documentation output for front such that the online docs will match the help output.

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2023

🦋 Changeset detected

Latest commit: 2f14f96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@vercel-internals/constants Patch
vercel Patch
@vercel-internals/types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Ethan-Arrowood
Copy link
Contributor Author

Ethan-Arrowood commented Jun 10, 2023

The algorithm now intelligently wraps the description for each option based on terminal width. Thanks @cb1kenobi for the idea!

Screenshot 2023-06-09 at 23 12 26 Screenshot 2023-06-09 at 23 16 13

@Ethan-Arrowood Ethan-Arrowood marked this pull request as ready for review June 14, 2023 19:20
packages/cli/src/commands/deploy/index.ts Outdated Show resolved Hide resolved
packages/cli/test/unit/commands/help.test.ts Outdated Show resolved Hide resolved
}

export function buildCommandOptionLines(command: Command) {
const MAX_LINE_LENGTH = process.stdout.columns;
Copy link
Member

Choose a reason for hiding this comment

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

Should be client.stderr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout. Noticed that the client types don't use tty.WriteStream, so I change that. Not sure if you did that intentionally or if you just didn't know that type existed. This is the type that process.stderr uses.

Copy link
Member

Choose a reason for hiding this comment

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

Ya we should probably use that type then.

@Ethan-Arrowood Ethan-Arrowood merged commit 718bbd3 into main Jun 29, 2023
104 checks passed
@Ethan-Arrowood Ethan-Arrowood deleted the improve-help-output-ux branch June 29, 2023 20:08
TooTallNate pushed a commit that referenced this pull request Jul 10, 2023
## @vercel/build-utils@6.8.1

### Patch Changes

- Revert "[build-utils] Allow file-ref sema to be controlled through env
flag" ([#10167](#10167))

## vercel@31.0.2

### Patch Changes

- Allow additional project settings in `createProject()`
([#10172](#10172))

- Run local Project detection during `vc link --repo`.
([#10094](#10094))
This allows for creation of new Projects that do not yet exist under the
selected scope.

- Redeploy command no longer redeploys preview deployments to production
([#10186](#10186))

- Added trailing new line at end of help output
([#10170](#10170))

- Create new help output and arg parsing for deploy command
([#10090](#10090))

- [cli] Remove `preinstall` script
([#10157](#10157))

- Updated dependencies
\[[`7021279b2`](7021279),
[`5e5332fbc`](5e5332f),
[`027bce00b`](027bce0)]:
    -   @vercel/build-utils@6.8.1
    -   @vercel/node@2.15.4
    -   @vercel/remix-builder@1.8.16
    -   @vercel/static-build@1.3.39

## @vercel/client@12.6.4

### Patch Changes

- Updated dependencies
\[[`7021279b2`](7021279)]:
    -   @vercel/build-utils@6.8.1

## @vercel/gatsby-plugin-vercel-builder@1.3.12

### Patch Changes

- Updated dependencies
\[[`7021279b2`](7021279),
[`5e5332fbc`](5e5332f)]:
    -   @vercel/build-utils@6.8.1
    -   @vercel/node@2.15.4

## @vercel/node@2.15.4

### Patch Changes

- [node] fix decompress mismatching
([#10184](#10184))

- Updated dependencies
\[[`7021279b2`](7021279)]:
    -   @vercel/build-utils@6.8.1

## @vercel/remix-builder@1.8.16

### Patch Changes

- Update `@remix-run/dev` fork to v1.18.1
([#10180](#10180))

- Updated dependencies
\[[`7021279b2`](7021279)]:
    -   @vercel/build-utils@6.8.1

## @vercel/static-build@1.3.39

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@1.3.12

## @vercel-internals/constants@1.0.4

### Patch Changes

- Create new help output and arg parsing for deploy command
([#10090](#10090))

## @vercel-internals/types@1.0.4

### Patch Changes

- Updated dependencies
\[[`7021279b2`](7021279),
[`718bbd365`](718bbd3)]:
    -   @vercel/build-utils@6.8.1
    -   @vercel-internals/constants@1.0.4

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kodiakhq bot pushed a commit that referenced this pull request Jul 27, 2023
Followup PR to #10090. Some of our commands duplicate global options into their `args` structure e.g. https://github.com/vercel/vercel/blob/2661f56347d5c32de369a6cea74bc9fb46d565a2/packages/cli/src/commands/logs.ts#L25-L26

 Others commands omit it entirely.

This updates the `--help` output for commands migrated to our new structure (so far, only `deploy`) will show a "Global Options" section:

```
▲ vercel deploy [project-path] [options]

Deploy your project to Vercel. The `deploy` command is the default command for the Vercel CLI, and can be omitted (`vc deploy my-app` equals `vc my-app`).

Options

  --archive                    Compress the deployment code into a file before uploading it
  -b, --build-env <key=value>  Specify environment variables during build-time (e.g. `-b KEY1=value1 -b KEY2=value2`)
  -e, --env <key=value>        Specify environment variables during run-time (e.g. `-e KEY1=value1 -e KEY2=value2`)
  -f, --force                  Force a new deployment even if nothing has changed
  -m, --meta <key=value>       Specify metadata for the deployment (e.g. `-m KEY1=value1 -m KEY2=value2`)
  --no-wait                    Don't wait for the deployment to finish
  --prebuilt                   Use in combination with `vc build`. Deploy an existing build
  --prod                       Create a production deployment
  -p, --public                 Deployment is public (`/_src`) is exposed)
  --regions                    Set default regions to enable the deployment on
  --with-cache                 Retain build cache when using "--force"
  -y, --yes                    Use default options to skip all prompts

Global Options

  --cwd <DIR>                Sets the current working directory for a single run of a command
  -d, --debug                Debug mode (default off)
  -Q, --global-config <DIR>  Path to the global ${'`.vercel`'} directory
  -h, --help                 Output usage information
  -A, --local-config <FILE>  Path to the local `vercel.json` file
  --no-color                 No color mode (default off)
  -S, --scope                Set a custom scope
  -t, --token <TOKEN>        Login token
  -v, --version              Output the version number
```

As commands are migrated to this new structure, they'll gain this output automatically.
kodiakhq bot pushed a commit that referenced this pull request Jul 31, 2023
Migrating `remove` to the command structure created in #10090. Unsure about tests. This is technically a refactor so existing tests should suffice.
kodiakhq bot pushed a commit that referenced this pull request Jul 31, 2023
Migrating `bisect` to the command structure created in #10090. Unsure about tests. This is technically a refactor so existing tests should suffice.

Before:
<img width="534" alt="CleanShot 2023-07-31 at 08 14 29@2x" src="https://github.com/vercel/vercel/assets/9736/8ae53672-9b1f-444a-94d3-296ac0fa8d30">

After:
<img width="674" alt="CleanShot 2023-07-31 at 08 15 02@2x" src="https://github.com/vercel/vercel/assets/9736/0ba12f19-fb34-41f3-84fb-0c1498d7a485">
kodiakhq bot pushed a commit that referenced this pull request Aug 2, 2023
Migrating `whoami` to the command structure created in #10090. Unsure about tests. This is technically a refactor so existing tests should suffice.
jeffsee55 added a commit that referenced this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants