From 5d4708dfdf2e82934932ee4c40e78e0a50fc7678 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Mon, 5 Dec 2022 22:44:35 +0400 Subject: [PATCH] Update info --- .eslintrc | 4 +- .vscode/c_cpp_properties.json | 3 +- README.md | 3 +- doc/addon-tools.md | 4 +- doc/snippets.md | 142 +++++++++++++++++----------------- package-lock.json | 4 +- package.json | 4 +- test/binding.gyp | 85 +++++++++----------- 8 files changed, 116 insertions(+), 133 deletions(-) diff --git a/.eslintrc b/.eslintrc index b99c236..43aec9f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -82,11 +82,11 @@ "no-console": [0], "node/no-unsupported-features/es-builtins": [ "error", - { "version": ">=16.17.0" } + { "version": ">=18.12.1" } ], "node/no-unsupported-features/node-builtins": [ "error", - { "version": ">=16.17.0" } + { "version": ">=18.12.1" } ], "func-names": [ "error", diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index dae57c0..a791e80 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,7 +4,8 @@ "name": "Win32", "includePath": [ "${workspaceFolder}/**", - "${LocalAppData}/node-gyp/Cache/16.17.0/include/node" + "${LocalAppData}/node-gyp/Cache/16.17.0/include/node", + "${LocalAppData}/node-gyp/Cache/18.12.1/include/node" ], "defines": [ "UNICODE", diff --git a/README.md b/README.md index 10c88b1..80c17d4 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ This is a part of [Node3D](https://github.com/node-3d) project. -[![NPM Package][npm]][npm-url] -[![NPM](https://nodei.co/npm/addon-tools-raub.png?compact=true)](https://www.npmjs.com/package/addon-tools-raub) +[![NPM](https://badge.fury.io/js/addon-tools-raub.svg)](https://badge.fury.io/js/addon-tools-raub) [![CodeFactor](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub/badge)](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub) ``` diff --git a/doc/addon-tools.md b/doc/addon-tools.md index b6848d7..9bc7376 100644 --- a/doc/addon-tools.md +++ b/doc/addon-tools.md @@ -22,7 +22,7 @@ require('addon-tools-raub').include // a string ### Helpers in **addon-tools.hpp**: Usually all the helpers work within the context of a method. In this case we -have `CallbackInfo info` passed as an argument. And we can return `undefined` +have `Napi::CallbackInfo info` passed as an argument. And we can return `undefined` in case a problem has occured. So most of these macros are only usable within `Napi::Value`-returning functions. @@ -42,6 +42,7 @@ within `Napi::Value`-returning functions. * `RET_NUM(VAL)` - return `Napi::Number`, expected `VAL` is of numeric type. * `RET_EXT(VAL)` - return `Napi::External`, expected `VAL` is a pointer. * `RET_BOOL(VAL)` - return `Napi::Boolean`, expected `VAL` is convertible to bool. +* `RET_ARRAY_STR(VAL)` - return `Napi::Array`, expected `VAL` is `std::vector`. @@ -150,6 +151,7 @@ That extrapolates well to all the helpers below: | `REQ_ARRAY_ARG` | `object` | `Napi::Array` | - | | `USE_ARRAY_ARG` | `object` | `Napi::Array` | - | | `LET_ARRAY_ARG` | `object` | `Napi::Array` | `[]` | +| `LET_ARRAY_STR_ARG` | `object` | `std::vector` | `std::vector()` | | `REQ_FUN_ARG` | `function` | `Napi::Function` | - | | `REQ_ARRV_ARG` | `ArrayBuffer` | `Napi::ArrayBuffer` | - | | `REQ_BUF_ARG` | `Buffer` | `Napi::Buffer` | - | diff --git a/doc/snippets.md b/doc/snippets.md index 00bff00..65ba28d 100644 --- a/doc/snippets.md +++ b/doc/snippets.md @@ -14,10 +14,12 @@ A snippet for **src/package.json**: "version": "0.0.0", "private": true, "scripts": { - "build": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" + "build": "node-gyp rebuild" + "build-dev": "node-gyp build && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" + "rebuild-dev": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" }, "dependencies": { - "addon-tools-raub": "6.0.0", + "addon-tools-raub": "6.1.0", "DEPS": "1.0.0" } } @@ -34,26 +36,32 @@ In **package.json** use the `"postinstall"` script to download the libraries. For example the following structure might work. Note that **Addon Tools** will append any given URL with `/${platform}.zip` +In **package.json**: + ``` - "config" : { - "install" : "v1.0.0" - }, "scripts": { - "postinstall": "install", + "postinstall": "node install", }, + "dependencies": { + "addon-tools-raub": "^6.0.2", + "adm-zip": "^0.5.9" + }, + "devDependencies": { + "node-addon-api": "^5.0.0" + } ``` -Here `config.install` is the tag name to download the binaries from. -To use it, create the *install.js* file in your addon: +Create the **install.js** file: ``` +'use strict'; const install = require('addon-tools-raub/install'); -const prefix = 'https://github.com/USER/ADDON/releases/download'; -const tag = process.env.npm_package_config_install; +const prefix = 'https://github.com/node-3d/glfw-raub/releases/download'; +const tag = '4.8.0'; install(`${prefix}/${tag}`); ``` -**Addon Tools** will unzip the downloaded file into the platform binary +**Addon Tools** will unzip (using **adm-zip**) the downloaded file into the platform binary directory. E.g. on Windows it will be **bin-windows**. * For a dependency package: @@ -76,7 +84,7 @@ directory. E.g. on Windows it will be **bin-windows**. 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 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. +**install.js**. > NOTE: You can publish your binaries to anywhere, not necessarily GitHub. Just tweak **YOUR install.js** script as appropriate. The only limitation @@ -128,70 +136,58 @@ dependency include path(s). 'DEPS_include' : '=16.17.0", - "npm": ">=8.15.0" + "node": ">=18.12.1", + "npm": ">=8.19.2" }, "peerDependencies": { "adm-zip": "^0.5.9", diff --git a/package.json b/package.json index e8dd4b9..a7ea785 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "README.md" ], "engines": { - "node": ">=16.17.0", - "npm": ">=8.15.0" + "node": ">=18.12.1", + "npm": ">=8.19.2" }, "scripts": { "eslint": "eslint .", diff --git a/test/binding.gyp b/test/binding.gyp index a38cb16..e03fa77 100644 --- a/test/binding.gyp +++ b/test/binding.gyp @@ -1,53 +1,38 @@ { - 'targets': [ - { - 'target_name': 'test', - 'sources': [ - 'test.cpp', - ], - 'defines': [ - 'UNICODE', '_UNICODE' - ], - 'include_dirs': [ - '