From 5e659b8b42c7f89928433a96802b800301587fbd Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 23 Oct 2026 13:39:53 +0200 Subject: [PATCH] fix: replace Android and Apple template placeholders in nitrogen init #1972 renamed the nitro.json keys and also changed the names init.ts passes to replaceTemplate to `android.namespace`, `android.cxxLibName` and `apple.moduleName`. The template still uses `$$androidNamespace$$`, `$$androidCxxLibName$$` and `$$appleModuleName$$`, so new libraries kept those placeholders in the podspec name, the Kotlin package path and file contents. Go back to the template's names. The init workflow now fails if any file name or file content in the generated library still contains `$$`. Also make the HybridObject JSDoc example import `Apple`, which it uses, instead of `iOS`. --- .github/workflows/run-nitrogen-init.yml | 12 ++++++++++++ packages/nitro-core/js/src/HybridObject.ts | 2 +- packages/nitrogen/src/init.ts | 6 +++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-nitrogen-init.yml b/.github/workflows/run-nitrogen-init.yml index bd089007c2..9ff4f6810e 100644 --- a/.github/workflows/run-nitrogen-init.yml +++ b/.github/workflows/run-nitrogen-init.yml @@ -38,3 +38,15 @@ jobs: - name: Run nitrogen init outside the checkout working-directory: ${{ runner.temp }} run: bun run --bun nitrogen init react-native-math + + - name: Check that all template placeholders were replaced + working-directory: ${{ runner.temp }}/react-native-math + run: | + if find . -name '*$$*' | grep .; then + echo "::error::File names above still contain \$\$ template placeholders" + exit 1 + fi + if grep -rnIF '$$' .; then + echo "::error::File contents above still contain \$\$ template placeholders" + exit 1 + fi diff --git a/packages/nitro-core/js/src/HybridObject.ts b/packages/nitro-core/js/src/HybridObject.ts index bb6474d2db..d19f73fc1a 100644 --- a/packages/nitro-core/js/src/HybridObject.ts +++ b/packages/nitro-core/js/src/HybridObject.ts @@ -80,7 +80,7 @@ declare abstract class HybridObject { * @example * ```ts * // Image.nitro.ts - * import { iOS, type HybridObject } from 'nitro-core' + * import { Apple, type HybridObject } from 'nitro-core' * * export * from '#nitro/Image' * diff --git a/packages/nitrogen/src/init.ts b/packages/nitrogen/src/init.ts index cfe0f370c9..f8bb3b52a0 100644 --- a/packages/nitrogen/src/init.ts +++ b/packages/nitrogen/src/init.ts @@ -35,9 +35,9 @@ export async function initNewNitroModule(baseDirectory: string, moduleName: stri } await replaceTemplate(modulePath, `cxxNamespace`, cxxNamespace) - await replaceTemplate(modulePath, `android.namespace`, cxxNamespace) - await replaceTemplate(modulePath, `android.cxxLibName`, camelCaseName) - await replaceTemplate(modulePath, `apple.moduleName`, camelCaseName) + await replaceTemplate(modulePath, `androidNamespace`, cxxNamespace) + await replaceTemplate(modulePath, `androidCxxLibName`, camelCaseName) + await replaceTemplate(modulePath, `appleModuleName`, camelCaseName) await replaceTemplate(modulePath, `packageName`, moduleName) await replaceTemplate(modulePath, `packageDescription`, moduleName) await replaceTemplate(modulePath, `nitroVersion`, NITROGEN_VERSION)