Skip to content

Commit

Permalink
feat(upgrade): Improve CLI output (#4393)
Browse files Browse the repository at this point in the history
Co-authored-by: Lennart <[email protected]>
  • Loading branch information
jacekradko and LekoArts authored Oct 23, 2024
1 parent 1c7e105 commit a917a2d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-guests-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/upgrade": patch
---

Updating the CLI output to match the DX of core-1 to core-2 migration
2 changes: 1 addition & 1 deletion packages/upgrade/src/components/Codemod.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function Codemod(props) {
.finally(() => {
callback(true);
});
}, [glob]);
}, [callback, glob, transform]);

return (
<>
Expand Down
56 changes: 36 additions & 20 deletions packages/upgrade/src/components/SDKWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export function SDKWorkflow(props) {
const { packageManager, sdk } = props;

const [done, setDone] = useState(false);
const [runCodemod, setRunCodemod] = useState(false);
const [upgradeComplete, setUpgradeComplete] = useState(false);

const version = getClerkSdkVersion(sdk);
// eslint-disable-next-line no-unused-vars
const [version, setVersion] = useState(getClerkSdkVersion(sdk));

if (sdk !== 'nextjs') {
return (
Expand All @@ -41,6 +43,18 @@ export function SDKWorkflow(props) {
return (
<>
<Header />
<Text>
Clerk SDK used: <Text color='green'>@clerk/{sdk}</Text>
</Text>
<Text>
Migrating from version: <Text color='green'>{version}</Text>
</Text>
{runCodemod ? (
<Text>
Executing codemod: <Text color='green'>yes</Text>
</Text>
) : null}
<Newline />
{version === 5 && (
<>
<UpgradeSDK
Expand All @@ -57,32 +71,34 @@ export function SDKWorkflow(props) {
) : null}
</>
)}
{!done && version === 6 && (
{version === 6 && (
<>
<Text>
Looks like you are already on the latest version of <Text bold>@clerk/{sdk}</Text>. Would you like to run
the associated codemod?.
</Text>
{upgradeComplete ? (
{runCodemod ? (
<Codemod
sdk={sdk}
callback={setDone}
transform='transform-async-request'
/>
) : (
<Select
options={[
{ label: 'yes', value: 'yes' },
{ label: 'no', value: 'no' },
]}
onChange={value => {
if (value === 'yes') {
setUpgradeComplete(true);
} else {
setDone(true);
}
}}
/>
<>
<Text>
Looks like you are already on the latest version of <Text bold>@clerk/{sdk}</Text>. Would you like to
run the associated codemod?
</Text>
<Select
options={[
{ label: 'yes', value: 'yes' },
{ label: 'no', value: 'no' },
]}
onChange={value => {
if (value === 'yes') {
setRunCodemod(true);
} else {
setDone(true);
}
}}
/>
</>
)}
</>
)}
Expand Down

0 comments on commit a917a2d

Please sign in to comment.