Skip to content
Preview: packages are not published yet.

CLI: dev and check

CLI reference for the React team and CI: commands for development and checks. Every nuib command at a glance, then nuib dev, its ios, android and viewer forms, and nuib check.

Run every command in the React project directory, or pass --project <dir>. Each command accepts -h or --help, which prints its options and exits with 0. An option that takes a value needs one: a missing value, or an unknown option, stops the command with exit code 1.

nuib is not on your PATH. The nitro-ui-brownfield-cli package puts it in the project’s node_modules/.bin, and it runs with Bun. Run it inside the project as bun run nuib <command>. The synopses on this page write nuib for short; the examples write the full form.

Command What it does Builds native code
nuib dev Starts the dev server of the project. No
nuib dev ios, nuib dev android Opens the native app on a simulator or emulator with the React project live in it. Yes
nuib dev ios --viewer, nuib dev android --viewer Opens the viewer app instead of the native app. Yes
nuib check Checks types, contract, version and size against the previous manifest. No
nuib package Packages the project as one binary artifact per platform, with manifest.json. Yes
nuib publish Publishes the packaged artifacts as one version in a local registry directory. No
nuib link Advanced. Packages locally and makes a native app use the local artifact. Yes
nuib unlink Advanced. Undoes nuib link. No
nuib help, nuib --help, nuib -h Prints the list of commands. No

Synopsis:

nuib dev [--port <n>] [--project <dir>]

Starts the dev server of the React project and nothing else. The server runs in the foreground of the terminal and its keys work: r reloads, m opens the developer menu, q quits.

If a dev server already answers on the port, the command uses it and exits with 0. A new server must answer within 60 seconds, or the command fails.

Option Default Meaning
--port <n> dev.port, else 8081 The dev server port, 1 to 65535.
--project <dir> Current directory The React project.
-h, --help Prints the help text.

The exit code of the dev server when it ends. 0 when a server that was already running is used. 1 on a usage or configuration error. 130, 143 or 129 when the command is stopped by SIGINT (Ctrl-C), SIGTERM or SIGHUP.

Terminal window
bun run nuib dev --port 8090

Synopsis:

nuib dev ios [--device <udid|name>] [--port <n>] [--project <dir>]
nuib dev android [--device <serial>] [--port <n>] [--project <dir>]

Opens the native app configured in hosts.ios or hosts.android on a booted simulator or a connected emulator, with the React project live in it. The command takes one platform. It runs these steps in order:

  • Picks the simulator or emulator, before anything is built.
  • Packages the dev variant for it (iOS: the simulator slice). Caches skip what did not change.
  • Points the native app at that artifact, as nuib link --dev does.
  • Builds the native app. iOS uses the scheme in hosts.ios.scheme and the Debug configuration by default. Android runs the assembleDebug task of the module in hosts.android.module (app by default).
  • Installs the build, unless the same build is already installed on that device.
  • Android only: forwards the port with adb reverse.
  • Starts the dev server, unless one already answers on the port.
  • Launches the app.

The app loads from the dev server and shows its embedded content when the server does not answer. The command stays in the foreground with the server. When it ends, with q, Ctrl-C, a signal or an error at any step, it points the native app back at its published dependency, as nuib unlink does. If a server already answered on the port, the command launches the app, points the native app back and exits.

If an earlier nuib dev was killed before it could clean up, the next nuib dev undoes the link it left and says so.

Option Default Meaning
--device <udid|name|serial> The only one running The simulator (UDID or name) or the emulator (serial). Needed when several are running. Needs a platform.
--port <n> dev.port, else 8081 The dev server port, 1 to 65535. The dev artifact records http://localhost:<n>.
--viewer Off Opens the viewer instead of the native app.
--project <dir> Current directory The React project.
-h, --help Prints the help text.

The exit code of the dev server when it ends. 0 when a server that was already running is used. 1 when a step fails: no hosts entry, no device or several without --device, a failed build. 130, 143 or 129 when stopped by SIGINT, SIGTERM or SIGHUP.

Terminal window
bun run nuib dev ios --device "iPhone 16"

Synopsis:

nuib dev ios --viewer [--device <udid|name>] [--port <n>] [--project <dir>]
nuib dev android --viewer [--device <serial>] [--port <n>] [--project <dir>]

The viewer is a small native app for working on surfaces without the real native app. It lists the project’s surfaces and opens each one with props from a form generated from the contract. The viewer is not a separate command: it is the --viewer option of nuib dev ios and nuib dev android. It needs no hosts entry.

