Skip to content

feat: add bru.hasGlobalEnvVar method and update translations - #8037

Merged
bijin-bruno merged 2 commits into
usebruno:mainfrom
sanish-bruno:feat/add-has-global-env-var
May 20, 2026
Merged

bijin-bruno merged 2 commits into
usebruno:mainfrom
sanish-bruno:feat/add-has-global-env-var

Conversation

@sanish-bruno

@sanish-bruno sanish-bruno commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

JIRA

Description

  • Introduced the bru.hasGlobalEnvVar(key) method to check for the existence of global environment variables.
  • Updated translation mappings in Postman converters to include pm.globals.has for bru.hasGlobalEnvVar.
  • Enhanced test cases to validate the new method and its translation in both directions between Bruno and Postman.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Added bru.hasGlobalEnvVar() to check existence of global environment variables.
    • Autocomplete now suggests the new environment-variable check.
    • Postman import/export translations updated to map Postman global-existence checks to the new helper.
  • Tests

    • Added and updated tests covering the new helper and its Postman translation behavior.

Review Change Stack

- Introduced the `bru.hasGlobalEnvVar(key)` method to check for the existence of global environment variables.
- Updated translation mappings in Postman converters to include `pm.globals.has` for `bru.hasGlobalEnvVar`.
- Enhanced test cases to validate the new method and its translation in both directions between Bruno and Postman.
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77b76215-74fd-4247-b7d0-67bd3411c78c

📥 Commits

Reviewing files that changed from the base of the PR and between 28e66c7 and 8605687.

📒 Files selected for processing (1)
  • packages/bruno-js/src/sandbox/quickjs/shims/bru.js

Walkthrough

Adds Bru.hasGlobalEnvVar(key), exposes it to the QuickJS shim, wires bidirectional 1:1 translations with Postman's pm.globals.has, updates Postman translation regex, adds the autocomplete hint, and updates/introduces tests to assert direct boolean checks.

Changes

Global Environment Variable Existence Check

Layer / File(s) Summary
Core API: hasGlobalEnvVar method
packages/bruno-js/src/bru.js
Adds hasGlobalEnvVar(key) to the Bru class that returns whether globalEnvironmentVariables has the specified own property.
Bidirectional translation mappings
packages/bruno-converters/src/utils/bruno-to-postman-translator.js, packages/bruno-converters/src/utils/postman-to-bruno-translator.js, packages/bruno-converters/src/postman/postman-translations.js
Adds simple 1:1 mappings between bru.hasGlobalEnvVar and pm.globals.has in both directions, removes the previous complex Postman-to-Bruno transformation, and adds a Postman regex replacement.
Autocomplete hints and test coverage
packages/bruno-app/src/utils/codemirror/autocomplete.js, packages/bruno-converters/tests/bruno/bruno-to-postman-translations/variables.test.js, packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/variables.test.js, packages/bruno-js/src/sandbox/quickjs/shims/bru.js
Adds bru.hasGlobalEnvVar(key) to CodeMirror static hints, exposes the method through the QuickJS bru shim, adds a Bruno->Postman translation test, and updates Postman->Bruno translation tests to expect bru.hasGlobalEnvVar(...) boolean checks instead of undefined/null comparisons.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#7052: Related earlier changes around pm.globals.has() translation handling; this PR replaces the complex transformation with a direct mapping to bru.hasGlobalEnvVar(...).

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🌱 A tiny check for global keys so bright,
Bruno and Postman now share clearer sight,
Hints and shims and tests all sing in tune,
A boolean whisper under the dev moon. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding a new bru.hasGlobalEnvVar method and updating related translation mappings across multiple converter files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Implemented the `hasGlobalEnvVar` method in the bru shim to check for the existence of global environment variables.
- Updated the context setup to include the new method, enhancing the functionality of the environment variable management.
@bijin-bruno
bijin-bruno merged commit 113e28d into usebruno:main May 20, 2026
15 of 19 checks passed
lyh543 pushed a commit to lyh543/bruno that referenced this pull request May 22, 2026
…o#8037)

* feat: add bru.hasGlobalEnvVar method and update translations

- Introduced the `bru.hasGlobalEnvVar(key)` method to check for the existence of global environment variables.
- Updated translation mappings in Postman converters to include `pm.globals.has` for `bru.hasGlobalEnvVar`.
- Enhanced test cases to validate the new method and its translation in both directions between Bruno and Postman.

* feat: add hasGlobalEnvVar method to bru shim

- Implemented the `hasGlobalEnvVar` method in the bru shim to check for the existence of global environment variables.
- Updated the context setup to include the new method, enhancing the functionality of the environment variable management.
jattsson pushed a commit to jattsson/bruno that referenced this pull request May 26, 2026
…o#8037)

* feat: add bru.hasGlobalEnvVar method and update translations

- Introduced the `bru.hasGlobalEnvVar(key)` method to check for the existence of global environment variables.
- Updated translation mappings in Postman converters to include `pm.globals.has` for `bru.hasGlobalEnvVar`.
- Enhanced test cases to validate the new method and its translation in both directions between Bruno and Postman.

* feat: add hasGlobalEnvVar method to bru shim

- Implemented the `hasGlobalEnvVar` method in the bru shim to check for the existence of global environment variables.
- Updated the context setup to include the new method, enhancing the functionality of the environment variable management.
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
…o#8037)

* feat: add bru.hasGlobalEnvVar method and update translations

- Introduced the `bru.hasGlobalEnvVar(key)` method to check for the existence of global environment variables.
- Updated translation mappings in Postman converters to include `pm.globals.has` for `bru.hasGlobalEnvVar`.
- Enhanced test cases to validate the new method and its translation in both directions between Bruno and Postman.

* feat: add hasGlobalEnvVar method to bru shim

- Implemented the `hasGlobalEnvVar` method in the bru shim to check for the existence of global environment variables.
- Updated the context setup to include the new method, enhancing the functionality of the environment variable management.
@coderabbitai coderabbitai Bot mentioned this pull request Jun 18, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants