refactor(installer): extract pure domain helpers#3107
Conversation
This reverts commit 4ebeae4.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces a new ChangesInstaller Domain Foundation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/domain/installer/provider.ts`:
- Around line 36-45: The help/usage text in installerProviderHelpValues() and
installerProviderUsageLines() is missing the accepted alias
"anthropiccompatible" and can drift from normalizeInstallerProvider; update the
hardcoded strings to include "anthropiccompatible" (matching the value accepted
by normalizeInstallerProvider) and, to prevent future drift, refactor to
export/use a single canonical list of provider/alias names (e.g., a const
PROVIDER_NAMES or PROVIDER_ALIASES) referenced by installerProviderHelpValues(),
installerProviderUsageLines(), and normalizeInstallerProvider so all three read
from the same source of truth.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a07181f3-ce79-430b-b4e8-bb1c1b008c05
📒 Files selected for processing (8)
src/lib/domain/installer/npm.test.tssrc/lib/domain/installer/npm.tssrc/lib/domain/installer/provider.test.tssrc/lib/domain/installer/provider.tssrc/lib/domain/installer/ref.test.tssrc/lib/domain/installer/ref.tssrc/lib/domain/installer/version.test.tssrc/lib/domain/installer/version.ts
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Automated PR review summaryReviewed PR #3107: refactor(installer): extract pure domain helpers Recommendation
Installation and setup findings
What was validated
Failing tests and unresolved impact
Passing tests and why they matteredPassing test 1: Provider normalization/help parity
Passing test 2: Install ref/version precedence parity
Passing test 3: npm link-target writability parity
Passing test 4: Runtime version gate parity
Bottom line
|
cjagwani
left a comment
There was a problem hiding this comment.
pure additions, 1:1 faithful to install.sh equivalents (npm_link_targets_writable, version_gte, getNonInteractiveProvider, resolve_release_tag). 40 assertions across 10 test cases cover empty/whitespace/prerelease/multi-failure-mode edges. type sigs are discriminated unions, no narrowing regressions.
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
prekshivyas
left a comment
There was a problem hiding this comment.
Pure additive helper extraction, same staging as #3080 → #3083. install.sh is untouched; this lands the typed planning layer first. Four typed modules + four matching test files under src/lib/domain/installer/:
version.ts—versionGte,versionMajor,checkInstallerRuntimewith constantsMIN_NODE_VERSION = \"22.16.0\",MIN_NPM_MAJOR = 10. Tagged result with reason codes (invalid-node-version/invalid-npm-version/unsupported).provider.ts— 9 canonical provider values + 3 aliases (anthropiccompatible,cloud,nim); case/trim/alias normalization innormalizeInstallerProvider.ref.ts—resolveInstallRef(env priorityNEMOCLAW_INSTALL_REF>NEMOCLAW_INSTALL_TAG>\"latest\"),resolveInstallerVersionwith multi-source fallback (ref-version > git-describe > stamped > package.json > default).npm.ts—npmLinkTargetsWritablewith tagged result (bin-unwritable/lib-unwritable/empty-prefix) and chained existence/writability checks;pathWithPrependedEntries(no duplicates).
Test coverage is the right shape for a parity-with-shell extraction: edge cases (0.18.1 ≥ 0.18.0, 22.16 vs 22.16.0, RC tags rejected, all 4 writability outcomes including chained fallback to prefix-writability), round-trip invariants (every INSTALLER_PROVIDER_VALUES entry and every alias normalizes correctly), and explicit help-text string matches that act as a regression net against install.sh divergence.
Observations (non-blocking):
MIN_NODE_VERSION/MIN_NPM_MAJORduplicate the valuesinstall.shuses today. A comment pointing at the canonical shell source would help future maintainers know where to update both, but this matches the duplication pattern accepted in the #3080 uninstall extraction.installerVersionFromRefedge case:ref = \"v\"returnsfallbackVersionrather thannull. Minor, not exercised by tests but consistent with the "strip v, fall back if empty" intent.
CI: pr.yaml lightweight checks pass (commit-lint, dco, layer-boundary, check-hash, changes). checks / macos-e2e / 2 self-hosted runs still in progress at approval time.
Summary
Extracts pure installer decision helpers into typed domain modules as the first step toward moving installer behavior out of shell. This adds TypeScript coverage for release ref resolution, runtime version checks, provider normalization, and npm prefix/link target decisions without changing installer shell behavior yet.
Changes
src/lib/domain/installer/version.tsfor semver/runtime support checks.src/lib/domain/installer/provider.tsfor installer provider aliases and help values.src/lib/domain/installer/ref.tsfor install ref and installer version source precedence.src/lib/domain/installer/npm.tsfor npm global bin/path and link-target writability decisions.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit