Skip to content

feat: npm package report and installation support - #8143

Merged
sid-bruno merged 2 commits into
usebruno:mainfrom
naman-bruno:feat/npm-import
Jun 1, 2026
Merged

sid-bruno merged 2 commits into
usebruno:mainfrom
naman-bruno:feat/npm-import

Conversation

@naman-bruno

@naman-bruno naman-bruno commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

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

    • Detects npm packages referenced in imported Postman collections and attaches a package report.
    • Modal UI to review required/unsupported packages, copy manual install commands, and run installs with progress/results.
    • Option to enable Developer Mode for collections that require external modules; prompts when needed.
    • Import flow queues and surfaces package prompts per-import.
  • Tests

    • Comprehensive unit and integration tests covering detection, rewrite, prompt queuing, and install flows.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Converter detects npm packages in Postman scripts, produces a packageReport, the app shows a styled modal prompting install or Developer Mode changes, installs via an IPC handler that runs npm, and a hook queues prompts for bulk imports.

Changes

Postman Package Detection and Installation

Layer / File(s) Summary
Package detection and classification
packages/bruno-converters/src/postman/postman-package-detector.js
Regex-based extraction and normalization of pm.require/require, classification into safeMode/devMode/needsInstall/unsupported, and report builder exports.
Converter scanning & rewrite
packages/bruno-converters/src/postman/postman-to-bruno.js
Scan Postman envelope for script events, collect raw packages, rewrite translated Bruno scripts to replace pm.require, collect injected globals, and attach packageReport to validated collection.
Package report modal and styling
packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.js, packages/bruno-app/src/components/Sidebar/PostmanPackageReport/StyledWrapper.js
Styled React modal renders package lists, manual npm install command with copy, invokes IPC install, shows progress/results, prompts for Developer Mode, and displays truncated logs on failure.
Package prompt queueing hook
packages/bruno-app/src/hooks/usePostmanPackagePrompt/index.js
Hook maintains FIFO queue of {report, collectionPath} prompts with handleImportResolved to append and clearPostmanPackagePrompt to advance.
Integration into import flows
packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js
Call handleImportResolved after successful Postman imports and conditionally render PostmanPackageReport when the hook exposes a prompt.
NPM install utilities
packages/bruno-electron/src/utils/install-packages.js, packages/bruno-electron/tests/utils/install-packages.spec.js
Conservative npm name validator and runNpmInstall that spawns npm install --save with shell:false, caps output, enforces timeout/kill, handles spawn errors/ENOENT, and returns structured results.
IPC handler for package installation
packages/bruno-electron/src/ipc/collection.js
renderer:install-postman-packages validates collectionPathname and package names, then delegates to runNpmInstall and returns its result.
Tests & integration specs
packages/bruno-converters/tests/*, packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx, packages/bruno-app/src/hooks/usePostmanPackagePrompt/index.spec.js
Unit and integration tests covering detector utils, converter integration, modal UI flows, hook queueing, and installer edge cases (timeouts, spawn errors, output truncation).

Sequence Diagram

sequenceDiagram
  participant User
  participant UI as PostmanPackageReport
  participant Redux
  participant IPC as MainIPC
  participant InstallUtil as runNpmInstall
  participant Child as npmProcess

  User->>UI: click Install
  UI->>IPC: invoke('renderer:install-postman-packages', path, packages)
  IPC->>InstallUtil: runNpmInstall(...)
  InstallUtil->>Child: spawn npm install
  Child-->>InstallUtil: stdout/stderr or error/exit
  InstallUtil-->>IPC: result
  IPC-->>UI: install result
  UI->>User: show success or error + logs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • usebruno/bruno#8098: Modifies the Postman→Bruno conversion path related to import return structure and issues aggregation (affects what the converter returns to the UI).
  • usebruno/bruno#7878: Translator pass that injects require() for sandbox globals; closely related to detector handling of translator-injected globals.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno
  • sid-bruno

Poem

📦 pm.require calls stir the night,
Bruno scans, rewrites, and brings them light.
npm hums beneath the hood,
Modal asks, "Shall I make it good?"
Collections bloom with packages—done and bright.

🚥 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 'feat: npm package report and installation support' clearly summarizes the main change: adding npm package reporting and installation functionality for Postman imports.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js (1)

120-126: ⚡ Quick win

Consider a .catch on the import dispatch.

handleImportResolved now runs in the success path, but a rejected importAction leaves importCollectionLocationModalOpen/importData un-reset and surfaces an unhandled rejection. If this predates the PR feel free to defer, but it's adjacent to the touched lines.

♻️ Suggested handling
     dispatch(importAction)
       .then((importedItem) => {
         setImportCollectionLocationModalOpen(false);
         setImportData(null);
         handleImportResolved(convertedCollection, importedItem);
-      });
+      })
+      .catch((err) => {
+        console.error(err);
+        toast.error('Failed to import collection');
+      });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js`
around lines 120 - 126, dispatch(importAction) currently only handles the
success path which calls setImportCollectionLocationModalOpen(false),
setImportData(null) and handleImportResolved(convertedCollection, importedItem);
add a .catch handler on the dispatched promise to reset UI state on failure
(call setImportCollectionLocationModalOpen(false) and setImportData(null)), and
surface/log the error (or show an error toast) so the rejection is handled and
no unhandled promise remains; ensure handleImportResolved is invoked only on
success.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-converters/src/postman/postman-package-detector.js`:
- Around line 24-37: normalizePackageName should strip any leading "node:"
prefix and drop subpaths so imports like "node:crypto" or "lodash/get" normalize
to their package roots; update normalizePackageName to first remove a "node:"
prefix (if present), then after existing version-stripping logic remove path
segments: for non-scoped names cut at the first '/' and for scoped names (name
starting with '@') keep up through the first two path segments (i.e. strip after
the second '/'); keep the existing handling of "npm:" and version "@" separators
and return null for non-strings or local paths as before.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js`:
- Around line 120-126: dispatch(importAction) currently only handles the success
path which calls setImportCollectionLocationModalOpen(false),
setImportData(null) and handleImportResolved(convertedCollection, importedItem);
add a .catch handler on the dispatched promise to reset UI state on failure
(call setImportCollectionLocationModalOpen(false) and setImportData(null)), and
surface/log the error (or show an error toast) so the rejection is handled and
no unhandled promise remains; ensure handleImportResolved is invoked only on
success.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 503ef866-ee07-4819-a6bb-7490e9115785

📥 Commits

Reviewing files that changed from the base of the PR and between 244f528 and cbfca95.

📒 Files selected for processing (14)
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/StyledWrapper.js
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.js
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx
  • packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js
  • packages/bruno-app/src/hooks/usePostmanPackagePrompt/index.js
  • packages/bruno-app/src/hooks/usePostmanPackagePrompt/index.spec.js
  • packages/bruno-converters/src/postman/postman-package-detector.js
  • packages/bruno-converters/src/postman/postman-to-bruno.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-package-detector-integration.spec.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-package-detector.spec.js
  • packages/bruno-electron/src/ipc/collection.js
  • packages/bruno-electron/src/utils/install-packages.js
  • packages/bruno-electron/tests/utils/install-packages.spec.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx (1)

100-141: ⚡ Quick win

Apply semicolons in the changed statements to match repo JS rules.

The updated lines still omit statement-ending semicolons.

As per coding guidelines, "Always add semicolons at the end of statements."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx`
around lines 100 - 141, Add missing statement-ending semicolons in the test:
terminate the mockCollection assignment, the const onClose = jest.fn()
declaration, and any standalone statements in the affected tests (e.g., the
renderModal(...) call results/assignments and expect(...) lines) with semicolons
so they follow the repo JS rule; specifically update the mockCollection
initializer, the onClose declaration, and the surrounding statements in the
"auto-dismisses..." test and related renderModal usages to end with a semicolon.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx`:
- Around line 122-141: The test "auto-dismisses when only dev-mode libs..."
should be made async-safe: mark the spec callback async, import and use waitFor
from `@testing-library/react`, and replace the immediate assertions on onClose and
container with awaited waitFor assertions (e.g., await waitFor(() =>
expect(onClose).toHaveBeenCalled()) and await waitFor(() =>
expect(container).toBeEmptyDOMElement())). Update the test that calls
renderModal to use these awaited waitFor checks so the assertions run after any
effects/state updates.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx`:
- Around line 100-141: Add missing statement-ending semicolons in the test:
terminate the mockCollection assignment, the const onClose = jest.fn()
declaration, and any standalone statements in the affected tests (e.g., the
renderModal(...) call results/assignments and expect(...) lines) with semicolons
so they follow the repo JS rule; specifically update the mockCollection
initializer, the onClose declaration, and the surrounding statements in the
"auto-dismisses..." test and related renderModal usages to end with a semicolon.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1e985181-8d5c-4717-95bc-840c3058f5c8

📥 Commits

Reviewing files that changed from the base of the PR and between cbfca95 and ac18cf4.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.js
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.spec.jsx
  • packages/bruno-converters/src/postman/postman-package-detector.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-package-detector.spec.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/bruno-converters/src/postman/postman-package-detector.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-package-detector.spec.js
  • packages/bruno-app/src/components/Sidebar/PostmanPackageReport/index.js

@sid-bruno
sid-bruno merged commit db91dbf into usebruno:main Jun 1, 2026
18 of 19 checks passed
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
sid-bruno pushed a commit to sid-bruno/bruno that referenced this pull request Aug 21, 2026
* feat: npm package report and installation support (usebruno#8143)

* feat: show scripted requests in timeline (usebruno#8047)

* fix(proxy): proxy config export from v2 to import in v3  (usebruno#8112)

* FIXED regression for proxy config from v2 to v3

* REMOVED console.log

* ADDED test case with fixture to test proxy import

* ADDED proxy handling for older brunoConfig in  packages/bruno-electron/src/utils/collection-import.js

* RESOLVED githiub converstation

changed afterAll --> afterEach

* ADDED guard to transformProxyConfig(brunoConfig.proxy) function

* fix: route runner scripted-request/oauth2-debug timeline entries

Use the enterprise per-iteration runner shape in the reducers, propagate
iterationIndex on all run-folder-event emits, and fix the bruno-js test
argument positions.

---------

Co-authored-by: naman-bruno <[email protected]>
Co-authored-by: Pooja <[email protected]>
Co-authored-by: Abhishek Patil <[email protected]>
Co-authored-by: lohit <[email protected]>
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.

3 participants