Skip to content

feat: support pnpm / yarn / bun in purus new and purus init#10

Merged
otnc merged 1 commit into
mainfrom
fix/issue-3-package-managers
Jul 14, 2026
Merged

feat: support pnpm / yarn / bun in purus new and purus init#10
otnc merged 1 commit into
mainfrom
fix/issue-3-package-managers

Conversation

@otnc

@otnc otnc commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

purus new hardcoded npm init / npm install. This PR adds pkg/lib/pm.js, which detects the package manager instead of assuming one — nothing is hardcoded to a specific manager:

  1. npm_config_user_agent — set by the launcher (npx, pnpm dlx, yarn dlx, bunx, and <pm> run scripts), so pnpm dlx purus new my-app naturally uses pnpm
  2. Lockfile in the target directory (package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lock / bun.lockb) — relevant for purus init in existing projects
  3. npm as the final fallback

What the detected manager drives

  • package.json init (npm init [-y] / pnpm init / yarn init [-y])
  • devDependency install (npm install --save-dev / pnpm add -D / yarn add --dev / bun add --dev)
  • the generated README (install command and <pm> run ... script table)
  • post-create hints (bun install etc.)
  • purus init: suggests <pm> init when no package.json exists

For bun, whose bun init scaffolds extra files (index.ts, tsconfig), a minimal package.json is written directly instead.

Tests

Manually verified on Windows:

  • user-agent detection for pnpm / yarn / bun / npm / unknown (falls back to npm)
  • purus new demo -y with npm: npm init -y + auto-install ran, scripts added
  • purus new demo with bun user agent: minimal package.json written, README and hints use bun

Fixes #3

`purus new` hardcoded npm for project init and dependency install.
Add pkg/lib/pm.js, which detects the package manager instead of
assuming one:

1. npm_config_user_agent — set by the launcher (npx, pnpm dlx,
   yarn dlx, bunx, and <pm> run scripts)
2. lockfile in the target directory (package-lock.json,
   pnpm-lock.yaml, yarn.lock, bun.lock/bun.lockb)
3. npm as the final fallback

The detected manager drives package.json init, devDependency
installation, the generated README (install/run commands), and the
post-create hints. For bun, whose `init` scaffolds extra files
(index.ts, tsconfig), a minimal package.json is written directly.
`purus init` suggests `<pm> init` based on the same detection.

Fixes #3
@otnc
otnc merged commit 26ca38a into main Jul 14, 2026
1 check passed
@otnc
otnc deleted the fix/issue-3-package-managers branch July 14, 2026 04:58
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.

support package managers: new / create

1 participant