feat: add migration command for global cli#313
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
b2efe90 to
ffb9f05
Compare
82e36fc to
6b0deac
Compare
fcd5cbf to
88272ab
Compare
2be81ff to
6fcd480
Compare
88272ab to
7b89d29
Compare
6fcd480 to
68fe850
Compare
7b89d29 to
349685c
Compare
349685c to
b6ca06e
Compare
61d1667 to
c237124
Compare
b6ca06e to
c109707
Compare
c237124 to
f9bd6bf
Compare
c109707 to
9eae888
Compare
f9bd6bf to
952288e
Compare
9eae888 to
6d0c02e
Compare
952288e to
e5bbf69
Compare
da1d4d3 to
88f6cb5
Compare
e5bbf69 to
09993f5
Compare
1ba133d to
fea670a
Compare
fea670a to
9b0b3d3
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new vite migration command to automate the migration from standalone tools (vite, vitest, oxlint, oxfmt, tsdown) to the unified vite-plus toolchain. The implementation refactors the script rewriting system to be more flexible and adds support for migrating lint-staged configurations.
Key changes include:
- Refactored
rewritePackageJsonScripts→rewriteScriptswith a content-based API that accepts strings instead of file paths and returns updated content instead of writing directly - Added support for migrating lint-staged configurations in both package.json and standalone .lintstagedrc.json files
- Removed async tokio dependency from the vite_migration crate (now synchronous)
- Reorganized global package utilities into separate modules (json.ts, yaml.ts, package.ts, prompts.ts, command.ts)
- Added comprehensive RFC documentation for the migration command
Reviewed changes
Copilot reviewed 51 out of 54 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| rfcs/migration-command.md | New RFC documenting the migration command design, usage, and scope |
| crates/vite_migration/src/package.rs | Refactored script rewriting to be content-based instead of file-based; added support for array-based scripts |
| crates/vite_migration/Cargo.toml | Removed tokio dependency since migration is now synchronous |
| packages/cli/binding/src/migration.rs | Updated binding to use new rewriteScripts API |
| packages/cli/binding/index.js | Updated export from rewritePackageJsonScripts to rewriteScripts |
| packages/cli/binding/index.d.ts | Updated TypeScript definitions for the new API |
| packages/global/src/migration/migrator.ts | Core migration logic for standalone and monorepo projects |
| packages/global/src/migration/detector.ts | Configuration file detection logic |
| packages/global/src/migration/bin.ts | CLI entry point for the migration command |
| packages/global/src/utils/*.ts | Split utilities into separate modules (json, yaml, package, prompts, command, path, workspace) |
| packages/global/rules/vite-tools.yml | Removed tsdown migration rules (out of scope for this PR) |
| packages/global/templates/monorepo/* | Updated templates to remove vite-plus pre-configuration (applied during migration instead) |
| packages/global/snap-tests/migration-lintstagedrc/* | Integration test for lint-staged migration |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 57 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 61 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 59 out of 62 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 59 out of 62 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 67 out of 70 changed files in this pull request and generated 5 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

TL;DR
Refactored the package script migration system to be more flexible and support additional use cases like lint-staged configurations.
What changed?
rewritePackageJsonScriptstorewriteScriptswith a more flexible APInullwhen no changes are neededHow to test?
Test with a project that has lint-staged configuration:
Test with a standalone .lintstagedrc.json file:
Verify that:
Why make this change?
The previous implementation was limited to only migrating scripts in package.json and required file system access. This refactoring makes the script migration system more flexible and reusable across different contexts.
By supporting lint-staged configurations, we ensure that pre-commit hooks are properly migrated to use the unified vite-plus commands. This is particularly important for maintaining code quality workflows during migration.
The new design also follows better separation of concerns - the core migration logic doesn't need to know about file paths or perform I/O operations, making it easier to test and more composable.