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

🏗 build(cli): extract args before running build cmd #196

Merged
merged 10 commits into from
Jan 7, 2025
Merged

Conversation

tyler-dane
Copy link
Contributor

@tyler-dane tyler-dane commented Dec 20, 2024

This pull request includes significant refactoring and improvements to the CLI tools, including the introduction of a new CliValidator class, enhancements to the build and delete commands, and the addition of the zod library for schema validation. The most important changes are summarized below:

CLI Refactoring:

  • Introduction of CliValidator class: Added a new CliValidator class to handle CLI option validation and error handling, replacing inline validation logic. (packages/scripts/src/cli.validator.ts)
  • Refactor of cli.ts: Refactored the CLI script to use the new CliValidator class and encapsulated CLI logic within a CompassCli class for better modularity and maintainability. (packages/scripts/src/cli.ts)

Build and Delete Command Enhancements:

  • Improved build command: Modified the runBuild function and related helper functions to use the new options structure and environment handling. (packages/scripts/src/commands/build.ts) [1] [2] [3] [4]
  • Enhanced delete command validation: Updated the delete command to validate user input using the new CliValidator class. (packages/scripts/src/cli.ts)

Schema Validation:

  • Added zod library: Introduced the zod library for schema validation of CLI options, ensuring that the provided options adhere to the expected structure. (packages/backend/package.json)
  • Defined schemas for CLI options: Created schemas for root, build, and delete options using zod and integrated them into the validation process. (packages/scripts/src/common/cli.types.ts)

Utility Functions:

  • Environment and API base URL handling: Added utility functions to handle environment selection and API base URL retrieval, improving the flexibility and robustness of the CLI. (packages/scripts/src/common/cli.utils.ts) [1] [2]

These changes collectively enhance the robustness, maintainability, and user experience of the CLI tools.

Closes #195

@tyler-dane tyler-dane self-assigned this Dec 20, 2024
@tyler-dane tyler-dane changed the title 🐛 fix: extract cli args before running cmd 🐛 fix: extract cli args before running build cmd Dec 28, 2024
@tyler-dane tyler-dane force-pushed the feat/195-cli branch 2 times, most recently from 60c043b to 2bda7f0 Compare December 30, 2024 11:53
@tyler-dane tyler-dane changed the title 🐛 fix: extract cli args before running build cmd 🐛 build(cli): extract args before running build cmd Dec 31, 2024
@tyler-dane tyler-dane changed the title 🐛 build(cli): extract args before running build cmd 🏗 build(cli): extract args before running build cmd Dec 31, 2024
@tyler-dane tyler-dane force-pushed the feat/195-cli branch 2 times, most recently from 1259eb7 to 7b18fe2 Compare January 5, 2025 13:12
this improves readability, because the class has access to the 'options', which means we don't have to keep passing that arg to the util functions
this makes the division of responsibilities more clear: the Validator parses cli args and validates their inputs against our types. The CLI is then free to accept the parsed args and simply trigger the provided commands
@tyler-dane tyler-dane marked this pull request as ready for review January 7, 2025 13:30
@tyler-dane tyler-dane merged commit 67db6a0 into main Jan 7, 2025
3 checks passed
@tyler-dane tyler-dane deleted the feat/195-cli branch January 7, 2025 13:32
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.

Cli's build command always prompts for package
1 participant