Skip to content

feat: add migration command for global cli - #313

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

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

Conversation

@fengmk2

@fengmk2fengmk2 commented Nov 21, 2025

Copy link
Copy Markdown
Member

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 fileecho'{"*.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.

@fengmk2Graphite App

fengmk2 commented Nov 21, 2025

Copy link
Copy Markdown
MemberAuthor

@fengmk2fengmk2 changed the title feat: add vite migration commandfeat(cli): add migration command for consolidating standalone toolsNov 21, 2025
@fengmk2fengmk2 changed the title feat(cli): add migration command for consolidating standalone toolsfeat(cli): add migration command for global cliNov 21, 2025
@fengmk2fengmk2 self-assigned this Nov 21, 2025
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from b2efe90 to ffb9f05CompareNovember 21, 2025 05:35
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 82e36fc to 6b0deacCompareNovember 21, 2025 05:35
@fengmk2fengmk2 changed the title feat(cli): add migration command for global clifeat: add migration command for global cliNov 21, 2025
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch 2 times, most recently from fcd5cbf to 88272abCompareNovember 21, 2025 07:28
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 2be81ff to 6fcd480CompareNovember 21, 2025 07:30
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from 88272ab to 7b89d29CompareNovember 21, 2025 07:30
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 6fcd480 to 68fe850CompareNovember 21, 2025 07:37
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from 7b89d29 to 349685cCompareNovember 21, 2025 07:37
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from 349685c to b6ca06eCompareNovember 21, 2025 07:51
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 61d1667 to c237124CompareNovember 21, 2025 08:25
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from b6ca06e to c109707CompareNovember 21, 2025 08:25
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from c237124 to f9bd6bfCompareNovember 21, 2025 08:47
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from c109707 to 9eae888CompareNovember 21, 2025 08:47
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from f9bd6bf to 952288eCompareNovember 21, 2025 08:59
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch from 9eae888 to 6d0c02eCompareNovember 21, 2025 08:59
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 952288e to e5bbf69CompareNovember 21, 2025 09:47
@fengmk2
fengmk2force-pushed the 11-18-feat_add_vite_migration_crate branch 2 times, most recently from da1d4d3 to 88f6cb5CompareNovember 21, 2025 09:54
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from e5bbf69 to 09993f5CompareNovember 21, 2025 09:54
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch 9 times, most recently from 1ba133d to fea670aCompareNovember 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, Copilot and wan9chi and removed request for CopilotNovember 27, 2025 12:38
CopilotAI review requested due to automatic review settings November 27, 2025 12:45
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from fea670a to 9b0b3d3CompareNovember 27, 2025 12:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
rfcs/migration-command.mdNew RFC documenting the migration command design, usage, and scope
crates/vite_migration/src/package.rsRefactored script rewriting to be content-based instead of file-based; added support for array-based scripts
crates/vite_migration/Cargo.tomlRemoved tokio dependency since migration is now synchronous
packages/cli/binding/src/migration.rsUpdated binding to use new rewriteScripts API
packages/cli/binding/index.jsUpdated export from rewritePackageJsonScripts to rewriteScripts
packages/cli/binding/index.d.tsUpdated TypeScript definitions for the new API
packages/global/src/migration/migrator.tsCore migration logic for standalone and monorepo projects
packages/global/src/migration/detector.tsConfiguration file detection logic
packages/global/src/migration/bin.tsCLI entry point for the migration command
packages/global/src/utils/*.tsSplit utilities into separate modules (json, yaml, package, prompts, command, path, workspace)
packages/global/rules/vite-tools.ymlRemoved 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.

Comment threadcrates/vite_migration/src/package.rs Outdated
Comment threadpackages/global/src/migration/bin.ts Outdated
Comment threadrfcs/migration-command.md
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/utils/yaml.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadrfcs/migration-command.md
Comment threadpackages/global/src/migration/migrator.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/bin.ts Outdated
Comment threadpackages/global/src/utils/json.ts
Comment threadpackages/global/src/migration/migrator.ts

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/utils/json.ts

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/detector.ts
Comment threadrfcs/migration-command.md

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/utils/json.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadcrates/vite_migration/src/package.rs
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
@fengmk2Graphite App

fengmk2 commented Nov 30, 2025

Copy link
Copy Markdown
MemberAuthor

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 freeto 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

@fengmk2@Brooooooklyn