diff --git a/.gitignore b/.gitignore index 7990d97d5..b3634130d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ local.env .eslintrc.js setup.sh /build-tmp-napi-v3 +/build-tmp-napi-v6 diff --git a/.travis.yml b/.travis.yml index 14b7374ae..d07a1d556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ matrix: # electron Linux - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.2.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.2.0" dist: trusty addons: apt: @@ -83,7 +83,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.1.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.1.0" dist: trusty addons: apt: @@ -91,7 +91,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.0.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.0.0" dist: trusty addons: apt: @@ -99,7 +99,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.2.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.2.0" dist: trusty addons: apt: @@ -107,7 +107,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.1.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.1.0" dist: trusty addons: apt: @@ -115,7 +115,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.0.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.0.0" dist: trusty addons: apt: @@ -123,7 +123,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="6.1.0" + env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.1.0" dist: trusty addons: apt: @@ -131,7 +131,7 @@ matrix: packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] - os: linux compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="6.0.0" + env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.0.0" dist: trusty # needed for libc6 / 'version `GLIBC_2.17` not found' error on precise addons: apt: @@ -140,28 +140,28 @@ matrix: # electron MacOs - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.2.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.2.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.1.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.1.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="8.0.0" + env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.0.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.2.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.2.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.1.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.1.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="7.0.0" + env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.0.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="6.1.0" + env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.1.0" - os: osx compiler: clang - env: NODE_VERSION="12" ELECTRON_VERSION="6.0.0" + env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.0.0" env: global: diff --git a/appveyor.yml b/appveyor.yml index 249b24028..80bdbbb09 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,88 +21,88 @@ environment: - nodejs_version: 14 platform: x86 # electron - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.2.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.2.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.13.0 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 8.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.2.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.2.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.8.1 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 7.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.4.0 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 6.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.4.0 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 6.1.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.4.0 platform: x64 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 6.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers - - nodejs_version: 12 + - nodejs_version: 12.4.0 platform: x86 NODE_RUNTIME: electron NODE_RUNTIME_VERSION: 6.0.0 TOOLSET_ARGS: --dist-url=https://electronjs.org/headers -os: Visual Studio 2015 +image: Visual Studio 2017 install: diff --git a/package.json b/package.json index 0e9858259..944c29db1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "remote_path": "./{name}/v{version}/{toolset}/", "package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz", "napi_versions": [ - 3 + 3, + 6 ] }, "contributors": [ @@ -40,7 +41,7 @@ "url": "git://github.com/mapbox/node-sqlite3.git" }, "dependencies": { - "node-addon-api": "2.0.0", + "node-addon-api": "^3.0.0", "node-pre-gyp": "^0.11.0" }, "devDependencies": { diff --git a/scripts/build-appveyor.bat b/scripts/build-appveyor.bat index 942845d0a..1e542b17f 100644 --- a/scripts/build-appveyor.bat +++ b/scripts/build-appveyor.bat @@ -4,25 +4,22 @@ SET EL=0 ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -IF /I "%msvs_toolset%"=="" ECHO msvs_toolset unset, defaulting to 14 && SET msvs_toolset=14 -IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2015 && SET msvs_version=2015 +IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2017 && SET msvs_version=2017 SET PATH=%CD%;%PATH% -IF "%msvs_toolset%"=="12" SET msvs_version=2013 IF NOT "%NODE_RUNTIME%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --runtime=%NODE_RUNTIME%" IF NOT "%NODE_RUNTIME_VERSION%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --target=%NODE_RUNTIME_VERSION%" ECHO APPVEYOR^: %APPVEYOR% ECHO nodejs_version^: %nodejs_version% ECHO platform^: %platform% -ECHO msvs_toolset^: %msvs_toolset% ECHO msvs_version^: %msvs_version% ECHO TOOLSET_ARGS^: %TOOLSET_ARGS% ECHO activating VS command prompt :: NOTE this call makes the x64 -> X64 -IF /I "%platform%"=="x64" ECHO x64 && CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" amd64 -IF /I "%platform%"=="x86" ECHO x86 && CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" x86 +IF /I "%platform%"=="x64" ECHO x64 && CALL "C:\Program Files (x86)\Microsoft Visual Studio\%msvs_version%\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 +IF /I "%platform%"=="x86" ECHO x86 && CALL "C:\Program Files (x86)\Microsoft Visual Studio\%msvs_version%\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 IF %ERRORLEVEL% NEQ 0 GOTO ERROR ECHO using compiler^: && CALL cl diff --git a/src/backup.cc b/src/backup.cc index 470d8f5f4..934379b82 100644 --- a/src/backup.cc +++ b/src/backup.cc @@ -7,9 +7,6 @@ using namespace node_sqlite3; -Napi::FunctionReference Backup::constructor; - - Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) { Napi::HandleScope scope(env); @@ -24,9 +21,6 @@ Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) { InstanceAccessor("retryErrors", &Backup::RetryErrorGetter, &Backup::RetryErrorSetter), }); - constructor = Napi::Persistent(t); - constructor.SuppressDestruct(); - exports.Set("Backup", t); return exports; } diff --git a/src/backup.h b/src/backup.h index 95edc1ab6..c44e02b89 100644 --- a/src/backup.h +++ b/src/backup.h @@ -93,8 +93,6 @@ namespace node_sqlite3 { */ class Backup : public Napi::ObjectWrap { public: - static Napi::FunctionReference constructor; - static Napi::Object Init(Napi::Env env, Napi::Object exports); struct Baton { diff --git a/src/database.cc b/src/database.cc index 7b33193ae..c3507b232 100644 --- a/src/database.cc +++ b/src/database.cc @@ -1,4 +1,5 @@ #include +#include #include "macros.h" #include "database.h" @@ -6,7 +7,9 @@ using namespace node_sqlite3; +#if NAPI_VERSION < 6 Napi::FunctionReference Database::constructor; +#endif Napi::Object Database::Init(Napi::Env env, Napi::Object exports) { Napi::HandleScope scope(env); @@ -23,8 +26,14 @@ Napi::Object Database::Init(Napi::Env env, Napi::Object exports) { InstanceAccessor("open", &Database::OpenGetter, nullptr) }); +#if NAPI_VERSION < 6 constructor = Napi::Persistent(t); constructor.SuppressDestruct(); +#else + Napi::FunctionReference* constructor = new Napi::FunctionReference(); + *constructor = Napi::Persistent(t); + env.SetInstanceData(constructor); +#endif exports.Set("Database", t); return exports; diff --git a/src/database.h b/src/database.h index b31f68136..13af919f9 100644 --- a/src/database.h +++ b/src/database.h @@ -21,7 +21,9 @@ class Database; class Database : public Napi::ObjectWrap { public: +#if NAPI_VERSION < 6 static Napi::FunctionReference constructor; +#endif static Napi::Object Init(Napi::Env env, Napi::Object exports); static inline bool HasInstance(Napi::Value val) { @@ -29,7 +31,13 @@ class Database : public Napi::ObjectWrap { Napi::HandleScope scope(env); if (!val.IsObject()) return false; Napi::Object obj = val.As(); +#if NAPI_VERSION < 6 return obj.InstanceOf(constructor.Value()); +#else + Napi::FunctionReference* constructor = + env.GetInstanceData(); + return obj.InstanceOf(constructor->Value()); +#endif } struct Baton { diff --git a/src/statement.cc b/src/statement.cc index fce3f43d8..088707800 100644 --- a/src/statement.cc +++ b/src/statement.cc @@ -8,8 +8,6 @@ using namespace node_sqlite3; -Napi::FunctionReference Statement::constructor; - Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) { Napi::HandleScope scope(env); @@ -23,9 +21,6 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) { InstanceMethod("finalize", &Statement::Finalize_), }); - constructor = Napi::Persistent(t); - constructor.SuppressDestruct(); - exports.Set("Statement", t); return exports; } diff --git a/src/statement.h b/src/statement.h index 04a572153..1d2a559ff 100644 --- a/src/statement.h +++ b/src/statement.h @@ -72,8 +72,6 @@ typedef Row Parameters; class Statement : public Napi::ObjectWrap { public: - static Napi::FunctionReference constructor; - static Napi::Object Init(Napi::Env env, Napi::Object exports); static Napi::Value New(const Napi::CallbackInfo& info);