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

feat(cli): add support for request variables #4275

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

jamesgeorge007
Copy link
Member

@jamesgeorge007 jamesgeorge007 commented Aug 19, 2024

Description

This PR adds support for request variables in the CLI. Request variables will have the topmost priority, meaning they will be preferred over any environment variables sharing the same name.

Closes HFE-552.

Changes

  • New getResolvedVariables() helper function added under ~/utils/getters.ts that takes in the list of request variables and environment variables for a session and returns a resolved list of variables where keys sharing the same name from environment variables are removed ensuring request variables take priority.
  • Relevant instances are updated to account for request variables, alongside environment variables via the above helper function.
  • Relevant test updates and associated fixture additions.
  • Bumps CLI version to 0.11.0.

Notes to reviewers

Steps to verify

Navigate to the hoppscotch-cli package path locally, and run pnpm build. Run the collection via:

secretBasicAuthPasswordEnvVar=password  bin/hopp.js test <collection_export_file_path> --env <environment_export_file_path>

secretBasicAuthPasswordEnvVar being a secret environment variable, can either be supplied along with environment variables for the session as above or specifying the value field in the environment export file.

The collection and environment export files added under test fixtures can be used to verify the behaviour comprising relevant tests covering various scenarios where a request variable comes into play:

  • Ignores inactive request variables.
  • Usage alongside environment variables where request variables take priority and ensure support for recursive resolution.

@jamesgeorge007 jamesgeorge007 force-pushed the feat/cli-request-variables branch 2 times, most recently from 94bab83 to ba9c9a6 Compare August 19, 2024 07:37
@jamesgeorge007 jamesgeorge007 force-pushed the feat/cli-request-variables branch 2 times, most recently from d733240 to 4a756f0 Compare August 19, 2024 16:26
Copy link
Member

@nivedin nivedin left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@nivedin nivedin merged commit 33b0a54 into next Aug 26, 2024
@nivedin nivedin deleted the feat/cli-request-variables branch August 26, 2024 13:51
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.

2 participants