-
Notifications
You must be signed in to change notification settings - Fork 16
feature: extend CLI for expo / gt-react-native #790
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
Open
SamEggert
wants to merge
10
commits into
main
Choose a base branch
from
s/cli/gt-react-native
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Contributor
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.
Greptile Overview
Greptile Summary
Extended CLI to support Expo/React Native projects with gt-react-native library integration.
Key changes:
- Added
ReactNativeCLIclass with Expo-specific setup workflow - Implemented entry point detection for various Expo configurations (expo-router, standard RN)
- Created babel config AST manipulation to inject
gt-react-native/plugin - Added JSX wrapping logic to insert
<T>tags andGTProviderin root layouts - Generated
loadTranslations.jswith locale-specific require statements - Extended setup wizard with Expo framework option and automatic package installation
Issues found:
console.warnused in CLI code instead oflogWarningutility (line 45 in createLoadTranslations.ts)- Path construction bug in wrapContent.ts when generating relative imports for nested files (missing
./prefix)
Confidence Score: 4/5
- Safe to merge with minor fixes for console.warn and import path bug
- Well-structured implementation with comprehensive tests. Two issues found: console.warn usage violates custom rule, and relative import path construction will break for nested layouts. Both are fixable but the path bug could cause runtime errors.
- Pay attention to
packages/cli/src/react-native/parse/wrapContent.ts(import path bug) andpackages/cli/src/react-native/parse/createLoadTranslations.ts(console.warn usage)
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/cli/src/react-native/parse/createLoadTranslations.ts | 4/5 | Creates loadTranslations.js for Expo projects with locale-specific require statements. Has console.warn in CLI code that should use logWarning instead. |
| packages/cli/src/react-native/parse/wrapContent.ts | 3/5 | Wraps JSX content with T tags and adds GTProvider to root layout. Has path construction bug for relative imports that may break when fileDir != cwd. |
| packages/cli/src/react-native/utils/updateBabelConfig.ts | 5/5 | Updates babel.config.js with gt-react-native plugin using AST manipulation. Well-structured with proper checks for existing config. |
| packages/cli/src/react-native/utils/detectEntryPoint.ts | 5/5 | Detects Expo entry point with fallback strategies. Logic correctly handles node_modules entries vs local files. |
| packages/cli/src/setup/wizard.ts | 5/5 | Added Expo framework option to setup wizard with automatic gt-react-native installation and initialization flow. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as CLI/Wizard
participant Detect as detectEntryPoint
participant Babel as updateBabelConfig
participant Wrap as wrapContent
participant Init as handleInitGT
User->>CLI: Run setup command
CLI->>CLI: Detect gt-react-native in package.json
CLI->>CLI: Install gt-react-native if needed
CLI->>Detect: detectEntryPoint(projectRoot)
Detect->>Detect: Check package.json main field
Detect->>Detect: Check for existing entry files
Detect-->>CLI: Return strategy & entryPoint
CLI->>Init: handleInitGT(paths, detectionResult)
Init->>Babel: updateBabelConfig(babelPath, entryPath)
Babel->>Babel: Parse existing babel.config.js AST
Babel->>Babel: Add/update gt-react-native plugin
Babel-->>Init: Config updated
Init->>Init: Create index.js wrapper if needed
Init->>Init: Update package.json main field
Init-->>CLI: Initialization complete
CLI->>Wrap: wrapContentReactNative(options)
Wrap->>Wrap: Match files in src directory
loop For each file
Wrap->>Wrap: Parse file as AST
Wrap->>Wrap: Check if root layout (_layout.tsx)
Wrap->>Wrap: Add GTProvider with config imports
Wrap->>Wrap: Wrap JSX elements with T tags
Wrap->>Wrap: Generate updated code
end
Wrap-->>CLI: Return filesUpdated list
CLI->>CLI: Create loadTranslations.js
CLI->>CLI: Create gt.config.json
CLI-->>User: Setup complete
19 files reviewed, 2 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.