Skip to content

fix: correct package-manager detection and harden the CLI#1

Merged
arzafran merged 2 commits into
mainfrom
fix/detection-and-tooling
Jun 3, 2026
Merged

fix: correct package-manager detection and harden the CLI#1
arzafran merged 2 commits into
mainfrom
fix/detection-and-tooling

Conversation

@arzafran
Copy link
Copy Markdown
Member

@arzafran arzafran commented Jun 3, 2026

What this does

Omnes advertised monorepo support — "run it from any sub-package and it finds the root lockfile" — but that never worked. The directory walk had an off-by-one bug that made it check only the directory you started in, so running omnes install from packages/api silently fell back to npm even when the root had a pnpm-lock.yaml. This fixes the walk so detection works from anywhere in the tree, and adds support for the Corepack packageManager field that modern repos pin.

It also cleans up a handful of smaller correctness gaps and gives the project tests + CI so these don't regress.

Summary

  • Detection walks up to the filesystem root (detectPackageManager). The old root = dirname(startDir) sentinel exited the loop after one iteration. Verified from a subdirectory end-to-end.
  • Corepack packageManager field is honored and takes precedence over a lockfile in the same directory; closest directory wins.
  • Lockfile priority now matches the README (yarn before npm).
  • --version reads from package.json instead of a hardcoded string that had drifted to 0.1.0.
  • --help / --version print to stdout (were on stderr, so --version | cat produced nothing).
  • Missing package manager exits 127 as the API table documents (was 1).
  • Using: line shows the resolved command (Using bun: bun run dev).
  • Refactor: pure logic extracted to src/lib.ts; src/omnes.ts is a thin bin.
  • Tooling: Biome, typecheck/test/lint/format scripts, GitHub Actions CI, .tldr/ gitignored.
  • Release: version bumped to 0.1.3.

Test Plan

  • bun run typecheck — clean
  • bun run lint (Biome) — clean
  • bun run test — 13/13 pass (traversal, Corepack, priority, npm arg transform)
  • bun run build — succeeds, tests excluded from dist/
  • bun install --frozen-lockfile — no changes (CI-safe)
  • Manual: --versionomnes v0.1.3 on stdout; detection from src/ resolves bun via root bun.lock

arzafran added 2 commits June 3, 2026 16:38
The monorepo traversal never actually walked up the directory tree — it
only checked the starting directory, so running omnes from a sub-package
fell back to npm instead of finding the root lockfile. Detection now
walks to the filesystem root, honors a Corepack "packageManager" field,
and matches the lockfile priority documented in the README (yarn before
npm).

Also fixes: --version reported a hardcoded "0.1.0" (now read from
package.json), --help/--version print to stdout instead of stderr, the
"Using" line shows the fully resolved command, and a missing package
manager exits 127 as documented.

Pure logic is extracted into src/lib.ts with unit tests covering
traversal, Corepack, priority, and the npm arg transform. Adds Biome,
typecheck/test/lint scripts, and a GitHub Actions CI workflow.
@arzafran arzafran merged commit a00aace into main Jun 3, 2026
3 checks passed
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.

1 participant