-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: S2 migration docs and codemod setup (#6828)
* initialize migration docs * more docs for Item updates * move upgrade-cli to codemods package * improve rendered diffs * setup codemod entry * update yarn.lock * fix component index path resolving * update package.json * update yarn.lock * move to src * update component index path * update lock file * fix ts * update command in docs * fix --components option for providing a subset of components to upgrade * update docs to not collapse manual guide * update index to use parseArgs and pass args into codemod functions * just rely on require.resolve to get S2 index path * remove commander dep * move use-monopackages codemod into new package * update @react-spectrum/s2 dep * update yarn.lock * fix types and update use-monopackages readme * try removing main from package.json * use path module * use moduleResolution in tsconfig * remove module.exports * try renaming transformer functions * Revert "try renaming transformer functions" This reverts commit b2177f7. * try targets: main: false in package.json * move to packages/dev * update docs * add anchor links * update yarn.lock * fix anchor links in built docs --------- Co-authored-by: Robert Snow <[email protected]>
- Loading branch information
1 parent
e2bf18a
commit 6932a9f
Showing
145 changed files
with
1,128 additions
and
163 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,4 @@ | ||
import {Migrating} from './Migrating.jsx'; | ||
import {H3} from './typography'; | ||
|
||
<Migrating /> |
This file contains 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 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 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,100 @@ | ||
const {parseArgs} = require('node:util'); | ||
import {s1_to_s2} from './s1-to-s2/src'; | ||
import {use_monopackages} from './use-monopackages/src'; | ||
|
||
interface JSCodeshiftOptions { | ||
/** | ||
* The parser for jscodeshift to use for parsing the source files: https://github.com/facebook/jscodeshift?tab=readme-ov-file#parser. | ||
* | ||
* @default 'tsx' | ||
*/ | ||
parser?: 'babel' | 'babylon' | 'flow' | 'ts' |' tsx', | ||
/** | ||
* A glob pattern of files to ignore: https://github.com/facebook/jscodeshift?tab=readme-ov-file#ignoring-files-and-directories. | ||
* | ||
* @default '*\*\/node_modules/*\*\' | ||
*/ | ||
ignorePattern?: string, | ||
/** | ||
* Whether to run the codemod in dry mode, which will not write any changes to disk. | ||
* | ||
* @default false | ||
*/ | ||
dry?: boolean, | ||
/** | ||
* The path to the directory to run the codemod in. | ||
* | ||
* @default '.' | ||
*/ | ||
path?: string | ||
} | ||
|
||
export interface S1ToS2CodemodOptions extends JSCodeshiftOptions { | ||
/** | ||
* An optional subset of components to have the s1-to-s2 codemod apply to. | ||
* Provide a comma-separated list of component names. | ||
*/ | ||
components?: string | ||
} | ||
|
||
export interface UseMonopackagesCodemodOptions extends JSCodeshiftOptions { | ||
/** | ||
* The packages to apply the use-monopackages codemod to. | ||
*/ | ||
packages?: string | ||
} | ||
|
||
const codemods: Record<string, (options: S1ToS2CodemodOptions | UseMonopackagesCodemodOptions) => void> = { | ||
's1-to-s2': s1_to_s2, | ||
'use-monopackages': use_monopackages | ||
}; | ||
|
||
// https://github.com/facebook/jscodeshift?tab=readme-ov-file#usage-cli | ||
const options = { | ||
'parser': { | ||
type: 'string' | ||
}, | ||
'ignore-pattern': { | ||
type: 'string' | ||
}, | ||
'dry': { | ||
type: 'boolean', | ||
short: 'd' | ||
}, | ||
'path': { | ||
type: 'string' | ||
}, | ||
'components': { | ||
type: 'string' | ||
} | ||
}; | ||
|
||
const {values, positionals} = parseArgs({ | ||
options, | ||
allowPositionals: true | ||
}); | ||
|
||
if (positionals.length < 1) { | ||
console.error('Please specify a codemod to run. Available codemods: ', Object.keys(codemods).join(', ')); | ||
process.exit(1); | ||
} | ||
|
||
const codemodName = positionals[0]; | ||
const codemodFunction = codemods[codemodName]; | ||
|
||
if (!codemodFunction) { | ||
console.error(`Unknown codemod: ${codemodName}, available codemods: ${Object.keys(codemods).join(', ')}`); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
codemodFunction({ | ||
parser: 'tsx', | ||
ignorePattern: '**/node_modules/**', | ||
path: '.', | ||
...values | ||
}); | ||
} catch (error) { | ||
console.error(`Error running codemod: ${error}`); | ||
process.exit(1); | ||
} |
This file contains 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/subset.test.ts.snap
This file contains 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,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Should not update components that are not provided to --components option 1`] = ` | ||
"import {Button, TextArea} from '@adobe/react-spectrum'; | ||
<div> | ||
<Button variant="cta">Test</Button> | ||
<Button variant="overBackground">Test</Button> | ||
<TextArea isQuiet /> | ||
</div>" | ||
`; | ||
|
||
exports[`Should only update components provided to --components option 1`] = ` | ||
"import { TextArea } from '@adobe/react-spectrum'; | ||
import { Button } from "@react-spectrum/s2"; | ||
<div> | ||
<Button variant="accent">Test</Button> | ||
<Button variant="primary" staticColor="white">Test</Button> | ||
<TextArea isQuiet /> | ||
</div>" | ||
`; | ||
|
||
exports[`Should update multiple components provided to --components option 1`] = ` | ||
"import { Button, TextArea } from "@react-spectrum/s2"; | ||
<div> | ||
<Button variant="accent">Test</Button> | ||
<Button variant="primary" staticColor="white">Test</Button> | ||
<TextArea /> | ||
</div>" | ||
`; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
packages/dev/codemods/src/s1-to-s2/__tests__/subset.test.ts
This file contains 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,37 @@ | ||
// @ts-ignore | ||
import {defineSnapshotTest} from 'jscodeshift/dist/testUtils'; | ||
import transform from '../src/codemods/codemod'; | ||
|
||
const testSubset = (name: string, input: string, components: string) => { | ||
defineSnapshotTest(transform, {components}, input, name); | ||
}; | ||
|
||
testSubset('Should update multiple components provided to --components option', ` | ||
import {Button, TextArea} from '@adobe/react-spectrum'; | ||
<div> | ||
<Button variant="cta">Test</Button> | ||
<Button variant="overBackground">Test</Button> | ||
<TextArea isQuiet /> | ||
</div> | ||
`, 'Button,TextArea'); | ||
|
||
testSubset('Should only update components provided to --components option', ` | ||
import {Button, TextArea} from '@adobe/react-spectrum'; | ||
<div> | ||
<Button variant="cta">Test</Button> | ||
<Button variant="overBackground">Test</Button> | ||
<TextArea isQuiet /> | ||
</div> | ||
`, 'Button'); | ||
|
||
testSubset('Should not update components that are not provided to --components option', ` | ||
import {Button, TextArea} from '@adobe/react-spectrum'; | ||
<div> | ||
<Button variant="cta">Test</Button> | ||
<Button variant="overBackground">Test</Button> | ||
<TextArea isQuiet /> | ||
</div> | ||
`, 'TableView'); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions
10
...spectrum/upgrade-cli/src/getComponents.ts → ...odemods/src/s1-to-s2/src/getComponents.ts
This file contains 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.
6932a9f
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.
Verdaccio builds:
CRA Test App
NextJS Test App
RAC Tailwind Example
RAC Spectrum + Tailwind Example
CRA Test App Size
NextJS App Size
Publish stats
Size diff since last release
Docs
Storybook
S2 Storybook