-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add Agent Skill for S1 to S2 migration #9778
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5b0ef13
fixed TabList render function children kept Item instead of convertin…
reidbarber be66290
import cleanup: removeComponentImport was only checking the first mat…
reidbarber 914f03c
dynamic import('@react-spectrum/s2') was incorrectly flagged as a v3 …
reidbarber d596a6c
Fixed in codemod options parsing
reidbarber 171529a
more import fixes
reidbarber a2509b5
add agent mode (non-interactive, run transforms only)
reidbarber 48f1768
add e2e tests
reidbarber ff6271f
have --components include related components
reidbarber 5c023f9
yarn.lock
reidbarber b871a88
update outdated links
reidbarber 6186108
Merge branch 'main' into codemod-fixes
reidbarber 4d6af4c
bump @adobe/react-spectrum version
reidbarber 323ad01
fix missing imports and remove unused
reidbarber 9bb8185
Merge remote-tracking branch 'origin/main' into codemod-fixes
reidbarber 3e71ffb
fix snapshot
reidbarber 83b52c6
yarn.lock
reidbarber 62a60ab
map illustrations to s2 illustrations
reidbarber d4dfa4e
Merge remote-tracking branch 'origin/main' into codemod-fixes
reidbarber 631e45a
initialize migration skill
reidbarber 693d822
typo
reidbarber 202903e
update README
reidbarber eb12fc2
Merge branch 'main' into s1-to-s2-upgrade-skill
reidbarber 8a70ab7
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber eacd571
Merge branch 's1-to-s2-upgrade-skill' of https://github.com/adobe/rea…
reidbarber 80d9703
add more content to skill content
reidbarber f39e420
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber a6bd663
lint
reidbarber 3d7fb2a
update migration skill
reidbarber 17e26a2
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber 9ca95bd
update docs
reidbarber b9b90b7
reference react-spectrum-s2 in migration skill
reidbarber 0d85709
rename skill to migrate-react-spectrum-v3-to-s2
reidbarber 3502ec0
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber 7f8faf2
improve skill content
reidbarber a01ed2a
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber 762f601
include scope and final report
reidbarber c0f1ac3
Merge remote-tracking branch 'origin/main' into s1-to-s2-upgrade-skill
reidbarber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
packages/dev/s2-docs/migration-references/focused-manual-fixes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # Manual fixes after the codemod | ||
|
|
||
| ## Icons and illustrations | ||
|
|
||
| - If the codemod leaves `TODO(S2-upgrade)` next to an icon or illustration import, pick the nearest S2 replacement manually. | ||
|
|
||
| ## Layout components | ||
|
|
||
| `Flex`, `Grid`, `View`, and `Well` are not part of S2. These should be updated to `div` elements styled with the macro. | ||
|
|
||
| ### Flex example | ||
|
|
||
| Before: | ||
|
|
||
| ```jsx | ||
| <Flex direction="column"> | ||
| <div>Item 1</div> | ||
| <div>Item 2</div> | ||
| <div>Item 3</div> | ||
| </Flex> | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```jsx | ||
| import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; | ||
|
|
||
| <div className={style({display: 'flex', flexDirection: 'column'})}> | ||
| <div>Item 1</div> | ||
| <div>Item 2</div> | ||
| <div>Item 3</div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Grid example | ||
|
|
||
| Before: | ||
|
|
||
| ```jsx | ||
| <Grid justifyContent="center"> | ||
| <div>Item 1</div> | ||
| <div>Item 2</div> | ||
| <div>Item 3</div> | ||
| </Grid> | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```jsx | ||
| import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; | ||
|
|
||
| <div className={style({display: 'grid', justifyContent: 'center'})}> | ||
| <div>Item 1</div> | ||
| <div>Item 2</div> | ||
| <div>Item 3</div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### View example | ||
|
|
||
| Before: | ||
|
|
||
| ```jsx | ||
| <View> | ||
| Content | ||
| </View> | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```jsx | ||
| <div> | ||
| Content | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Well example | ||
|
|
||
| Before: | ||
|
|
||
| ```jsx | ||
| <Well> | ||
| Content | ||
| </Well> | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```jsx | ||
| import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; | ||
|
|
||
| <div className={style({ | ||
| display: 'block', | ||
| textAlign: 'start', | ||
| padding: 16, | ||
| minWidth: 160, | ||
| marginTop: 4, | ||
| borderWidth: 1, | ||
| borderRadius: 'sm', | ||
| borderStyle: 'solid', | ||
| borderColor: 'transparent-black-75', | ||
| font: 'body-sm' | ||
| })}> | ||
| Content | ||
| </div> | ||
| ``` | ||
|
|
||
| ## UNSAFE_style and UNSAFE_className | ||
|
|
||
| Move `UNSAFE_style` usage to the S2 style macro when possible. | ||
|
|
||
| Move `UNSAFE_className` usage to the S2 style macro when possible. | ||
|
|
||
| Reference the S2 styling docs to see the supported CSS properties. | ||
|
|
||
| ## Dialogs | ||
|
|
||
| - `DialogContainer` and `useDialogContainer` still exist in S2, but the dismiss logic may need to move between `Dialog`, `DialogTrigger`, and `DialogContainer`. See the S2 Dialog documentation for more details. | ||
|
|
||
| ## Collections | ||
|
|
||
| - When `Item` survives the codemod, rename it based on its parent component: | ||
|
|
||
| | Parent component | v3 child | S2 child | | ||
| |---|---|---| | ||
| | Menu / ActionMenu | Item | MenuItem | | ||
| | Picker | Item | PickerItem | | ||
| | ComboBox | Item | ComboBoxItem | | ||
| | Tabs | Item | Tab / TabPanel | | ||
| | TagGroup | Item | Tag | | ||
| | Breadcrumbs | Item | Breadcrumb | | ||
|
|
||
| - Preserve React `key` when mapping arrays, but ensure collection data items expose `id` when S2 expects it. See the S2 Collections documentation for more details. | ||
| - Table and ListView migrations often need manual review for row headers, nested columns, and explicit item ids. | ||
|
|
||
| ## Toast migration | ||
|
|
||
| - Move `ToastContainer` and `ToastQueue` imports from `@react-spectrum/toast` to `@react-spectrum/s2`. | ||
| - Keep a shared `ToastContainer` mounted near the app root or test harness, then update all queue calls to use the S2 import path. | ||
| - S2 supports `ToastQueue.neutral`, `positive`, `negative`, and `info`. | ||
| - Re-check options such as `timeout`, `actionLabel`, `onAction`, `shouldCloseOnAction`, and `onClose` after the import move. | ||
| - The queue methods still return a close function. Keep programmatic dismissal logic when the existing UX depends on it. | ||
| - Search for every `ToastContainer` mount and every `ToastQueue` usage after moving imports. Shared app roots, secondary entrypoints, and test harnesses are easy to miss. |
23 changes: 23 additions & 0 deletions
23
packages/dev/s2-docs/migration-references/focused-prerequisites.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Inspection checklist | ||
|
|
||
| ## Minimum tool versions | ||
|
|
||
| These tools are not all strictly required, but if the project uses them they must be at these minimum versions to avoid issues with the `with {type: 'macro'}` import syntax: | ||
|
|
||
| - **TypeScript 5.3+** — required for the import attributes syntax (`with {type: 'macro'}`). | ||
| - **Babel 7.27.0+** or the `@babel/plugin-syntax-import-attributes` plugin — enables Babel to parse import attributes. Alternatively, `@babel/preset-env` with `shippedProposals: true` also enables import attribute parsing. | ||
| - **ESLint 9.14.0+** with `@typescript-eslint/parser`. | ||
| - **Prettier 3.1.1+** — needed to format `with {type: 'macro'}` import syntax correctly. | ||
|
|
||
| ## What to look for | ||
|
|
||
| - Search package manifests and source for `@adobe/react-spectrum`, `@react-spectrum/*`, and `@spectrum-icons/*`. | ||
| - In monorepos or mixed-tooling repos, inspect the target package or app first instead of assuming the root manifest represents the runtime target being migrated. | ||
| - Determine the package manager from the relevant lockfile or workspace setup. | ||
| - Detect the bundler at the migration target level. The workspace root may include Storybook, Vite, or other tooling that does not represent the runtime bundler for the package being migrated. | ||
| - **Parcel v2.12.0+** already supports S2 style macros natively. | ||
| - **Vite, webpack, Next.js, Rollup, ESBuild** and similar toolchains need `unplugin-parcel-macros`. Keep plugin ordering correct so macros run before the rest of the toolchain. | ||
| - If the repo already has a framework-specific S2 or macro setup, preserve it instead of layering a second macro configuration on top. | ||
| - Find **all** app entrypoints, including standalone pages, alternate render roots, embedded sub-apps, utility apps, and test-only render targets. Do not assume there is only one entry. | ||
| - Locate root providers, shared test wrappers, toast setup, and any direct `defaultTheme` usage. | ||
| - Search for `ToastContainer`, `ToastQueue`, `DialogContainer`, `useDialogContainer`, `ClearSlots`, style props, and `UNSAFE_style`. These are common follow-up areas after the codemod. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decide to have this command include both skills (
migrate-react-spectrum-v3-to-s2andreact-spectrum-s2) since the main S2 skill is useful for referencing component docs during migration.