|
1 | | -# `@napi-rs/package-template` |
| 1 | +# `@alphahydrae/exec` |
2 | 2 |
|
3 | | - |
| 3 | +The [`execvp` function](https://linux.die.net/man/3/execvp) for Node.js. |
4 | 4 |
|
5 | | -> Template project for writing node packages with napi-rs. |
6 | | -
|
7 | | -# Usage |
8 | | - |
9 | | -1. Click **Use this template**. |
10 | | -2. **Clone** your project. |
11 | | -3. Run `yarn install` to install dependencies. |
12 | | -4. Run `npx napi rename -n [name]` command under the project folder to rename your package. |
13 | | - |
14 | | -## Install this test package |
15 | | - |
16 | | -``` |
17 | | -yarn add @napi-rs/package-template |
18 | | -``` |
19 | | - |
20 | | -## Support matrix |
21 | | - |
22 | | -### Operating Systems |
23 | | - |
24 | | -| | node14 | node16 | node18 | |
25 | | -| ---------------- | ------ | ------ | ------ | |
26 | | -| Windows x64 | ✓ | ✓ | ✓ | |
27 | | -| Windows x32 | ✓ | ✓ | ✓ | |
28 | | -| Windows arm64 | ✓ | ✓ | ✓ | |
29 | | -| macOS x64 | ✓ | ✓ | ✓ | |
30 | | -| macOS arm64 | ✓ | ✓ | ✓ | |
31 | | -| Linux x64 gnu | ✓ | ✓ | ✓ | |
32 | | -| Linux x64 musl | ✓ | ✓ | ✓ | |
33 | | -| Linux arm gnu | ✓ | ✓ | ✓ | |
34 | | -| Linux arm64 gnu | ✓ | ✓ | ✓ | |
35 | | -| Linux arm64 musl | ✓ | ✓ | ✓ | |
36 | | -| Android arm64 | ✓ | ✓ | ✓ | |
37 | | -| Android armv7 | ✓ | ✓ | ✓ | |
38 | | -| FreeBSD x64 | ✓ | ✓ | ✓ | |
39 | | - |
40 | | -## Ability |
41 | | - |
42 | | -### Build |
43 | | - |
44 | | -After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs). |
45 | | - |
46 | | -### Test |
47 | | - |
48 | | -With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want. |
49 | | - |
50 | | -### CI |
51 | | - |
52 | | -With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@14`, `node@16`, `@node18`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms. |
53 | | - |
54 | | -### Release |
55 | | - |
56 | | -Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more. |
57 | | - |
58 | | -With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**. |
59 | | - |
60 | | -The other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror). |
61 | | - |
62 | | -In this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm. |
63 | | - |
64 | | -`NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `yarn add @napi-rs/package-template` to see how it works. |
65 | | - |
66 | | -## Develop requirements |
67 | | - |
68 | | -- Install the latest `Rust` |
69 | | -- Install `Node.js@10+` which fully supported `Node-API` |
70 | | -- Install `yarn@1.x` |
71 | | - |
72 | | -## Test in local |
73 | | - |
74 | | -- yarn |
75 | | -- yarn build |
76 | | -- yarn test |
77 | | - |
78 | | -And you will see: |
| 5 | +## Install this package |
79 | 6 |
|
80 | 7 | ```bash |
81 | | -$ ava --verbose |
82 | | - |
83 | | - ✔ sync function from native code |
84 | | - ✔ sleep function from native code (201ms) |
85 | | - ─ |
86 | | - |
87 | | - 2 tests passed |
88 | | -✨ Done in 1.12s. |
| 8 | +npm i @alphahydrae/exec |
89 | 9 | ``` |
90 | 10 |
|
91 | | -## Release package |
92 | | - |
93 | | -Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting. |
94 | | - |
95 | | -In `Settings -> Secrets`, add **NPM_TOKEN** into it. |
96 | | - |
97 | | -When you want to release the package: |
98 | | - |
99 | | -``` |
100 | | -npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git] |
101 | | -
|
102 | | -git push |
103 | | -``` |
| 11 | +## Support matrix |
104 | 12 |
|
105 | | -GitHub actions will do the rest job for you. |
| 13 | +| OS & Architecture | Node 18 | Node 20 | Node 22 | |
| 14 | +| ----------------- | ------- | ------- | ------- | |
| 15 | +| macOS x64 | ✓ | ✓ | ✓ | |
| 16 | +| macOS arm64 | ✓ | ✓ | ✓ | |
| 17 | +| Linux x64 gnu | ✓ | ✓ | ✓ | |
| 18 | +| Linux x64 musl | ✓ | ✓ | ✓ | |
| 19 | +| Linux arm64 gnu | ✓ | ✓ | ✓ | |
| 20 | +| Linux arm64 musl | ✓ | ✓ | ✓ | |
0 commit comments