Skip to content

feat: add migration command for global cli#313

Merged
fengmk2 merged 3 commits intomainfrom
11-21-feat_add_vite_migration_command
Nov 30, 2025
Merged

feat: add migration command for global cli#313
fengmk2 merged 3 commits intomainfrom
11-21-feat_add_vite_migration_command

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Nov 21, 2025

TL;DR

Refactored the package script migration system to be more flexible and support additional use cases like lint-staged configurations.

What changed?

  • Renamed rewritePackageJsonScripts to rewriteScripts with a more flexible API
    • Now accepts script content as a string instead of requiring file paths
    • Returns the updated content instead of writing to files directly
    • Returns null when no changes are needed
  • Added support for migrating lint-staged configurations in package.json and .lintstagedrc.json
  • Removed tokio dependency from vite_migration crate
  • Added comprehensive test coverage for the new functionality
  • Created a new migration command infrastructure in the global package
  • Added snap tests to verify lint-staged migration works correctly

How to test?

  1. Test with a project that has lint-staged configuration:

    # Create a project with lint-staged config
    mkdir test-project && cd test-project
    echo '{"lint-staged":{"*.js":["oxlint --fix"]}}' > package.json
    
    # Run migration
    vite migration
  2. Test with a standalone .lintstagedrc.json file:

    # Create a .lintstagedrc.json file
    echo '{"*.js":"oxlint --fix"}' > .lintstagedrc.json
    
    # Run migration
    vite migration
  3. Verify that:

    • The lint-staged configurations are properly updated
    • Both array and string formats are handled correctly
    • The migration preserves the original structure

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.

Copy link
Copy Markdown
Member Author

fengmk2 commented Nov 21, 2025

@fengmk2 fengmk2 changed the title feat: add vite migration command feat(cli): add migration command for consolidating standalone tools Nov 21, 2025
@fengmk2 fengmk2 changed the title feat(cli): add migration command for consolidating standalone tools feat(cli): add migration command for global cli Nov 21, 2025
@fengmk2 fengmk2 self-assigned this Nov 21, 2025
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from b2efe90 to ffb9f05 Compare November 21, 2025 05:35
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 82e36fc to 6b0deac Compare November 21, 2025 05:35
@fengmk2 fengmk2 changed the title feat(cli): add migration command for global cli feat: add migration command for global cli Nov 21, 2025
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch 2 times, most recently from fcd5cbf to 88272ab Compare November 21, 2025 07:28
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 2be81ff to 6fcd480 Compare November 21, 2025 07:30
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from 88272ab to 7b89d29 Compare November 21, 2025 07:30
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 6fcd480 to 68fe850 Compare November 21, 2025 07:37
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from 7b89d29 to 349685c Compare November 21, 2025 07:37
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from 349685c to b6ca06e Compare November 21, 2025 07:51
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 61d1667 to c237124 Compare November 21, 2025 08:25
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from b6ca06e to c109707 Compare November 21, 2025 08:25
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from c237124 to f9bd6bf Compare November 21, 2025 08:47
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from c109707 to 9eae888 Compare November 21, 2025 08:47
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from f9bd6bf to 952288e Compare November 21, 2025 08:59
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch from 9eae888 to 6d0c02e Compare November 21, 2025 08:59
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 952288e to e5bbf69 Compare November 21, 2025 09:47
@fengmk2 fengmk2 force-pushed the 11-18-feat_add_vite_migration_crate branch 2 times, most recently from da1d4d3 to 88f6cb5 Compare November 21, 2025 09:54
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from e5bbf69 to 09993f5 Compare November 21, 2025 09:54
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch 9 times, most recently from 1ba133d to fea670a Compare November 27, 2025 12:36
@fengmk2 fengmk2 marked this pull request as ready for review November 27, 2025 12:38
@fengmk2 fengmk2 requested review from Brooooooklyn, branchseer and Copilot and removed request for Copilot November 27, 2025 12:38
Copilot AI review requested due to automatic review settings November 27, 2025 12:45
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from fea670a to 9b0b3d3 Compare November 27, 2025 12:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rewritePackageJsonScriptsrewriteScripts with 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

fengmk2 commented Nov 30, 2025

Merge activity

  • Nov 30, 6:23 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 30, 6:23 AM UTC: @fengmk2 merged this pull request with Graphite.

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.

3 participants