Add peer meta
This commit is contained in:
parent
f9fe9f0124
commit
9857670794
|
@ -3,6 +3,7 @@
|
||||||
There is a C++ header file, `addon-tools.hpp`, shipped with this package. It
|
There is a C++ header file, `addon-tools.hpp`, shipped with this package. It
|
||||||
introduces several useful macros and utilities. Also it includes **Napi**
|
introduces several useful macros and utilities. Also it includes **Napi**
|
||||||
implicitly, so you can replace:
|
implicitly, so you can replace:
|
||||||
|
|
||||||
```
|
```
|
||||||
#include <napi.h>
|
#include <napi.h>
|
||||||
```
|
```
|
||||||
|
|
|
@ -31,7 +31,6 @@ public:
|
||||||
JS_DECLARE_METHOD(ClassName, ClassName, destroy);
|
JS_DECLARE_METHOD(ClassName, ClassName, destroy);
|
||||||
|
|
||||||
bool _isDestroyed;
|
bool _isDestroyed;
|
||||||
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -62,13 +61,10 @@ void ClassName::init(Napi::Env env, Napi::Object exports) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassName::ClassName(const Napi::CallbackInfo &info) { NAPI_ENV;
|
ClassName::ClassName(const Napi::CallbackInfo &info) { NAPI_ENV;
|
||||||
|
|
||||||
super(info);
|
super(info);
|
||||||
|
|
||||||
_isDestroyed = false;
|
_isDestroyed = false;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassName::~ClassName() {
|
ClassName::~ClassName() {
|
||||||
|
|
|
@ -73,12 +73,12 @@ directory. E.g. on Windows it will be **bin-windows**.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Publishing binaries is done by attaching a zipped platform folder to the Github
|
Publishing binaries is done by attaching a zipped platform folder to the GitHub
|
||||||
release. Zip file must NOT contain platform folder as a subfolder, but rather
|
release. Zip file must NOT contain platform folder as a subfolder, but rather
|
||||||
contain the final binaries. The tag of the release should be the same as in
|
contain the final binaries. The tag of the release should be the same as in
|
||||||
`npm_package_config_install` - that is the way installer will find it.
|
`npm_package_config_install` - that is the way installer will find it.
|
||||||
|
|
||||||
> NOTE: You can publish your binaries to anywhere, not necessarily Github.
|
> NOTE: You can publish your binaries to anywhere, not necessarily GitHub.
|
||||||
Just tweak **YOUR install.js** script as appropriate. The only limitation
|
Just tweak **YOUR install.js** script as appropriate. The only limitation
|
||||||
from **Addon Tools** is that it should be a zipped set of files/folders.
|
from **Addon Tools** is that it should be a zipped set of files/folders.
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ from **Addon Tools** is that it should be a zipped set of files/folders.
|
||||||
|
|
||||||
```
|
```
|
||||||
'variables': {
|
'variables': {
|
||||||
'bin' : '<!(node -p "require(\'addon-tools-raub\').bin")',
|
'bin': '<!(node -p "require(\'addon-tools-raub\').bin")',
|
||||||
'DEPS_include' : '<!(node -p "require(\'DEPS\').include")',
|
'DEPS_include': '<!(node -p "require(\'DEPS\').include")',
|
||||||
'DEPS_bin' : '<!(node -p "require(\'DEPS\').bin")',
|
'DEPS_bin': '<!(node -p "require(\'DEPS\').bin")',
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
22
index.js
22
index.js
|
@ -1,12 +1,18 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const napi = require('node-addon-api');
|
let napi = null;
|
||||||
|
try {
|
||||||
|
napi = require('node-addon-api');
|
||||||
|
} catch (ex) {
|
||||||
|
console.error('To build addons, `node-addon-api` module is required.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const platformNames = {
|
const platformNames = {
|
||||||
win32 : 'windows',
|
win32: 'windows',
|
||||||
linux : 'linux',
|
linux: 'linux',
|
||||||
darwin : 'osx',
|
darwin: 'osx',
|
||||||
};
|
};
|
||||||
|
|
||||||
const platformName = platformNames[process.platform];
|
const platformName = platformNames[process.platform];
|
||||||
|
@ -27,7 +33,7 @@ const includePath = `${napiInclude} ${thisInclude}`;
|
||||||
const paths = dir => {
|
const paths = dir => {
|
||||||
dir = dir.replace(/\\/g, '/');
|
dir = dir.replace(/\\/g, '/');
|
||||||
|
|
||||||
const bin = `${dir}/bin-${platformName}`;
|
const bin = `${dir}/bin-${platformName}`;
|
||||||
const include = `${dir}/include`;
|
const include = `${dir}/include`;
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
|
@ -40,7 +46,7 @@ const paths = dir => {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
paths,
|
paths,
|
||||||
bin : `bin-${platformName}`,
|
bin: `bin-${platformName}`,
|
||||||
platform : platformName,
|
platform: platformName,
|
||||||
include : includePath,
|
include: includePath,
|
||||||
};
|
};
|
||||||
|
|
14
install.js
14
install.js
|
@ -1,10 +1,16 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const AdmZip = require('adm-zip');
|
|
||||||
|
let AdmZip = null;
|
||||||
|
try {
|
||||||
|
AdmZip = require('adm-zip');
|
||||||
|
} catch (ex) {
|
||||||
|
console.error('The `install` script requires `adm-zip` module to be installed.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const { bin, platform } = require('.');
|
const { bin, platform } = require('.');
|
||||||
const { mkdir, rm } = require('./utils');
|
const { mkdir, rm } = require('./utils');
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
"adm-zip": "^0.5.9",
|
"adm-zip": "^0.5.9",
|
||||||
"node-addon-api": "^5.0.0"
|
"node-addon-api": "^5.0.0"
|
||||||
},
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"adm-zip": { "optional": true },
|
||||||
|
"node-addon-api": { "optional": true }
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"adm-zip": "^0.5.9",
|
"adm-zip": "^0.5.9",
|
||||||
"eslint-plugin-jest": "^27.0.4",
|
"eslint-plugin-jest": "^27.0.4",
|
||||||
|
|
Loading…
Reference in New Issue