Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = off

[*.{cc,h}]
max_line_length = 120

[*.js]
max_line_length = 120
44 changes: 44 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: sunday
cooldown:
default-days: 3
commit-message:
prefix: ci
labels: [dependencies]
open-pull-requests-limit: 1
groups:
actions:
patterns: ["*"]

- package-ecosystem: gitsubmodule
directory: /
schedule:
interval: weekly
day: friday
commit-message:
prefix: build
labels: [dependencies]
open-pull-requests-limit: 1
groups:
submodules:
patterns: ["*"]

- package-ecosystem: npm
directory: /
schedule:
interval: weekly
day: saturday
cooldown:
default-days: 3
commit-message:
prefix: build
labels: [dependencies]
open-pull-requests-limit: 1
groups:
npm:
patterns: ["*"]
55 changes: 22 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: CI

on:
push:
branches:
- master
branches: [master]
pull_request:
branches:
- master
branches: [master]
workflow_call:

concurrency:
Expand All @@ -18,58 +16,49 @@ jobs:
strategy:
matrix:
os:
- windows-latest
- macos-latest
- windows-2022
- windows-11-arm
- macos-15
- macos-13
- ubuntu-22.04
- ubuntu-22.04-arm
node:
- 18
- 20
- 22
- 20.19.5
- 22.19.0
- 24.7.0
fail-fast: false
name: Test Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: Test Node ${{matrix.node}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm ci --legacy-peer-deps
node-version: ${{matrix.node}}

- name: Set npm_config_target
run: echo "CONFIG_TARGET=${{ matrix.node == 22 && '22.12.0' || '20.9.0' }}" >> $GITHUB_ENV
run: printf 'npm_config_target=${{matrix.node}}\n' >> "$GITHUB_ENV"

- name: Build x64 binary
run: npm_config_target=${{ env.CONFIG_TARGET }} npm x -- prebuildify --napi --arch x64 -t 20.9.0

- name: Set up cross-compilation
if: runner.os == 'Linux'
run: |-
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu
printf '%s\n' >> "$GITHUB_ENV" \
'CC=aarch64-linux-gnu-gcc' 'CXX=aarch64-linux-gnu-g++'
- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Build arm64 binary
run: npm_config_target=${{ env.CONFIG_TARGET }} npm x -- prebuildify --napi --arch arm64 -t 20.9.0
- name: Build binary
run: npm x -- prebuildify --napi

- name: Run tests
run: npm test

- name: Upload prebuilds
uses: actions/upload-artifact@v4
if: github.ref_type == 'tag' && matrix.node == 20
if: github.ref_type == 'tag' && startsWith(matrix.node, '20')
with:
path: prebuilds/**
name: prebuilds-${{matrix.os}}
name: prebuilds-${{runner.os}}-${{runner.arch}}
retention-days: 2
7 changes: 3 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ jobs:
url: ${{steps.deployment.outputs.page_url}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20
cache: 'npm'
Expand All @@ -40,7 +39,7 @@ jobs:
- name: Generate documentation
run: npm run docs
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v4
with:
path: docs/api
- name: Deploy to GitHub Pages
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ jobs:
publish:
name: Publish
runs-on: ubuntu-latest
environment: npm
permissions:
id-token: write
attestations: write
contents: read
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20
registry-url: https://registry.npmjs.org

- name: Download prebuilds
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5
with:
path: prebuilds
pattern: prebuilds-*
Expand All @@ -41,8 +45,6 @@ jobs:

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Prepare release artifacts
run: |
Expand All @@ -53,8 +55,12 @@ jobs:
done
ls -l dist

- name: Generate attestations
uses: actions/attest-build-provenance@v3
with:
subject-path: dist/*

- name: Create release
run: |-
gh release create ${{ github.ref_name }} --generate-notes dist/*
run: gh release create "$GITHUB_REF_NAME" --generate-notes dist/*
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{github.token}}
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "vendor/tree-sitter"]
path = vendor/tree-sitter
url = https://github.com/tree-sitter/tree-sitter.git
branch = release-0.25
12 changes: 0 additions & 12 deletions .npmignore

This file was deleted.

28 changes: 18 additions & 10 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,29 @@
"defines": [
"NAPI_VERSION=<(napi_build_version)",
],
"cflags_cc": [
"-std=c++17"
],
"conditions": [
["OS=='mac'", {
"xcode_settings": {
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES", # -fvisibility=hidden
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
"CLANG_CXX_LANGUAGE_STANDARD": "<(cxxstd)",
"MACOSX_DEPLOYMENT_TARGET": "10.9",
},
}],
["OS=='win'", {
"msvs_settings": {
"VCCLCompilerTool": {
"AdditionalOptions": [
"/std:c++17",
"/std:<(cxxstd)",
],
"RuntimeLibrary": 0,
},
},
}],
["OS == 'linux'", {
"cflags_cc": [
"-Wno-cast-function-type"
"-std=<(cxxstd)",
"-fvisibility=hidden",
"-Wno-cast-function-type",
]
}],
]
Expand All @@ -62,19 +61,28 @@
"vendor/tree-sitter/lib/src",
"vendor/tree-sitter/lib/include",
],
"cflags": [
"-std=c11"
],
"defines": [
"_POSIX_C_SOURCE=200112L",
"_DEFAULT_SOURCE",
]
],
"conditions": [
["OS!='win'", {
"cflags_c": [
"-std=c11",
],
}, { # OS == "win"
"cflags_c": [
"/std:c11",
],
}],
],
}
],
"variables": {
"runtime%": "node",
"openssl_fips": "",
"v8_enable_pointer_compression%": 0,
"v8_enable_31bit_smis_on_64bit_arch%": 0,
"cxxstd%": "<!(node -p \"parseInt(process.env.npm_config_target ?? process.versions.node) > 22 ? 'c++20' : 'c++17'\")",
}
}
Loading