Skip to content

Finishing the project commands TS port #1449

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

Merged
merged 11 commits into from
Apr 25, 2025
Merged

Conversation

brandenrodgers
Copy link
Contributor

Description and Context

This wraps up the work to port all of the project command files to TS. I had to make some yargs typing changes to make things work well. I'm trying to strike the balance between getting value out of the yargs types, and making this so clunky to use that it's too much of a hassle to follow the patterns.

I had to make a few changes:

  • I realized that the makeYargsBuilder util was incorrectly matching on command buckets for help output. For example, running hs project create --help was returning the help output for hs project --hlep. I fixed this by matching on the last command that the user ran (e.g "create" in hs project create --help)
  • I had to add some custom yargs types. The CommandModule interface is a little annoying to use because it makes the builder optional, and changes the type from a simple function to something else. I created some overrides that simplifies that type for our use cases
  • All of the commands use makeYargsBuilder now
  • All of the commands have one default export (except some of them also export their handler arg types)

Screenshots

TODO

Who to Notify

@brandenrodgers
Copy link
Contributor Author

I'm going to wait for this to be merged before I put this up for review.

@brandenrodgers brandenrodgers marked this pull request as ready for review April 18, 2025 16:30
Copy link
Contributor

@camden11 camden11 left a comment

Choose a reason for hiding this comment

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

Found a few minor TS issues but otherwise this is looking good!

joe-yeager
joe-yeager previously approved these changes Apr 25, 2025
Copy link
Contributor

@joe-yeager joe-yeager left a comment

Choose a reason for hiding this comment

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

LGTM! Just a few nits

types/Yargs.ts Outdated
Comment on lines 40 to 42
export type YargsCommandModule<T, U> = Omit<CommandModule<T, U>, 'builder'> & {
builder: (yargs: Argv) => Promise<Argv<U>>;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Since CommandModule is an interface we can extend it and it might simplify the TS logic here.

export interface CommandModuleWithRequiredBuilder<T, U> extends CommandModule<T, U> {
  builder: (yargs: Argv) => Promise<Argv<U>>
}

camden11
camden11 previously approved these changes Apr 25, 2025
@brandenrodgers brandenrodgers dismissed stale reviews from camden11 and joe-yeager via df00fca April 25, 2025 21:32
@brandenrodgers brandenrodgers merged commit c496de4 into main Apr 25, 2025
1 check passed
@brandenrodgers brandenrodgers deleted the br/finish-project-ts-port branch April 25, 2025 21:36
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.

3 participants