-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: base RN upgrades experience #36
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ export const getReactNativeConfig = tool({ | |
Returns: | ||
- "root" - root directory of the project | ||
- "path" - path to React Native CLI installation | ||
- "version" - React Native version | ||
- "platforms" - available platforms | ||
- "project" - project configuration per platform | ||
|
||
|
@@ -68,17 +67,10 @@ export const getReactNativeConfig = tool({ | |
parameters: z.object({}), | ||
execute: async () => { | ||
try { | ||
const { | ||
root, | ||
reactNativePath: path, | ||
reactNativeVersion: version, | ||
project, | ||
platforms, | ||
} = await loadReactNativeConfig() | ||
const { root, reactNativePath: path, project, platforms } = await loadReactNativeConfig() | ||
return { | ||
root, | ||
path, | ||
version, | ||
project, | ||
platforms, | ||
} | ||
|
@@ -139,3 +131,79 @@ export const listReactNativeLibraries = tool({ | |
} | ||
}, | ||
}) | ||
|
||
export const getReactNativeReleases = tool({ | ||
description: dedent` | ||
Gets releases of React Native from GitHub. | ||
|
||
When upgrading React Native, ask user to select a version from the list. | ||
|
||
RnDiffApp is the name of the app that generates diffs between two versions of React Native. | ||
|
||
Make sure to replace RnDiffApp with the actual name of the app in the response. | ||
`, | ||
parameters: z.object({}), | ||
execute: async () => { | ||
try { | ||
const response = await fetch(`https://api.github.com/repos/facebook/react-native/releases`) | ||
const list = await response.json() | ||
|
||
const mappedList = list | ||
.filter((release: any) => !release.prerelease) | ||
.map((release: any) => ({ | ||
name: release.name, | ||
tag: release.tag_name, | ||
})) | ||
|
||
return { | ||
success: true, | ||
action: dedent` | ||
Ask user to select a version from the list. | ||
`, | ||
releases: mappedList, | ||
} | ||
} catch (error) { | ||
return { | ||
error: error instanceof Error ? error.message : 'Failed to retrieve versions', | ||
} | ||
} | ||
}, | ||
}) | ||
|
||
export const upgradeReactNativeDiff = tool({ | ||
description: dedent` | ||
Upgrade React Native diff tool, returns a diff between two versions of React Native. | ||
|
||
Parameters: | ||
- "from" - source version, (Read the exact version from package.json using "readFile" tool). Example: "0.75.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I typically use this format just for |
||
- "to" - target version (latest React Native version). Example: "0.76.3" | ||
|
||
Returns: | ||
- "diff" - diff between two versions, containing differences in the project files you need to apply. Make sure to apply it 2 levels deep in the project tree. | ||
When applying the diff, make sure to ask user for confirmation before proceeding. Don't read the files before applying the diff just apply it. | ||
`, | ||
parameters: z.object({ | ||
from: z.string(), | ||
to: z.string(), | ||
}), | ||
execute: async ({ from, to }) => { | ||
try { | ||
const response = await fetch( | ||
`https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/${from}..${to}.diff` | ||
) | ||
const diff = await response.text() | ||
|
||
return { | ||
success: true, | ||
action: dedent` | ||
Go over user file tree and apply diffs to the project. | ||
`, | ||
diff, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. save diff into file in os.tmp() and return path here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: in the future, we will need to unify our response formats. I think since AIs are conversational ,we can safely return |
||
} | ||
} catch (error) { | ||
return { | ||
error: error instanceof Error ? error.message : 'Failed to retrieve diff', | ||
} | ||
} | ||
}, | ||
}) |
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.
nit: no need for
decent
if single line.Also, we can try
Ask user to select a version from the list: ${mappedList}
if it works .This is all serialized to string anyway at the end of the day