Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/run-codegen-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
run: |
set -euo pipefail
cd "${{ inputs.working-directory }}"
bunx nitro-codegen --logLevel="debug"
bunx nitrogen --logLevel="debug"
${{ inputs.pm }} run build
if [ -f post-script.js ]; then
node post-script.js
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ updates:
- 'react-native'
nitro:
patterns:
- 'nitro-codegen'
- 'nitrogen'
- 'react-native-nitro-modules'
2 changes: 1 addition & 1 deletion assets/template/.github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ updates:
- '@react-native/*'
nitro:
patterns:
- 'nitro-codegen'
- 'nitrogen'
- 'react-native-nitro-modules'
6 changes: 3 additions & 3 deletions assets/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
"@semantic-release/git": "^10.0.1",
"@types/jest": "^29.5.12",
"@types/react": "19.1.0",
"nitro-codegen": "^0.29.2",
"nitrogen": "^0.29.4",
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-builder-bob": "^0.37.0",
"react-native-nitro-modules": "^0.29.2",
"react-native-nitro-modules": "^0.2942",
"conventional-changelog-conventionalcommits": "^9.1.0",
Comment on lines +61 to 62
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.

Suggested change
"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.

"semantic-release": "^24.2.6",
"typescript": "5.0.4"
"typescript": "^5.8.3"
},
"peerDependencies": {
"react": "*",
Expand Down
18 changes: 9 additions & 9 deletions src/generate-nitro-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ export class NitroModuleFactory {
newWorkspacePackageJsonFile.scripts = {
...newWorkspacePackageJsonFile.scripts,
build: `${this.config.pm} run typecheck && bob build`,
codegen: `nitro-codegen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}`,
codegen: `nitrogen --logLevel="debug" && ${this.config.pm} run build${this.config.langs.includes(SupportedLang.KOTLIN) ? ' && node post-script.js' : ''}`,
postcodegen: this.getPostCodegenScript(),
}

// Resolve and pin latest Nitro tools to concrete versions
const nitroGen = 'nitro-codegen'
const nitrogen = 'nitrogen'
const nitroModules = 'react-native-nitro-modules'
const [nitroModulesVersion, nitroCodegenVersion] = await Promise.all([
const [nitroModulesVersion, nitrogenVersion] = await Promise.all([
this.getLatestVersion(nitroModules),
this.getLatestVersion(nitroGen),
this.getLatestVersion(nitrogen),
])
this.nitroModulesVersion = nitroModulesVersion
newWorkspacePackageJsonFile.devDependencies = {
Expand All @@ -198,10 +198,10 @@ export class NitroModuleFactory {
nitroModulesVersion ??
newWorkspacePackageJsonFile.devDependencies?.[nitroModules] ??
templatePackageJson.devDependencies[nitroModules],
[nitroGen]:
nitroCodegenVersion ??
newWorkspacePackageJsonFile.devDependencies?.[nitroGen] ??
templatePackageJson.devDependencies[nitroGen],
[nitrogen]:
nitrogenVersion ??
newWorkspacePackageJsonFile.devDependencies?.[nitrogen] ??
templatePackageJson.devDependencies[nitrogen],
}

newWorkspacePackageJsonFile.keywords = [
Expand Down Expand Up @@ -497,7 +497,7 @@ export class NitroModuleFactory {
await execAsync(`${this.config.pm} install`, { cwd: this.config.cwd })
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 })
}
Comment on lines 498 to 502
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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 be pnpm exec nitrogen or pnpm dlx)
  • bun: bun nitrogen (invalid; should be bunx or 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.

Suggested change
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.


Expand Down