Skip to content

fix(npa): Cleanup NPA code - #23358

Merged
markovejnovic merged 0 commit into
cleanup/npa-handlingfrom
user/markovejnovic/npa-handling-cleanup
Oct 8, 2025
Merged

markovejnovic merged 0 commit into
cleanup/npa-handlingfrom
user/markovejnovic/npa-handling-cleanup

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

What does this PR do?

How did you verify your code works?

@robobun

robobun commented Oct 8, 2025 •

Copy link
Copy Markdown
Collaborator
Updated 11:07 PM PT - Oct 7th, 2025

❌ @markovejnovic, your commit 3df1f27 has 9 failures in Build #28457 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 23358

That installs a local version of the PR into your bun-23358 executable, so you can run:

bun-23358 --bun

@markovejnovic
markovejnovic changed the base branch from main to cleanup/npa-handling October 8, 2025 01:52
@markovejnovic
markovejnovic merged this pull request into cleanup/npa-handling Oct 8, 2025
@markovejnovic
markovejnovic deleted the user/markovejnovic/npa-handling-cleanup branch October 8, 2025 01:53
@coderabbitai

coderabbitai Bot commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Adds URL fragment/hash accessors and Zig bindings; introduces hosted Git info parsing module with JS testing APIs and tests; implements npm-package-arg parsing/resolution with JS interop and tests; adds npm package name validator with tests; extends string and path utilities; adjusts which to use new path-slasher helpers; minor URL docs.

Changes

Cohort / File(s) Summary of changes
URL fragment accessors
src/bun.js/bindings/BunString.cpp, src/bun.js/bindings/URL.zig
New externs URL__hash and URL__fragmentIdentifier in C++; Zig extern bindings and public wrappers hash() and fragmentIdentifier().
Hosted Git info module + tests
src/install/hosted_git_info.zig, test/cli/install/hosted-git-info/*
New HostedGitInfo type, parsing pipeline, host providers, JS interop TestingAPIs, and tests for parseUrl/fromUrl with valid/invalid cases data.
npm-package-arg (NPA) module + tests
src/install/npm_package_arg.zig, test/cli/install/npm-package-arg/*
New NpaSpec union, NpaError, npa entrypoint, resolve workflow, JS TestingAPIs, file URL/path helpers, and comprehensive test suites/fixtures.
Validate npm package name + tests
src/install/validate_npm_package_name.zig, test/cli/install/validate-npm-package-name/*
New validator module with errors/warnings enums, result struct, validate(), JS TestingAPIs, and test fixtures/assertions.
Internal testing exports
src/js/internal-for-testing.ts
Remove previous Dependency/npa export; add hostedGitInfo (parseUrl/fromUrl), Npa (npa/resolve), and ValidateNpmPackageName.validate exports.
String utilities
src/string.zig, src/string/immutable.zig
Add hasPrefixComptimeCaseInsensitive; add multiple helpers (lastIndexBeforeChar, hasSuffixComptimeType, drop, trimSuffixComptime, trimSpaces, isAllLowercaseASCII); change concat/concatWithLength to return bun.OOM![]u8.
Comptime string map
src/comptime_string_map.zig
Add getKey(value: V) to return key by value via linear search.
Path slash detection + which
src/resolver/resolve_path.zig, src/which.zig
Add hasPathSlashes/hasWindowsPathSlashes/hasPosixPathSlashes; update which/whichWin to use bun.path.hasPathSlashes.
URL docstring
src/url.zig
Add documentation clarifying parser safety; no functional changes.
Hosted Git test data
test/cli/install/hosted-git-info/cases.ts
Add valid/invalid URL fixtures for multiple providers.

Suggested reviewers

  • Jarred-Sumner
  • nektro
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch user/markovejnovic/npa-handling-cleanup

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5f1ca17 and 3df1f27.

📒 Files selected for processing (21)
  • src/bun.js/bindings/BunString.cpp (1 hunks)
  • src/bun.js/bindings/URL.zig (1 hunks)
  • src/comptime_string_map.zig (1 hunks)
  • src/install/hosted_git_info.zig (1 hunks)
  • src/install/npm_package_arg.zig (1 hunks)
  • src/install/validate_npm_package_name.zig (1 hunks)
  • src/js/internal-for-testing.ts (1 hunks)
  • src/resolver/resolve_path.zig (1 hunks)
  • src/string.zig (1 hunks)
  • src/string/immutable.zig (7 hunks)
  • src/url.zig (1 hunks)
  • src/which.zig (2 hunks)
  • test/cli/install/hosted-git-info/cases.ts (1 hunks)
  • test/cli/install/hosted-git-info/from-url.test.ts (1 hunks)
  • test/cli/install/hosted-git-info/parse-url.test.ts (1 hunks)
  • test/cli/install/npm-package-arg/cases.ts (1 hunks)
  • test/cli/install/npm-package-arg/index.test.ts (1 hunks)
  • test/cli/install/npm-package-arg/invalid-url.test.ts (1 hunks)
  • test/cli/install/npm-package-arg/realize-package-specifier.test.ts (1 hunks)
  • test/cli/install/validate-npm-package-name/cases.ts (1 hunks)
  • test/cli/install/validate-npm-package-name/index.ts (1 hunks)

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

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