|
1 |
| -## To publish N-API version of a package alongside a non-N-API version |
| 1 | +--- |
| 2 | +title: How to publish N-API package |
| 3 | +layout: docs.hbs |
| 4 | +--- |
| 5 | + |
| 6 | +# To publish N-API version of a package alongside a non-N-API version |
2 | 7 |
|
3 | 8 | The following steps are illustrated using the package `iotivity-node`:
|
4 | 9 | - First, publish the non-N-API version:
|
5 |
| - - Update the version in `package.json`. For `iotivity-node`, the version |
| 10 | + - Update the version in `package.json`. For `iotivity-node`, the version |
6 | 11 | becomes `1.2.0-2`.
|
7 | 12 | - Go through the release checklist (ensure tests/demos/docs are OK)
|
8 | 13 | - `npm publish`
|
9 | 14 | - Then, publish the N-API version:
|
10 |
| - - Update the version in `package.json`. In the case of `iotivity-node`, |
11 |
| - the version becomes `1.2.0-3`. For versioning, we recommend following |
12 |
| - the pre-release version scheme as described by |
| 15 | + - Update the version in `package.json`. In the case of `iotivity-node`, |
| 16 | + the version becomes `1.2.0-3`. For versioning, we recommend following |
| 17 | + the pre-release version scheme as described by |
13 | 18 | [semver.org](http://semver.org/#spec-item-9) e.g. `1.2.0-napi`.
|
14 | 19 | - Go through the release checklist (ensure tests/demos/docs are OK)
|
15 | 20 | - `npm publish --tag n-api`
|
16 | 21 |
|
17 |
| -In this example, tagging the release with `n-api` has ensured that, although |
18 |
| -version 1.2.0-3 is later than the non-N-API published version (1.2.0-2), it |
19 |
| -will not be installed if someone chooses to install `iotivity-node` by simply |
20 |
| -running `npm install iotivity-node`. This will install the non-N-API version |
21 |
| -by default. The user will have to run `npm install iotivity-node@n-api` to |
22 |
| -receive the N-API version. For more information on using tags with npm check |
| 22 | +In this example, tagging the release with `n-api` has ensured that, although |
| 23 | +version 1.2.0-3 is later than the non-N-API published version (1.2.0-2), it |
| 24 | +will not be installed if someone chooses to install `iotivity-node` by simply |
| 25 | +running `npm install iotivity-node`. This will install the non-N-API version |
| 26 | +by default. The user will have to run `npm install iotivity-node@n-api` to |
| 27 | +receive the N-API version. For more information on using tags with npm check |
23 | 28 | out ["Using dist-tags"][].
|
24 | 29 |
|
25 |
| -## To introduce a dependency on an N-API version of a package |
| 30 | +# To introduce a dependency on an N-API version of a package |
26 | 31 |
|
27 |
| -To add the N-API version of `iotivity-node` as a dependency, the `package.json` |
| 32 | +To add the N-API version of `iotivity-node` as a dependency, the `package.json` |
28 | 33 | will look like this:
|
29 | 34 |
|
30 |
| -```JSON |
31 |
| - "dependencies": { |
32 |
| - "iotivity-node": "n-api" |
33 |
| - } |
| 35 | +```json |
| 36 | +"dependencies": { |
| 37 | + "iotivity-node": "n-api" |
| 38 | +} |
34 | 39 | ```
|
35 | 40 |
|
36 |
| -**Note:** As explained in |
37 |
| -["Using dist-tags"][], unlike regular versions, tagged versions cannot be |
38 |
| -addressed by version ranges such as `"^2.0.0"` inside `package.json`. The |
39 |
| -reason for this is that the tag refers to exactly one version. So, if the |
40 |
| -package maintainer chooses to tag a later version of the package using the |
41 |
| -same tag, `npm update` will receive the later version. This should be acceptable |
42 |
| -given the currently experimental nature of N-API. To depend on an N-API-enabled |
43 |
| -version other than the latest published, the `package.json` dependency will |
| 41 | +**Note:** As explained in |
| 42 | +["Using dist-tags"][], unlike regular versions, tagged versions cannot be |
| 43 | +addressed by version ranges such as `"^2.0.0"` inside `package.json`. The |
| 44 | +reason for this is that the tag refers to exactly one version. So, if the |
| 45 | +package maintainer chooses to tag a later version of the package using the |
| 46 | +same tag, `npm update` will receive the later version. This should be acceptable |
| 47 | +given the currently experimental nature of N-API. To depend on an N-API-enabled |
| 48 | +version other than the latest published, the `package.json` dependency will |
44 | 49 | have to refer to the exact version like the following:
|
45 | 50 |
|
46 |
| -```JSON |
47 |
| - "dependencies": { |
48 |
| - "iotivity-node": "1.2.0-3" |
49 |
| - } |
| 51 | +```json |
| 52 | +"dependencies": { |
| 53 | + "iotivity-node": "1.2.0-3" |
| 54 | +} |
50 | 55 | ```
|
51 | 56 |
|
52 |
| - |
53 | 57 | ["Using dist-tags"]: https://docs.npmjs.com/getting-started/using-tags
|
0 commit comments