Skip to content

chore: keep generated code out of git by default - #129

Open
huhuanming wants to merge 1 commit into
mainfrom
chore/ignore-generated-code
Open

huhuanming wants to merge 1 commit into
mainfrom
chore/ignore-generated-code

Conversation

@huhuanming

Copy link
Copy Markdown
Contributor

Problem

#126 removes 117 committed nitrogen/generated files from react-native-image and react-native-native-list. That was not an accident of those two packages — nothing in the repo stopped it. Three gaps:

  1. The root .gitignore has no nitrogen rule. It already covers builder-bob output (native-modules/*/lib/, native-views/*/lib/) and CMake output (native-*/*/android/.cxx/) for every workspace, so those artifacts are protected repo-wide. Nitrogen output was left entirely to each package's own .gitignore.
  2. The view scaffolder never emits a .gitignore. create-nitro-module.js writes one from scripts/nitro/template/.gitignore; create-nitro-view.js has no equivalent, and scripts/nitro-view/template ships no .gitignore at all. react-native-image (2026-09-03) and react-native-native-list (2026-09-14) are the two newest view packages, and they are exactly the two that committed their nitrogen trees. Older view packages have the file because it was copied in by hand at creation.
  3. 13 more packages have no .gitignore. All non-Nitro today, so nothing has leaked, but one codegen run away from the same thing.

Plus scripts/nitro/template/android/.gradle/: 10 Gradle lock and checksum binaries (40 KB) that get copied into every module created from that template. The template's own .gitignore has listed .gradle since it was written, but these files were already tracked, so the rule never applied.

Fix

  • Root .gitignore: add native-modules/*/nitrogen/ and native-views/*/nitrogen/ next to the existing bob and CMake rules.
  • Add scripts/nitro-view/template/.gitignore and write it out in step 8 of create-nitro-view.js, mirroring create-nitro-module.js.
  • Add the same .gitignore to the 13 packages that had none: aes-crypto, async-storage, cloud-fs, dns-lookup, network-info, network-throttle, pbkdf2, ping, sni-connect, split-bundle-loader, tcp-socket, native-sheet, text-input.
  • git rm --cached scripts/nitro/template/android/.gradle, and generalize the root entry to scripts/*/template/android/.gradle/ so it covers both templates.

Verification

  • git ls-files -i -c --exclude-standard returns exactly the 117 files #126 deletes and nothing else, so the 13 new .gitignore files catch no currently tracked file.
  • Scaffolded a throwaway view with node scripts/create-nitro-view.js; the generated package now carries a .gitignore identical to the other view packages. Test package deleted.
  • node --check scripts/create-nitro-view.js.

Notes

  • No package content changes and no version bump; .gitignore is not in any package's npm files, so published tarballs are unchanged. No CHANGELOG entry, which also keeps this clear of #126.
  • Independent of #126 — no shared files, either order merges cleanly. If this lands first, the 117 files stay tracked-but-ignored until #126 removes them, which is harmless.

🤖 Generated with Claude Code

The nitrogen output in react-native-image and react-native-native-list
was not an accident of those two packages; nothing in the repo stopped
it. Three gaps, all closed here.

The root .gitignore already covers builder-bob output
(native-*/*/lib/) and CMake output (native-*/*/android/.cxx/) for every
workspace, but had no rule for nitrogen. Add
native-modules/*/nitrogen/ and native-views/*/nitrogen/ so codegen
output is ignored repo-wide instead of depending on each package
carrying its own .gitignore.

create-nitro-module.js writes a .gitignore from scripts/nitro/template;
create-nitro-view.js had no equivalent, and scripts/nitro-view/template
shipped no .gitignore at all, so every view package scaffolded from it
was born without one. react-native-image and react-native-native-list,
the two newest view packages, are exactly the two that committed their
nitrogen trees. Add the template file and emit it in step 8.

Thirteen older packages never had a .gitignore either. They are all
non-Nitro today, so nothing leaked yet, but they are one codegen run
away from the same thing. Give them the same file the other packages
use. No currently tracked file matches the new rules.

Also drop scripts/nitro/template/android/.gradle: ten Gradle lock and
checksum binaries that get copied into every module created from that
template. The template's own .gitignore has listed .gradle since it was
written, but these files were already tracked, so the rule never
applied. The root ignore entry for the view template's .gradle is
generalized to scripts/*/template/android/.gradle/ to cover both.

The 117 generated files themselves are removed in the OK-63873 branch;
this change only stops them coming back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant