WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@SamEggert
Copy link
Contributor

No description provided.

@SamEggert SamEggert marked this pull request as ready for review November 6, 2025 04:13
@SamEggert SamEggert requested a review from a team as a code owner November 6, 2025 04:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 ReactNativeCLI class 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 and GTProvider in root layouts
  • Generated loadTranslations.js with locale-specific require statements
  • Extended setup wizard with Expo framework option and automatic package installation

Issues found:

  • console.warn used in CLI code instead of logWarning utility (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) and packages/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
Loading

19 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants