1 | # `@napi-rs/cli`
|
2 |
|
3 | [![Download](https://img.shields.io/npm/dm/@napi-rs/cli)](https://www.npmjs.com/package/@napi-rs/cli)
|
4 | [![Install size](https://packagephobia.com/badge?p=@napi-rs/cli)](https://packagephobia.com/result?p=@napi-rs/cli)
|
5 | <a href="https://discord.gg/SpWzYHsKHs">
|
6 | <img src="https://img.shields.io/discord/874290842444111882.svg?logo=discord&style=flat-square"
|
7 | alt="chat" />
|
8 | </a>
|
9 |
|
10 | > Cli tools for napi-rs
|
11 |
|
12 | ## Commands
|
13 |
|
14 | ### Debug mode
|
15 |
|
16 | ```bash
|
17 | DEBUG="napi:*" napi [command]
|
18 | ```
|
19 |
|
20 | ### `napi build`
|
21 |
|
22 | > Build command. Build rust codes and copy the dynamic lib binary file to the dist dir.
|
23 |
|
24 | #### `--platform`
|
25 |
|
26 | > default `false`
|
27 |
|
28 | Append `platform-arch-[abi]` name to dist file. eg: `index.darwin-x64.node`.
|
29 |
|
30 | #### `--release`
|
31 |
|
32 | > default `false`
|
33 |
|
34 | Is release build. This flag will be passed to `Cargo` directly.
|
35 |
|
36 | #### `--features`
|
37 |
|
38 | > default `''`
|
39 |
|
40 | Cargo features, passthrough to `cargo build` command.
|
41 |
|
42 | #### `--config,-c`
|
43 |
|
44 | > default `package.json`
|
45 |
|
46 | `napi-rs` config file name. `napi-rs` config example :
|
47 |
|
48 | ```js
|
49 | {
|
50 | "name": "@native-binding/fib",
|
51 | "version": "0.1.0",
|
52 | "napi": {
|
53 | "name": "fib", // binary name
|
54 | "triples": {
|
55 | "defaults": true, // default true, if this value is true, will build `x86_64-pc-windows-msvc`, `x86_64-apple-darwin` and `x86_64-unknown-linux-gnu`
|
56 | "additional": [
|
57 | "x86_64-unknown-linux-musl",
|
58 | "x86_64-unknown-freebsd",
|
59 | "aarch64-unknown-linux-gnu"
|
60 | ]
|
61 | }
|
62 | }
|
63 | }
|
64 | ```
|
65 |
|
66 | #### `--cargo-name`
|
67 |
|
68 | > default `undefined`
|
69 |
|
70 | If not set, cli will read the `package.name` field in `Cargo.toml` under `process.cwd()`. The `-` in the name will be replaced with `_`.
|
71 |
|
72 | #### `--target`
|
73 |
|
74 | > default `undefined`
|
75 |
|
76 | > Note you should have `rustup` installed if omit the `--target` flag. The `@napi-rs/cli` will try to find the default target on your system via `rustup` if no `--target` specified.
|
77 |
|
78 | You can also define this value using the `RUST_TARGET` environment variable.
|
79 |
|
80 | This value will be passed to `Cargo build` command directly. eg: `napi build --target x86_64-unknown-linux-musl`
|
81 |
|
82 | #### `--cargo-flags`
|
83 |
|
84 | > default `undefined`
|
85 |
|
86 | Other flags you want pass to `Cargo build`.
|
87 |
|
88 | #### `--cargo-cwd`
|
89 |
|
90 | > default `undefined`
|
91 |
|
92 | This flag can be used to build binaries that are not in the current directory. The path that is passed to this flag should be relative to the current directory.
|
93 |
|
94 | ### `napi artifacts`
|
95 |
|
96 | > Copy artifact files in Github actions.
|