Skip to content

fix(cli): align build and project configuration - #3387

Merged
Brooooooklyn merged 7 commits into
mainfrom
agent/cli-explicit-options
Jul 11, 2026
Merged

Brooooooklyn merged 7 commits into
mainfrom
agent/cli-explicit-options

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Summary

This consolidates the current CLI and README fixes into one change set:

  • resolve relative WASI artifact output paths from the project cwd
  • honor explicit --bin and dtsHeaderFile options
  • require ANDROID_NDK_LATEST_HOME for Android cross-builds
  • apply napi new --min-node-api to the generated Cargo features
  • refresh the napi crate's CLI setup example
  • add focused regression coverage for the affected CLI paths

Why

Several user-facing settings were advertised or accepted without being applied consistently:

  • artifact paths could resolve against the process cwd instead of the configured project
  • a mixed cdylib/binary crate could ignore --bin
  • the exported type-generation API ignored its explicit header-file option
  • Android builds continued with an undefined NDK path
  • generated projects changed their Node engine constraint without changing the Cargo Node-API feature
  • the README still showed obsolete package and napi configuration fields

Together these fixes make the CLI's declared configuration match the behavior users receive.

Validation

  • yarn workspace @napi-rs/cli test (123 passed)
  • yarn workspace @napi-rs/cli build
  • focused Oxlint checks
  • Prettier checks
  • git diff --check origin/main...HEAD

The Android behavior already matches the deployed documentation at https://napi.rs/docs/cross-build#android.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now supports newer Node.js and Node-API versions, updates generated Cargo configuration, handles explicit binaries and Android prerequisites, resolves relative WASI artifact paths, prioritizes DTS headers, and adds regression coverage and documentation updates.

Changes

CLI behavior and compatibility

Layer / File(s) Summary
Node-API version configuration
cli/src/api/new.ts, cli/src/utils/version.ts, cli/src/api/__tests__/new-node-api-version.spec.ts, cli/src/utils/__tests__/__snapshots__/version.spec.ts.md
Project creation validates minNodeApiVersion, supports Node-API 10, and rewrites Cargo.toml napi features and defaults for the selected version.
Build mode and validation behavior
cli/src/api/build.ts, cli/src/api/__tests__/android-build.spec.ts, cli/src/api/__tests__/build-regressions.spec.ts
Explicit --bin builds produce executable outputs without cdylib checks, Android builds require ANDROID_NDK_LATEST_HOME, and explicit DTS headers take precedence over configured headers.
WASI artifact path resolution
cli/src/api/artifacts.ts, cli/src/api/__tests__/artifacts.spec.ts
Relative WASI build output directories are resolved against cwd, with copied artifact and browser URL behavior covered by tests.
CLI compatibility documentation
cli/package.json, crates/napi/README.md
The supported Node.js engine range and CLI installation and configuration examples are updated.
Runtime error formatting
crates/napi/src/bindgen_runtime/callback_info.rs
Callback argument error formatting passes the argument count directly to interpolation.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProjectCreator
  participant OptionProcessor
  participant CargoTomlUpdater
  participant CargoToml
  ProjectCreator->>OptionProcessor: validate minimum Node-API version
  OptionProcessor-->>ProjectCreator: normalized project options
  ProjectCreator->>CargoTomlUpdater: apply Node-API configuration
  CargoTomlUpdater->>CargoToml: rewrite napi features and defaults
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and broadly matches the PR’s CLI build and project-configuration changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/cli-explicit-options

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Brooooooklyn Brooooooklyn changed the title fix(cli): honor explicit build and artifact options fix(cli): align build and project configuration Jul 10, 2026
@Brooooooklyn
Brooooooklyn marked this pull request as ready for review July 10, 2026 15:00
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_0ebb1872-ca25-4a61-9cd1-382522adb4a0)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51707a4aea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/src/api/build.ts Resolved
Comment thread cli/src/api/new.ts Resolved
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_dd406df8-9a27-4451-979c-bc1a63e26ec0)

@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_e90b7d68-29d6-4eb8-ba11-e8c4119ef2b8)

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