The command starts the dev server first, unless one already answers. It then picks the device, packages the dev variant into <project>/.nuib/viewer/<platform>/artifact, builds the viewer or reuses a cached build, installs it, pairs it with the dev server and opens it. Contract changes, presets and app code reach a cached viewer without a rebuild.

If the viewer step fails, the command prints the error and keeps the dev server it started running.

Option Default Meaning
--viewer Off Opens the viewer instead of the native app. Needs a platform.
--device <udid|name|serial> The only one running The simulator or emulator. When several are running and the option is missing, the viewer step stops before any packaging or build. --viewer-device is accepted as an older name of this option.
--port <n> dev.port, else 8081 The dev server port.
--project <dir> Current directory The React project.

A file named <Surface>.presets.json gives the viewer named sets of props for that surface. The command searches the whole project for these files, except node_modules, ios, android, build, dist, Pods, DerivedData and directories whose name starts with a dot. Each preset is checked against the contract: required props must be present, types must match, unknown keys and null are refused. An invalid preset is left out and printed.

PointsHistory.presets.json
{
"presets": [
{ "name": "Default", "props": { "userId": "42" } },
{ "name": "Compact", "props": { "userId": "42", "compact": true } }
]
}

The same as nuib dev. When the viewer does not open and the dev server was already running, the command exits with 1.

Terminal window
bun run nuib dev ios --viewer --port 8090

Synopsis:

nuib check [--against <manifest.json>] [--registry <dir>] [--manifest <manifest.json>]
[--max-size-increase <limit>] [--json] [--project <dir>]

Checks the React project without building native code and without a device. It runs five checks and reports every problem at once. The report also has an engine line that compares the engine with the previous manifest; it is information only and never fails the check.

Check What it does
types Runs the project’s own TypeScript: tsc --noEmit -p tsconfig.json. Skipped when the project has no tsconfig.json.
contract Reads every registerSurface call and its props. Reports each prop that does not fit in JSON, with file and line.
diff Compares the contract with the previous manifest and classifies each difference as breaking or additive.
version Proposes the next version from the diff and compares it with brownfield.version. Fails when the contract breaks without a major bump (in 0.x: without a minor bump), or when the configured version is lower than the previous one. A bump smaller or larger than needed for a non-breaking change is a warning.
size Compares the sizes in the current packaged manifest with the previous one, per layer and per iOS slice or Android ABI.
  • With --against: that file.
  • Otherwise, from the registry (--registry, else brownfield.registry): the manifest of the highest published version that is not newer than brownfield.version.
  • With no registry, or nothing published at or below the configured version: there is none. Every surface is listed as new, and the version policy and size are not checked.
Option Default Meaning
--against <manifest.json> None The previous manifest. Overrides the registry. A file that cannot be read is an error.
--registry <dir> brownfield.registry The local registry of nuib publish.
--manifest <manifest.json> <project>/.nuib/out/manifest.json, when it exists The current packaged manifest, used for sizes and engine hashes. An explicit file that cannot be read is an error. A default one that cannot be read only skips the size check.
--max-size-increase <limit> No limit Fails when a shipped figure grows by more than the limit: bytes (2048), KB or MB (1024-based), or a percentage (5%). Shipped figures are the iOS slice binary, the Android AAR and the runtime library of each ABI.
--json Off Prints one JSON document (schema nuib.check/1) instead of the report.
--project <dir> Current directory The React project.
-h, --help Prints the help text.

With --json, every key is always present; a value that does not apply is null or an empty list. CI usually reads these keys:

Key Value
status ok or failed
exitCode The exit code of the command
failures A list of types, contract, version, size
types.errors[] file, line, column, code, message
contract.errors[] file, line, column, surface, property, message
previous source, name, version, variant, schema of the previous manifest, or null
diff status (compared, no-previous, skipped), level (major, minor, patch) and changes[] with kind, impact, surface, path, detail, source. The kinds are listed in Check the contract.
engine status (same, changed, unknown), basis (engine-hash, nitro-ui-version, or null), details[], notice. Informational: it never fails the check. The last value means the comparison used the installed Nitro UI version.
version status (ok, warning, failed, skipped), previous, configured, level, proposed, actual, messages[]
size status (ok, failed, skipped), threshold, entries[], notes[]

The document also has schema (nuib.check/1), project and artifact (name, version).

0 when every check passed; warnings do not fail. 1 on a usage or configuration error, or a manifest that cannot be read. Otherwise the sum of the failing checks: 4 types, 8 contract, 16 version policy, 32 size threshold. Types and contract failing together give 12.

Terminal window
bun run nuib check
Terminal window
bun run nuib check --against last/manifest.json --max-size-increase 500KB
Terminal window
bun run nuib check --json > check.json