[PR #139] [MERGED] fix(init): detect Bun and invoking package manager reliably #341

Closed
opened 2026-05-06 12:39:19 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/139
Author: @liuxiaopai-ai
Created: 2/26/2026
Status: Merged
Merged: 3/3/2026
Merged by: @southpolesteve

Base: mainHead: fix/issue-109-package-manager-detection


📝 Commits (2)

  • e20e62b fix(init): detect bun and invoking package manager reliably
  • 5e0790b refactor: address review feedback on detectPackageManagerName

📊 Changes

2 files changed (+121 additions, -16 deletions)

View changed files

📝 packages/vinext/src/utils/project.ts (+69 -15)
📝 tests/init.test.ts (+52 -1)

📄 Description

Summary

Fixes package manager detection for vinext init / deploy dependency installs when lock files are missing or Bun is used.

What changed

  • Extend lockfile detection to support both Bun lockfile names:
    • bun.lockb (legacy)
    • bun.lock (current)
  • Detect package manager from package.json#packageManager when no lockfile exists.
  • Detect invoking package manager from npm_config_user_agent as a final hint (e.g. bun x vinext init, pnpm dlx vinext init).
  • Keep deterministic fallback to npm when no hints are available.
  • Reuse detectPackageManagerName() in detectPackageManager() to keep behavior consistent.

Why

Issue #109 reports that running bun x vinext init still installs deps via npm. This happened because detection only checked lock files and only recognized bun.lockb.

Fixes #109

Test plan

  • pnpm -s test tests/init.test.ts
  • pnpm -s test tests/deploy.test.ts

New coverage (init tests)

  • uses Bun when bun.lock exists
  • uses packageManager from package.json when lockfiles are missing
  • uses invoking package manager from npm_config_user_agent
  • falls back to npm when no PM hints exist

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/139 **Author:** [@liuxiaopai-ai](https://github.com/liuxiaopai-ai) **Created:** 2/26/2026 **Status:** ✅ Merged **Merged:** 3/3/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/issue-109-package-manager-detection` --- ### 📝 Commits (2) - [`e20e62b`](https://github.com/cloudflare/vinext/commit/e20e62b4a41a71ad056d3b755007dc1fbf1ed37f) fix(init): detect bun and invoking package manager reliably - [`5e0790b`](https://github.com/cloudflare/vinext/commit/5e0790b64209cef64d96bc7a896f62df8dabf143) refactor: address review feedback on detectPackageManagerName ### 📊 Changes **2 files changed** (+121 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/utils/project.ts` (+69 -15) 📝 `tests/init.test.ts` (+52 -1) </details> ### 📄 Description ## Summary Fixes package manager detection for `vinext init` / deploy dependency installs when lock files are missing or Bun is used. ### What changed - Extend lockfile detection to support both Bun lockfile names: - `bun.lockb` (legacy) - `bun.lock` (current) - Detect package manager from `package.json#packageManager` when no lockfile exists. - Detect invoking package manager from `npm_config_user_agent` as a final hint (e.g. `bun x vinext init`, `pnpm dlx vinext init`). - Keep deterministic fallback to npm when no hints are available. - Reuse `detectPackageManagerName()` in `detectPackageManager()` to keep behavior consistent. ### Why Issue #109 reports that running `bun x vinext init` still installs deps via npm. This happened because detection only checked lock files and only recognized `bun.lockb`. Fixes #109 ## Test plan - `pnpm -s test tests/init.test.ts` - `pnpm -s test tests/deploy.test.ts` ### New coverage (init tests) - uses Bun when `bun.lock` exists - uses `packageManager` from package.json when lockfiles are missing - uses invoking package manager from `npm_config_user_agent` - falls back to npm when no PM hints exist --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:19 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#341
No description provided.