feat: support pnpm / yarn / bun in purus new and purus init#10
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
purus newhardcodednpm init/npm install. This PR addspkg/lib/pm.js, which detects the package manager instead of assuming one — nothing is hardcoded to a specific manager:npm_config_user_agent— set by the launcher (npx,pnpm dlx,yarn dlx,bunx, and<pm> runscripts), sopnpm dlx purus new my-appnaturally uses pnpmpackage-lock.json,pnpm-lock.yaml,yarn.lock,bun.lock/bun.lockb) — relevant forpurus initin existing projectsWhat the detected manager drives
npm init [-y]/pnpm init/yarn init [-y])npm install --save-dev/pnpm add -D/yarn add --dev/bun add --dev)<pm> run ...script table)bun installetc.)purus init: suggests<pm> initwhen no package.json existsFor bun, whose
bun initscaffolds extra files (index.ts, tsconfig), a minimalpackage.jsonis written directly instead.Tests
Manually verified on Windows:
purus new demo -ywith npm:npm init -y+ auto-install ran, scripts addedpurus new demowith bun user agent: minimal package.json written, README and hints usebunFixes #3