refactor(scope): use nested directories for scoped packages#113
refactor(scope): use nested directories for scoped packages#113BlackHole1 merged 1 commit intomainfrom
Conversation
Remove the `+` hack that replaced `/` with `+` in scoped package names. Scoped packages like `@scope/pkg-1.0.0` now use proper nested directory structure (`@scope/pkg-1.0.0`) instead of flattened paths (`@scope+pkg-1.0.0`). Key changes: - Remove `normalizePackageName()` function - Update `move()` to lazily create parent directories on ENOENT - Add comprehensive tests for scoped package handling with nested deps BREAKING CHANGE: Existing distDir with `+` format directories will not be recognized. Users need to reinstall packages. Signed-off-by: Kevin Cui <bh@bugs.cc>
Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis pull request refactors scoped package handling by removing the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom Pre-merge Checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (16)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (3)src/cmd/install.ts (3)
src/cmd/list.test.ts (3)
src/cmd/install.test.ts (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (19)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the package storage system to use proper nested directory structures for scoped packages (e.g., @scope/pkg-1.0.0) instead of the previous flattened format using + as a separator (e.g., @scope+pkg-1.0.0).
Key changes:
- Removed the
normalizePackageName()utility function that converted/to+in package names - Updated the
move()function to create parent directories before moving files, enabling nested directory support - Added comprehensive test coverage for scoped package handling, including nested scoped dependencies
Reviewed changes
Copilot reviewed 10 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/utils/misc.ts |
Removed normalizePackageName() function that was previously used to flatten scoped package names |
src/utils/fs.ts |
Removed normalizePackageName import, added parent directory creation in move(), and updated walk() to use unmodified package names |
src/cmd/install.ts |
Removed normalizePackageName import and replaced all usages with direct package names for proper nested directory paths |
src/utils/fs.test.ts |
Added comprehensive tests for walk(), mkdir(), and exists() functions with scoped packages and nested dependencies |
src/cmd/list.test.ts |
Updated test assertions to expect nested directory paths instead of flattened paths with + separator |
src/cmd/install.test.ts |
Updated test assertions and added new test for scoped packages with scoped sub-dependencies via integrity check |
tests/fixtures/scoped_package_with_deps/* |
Added new test fixture with nested directory structure demonstrating scoped package with both normal and scoped dependencies |
tests/fixtures/scoped_package_list/* |
Updated fixture structure to use nested directories for scoped packages |
tests/fixtures/scoped_package_install/* |
Updated fixture structure to use nested directories for scoped packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export async function move(src: string, dest: string) { | ||
| try { | ||
| await mkdir(path.dirname(dest)); | ||
| await fsP.rename(src, dest); | ||
| } | ||
| catch (err) { |
There was a problem hiding this comment.
The new parent directory creation logic in the move function should be covered by tests, especially for scoped packages where nested directories are critical. Consider adding a test case that calls move() with a destination path containing nested directories (like moving to @scope/pkg-1.0.0) to verify parent directories are properly created.
Remove the
+hack that replaced/with+in scoped package names. Scoped packages like@scope/pkg-1.0.0now use proper nested directory structure (@scope/pkg-1.0.0) instead of flattened paths (@scope+pkg-1.0.0).Key changes:
normalizePackageName()functionmove()to lazily create parent directories on ENOENTBREAKING CHANGE: Existing distDir with
+format directories will not be recognized. Users need to reinstall packages.