Skip to content

Commit 42931ee

Browse files
authored
doc: reorganize readme (#1441)
1 parent f85e814 commit 42931ee

File tree

4 files changed

+280
-255
lines changed

4 files changed

+280
-255
lines changed

CONTRIBUTING.md

+117-7
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,147 @@
1+
# Contributing to **node-addon-api**
12

2-
# Developer's Certificate of Origin 1.1
3+
* [Code of Conduct](#code-of-conduct)
4+
* [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin)
5+
* [Tests](#tests)
6+
* [Debug](#debug)
7+
* [Benchmarks](#benchmarks)
8+
* [node-addon-api Contribution Philosophy](#node-addon-api-contribution-philosophy)
39

10+
## Code of Conduct
11+
12+
The Node.js project has a
13+
[Code of Conduct](https://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md)
14+
to which all contributors must adhere.
15+
16+
See [details on our policy on Code of Conduct](https://github.com/nodejs/node/blob/main/doc/contributing/code-of-conduct.md).
17+
18+
<a id="developers-certificate-of-origin"></a>
19+
20+
## Developer's Certificate of Origin 1.1
21+
22+
<pre>
423
By making a contribution to this project, I certify that:
524

625
(a) The contribution was created in whole or in part by me and I
7-
have the right to submit it under the open-source license
26+
have the right to submit it under the open source license
827
indicated in the file; or
928

1029
(b) The contribution is based upon previous work that, to the best
1130
of my knowledge, is covered under an appropriate open source
1231
license and I have the right under that license to submit that
1332
work with modifications, whether created in whole or in part
14-
by me, under the same open-source license (unless I am
33+
by me, under the same open source license (unless I am
1534
permitted to submit under a different license), as indicated
1635
in the file; or
1736

1837
(c) The contribution was provided directly to me by some other
19-
person who certified (a), (b), or (c) and I have not modified
38+
person who certified (a), (b) or (c) and I have not modified
2039
it.
2140

2241
(d) I understand and agree that this project and the contribution
2342
are public and that a record of the contribution (including all
2443
personal information I submit with it, including my sign-off) is
2544
maintained indefinitely and may be redistributed consistent with
2645
this project or the open source license(s) involved.
46+
</pre>
47+
48+
49+
## Tests
50+
51+
To run the **node-addon-api** tests do:
52+
53+
```
54+
npm install
55+
npm test
56+
```
57+
58+
To avoid testing the deprecated portions of the API run
59+
```
60+
npm install
61+
npm test --disable-deprecated
62+
```
63+
64+
To run the tests targeting a specific version of Node-API run
65+
```
66+
npm install
67+
export NAPI_VERSION=X
68+
npm test --NAPI_VERSION=X
69+
```
70+
71+
where X is the version of Node-API you want to target.
72+
73+
To run a specific unit test, filter conditions are available
74+
75+
**Example:**
76+
compile and run only tests on objectwrap.cc and objectwrap.js
77+
```
78+
npm run unit --filter=objectwrap
79+
```
80+
81+
Multiple unit tests cane be selected with wildcards
82+
83+
**Example:**
84+
compile and run all test files ending with "reference" -> function_reference.cc, object_reference.cc, reference.cc
85+
```
86+
npm run unit --filter=*reference
87+
```
88+
89+
Multiple filter conditions can be joined to broaden the test selection
2790

28-
# **node-addon-api** Contribution Philosophy
91+
**Example:**
92+
compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the objectwrap.cc file
93+
npm run unit --filter='*function objectwrap'
94+
95+
## Debug
96+
97+
To run the **node-addon-api** tests with `--debug` option:
98+
99+
```
100+
npm run-script dev
101+
```
102+
103+
If you want a faster build, you might use the following option:
104+
105+
```
106+
npm run-script dev:incremental
107+
```
108+
109+
Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
110+
111+
## Benchmarks
112+
113+
You can run the available benchmarks using the following command:
114+
115+
```
116+
npm run-script benchmark
117+
```
118+
119+
See [benchmark/README.md](benchmark/README.md) for more details about running and adding benchmarks.
120+
121+
## **node-addon-api** Contribution Philosophy
29122

30123
The **node-addon-api** team loves contributions. There are many ways in which you can
31124
contribute to **node-addon-api**:
32-
- Source code fixes
125+
- [New APIs](#new-apis)
126+
- [Source code fixes](#source-changes)
33127
- Additional tests
34128
- Documentation improvements
35129
- Joining the Node-API working group and participating in meetings
36130

37-
## Source changes
131+
### New APIs
132+
133+
As new APIs are added to Node-API, node-addon-api must be updated to provide
134+
wrappers for those new APIs. For this reason, node-addon-api provides
135+
methods that allow callers to obtain the underlying Node-API handles so
136+
direct calls to Node-API and the use of the objects/methods provided by
137+
node-addon-api can be used together. For example, in order to be able
138+
to use an API for which the node-addon-api does not yet provide a wrapper.
139+
140+
APIs exposed by node-addon-api are generally used to create and
141+
manipulate JavaScript values. Concepts and operations generally map
142+
to ideas specified in the **ECMA262 Language Specification**.
143+
144+
### Source changes
38145

39146
**node-addon-api** is meant to be a thin convenience wrapper around Node-API. With this
40147
in mind, contributions of any new APIs that wrap around a core Node-API API will
@@ -56,6 +163,7 @@ idioms while writing native addons with **node-addon-api**.
56163
where folks can build on top of it.
57164

58165
#### Larger Core
166+
59167
This is probably our simplest option in terms of immediate action needed. It
60168
would involve landing any open PRs against **node-addon-api**, and continuing to
61169
encourage folks to make PRs for utility helpers against the same repository.
@@ -65,6 +173,7 @@ The downside of the approach is the following:
65173
- More maintenance burden on the Node-API WG core team.
66174

67175
#### Extras Package
176+
68177
This involves us spinning up a new package that contains the utility classes
69178
and methods. This has the benefit of having a separate module where helpers
70179
make it easier to implement certain patterns and idioms for native addons
@@ -78,6 +187,7 @@ belongs in **node-addon-api** vs **node-addon-api-extras**)
78187
- Unclear if the maintenance burden on the Node-API WG is reduced or not
79188

80189
#### Ecosystem
190+
81191
This doesn't require a ton of up-front work from the Node-API WG. Instead of
82192
accepting utility PRs into **node-addon-api** or creating and maintaining a new
83193
module, the WG will encourage the creation of an ecosystem of modules that

0 commit comments

Comments
 (0)