Conversation
…ad of 'nitro-codegen'
WalkthroughThe codebase replaces all references to the nitro-codegen tool with nitrogen across CI, templates, Dependabot configs, and the generator script. Version resolution and devDependency keys are updated accordingly. No public API signatures change. Control flow remains the same; only the invoked tool and dependency names are updated. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub Action
participant Bun as Bun (bunx)
participant Nitrogen as nitrogen CLI
Dev->>GH: Trigger run-codegen-build
GH->>Bun: bunx nitrogen --logLevel=debug
Bun->>Nitrogen: Execute codegen
Nitrogen-->>GH: Exit status (success/failure)
GH-->>Dev: Job result
sequenceDiagram
autonumber
participant Gen as generate-nitro-package.ts
participant NPM as Package.json
participant Reg as Registry
participant Nitrogen as nitrogen CLI
Gen->>Reg: Resolve versions (nitrogen, nitro modules)
Reg-->>Gen: Latest versions
Gen->>NPM: Write devDependencies { nitrogen, react-native-nitro-modules }
Gen->>NPM: Write scripts { codegen: "nitrogen ..." }
Gen->>Nitrogen: Invoke codegen during install/build
Nitrogen-->>Gen: Complete
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/actions/run-codegen-build/action.yml (1)
17-21: Make codegen runner PM-aware or reuse the package.json script to avoid Bun requirementThe step hardcodes
bunx, which will fail if Bun isn’t installed on the runner. Either run the codegen script (<pm> run codegen, which you already add to package.json) or map to the correct “exec” per PM.Apply one of the following:
Option A (reuse script — simplest and consistent):
- bunx nitrogen --logLevel="debug" - ${{ inputs.pm }} run build + ${{ inputs.pm }} run codegenOption B (PM-aware exec mapping):
- bunx nitrogen --logLevel="debug" + case "${{ inputs.pm }}" in + npm) npx --yes nitrogen --logLevel="debug" ;; + pnpm) pnpm exec nitrogen --logLevel="debug" ;; + yarn) yarn dlx nitrogen --logLevel="debug" ;; + bun) bunx nitrogen --logLevel="debug" ;; + *) echo "Unsupported package manager: ${{ inputs.pm }}" >&2; exit 1 ;; + esac ${{ inputs.pm }} run build
🧹 Nitpick comments (2)
.github/actions/run-codegen-build/action.yml (1)
2-2: Nit: update description to reflect “nitrogen”The description still says “Run nitro codegen…”. Consider “Run nitrogen codegen…”.
src/generate-nitro-package.ts (1)
190-205: Guard against bad template fallbacks if version discovery failsIf
npm view/pnpm viewfail, you fall back totemplatePackageJson.devDependencies[...]. Given the template currently has a malformedreact-native-nitro-modulesversion, installs can still break. Consider validating with semver before applying the fallback.Minimal guard:
+ const isValid = (v?: string|null) => !!v && /^\d+\.\d+\.\d+/.test(v.replace(/^[^\d]*/, '')) newWorkspacePackageJsonFile.devDependencies = { ...newWorkspacePackageJsonFile.devDependencies, [nitroModules]: - nitroModulesVersion ?? - newWorkspacePackageJsonFile.devDependencies?.[nitroModules] ?? - templatePackageJson.devDependencies[nitroModules], + (isValid(nitroModulesVersion) && nitroModulesVersion) ?? + (isValid(newWorkspacePackageJsonFile.devDependencies?.[nitroModules]) && newWorkspacePackageJsonFile.devDependencies?.[nitroModules]) ?? + (isValid(templatePackageJson.devDependencies[nitroModules]) && templatePackageJson.devDependencies[nitroModules]) ?? + '*', [nitrogen]: - nitrogenVersion ?? - newWorkspacePackageJsonFile.devDependencies?.[nitrogen] ?? - templatePackageJson.devDependencies[nitrogen], + (isValid(nitrogenVersion) && nitrogenVersion) ?? + (isValid(newWorkspacePackageJsonFile.devDependencies?.[nitrogen]) && newWorkspacePackageJsonFile.devDependencies?.[nitrogen]) ?? + (isValid(templatePackageJson.devDependencies[nitrogen]) && templatePackageJson.devDependencies[nitrogen]) ?? + '^0', }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/actions/run-codegen-build/action.yml(1 hunks).github/dependabot.yml(1 hunks)assets/template/.github/dependabot.yml(1 hunks)assets/template/package.json(1 hunks)src/generate-nitro-package.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
assets/template/package.json (1)
src/types.ts (1)
Nitro(43-46)
🔇 Additional comments (5)
assets/template/package.json (1)
57-57: Verifynitrogenand TypeScript versions
npm view nitrogen version⇒ 0.29.4 matches^0.29.4npm view typescript version⇒ 5.9.2 (so^5.8.3will resolve within 5.x); confirm that TS 5.x is supported by React Native 0.81.x’s CLI template and your bob setup.github/dependabot.yml (2)
31-34: LGTM — group now tracks ‘nitrogen’Grouping
nitrogenwithreact-native-nitro-modulesaligns with the migration.
10-14: Confirm Dependabot bun support in root configRoot config uses
package-ecosystem: bunbut doesn’t setenable-beta-ecosystems: true(present in the template config). If required for your org, mirror that here to avoid Dependabot ignoring Bun updates.assets/template/.github/dependabot.yml (1)
54-57: LGTM — npm nitro group now tracks ‘nitrogen’Matches the tool rename; grouping remains coherent.
src/generate-nitro-package.ts (1)
183-185: Good: consolidated codegen script with Kotlin post-script gatingScript composes nitrogen, build, and optional post-script cleanly.
| "react-native-nitro-modules": "^0.2942", | ||
| "conventional-changelog-conventionalcommits": "^9.1.0", |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Suspicious version string for react-native-nitro-modules — likely typo
^0.2942 looks malformed (missing a dot). This will fail resolution and could cascade into install failures when getLatestVersion returns null and we fall back to the template value.
Proposed fix (pick a valid semver for the intended bump; placeholder uses the nearest plausible range):
- "react-native-nitro-modules": "^0.2942",
+ "react-native-nitro-modules": "^0.29.4",To verify available versions:
🏁 Script executed:
#!/bin/bash
npm view react-native-nitro-modules versions --json | jq '.[-10:]'Length of output: 122
Fix malformed react-native-nitro-modules version
Replace in assets/template/package.json:
- "react-native-nitro-modules": "^0.2942",
+ "react-native-nitro-modules": "^0.29.4",to match the latest published 0.29.4 release.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "react-native-nitro-modules": "^0.2942", | |
| "conventional-changelog-conventionalcommits": "^9.1.0", | |
| "react-native-nitro-modules": "^0.29.4", | |
| "conventional-changelog-conventionalcommits": "^9.1.0", |
🤖 Prompt for AI Agents
In assets/template/package.json around lines 61 to 62, the
react-native-nitro-modules version is malformed ("^0.2942"); update that
dependency value to the correct published release by replacing it with "^0.29.4"
(preserve the caret if semantic-range behavior is desired) and save the file.
| let packageManager = | ||
| this.config.pm === 'npm' ? 'npx --yes' : this.config.pm | ||
| let codegenCommand = `${packageManager} nitro-codegen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}` | ||
| let codegenCommand = `${packageManager} nitrogen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}` | ||
| await execAsync(codegenCommand, { cwd: this.config.cwd }) | ||
| } |
There was a problem hiding this comment.
Codegen invocation breaks for pnpm/bun; prefer running the script or PM-aware exec
packageManager = this.config.pm === 'npm' ? 'npx --yes' : this.config.pm leads to:
- pnpm:
pnpm nitrogen(invalid; should bepnpm exec nitrogenorpnpm dlx) - bun:
bun nitrogen(invalid; should bebunxor a script) - yarn: may work via bin shim, but inconsistent
You already define a codegen script; just run it.
Apply:
- let packageManager =
- this.config.pm === 'npm' ? 'npx --yes' : this.config.pm
- let codegenCommand = `${packageManager} nitrogen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}`
- await execAsync(codegenCommand, { cwd: this.config.cwd })
+ await execAsync(`${this.config.pm} run codegen`, { cwd: this.config.cwd })Alternative (PM-aware exec) if you don’t want to rely on the script:
- let packageManager =
- this.config.pm === 'npm' ? 'npx --yes' : this.config.pm
- let codegenCommand = `${packageManager} nitrogen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}`
- await execAsync(codegenCommand, { cwd: this.config.cwd })
+ const pm = this.config.pm
+ const x =
+ pm === 'npm' ? 'npx --yes' :
+ pm === 'pnpm' ? 'pnpm exec' :
+ pm === 'yarn' ? 'yarn dlx' :
+ pm === 'bun' ? 'bunx' : null
+ if (!x) throw new Error(`Unsupported package manager: ${pm}`)
+ await execAsync(`${x} nitrogen --logLevel="debug"`, { cwd: this.config.cwd })
+ await execAsync(`${pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}`, { cwd: this.config.cwd })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let packageManager = | |
| this.config.pm === 'npm' ? 'npx --yes' : this.config.pm | |
| let codegenCommand = `${packageManager} nitro-codegen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}` | |
| let codegenCommand = `${packageManager} nitrogen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}` | |
| await execAsync(codegenCommand, { cwd: this.config.cwd }) | |
| } | |
| await execAsync(`${this.config.pm} run codegen`, { cwd: this.config.cwd }) | |
| } |
🤖 Prompt for AI Agents
In src/generate-nitro-package.ts around lines 498 to 502, the current
packageManager construction (`this.config.pm === 'npm' ? 'npx --yes' :
this.config.pm`) produces invalid invocations for pnpm/bun and is brittle;
instead invoke the already-defined npm script or use PM-aware exec. Replace the
constructed direct binary call with a script invocation like `${this.config.pm}
run codegen` (so pnpm/yarn/npm/bun will run the project script correctly), then
chain the build and optional post-script as before, and run via execAsync with
the same cwd; alternatively, if you prefer not to rely on the script, detect pm
values and map to the correct exec form (pnpm -> `pnpm exec`, bun -> `bunx` or
run script) before composing the command.
Summary by CodeRabbit
Chores
Refactor