Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix experiment #254

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Quick fix experiment #254

wants to merge 6 commits into from

Conversation

alanknight-wk
Copy link
Contributor

@alanknight-wk alanknight-wk commented Oct 19, 2023

Motivation

The codemod is heavy, and designed for large migrations a package at a time. We'd like to be able to re-use the logic, but do it in a faster and much smaller way. This is an experiment in invoking something quickly that can make an individual change.

My thought is to write a special-purpose migrator that takes a file name and a character position. So if we give it a character position anywhere within a string it migrates just that string and exits.

Right now, all this does is run just the constant migrator on a single file. If it's already been compiled, then it runs in sub-second time. But that's not doing a ddev format on the _intl.dart file. So we could accept that and leave it unformatted, or we could make the IDE extension run the format on save operation, which is generally faster, or something else. I'm thinking something like

dart pub global run over_react_codemod:intl_quick --character-position=12345 --file=lib/src/stuff/thing.dart

So this seems reasonably promising. The migrators can run without a resolved analysis, and do it pretty quickly.

We'd still need to validate we can call this from the IDE extensions easily and get the information we need. And things like revert would take some doing.

Changes

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Frontend Frameworks Design member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

// final intlPropMigrator = IntlMigrator(messages.className, messages);
final constantStringMigrator =
ConstantStringMigrator(messages.className, messages);
// final importMigrator = (FileContext context) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should probably run the importer too, so unwind the change to run only a single migrator. But we shouldn't (I think) need the change that runs them all sequentially. Or we could let the IDE Extension still do the import.

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants