You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ci: run linting without building native code (#435)
* ci: run linting without building native code (#414)
The lint job set up a full native toolchain (JDK 17, Android SDK + NDK,
x86_64-linux-android Rust target) and ran two native bootstraps purely to
get generated TypeScript types for type-checking. Resolve both TODOs:
- Add `ferric build --dts-only`, which generates a crate's `.d.ts` and JS
entrypoint via a plain host `cargo build` (napi-rs typedef codegen),
without cross-compiling any Android/Apple binaries. The library basename
is derived from `cargo metadata`'s cdylib target instead of from built
artifact paths, so no platform build is needed to compute it. Wire this
up as `ferric-example`'s new `build:types` script.
- Use `weak-node-api`'s existing `prebuild:prepare` script (header copy +
C++/TS declaration codegen) instead of `bootstrap` (which also runs the
native CMake build). It already required nothing beyond clang-format.
With both native builds no longer needed for typing, the lint job drops
the JDK 17, Android SDK, and `rustup target add` steps entirely.
Verified locally (Node 24, cargo present, no Android/Apple SDK): fresh
`pnpm install && pnpm run build`, then `pnpm --filter weak-node-api run
prebuild:prepare`, `pnpm --filter @react-native-node-api/ferric-example
run build:types`, `pnpm run lint`, `pnpm run prettier:check`, `pnpm run
depcheck` and `pnpm run publint` all pass end-to-end with no native
toolchain present, reproducing the new lint job's steps.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaK9eAAF5G8wj6UT8VekAm
* ci: commit ferric-example's declarations as a fixture instead of building them
kraenhansen suspected generateTypeScriptDeclarations doesn't actually skip a
native build. Confirmed: napi-rs's `napi build` has no typegen-only mode — it
always runs a real `cargo build`, and --dts-only leaves a fully populated
~123MB target/ directory (including a compiled libferric_example.so) behind.
"Skipping the native build entirely" was wrong; only Android/Apple
cross-compilation was actually skipped, and the lint job stayed coupled to
the host Rust toolchain's health exactly as #414 wanted to avoid.
Switch to the issue's other suggested option: commit ferric_example.d.ts and
ferric_example.js as a checked-in fixture (no longer gitignored), and drop
the ferric-example build:types step from the lint job entirely — it no
longer needs to regenerate anything. --dts-only stays, now documented
accurately, as the way to regenerate the fixture by hand after changing
packages/ferric-example/src/lib.rs.
To catch drift, the two CI jobs that already do a real `ferric build`
(Android and Apple triplets) now `git diff --exit-code` the two committed
files right after building. Both are label-gated rather than running on
every PR, so this doesn't fully close the gap — flagged in the PR thread.
Also excludes the two fixture files from Prettier: they're left in napi-rs's
own output formatting so regenerating them reproduces the committed bytes
exactly, and the new drift check doesn't false-positive on formatting alone.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaK9eAAF5G8wj6UT8VekAm
* ci: drop the explanatory comment from ferric-example/.gitignore
Per review feedback on #435.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaK9eAAF5G8wj6UT8VekAm
---------
Co-authored-by: Claude <noreply@anthropic.com>
Add `--dts-only` flag to `ferric build`, generating just the TypeScript declaration file and JS entrypoint without cross-compiling any Android/Apple binaries. It still runs a real host `cargo build` (napi-rs has no lighter typegen-only mode), so it's meant for regenerating a checked-in declarations fixture rather than for environments without a Rust toolchain.
@@ -104,6 +104,10 @@ const xcframeworkExtensionOption = new Option(
104
104
"--xcframework-extension",
105
105
"Don't rename the xcframework to .apple.node",
106
106
).default(false);
107
+
constdtsOnlyOption=newOption(
108
+
"--dts-only",
109
+
"Only generate the TypeScript declarations and entrypoint, skipping Android/Apple cross-compilation. Still runs a real `cargo build` for the host target (napi-rs has no lighter typegen-only mode), so this is not a no-op — it's meant for regenerating a checked-in declarations fixture, not for toolchain-free environments.",
110
+
).default(false);
107
111
108
112
constoutputPathOption=newOption(
109
113
"--output <path>",
@@ -153,6 +157,7 @@ export const buildCommand = new Command("build")
153
157
.addOption(appleBundleIdentifierOption)
154
158
.addOption(concurrencyOption)
155
159
.addOption(verboseOption)
160
+
.addOption(dtsOnlyOption)
156
161
.action(
157
162
wrapAction(
158
163
async({
@@ -167,7 +172,53 @@ export const buildCommand = new Command("build")
167
172
appleBundleIdentifier,
168
173
concurrency,
169
174
verbose,
175
+
dtsOnly,
170
176
})=>{
177
+
if(dtsOnly){
178
+
assertFixable(
179
+
targetArg.length===0&&!apple&&!android&&!clean,
180
+
"The --dts-only flag cannot be combined with --target, --apple, --android or --clean",
181
+
{
182
+
instructions:
183
+
"Drop --dts-only to build native binaries, or remove the other flags to only generate TypeScript declarations",
0 commit comments