Aventuras/scripts/pm.js
Tony Frazier 0913b5ce7d
Route dev/build/release scripts through aube when it installed node_modules (#552)
## Summary

- Adds `scripts/package-manager.js`, which detects whether `aube` or
`npm` owns the current
`node_modules` (by checking for `node_modules/.aube-state`, then
confirming `aube` is still
on `PATH`) and builds the right `[cmd, args]` pair for
`spawnSync`/`execFileSync`, including
  the Windows `npm.cmd` workaround.
- Adds `scripts/pm.js`, a thin CLI (`node scripts/pm.js <args...>`) that
runs that detected
  package manager with the given arguments and forwards its exit status.
- Routes `lefthook.yml`'s `pre-push` `lint`/`check` commands and
`tauri.conf.json`'s
`beforeDevCommand`/`beforeBuildCommand` through `scripts/pm.js`, so they
use aube wherever
  aube did the install and npm otherwise.
- `scripts/release.js` keeps the version bump on npm (npm owns
`package-lock.json`), but now
runs its `format`/`lint:fix` steps through the detected package manager.
When that manager
is aube, it adds `--no-install --frozen-lockfile` so aube doesn't
re-resolve the lockfile npm
  just rewrote.
- Documents the new detection/routing behavior in
`docs/development/release.md`.

## Test plan

- [ ] `npm test` / `aube test` passes, including the new
`scripts/package-manager.test.js`
coverage for `detectPackageManager` and `commandFor` on both platforms.
- [ ] `npm run lint` / `aubr lint` and `npm run check` / `aubr check`
pass.
- [ ] Manually verify `npx tauri dev` still launches correctly on a
checkout with only npm
  installed, and on one where aube performed the install.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01YHkuCEJRUTBnsZaUnhfR9N

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Development, build, pre-push checks, and release tasks now use the
package manager detected for the project, supporting both npm and Aube.
* Command execution accounts for platform differences, including
Windows, and the existing lint memory limit is preserved.
* These changes apply to development and release workflows; they do not
change application features or behavior for end users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-28 14:34:27 -04:00

13 lines
478 B
JavaScript

/**
* Usage: node scripts/pm.js <args...> — same arg syntax as npm or aube directly, e.g.
* `run dev` or `run lint -- --fix`.
*/
import { spawnSync } from 'child_process'
import { detectPackageManager, commandFor } from './package-manager.js'
const [cmd, cmdArgs] = commandFor(detectPackageManager(), process.argv.slice(2))
const result = spawnSync(cmd, cmdArgs, { stdio: 'inherit' })
if (result.error) throw result.error
process.exit(result.signal ? 1 : result.status)