Skip to content

Commit 3e8966b

Browse files
committed
add updates from 16-latest re building on windows, upgrade node gyp
1 parent ec882d2 commit 3e8966b

File tree

10 files changed

+740
-462
lines changed

10 files changed

+740
-462
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build Dry Run
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [windows-latest, macos-latest, ubuntu-latest]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Build project
15+
run: |
16+
yarn
17+
- uses: actions/upload-artifact@v2
18+
with:
19+
name: build-artifact-${{ matrix.os }}
20+
path: |
21+
${{ matrix.os == 'macos-latest' && './libpg_query/osx/libpg_query.a' ||
22+
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' ||
23+
'' }}
24+
prepare-and-publish:
25+
needs: build
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: actions/download-artifact@v2
30+
with:
31+
path: downloaded-artifacts
32+
- name: Prepare artifacts
33+
run: |
34+
# move or prepare artifacts
35+
ls downloaded-artifacts/*
36+
# - name: Publish to NPM
37+
# run: |
38+
# # Assuming you've set up your package.json and .npmrc correctly
39+
# npm publish
40+
# env:
41+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/run-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run Tests 🧪
2+
3+
on:
4+
pull_request:
5+
types: [opened, push, reopened]
6+
workflow_dispatch:
7+
8+
jobs:
9+
run-tests:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository 📥
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js 🌐
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20.x'
19+
cache: 'yarn'
20+
21+
- name: Install Dependencies 🧶
22+
run: |
23+
yarn
24+
25+
- name: Build Project 🏗️
26+
run: |
27+
yarn build
28+
yarn symlink
29+
30+
- name: Test 🔍
31+
run: yarn test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ libpg_query/**/*.h
77
wasm/libpg-query.js
88
*.wasm
99
.cache
10+
libpg_query/windows/*.lib

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

binding.gyp

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
"src/sync.cc",
99
"src/async.cc"
1010
],
11-
"actions": [
12-
{
13-
"outputs": ['libpg_query/include/pg_query.h'],
14-
"inputs": [],
15-
"action": ['script/buildAddon.sh'],
16-
"action_name": 'prebuild_dependencies'
17-
}
18-
],
1911
'cflags!': [ '-fno-exceptions' ],
2012
'cflags_cc!': [ '-fno-exceptions' ],
2113
'include_dirs': [
@@ -25,22 +17,58 @@
2517
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
2618
'conditions': [
2719
['OS=="linux"', {
28-
"libraries": [ "-L<!(pwd)/libpg_query/linux", "-lpg_query" ]
20+
"libraries": [ "-L<!(pwd)/libpg_query/linux", "-lpg_query" ],
21+
"actions": [
22+
{
23+
"outputs": ['libpg_query/include/pg_query.h'],
24+
"inputs": [],
25+
"action": ['script/buildAddon.sh'],
26+
"action_name": 'prebuild_dependencies'
27+
}
28+
],
2929
}],
3030
['OS=="mac"', {
3131
"libraries": [ "-L<!(pwd)/libpg_query/osx", "-lpg_query" ],
3232
"xcode_settings": {
3333
"CLANG_CXX_LIBRARY": "libc++",
3434
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
3535
'MACOSX_DEPLOYMENT_TARGET': '10.7'
36-
}
36+
},
37+
"actions": [
38+
{
39+
"outputs": ['libpg_query/include/pg_query.h'],
40+
"inputs": [],
41+
"action": ['script/buildAddon.sh'],
42+
"action_name": 'prebuild_dependencies'
43+
}
44+
],
3745
}],
3846
['OS=="win"', {
47+
"link_settings": {
48+
"library_dirs": [
49+
"../libpg_query/windows"
50+
],
51+
"libraries": [
52+
"../libpg_query/windows/pg_query.lib"
53+
],
54+
},
3955
"msvs_settings": {
4056
"VCCLCompilerTool": {
41-
"ExceptionHandling": 1
57+
"ExceptionHandling": 0,
58+
"AdditionalOptions": ["/EHsc"]
59+
}
60+
},
61+
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
62+
"actions":[
63+
{
64+
"outputs": [
65+
""
66+
],
67+
"inputs": [],
68+
"action": ['../script/buildAddon.bat'],
69+
"action_name": 'prebuild_dependencies'
4270
}
43-
}
71+
]
4472
}]
4573
]
4674
}

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12.18.2-alpine3.11
1+
FROM node:20-alpine
22
RUN apk --no-cache add git
33
RUN apk add --no-cache bash
44
RUN apk add --no-cache make

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "libpg-query",
33
"version": "15.0.3",
44
"description": "The real PostgreSQL query parser",
5-
"homepage": "https://github.com/pyramation/libpg-query-node",
5+
"homepage": "https://github.com/launchql/libpg-query-node",
66
"main": "index.js",
77
"typings": "index.d.ts",
88
"publishConfig": {
@@ -46,7 +46,7 @@
4646
"license": "LICENSE IN LICENSE",
4747
"repository": {
4848
"type": "git",
49-
"url": "git://github.com/pyramation/libpg-query-node.git"
49+
"url": "git://github.com/launchql/libpg-query-node.git"
5050
},
5151
"devDependencies": {
5252
"chai": "^3.5.0",
@@ -58,7 +58,7 @@
5858
"@emnapi/runtime": "^0.43.1",
5959
"@mapbox/node-pre-gyp": "^1.0.8",
6060
"node-addon-api": "^7.0.0",
61-
"node-gyp": "^8.0.0"
61+
"node-gyp": "^10.0.1"
6262
},
6363
"keywords": [
6464
"sql",

script/buildAddon.bat

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@echo off
2+
3+
set commit=db39825bc7c1ddd45962ec6a626d740b7f8f027a
4+
set branch=15-latest
5+
6+
setlocal enabledelayedexpansion
7+
8+
rem Remember current's parent directory and create a new, unique, temporary directory
9+
set buildDir=%cd%
10+
set projectDir=%cd%\..
11+
set tmpDir=%temp%\tmpdir.libpg_query
12+
rmdir /s /q %tmpDir%
13+
md %tmpDir%
14+
15+
16+
rem Define the make target
17+
set makeTarget=build
18+
19+
rem Change to the newly created temp directory
20+
cd /D %tmpDir%
21+
22+
23+
rem Clone the selected branch of the libpg_query Git repo
24+
git clone -b %branch% --single-branch https://github.com/pganalyze/libpg_query.git
25+
cd libpg_query
26+
27+
rem Checkout the desired commit
28+
git checkout %commit%
29+
30+
rem needed if being invoked from within gyp
31+
set MAKEFLAGS=
32+
set MFLAGS=
33+
34+
rem set path with Windows Developer Command Prompt
35+
echo "please ensure you are running at Windows Developer Command Prompt environments"
36+
nmake /F Makefile.msvc clean
37+
nmake /F Makefile.msvc build
38+
39+
40+
rem Terminate if build fails
41+
if %errorlevel% NEQ 0 (
42+
echo ERROR: 'nmake' command failed
43+
)
44+
45+
rem Search for pg_query.obj (libpg_query.a), error if not found
46+
for /f "delims=" %%f in ('dir /b /s pg_query.lib') do set file=%%f
47+
if not defined file (
48+
echo "ERROR: pg_query.lib not found"
49+
50+
)
51+
52+
rem Error if pg_query.h is missing
53+
for /f "delims=" %%f in ('dir /b /s pg_query.h') do set file=%%f
54+
if not defined file (
55+
echo "ERROR: pg_query.h not found"
56+
57+
)
58+
59+
rem Copy pg_query.lib to windows dir
60+
copy /Y pg_query.lib "%projectDir%\libpg_query\windows\"
61+
62+
rem Copy header
63+
copy /Y pg_query.h "%projectDir%\libpg_query\include\"
64+
65+
rem Cleanup: revert to original directory
66+
cd /D %buildDir%
67+
68+
exit /B 0

test/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ describe("Queries", () => {
1818
(it) => it.stmts[0].stmt.SelectStmt.targetList
1919
);
2020

21-
expect(selectedDatas[0][0].ResTarget.val.A_Const.val.Integer.ival).to.eq(
21+
expect(selectedDatas[0][0].ResTarget.val.A_Const.ival.ival).to.eq(
2222
1
2323
);
24-
expect(selectedDatas[1][0].ResTarget.val.A_Const.val).to.have.property(
25-
"Null"
24+
expect(selectedDatas[1][0].ResTarget.val.A_Const.isnull).to.eq(
25+
true
2626
);
27-
expect(selectedDatas[2][0].ResTarget.val.A_Const.val.String.str).to.eq(
27+
expect(selectedDatas[2][0].ResTarget.val.A_Const.sval.sval).to.eq(
2828
""
2929
);
3030
expect(selectedDatas[3]).to.have.lengthOf(2);

0 commit comments

Comments
 (0)