feat: add strict input validation and robust plugin registration - #189
Conversation
…rove target selection and caching
WalkthroughThe PR introduces stricter input validation for features (default/full), replaces GitHub Actions error signaling with exception throwing, refactors shell command execution with a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Comment |
Code Analysis
Security Review
Optimization Suggestions
Overall Quality: 3 Note: While the code improvements show good architectural patterns and error handling, security concerns around command injection and path handling prevent a higher rating. The refactoring demonstrates solid TypeScript practices but requires additional security hardening. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/plugins.ts (1)
78-83: Consistent execOrThrow usage with the template; optional DRY opportunityMirroring the
execOrThrow+registerCommandpattern fromsrc/plugins-tpl.tskeeps the runtime implementation aligned with the template and ensures plugin registration failures are surfaced uniformly. If you find these helpers evolve further, consider extracting a small shared utility to avoid the two copies drifting over time, but it’s perfectly fine as-is.Also applies to: 91-94, 99-99
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
dist/index.jsis excluded by!**/dist/**
📒 Files selected for processing (4)
src/index.ts(2 hunks)src/plugins-tpl.ts(1 hunks)src/plugins.ts(1 hunks)src/setup.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/setup.ts (1)
dist/index.js (14)
PLATFORM_DEFAULT_MAP(57659-57668)PLATFORM_FULL_MAP(57669-57678)path(150-150)path(641-641)path(1266-1266)path(2739-2739)path(2928-2928)path(3473-3473)path(57654-57654)core(3373-3373)core(3467-3467)core(57417-57417)core(57655-57655)tc(57656-57656)
src/plugins.ts (1)
dist/index.js (1)
pluginRegisterScript(57491-57553)
src/plugins-tpl.ts (1)
dist/index.js (1)
pluginRegisterScript(57491-57553)
🔇 Additional comments (5)
src/plugins-tpl.ts (1)
18-23: execOrThrow-based registration flow looks soundCentralizing shell command handling via
execOrThrowand driving both theregister-plugins.nuanddo-register.nuinvocations through it makes failures explicit and keeps the registration logic straightforward. No issues spotted with the legacy flag handling or argument construction here.Also applies to: 31-34, 39-39
src/setup.ts (2)
55-60: Explicit target resolution + error is a nice tighteningSelecting the platform map from
featuresand throwing when no targets exist forselectormakes failures much clearer than quietly returningundefined. The assertion cast toPlatformis safely backed by the runtime guard.
305-310: Graceful cache fallback when no nu_plugin_ binaries are found*Using
extractDirascacheSourcewhenpathsis empty and emitting a warning avoids the previous potential crash onpaths[0]while still caching a usable directory. This should make odd/changed archive layouts more robust without affecting the common case.src/index.ts (2)
19-23: Stricter input validation for features and version is appropriateConstraining
featuresto'default' | 'full'and throwing on invalid values, plus throwing whensemver.coerce/validcan’t produce a version, makes misconfiguration fail fast and keeps downstream code simpler. This also aligns well with the typedfeaturesinTool.Also applies to: 29-29
46-48: Workspace directory fallback improves local run behaviorDeriving
workspaceDirfromGITHUB_WORKSPACEwith a fallback toprocess.cwd()is a sensible improvement over assuming the env var is always set. Thecdthen applies cleanly to both CI and local use cases.
feat: add strict input validation and robust plugin registration; improve target selection and caching
Summary by CodeRabbit
Bug Fixes
Refactor