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

refactor(cli): Updated configuration commands and mechanism #310

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

rajdip-b
Copy link
Member

@rajdip-b rajdip-b commented Jul 3, 2024

User description

Description

Changes in command

This PR makes the following changes to the CLI:

  • Removed the configure command
  • Added a profile command
  • Added an init command
  • Modified the internals of init command

Architectural changes

  • The base.command.ts class got a completely new overhaul that now allows you to seamlessly develop the commands by using OOP principles to the fullest.
  • Added the concept of profiles that will store the base URL and the API key. Any command that you run will use the default profile, or the profile that you specify using --profile or the --api-key and --base-url in order.

PR Type

Enhancement, Other


Description

  • Introduced a new BaseCommand class to serve as the base for all CLI commands, providing methods for setting global context fields and handling command options and arguments.
  • Removed the configure command and its related types and implementation.
  • Added a new init command for initializing project configurations, including prompts for user input and configuration file writing.
  • Added a new profile command to manage CLI profiles, with subcommands for creating, updating, listing, using, and deleting profiles.
  • Refactored the run command to extend BaseCommand, updating methods for fetching configurations and connecting to the socket.
  • Updated import paths for Configuration type in HTTP-related files.
  • Updated the CLI entry point to remove the configure command and add the profile and init commands, along with global options for profile, API key, and base URL.
  • Added new types for command options, arguments, action data, run command configuration, client response, project root, profile, and private key configurations.
  • Added methods for fetching and writing profile and private key configurations, and updated methods for project root configurations.

Changes walkthrough 📝

Relevant files
Enhancement
14 files
base.command.ts
Introduce BaseCommand class for CLI commands                         

apps/cli/src/commands/base.command.ts

  • Added a new BaseCommand class to serve as the base for all CLI
    commands.
  • Implemented methods for setting global context fields and handling
    command options and arguments.
  • Introduced error handling for missing API keys.
  • +155/-0 
    init.command.ts
    Add init command for project configuration                             

    apps/cli/src/commands/init.command.ts

  • Added a new init command for initializing project configurations.
  • Implemented prompts for user input and configuration file writing.
  • +109/-0 
    profile.command.ts
    Add profile command with subcommands                                         

    apps/cli/src/commands/profile.command.ts

  • Added a new profile command to manage CLI profiles.
  • Included subcommands for creating, updating, listing, using, and
    deleting profiles.
  • +26/-0   
    create.profile.ts
    Add create profile subcommand                                                       

    apps/cli/src/commands/profile/create.profile.ts

  • Added a subcommand to create a new profile.
  • Implemented prompts for user input and profile configuration writing.
  • +115/-0 
    delete.profile.ts
    Add delete profile subcommand                                                       

    apps/cli/src/commands/profile/delete.profile.ts

  • Added a subcommand to delete an existing profile.
  • Implemented confirmation prompts and profile configuration updates.
  • +70/-0   
    list.profile.ts
    Add list profile subcommand                                                           

    apps/cli/src/commands/profile/list.profile.ts

  • Added a subcommand to list all profiles.
  • Implemented verbose option for detailed profile information.
  • +50/-0   
    update.profile.ts
    Add update profile subcommand                                                       

    apps/cli/src/commands/profile/update.profile.ts

  • Added a subcommand to update an existing profile.
  • Implemented options for updating profile name, API key, and base URL.
  • +85/-0   
    use.profile.ts
    Add use profile subcommand                                                             

    apps/cli/src/commands/profile/use.profile.ts

  • Added a subcommand to set the default profile.
  • Implemented profile configuration updates.
  • +46/-0   
    run.command.ts
    Refactor run command to extend BaseCommand                             

    apps/cli/src/commands/run.command.ts

  • Refactored the run command to extend BaseCommand.
  • Updated methods for fetching configurations and connecting to the
    socket.
  • +56/-68 
    index.ts
    Update CLI entry point with new commands                                 

    apps/cli/src/index.ts

  • Removed configure command and added profile and init commands.
  • Updated global options for profile, API key, and base URL.
  • +13/-12 
    command.types.d.ts
    Add new types for command options and arguments                   

    apps/cli/src/types/command/command.types.d.ts

    • Added new types for command options, arguments, and action data.
    +16/-0   
    run.types.d.ts
    Add new types for run command                                                       

    apps/cli/src/types/command/run.types.d.ts

    • Added new types for run command configuration and client response.
    +12/-1   
    index.types.d.ts
    Add new types for project and profile configurations         

    apps/cli/src/types/index.types.d.ts

  • Added new types for project root, profile, and private key
    configurations.
  • +18/-0   
    configuration.ts
    Add methods for profile and private key configurations     

    apps/cli/src/util/configuration.ts

  • Added methods for fetching and writing profile and private key
    configurations.
  • Updated methods for fetching and writing project root configurations.
  • +44/-21 
    Other
    4 files
    configure.command.ts
    Remove configure command from CLI                                               

    apps/cli/src/commands/configure/configure.command.ts

    • Removed the configure command and its implementation.
    +0/-164 
    configure.types.d.ts
    Remove configure command types                                                     

    apps/cli/src/commands/configure/configure.types.d.ts

    • Removed types related to the configure command.
    +0/-11   
    secret.ts
    Update import paths for Configuration type                             

    apps/cli/src/http/secret.ts

    • Updated import paths for Configuration type.
    +1/-1     
    variable.ts
    Update import paths for Configuration type                             

    apps/cli/src/http/variable.ts

    • Updated import paths for Configuration type.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @rajdip-b rajdip-b merged commit 903fd84 into develop Jul 3, 2024
    5 checks passed
    @keyshade-xyz keyshade-xyz deleted a comment from codiumai-pr-agent-free bot Jul 3, 2024
    @keyshade-xyz keyshade-xyz deleted a comment from codiumai-pr-agent-free bot Jul 3, 2024
    @rajdip-b rajdip-b deleted the refactor/update-cli-configuration branch July 3, 2024 16:14
    rajdip-b pushed a commit that referenced this pull request Jul 11, 2024
    ## [2.2.0](v2.1.0...v2.2.0) (2024-07-11)
    
    ### 🚀 Features
    
    * **api-client:** Added API Client package ([#346](#346)) ([6734e1e](6734e1e))
    * **api:** Updated API key ([fbac312](fbac312))
    * **platform:** View [secure]s ([#313](#313)) ([97c4541](97c4541))
    * **web:** Add Pricing Page ([#243](#243)) ([2c7f1d6](2c7f1d6))
    
    ### 📚 Documentation
    
    * **cli:** Added docs for the CLI package ([#329](#329)) ([edad166](edad166))
    * **cli:** Added usage docs ([#330](#330)) ([b6963d5](b6963d5))
    * Update Discord link ([871b6cd](871b6cd))
    * Update README.md ([e66fcd2](e66fcd2))
    * **web:** Add documentation about our web package ([#268](#268)) ([3d848e7](3d848e7))
    
    ### 🔧 Miscellaneous Chores
    
    * **api:** Updated response types in environment service ([b8a3ddd](b8a3ddd))
    * **ci:** Added release scripts for platform and api ([02dae60](02dae60))
    * **CI:** Updated action plugin versions ([88bb317](88bb317))
    * **CI:** Updated pnpm version in CI file ([2692e88](2692e88))
    * **platform:** Fixed env parsing in platform ([d6ffafa](d6ffafa))
    * **web:** Update Terms and Conditions and Privacy Policy ([#282](#282)) ([d621dcb](d621dcb))
    
    ### 🔨 Code Refactoring
    
    * **api:** Update [secure] and variable fetching endpoints ([7d9acd0](7d9acd0))
    * **cli:** Refactored profile commands into readable blocks ([#331](#331)) ([4a8a089](4a8a089))
    * **cli:** Updated configuration commands and mechanism ([#310](#310)) ([9079b6d](9079b6d))
    rajdip-b pushed a commit that referenced this pull request Jul 11, 2024
    ## [2.2.0](v2.1.0...v2.2.0) (2024-07-11)
    
    ### 🚀 Features
    
    * **api-client:** Added API Client package ([#346](#346)) ([6734e1e](6734e1e))
    * **api:** Updated API key ([fbac312](fbac312))
    * **platform:** View [secure]s ([#313](#313)) ([97c4541](97c4541))
    * **web:** Add Pricing Page ([#243](#243)) ([2c7f1d6](2c7f1d6))
    
    ### 📚 Documentation
    
    * **cli:** Added docs for the CLI package ([#329](#329)) ([edad166](edad166))
    * **cli:** Added usage docs ([#330](#330)) ([b6963d5](b6963d5))
    * Update Discord link ([871b6cd](871b6cd))
    * Update README.md ([e66fcd2](e66fcd2))
    * **web:** Add documentation about our web package ([#268](#268)) ([3d848e7](3d848e7))
    
    ### 🔧 Miscellaneous Chores
    
    * **api:** Updated response types in environment service ([b8a3ddd](b8a3ddd))
    * **ci:** Added release scripts for platform and api ([02dae60](02dae60))
    * **CI:** Updated action plugin versions ([88bb317](88bb317))
    * **CI:** Updated pnpm version in CI file ([2692e88](2692e88))
    * **platform:** Fixed env parsing in platform ([d6ffafa](d6ffafa))
    * **web:** Update Terms and Conditions and Privacy Policy ([#282](#282)) ([d621dcb](d621dcb))
    
    ### 🔨 Code Refactoring
    
    * **api:** Update [secure] and variable fetching endpoints ([7d9acd0](7d9acd0))
    * **cli:** Refactored profile commands into readable blocks ([#331](#331)) ([4a8a089](4a8a089))
    * **cli:** Updated configuration commands and mechanism ([#310](#310)) ([9079b6d](9079b6d))
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant