1
+ # Contributing to ** node-addon-api**
1
2
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 )
3
9
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 >
4
23
By making a contribution to this project, I certify that:
5
24
6
25
(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
8
27
indicated in the file; or
9
28
10
29
(b) The contribution is based upon previous work that, to the best
11
30
of my knowledge, is covered under an appropriate open source
12
31
license and I have the right under that license to submit that
13
32
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
15
34
permitted to submit under a different license), as indicated
16
35
in the file; or
17
36
18
37
(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
20
39
it.
21
40
22
41
(d) I understand and agree that this project and the contribution
23
42
are public and that a record of the contribution (including all
24
43
personal information I submit with it, including my sign-off) is
25
44
maintained indefinitely and may be redistributed consistent with
26
45
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
27
90
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
29
122
30
123
The ** node-addon-api** team loves contributions. There are many ways in which you can
31
124
contribute to ** node-addon-api** :
32
- - Source code fixes
125
+ - [ New APIs] ( #new-apis )
126
+ - [ Source code fixes] ( #source-changes )
33
127
- Additional tests
34
128
- Documentation improvements
35
129
- Joining the Node-API working group and participating in meetings
36
130
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
38
145
39
146
** node-addon-api** is meant to be a thin convenience wrapper around Node-API. With this
40
147
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**.
56
163
where folks can build on top of it.
57
164
58
165
#### Larger Core
166
+
59
167
This is probably our simplest option in terms of immediate action needed. It
60
168
would involve landing any open PRs against ** node-addon-api** , and continuing to
61
169
encourage folks to make PRs for utility helpers against the same repository.
@@ -65,6 +173,7 @@ The downside of the approach is the following:
65
173
- More maintenance burden on the Node-API WG core team.
66
174
67
175
#### Extras Package
176
+
68
177
This involves us spinning up a new package that contains the utility classes
69
178
and methods. This has the benefit of having a separate module where helpers
70
179
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**)
78
187
- Unclear if the maintenance burden on the Node-API WG is reduced or not
79
188
80
189
#### Ecosystem
190
+
81
191
This doesn't require a ton of up-front work from the Node-API WG. Instead of
82
192
accepting utility PRs into ** node-addon-api** or creating and maintaining a new
83
193
module, the WG will encourage the creation of an ecosystem of modules that
0 commit comments