From a9eef892c566ec7bcfebe1a1ca3560aaacd95803 Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Wed, 9 Aug 2023 11:44:04 -0500 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20fixed=20error:=20=E2=80=98class=20?= =?UTF-8?q?v8::Object=E2=80=99=20has=20no=20member=20named=20=E2=80=98Crea?= =?UTF-8?q?tionContext=E2=80=99;=20allowing=20node-gyp=20to=20rebind=20wit?= =?UTF-8?q?h=20node-postal,=20which=20enables=20node-postal=20to=20be=20us?= =?UTF-8?q?ed=20on=20Node=20v20.5.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/expand.cc | 2 +- src/parser.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index d3cb950..a24e7c8 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -133,7 +133,7 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->CreationContext(); + v8::Local context = exports->GetCreationContext().ToLocalChecked(); if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); diff --git a/src/parser.cc b/src/parser.cc index 240d591..2f2bd6c 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -96,7 +96,7 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->CreationContext(); + v8::Local context = exports->GetCreationContext().ToLocalChecked(); if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); From d94cd78b1aa1b9545ca1a6974cd54b56b41507ec Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Sat, 20 Jan 2024 18:10:21 -0600 Subject: [PATCH 02/16] feat: add node v16 and v20 to github actions matrix --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c98b709..a0d78f6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,6 +13,8 @@ jobs: - 12.x - 14.x - 16.x + - 18.x + - 20.x include: - os: ubuntu-20.04 node-version: 8.x From a3b2acf8a04af890794c6110aee2fbe1400d3145 Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Sat, 20 Jan 2024 20:00:29 -0600 Subject: [PATCH 03/16] fix: updated workflow script to run on push and pull request events --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a0d78f6..fa029af 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,5 @@ name: 'Continuous Integration' -on: push +on: [push, pull_request] jobs: unit-tests: runs-on: '${{ matrix.os }}' From 36bea99bf2ac469cd9ae0dfe4698047aeba077f6 Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 20:27:59 -0600 Subject: [PATCH 04/16] fix: updated actions/checkout@v2 to v3 as the former was deprecated --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index fa029af..b789871 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -23,7 +23,7 @@ jobs: node-version: 10.x status: 'deprecated' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: 'Install apt packages' shell: bash run: | From c6fc128290a1d6bfd15bac34321fa0c23f0903ea Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 21:33:57 -0600 Subject: [PATCH 05/16] test: trying to get the bindings file made/located correctly --- .github/workflows/push.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b789871..9f9530d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -28,7 +28,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install curl autoconf automake libtool pkg-config + sudo apt-get install build-essential curl autoconf automake libtool pkg-config - name: 'Create working directories' shell: bash run: | @@ -43,6 +43,7 @@ jobs: ./bootstrap.sh ./configure --datadir=/data --prefix=/deps --bindir=/deps || cat config.log make -j4 + cd build make install - name: 'Install node.js ${{ matrix.node-version }}' uses: actions/setup-node@v2-beta From 8e4d2f9b913b5334b86f429757170caf060799f1 Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 21:41:13 -0600 Subject: [PATCH 06/16] fix: removed incorrect cd step --- .github/workflows/push.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9f9530d..dfb5857 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -43,7 +43,6 @@ jobs: ./bootstrap.sh ./configure --datadir=/data --prefix=/deps --bindir=/deps || cat config.log make -j4 - cd build make install - name: 'Install node.js ${{ matrix.node-version }}' uses: actions/setup-node@v2-beta From 2fcbc7c1fa6b4dad26474922cf9b5b9b69d00950 Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 21:54:49 -0600 Subject: [PATCH 07/16] feat: added fail-fast so jobs will continue running after a node version test fails in the matrix --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index dfb5857..bd2117c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,6 +5,7 @@ jobs: runs-on: '${{ matrix.os }}' continue-on-error: ${{ matrix.status != 'current' }} strategy: + fail-fast: false matrix: status: ['current'] os: From 4c0057d6e1e959f4c42325a21eb47440973d08ec Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 22:23:35 -0600 Subject: [PATCH 08/16] feat/test: set the context depending on the node version; node v16+ use new update, else use old way --- src/expand.cc | 7 ++++++- src/parser.cc | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index a24e7c8..226e306 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -1,6 +1,7 @@ #include #include #include +#include #define EXPAND_USAGE "Usage: expand_address(address, options)" @@ -133,7 +134,11 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #else + v8::Local context = exports->CreationContext(); + #endif if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); diff --git a/src/parser.cc b/src/parser.cc index 2f2bd6c..6a28a3f 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -5,7 +5,6 @@ void ParseAddress(const Nan::FunctionCallbackInfo& info) { v8::Isolate *isolate = info.GetIsolate(); - v8::Local context = isolate->GetCurrentContext(); if (info.Length() < 1) { Nan::ThrowTypeError(PARSER_USAGE); @@ -96,7 +95,11 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #else + v8::Local context = exports->CreationContext(); + #endif if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); From f4255b3829c29fe5f5e358ef99c1cb91ad4e48ca Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 22:32:29 -0600 Subject: [PATCH 09/16] fix/test: added node version header to expand.cc and parser.cc --- src/expand.cc | 2 +- src/parser.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index 226e306..32d3f57 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -1,7 +1,7 @@ +#include #include #include #include -#include #define EXPAND_USAGE "Usage: expand_address(address, options)" diff --git a/src/parser.cc b/src/parser.cc index 6a28a3f..2f653be 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1,3 +1,4 @@ +#include #include #include @@ -95,12 +96,12 @@ static void cleanup(void*) { } void init(v8::Local exports) { - #if NODE_MAJOR_VERSION >= 16 + #if NODE_MAJOR_VERSION >= 16 v8::Local context = exports->GetCreationContext().ToLocalChecked(); #else v8::Local context = exports->CreationContext(); #endif - + if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); return; From ccf6e3db2de7609b60dff5ae00cd3875429fccad Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 22:37:45 -0600 Subject: [PATCH 10/16] test: changed node_version header to node header --- src/expand.cc | 2 +- src/parser.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index 32d3f57..b9a5c2d 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/parser.cc b/src/parser.cc index 2f653be..9ee302c 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -101,7 +101,7 @@ void init(v8::Local exports) { #else v8::Local context = exports->CreationContext(); #endif - + if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); return; From a05e2e137b618814a746042ef5c120ac7b2cc081 Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 22:42:52 -0600 Subject: [PATCH 11/16] fix: reverting back to state where node 16,18,20 tests worked... --- src/expand.cc | 7 +------ src/parser.cc | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index b9a5c2d..a24e7c8 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -1,4 +1,3 @@ -#include #include #include #include @@ -134,11 +133,7 @@ static void cleanup(void*) { } void init(v8::Local exports) { - #if NODE_MAJOR_VERSION >= 16 - v8::Local context = exports->GetCreationContext().ToLocalChecked(); - #else - v8::Local context = exports->CreationContext(); - #endif + v8::Local context = exports->GetCreationContext().ToLocalChecked(); if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); diff --git a/src/parser.cc b/src/parser.cc index 9ee302c..64050f1 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1,4 +1,3 @@ -#include #include #include @@ -96,11 +95,7 @@ static void cleanup(void*) { } void init(v8::Local exports) { - #if NODE_MAJOR_VERSION >= 16 - v8::Local context = exports->GetCreationContext().ToLocalChecked(); - #else - v8::Local context = exports->CreationContext(); - #endif + v8::Local context = exports->GetCreationContext().ToLocalChecked(); if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); From 1b058f9b5fc2295e4b8adf79b79cb9d6b2ede941 Mon Sep 17 00:00:00 2001 From: Zack Holland Date: Sat, 20 Jan 2024 22:57:21 -0600 Subject: [PATCH 12/16] fix/test: reverted github actions to v2 from v3... --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bd2117c..ffdb5ec 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -24,7 +24,7 @@ jobs: node-version: 10.x status: 'deprecated' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: 'Install apt packages' shell: bash run: | From 90a500145655fc15c1518820b1e9ee9fb5a40b85 Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Sun, 21 Jan 2024 15:53:49 -0600 Subject: [PATCH 13/16] test: attempt to get tests to pass for node v16+ --- src/expand.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expand.cc b/src/expand.cc index a24e7c8..df1e130 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -133,7 +133,7 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->GetCreationContext().ToLocalChecked(); + v8::Local context = exports->GetCreationContext().ToLocalChecked(); //required to work on node v16+ if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); From 7b1cb90053525db9ff5873396c6d9318dd350034 Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Mon, 22 Jan 2024 09:27:32 -0600 Subject: [PATCH 14/16] fix: re-added line in ParseAddress that had been incorrectly removed --- src/parser.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parser.cc b/src/parser.cc index 64050f1..2f2bd6c 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -5,6 +5,7 @@ void ParseAddress(const Nan::FunctionCallbackInfo& info) { v8::Isolate *isolate = info.GetIsolate(); + v8::Local context = isolate->GetCurrentContext(); if (info.Length() < 1) { Nan::ThrowTypeError(PARSER_USAGE); From 733a383545746d0decca7fb2cddc8c727ab435d5 Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Mon, 22 Jan 2024 11:24:35 -0600 Subject: [PATCH 15/16] fix: depending on node version call the right context function --- src/expand.cc | 9 +++++++-- src/parser.cc | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index df1e130..00cc327 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -133,8 +133,13 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->GetCreationContext().ToLocalChecked(); //required to work on node v16+ - + // Check Node.js version + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); #else + #else + v8::Local context = exports->CreationContext(); + #endif + if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); return; diff --git a/src/parser.cc b/src/parser.cc index 2f2bd6c..b93d26b 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -96,7 +96,12 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->GetCreationContext().ToLocalChecked(); + // Check Node.js version + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #else + v8::Local context = exports->CreationContext(); + #endif if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); From 7dbdfe1d0b4d6fce7edcc1929e2fe15b9bd0a5ba Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Mon, 22 Jan 2024 11:36:17 -0600 Subject: [PATCH 16/16] fix: removed typo --- src/expand.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expand.cc b/src/expand.cc index 00cc327..5a56d7c 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -135,7 +135,7 @@ static void cleanup(void*) { void init(v8::Local exports) { // Check Node.js version #if NODE_MAJOR_VERSION >= 16 - v8::Local context = exports->GetCreationContext().ToLocalChecked(); #else + v8::Local context = exports->GetCreationContext().ToLocalChecked(); #else v8::Local context = exports->CreationContext(); #endif