diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 78f1b3099..e4cb0afbb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ jobs: name: build strategy: matrix: - node: [22] + node: [22, 24, 26] os: # https://github.com/actions/runner-images#available-images - name: darwin @@ -33,7 +33,6 @@ jobs: CXX: clang++ npm_config_clang: 1 GYP_DEFINES: use_obsolete_asm=true - CXXFLAGS: -std=c++17 runs-on: ${{ matrix.os.host }} steps: - uses: actions/checkout@v5 @@ -45,9 +44,18 @@ jobs: check-latest: true - name: Prebuildify run: | - [[ $(uname -o) == *Linux ]] && \ - sudo apt-get update && \ - sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev + if [[ $(uname -o) == *Linux ]]; then + sudo apt-get update + sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev lsb-release gnupg + # Node 24+ headers use C++20 std::source_location, which needs + # clang >= 16; ubuntu 22.04 ships clang 14. Stay on 22.04 (rather + # than a newer runner) to keep the glibc 2.35 prebuild baseline. + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 18 + export CC=clang-18 + export CXX=clang++-18 + fi npm ci JOBS=2 npx prebuildify --strip --napi=false --tag-libc -t "$(node --version | tr -d 'v')" @@ -63,7 +71,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - node: [22] + node: [22, 24, 26] steps: - uses: actions/checkout@v5 - uses: docker/setup-qemu-action@v3 @@ -85,7 +93,7 @@ jobs: runs-on: ubuntu-22.04-arm strategy: matrix: - node: [22] + node: [22, 24, 26] steps: - uses: actions/checkout@v5 - name: build linux musl arm64 @@ -134,13 +142,13 @@ jobs: mkdir -p prebuilds/darwin-arm64 mkdir -p prebuilds/darwin-x64 find ${{ steps.download.outputs.download-path }} - # Copy prebuilds for each platform - mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-X64-node22/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true - mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-ARM64-node22/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true - mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-amd64-node22/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true - mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-arm64-node22/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true - mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-ARM64-node22/darwin-arm64/* ./prebuilds/darwin-arm64/ 2>/dev/null || true - mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-X64-node22/darwin-x64/* ./prebuilds/darwin-x64/ 2>/dev/null || true + # Merge prebuilds for each platform across all node versions; + # ABI-tagged filenames don't collide. + for d in ${{ steps.download.outputs.download-path }}/prebuild-*/; do + for platarch in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do + [ -d "$d$platarch" ] && mv "$d$platarch"/* "./prebuilds/$platarch/" 2>/dev/null || true + done + done find ./prebuilds - name: npm install run: npm ci diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 918169601..8823031fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,8 +11,8 @@ jobs: linux-test: name: "test node ${{ matrix.node-version }} on linux" env: - CC: clang - CXX: clang++ + CC: clang-18 + CXX: clang++-18 npm_config_clang: 1 GYP_DEFINES: use_obsolete_asm=true DEBIAN_FRONTEND: "noninteractive" @@ -20,12 +20,17 @@ jobs: container: ubuntu:22.04 strategy: matrix: - node-version: [22] + node-version: [22, 24, 26] steps: - name: prerequisites run: | apt-get update - apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev + apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev lsb-release gnupg + # Node 24+ headers use C++20 std::source_location, which needs + # clang >= 16; ubuntu 22.04 ships clang 14 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + ./llvm.sh 18 - uses: actions/checkout@v5 with: submodules: true @@ -61,7 +66,7 @@ jobs: GYP_DEFINES: use_obsolete_asm=true strategy: matrix: - node-version: [22] + node-version: [22, 24, 26] runner: ["macos-26", "macos-15-intel"] runs-on: ${{ matrix.runner }} steps: @@ -93,15 +98,14 @@ jobs: linux-arm-test: name: "test node ${{ matrix.node-version }} on linux-arm" env: - CC: clang - CXX: clang++ + CC: clang-18 + CXX: clang++-18 npm_config_clang: 1 GYP_DEFINES: use_obsolete_asm=true - CXXFLAGS: -std=c++17 runs-on: ubuntu-22.04-arm strategy: matrix: - node-version: [22] + node-version: [22, 24, 26] steps: - uses: actions/checkout@v5 with: @@ -113,7 +117,12 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev + sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev lsb-release gnupg + # Node 24+ headers use C++20 std::source_location, which needs + # clang >= 16; ubuntu 22.04 ships clang 14 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 18 - name: Test run: | set -xe diff --git a/CLAUDE.md b/CLAUDE.md index 123b0f81c..907ada858 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,12 +2,12 @@ ## Overview -This is [@readme/nodegit](https://www.npmjs.com/package/@readme/nodegit), a fork of the original NodeGit library that provides Node.js bindings to libgit2. This fork is maintained by Readme and includes compatibility updates for Node.js 20 and 22. +This is [@readme/nodegit](https://www.npmjs.com/package/@readme/nodegit), a fork of the original NodeGit library that provides Node.js bindings to libgit2. This fork is maintained by ReadMe and includes compatibility updates for Node.js 22, 24, and 26. ## Quick Start ### Prerequisites -- Node.js >= 20 (supports Node 20 and 22) +- Node.js >= 22 (supports Node 22, 24, and 26) - Git installed on your system - Build tools (automatically handled during install) @@ -101,7 +101,7 @@ Tests are located in: ## CI/CD GitHub Actions workflows: -- **tests.yml**: Runs tests on Ubuntu 22.04 and macOS-26 +- **tests.yml**: Runs tests on Ubuntu 22.04 and macOS-26 across Node 22, 24, and 26 - **publish.yml**: Handles package publishing ## Architecture @@ -139,7 +139,7 @@ npm install 1. Run tests locally: `npm test` 2. Ensure linting passes: `npm run lint` -3. Test on target Node versions (20, 22) +3. Test on target Node versions (22, 24, 26) 4. Update tests if adding new functionality For more detailed API documentation, visit [nodegit.org](http://www.nodegit.org/). \ No newline at end of file diff --git a/README.md b/README.md index 27c301535..f5928c9ce 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## What is this fork? This fork contains a prebuilt version of nodegit that is compatible with **node -22.x** and the following platforms/arch/libc type: +22.x, 24.x, and 26.x** and the following platforms/arch/libc type: - **darwin/arm64/glibc** - **darwin/amd64/glibc** @@ -16,7 +16,7 @@ This fork contains a prebuilt version of nodegit that is compatible with **node - **linux/amd64/musl** - **linux/arm64/musl** -This means that if you are using node 22 and one of those platforms, you can +This means that if you are using node 22, 24, or 26 and one of those platforms, you can have a much faster install because you won't need to build nodegit from source. It also means that you will have a slightly larger file in your node_modules folder. diff --git a/generate/templates/manual/src/context.cc b/generate/templates/manual/src/context.cc index a4c9483dc..2920bd2f1 100644 --- a/generate/templates/manual/src/context.cc +++ b/generate/templates/manual/src/context.cc @@ -46,8 +46,7 @@ namespace nodegit { Context *Context::GetCurrentContext() { Nan::HandleScope scope; - v8::Local context = Nan::GetCurrentContext(); - v8::Isolate *isolate = context->GetIsolate(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); return contexts[isolate]; } diff --git a/generate/templates/manual/src/thread_pool.cc b/generate/templates/manual/src/thread_pool.cc index 4cd5c095a..feb12cf20 100644 --- a/generate/templates/manual/src/thread_pool.cc +++ b/generate/templates/manual/src/thread_pool.cc @@ -658,8 +658,7 @@ namespace nodegit { // NOTE this should theoretically never be triggered during a cleanup operation void ThreadPoolImpl::RunLoopCallbacks() { Nan::HandleScope scope; - v8::Local context = Nan::GetCurrentContext(); - node::CallbackScope callbackScope(context->GetIsolate(), Nan::New(), {0, 0}); + node::CallbackScope callbackScope(v8::Isolate::GetCurrent(), Nan::New(), {0, 0}); std::unique_lock lock(*jsThreadCallbackMutex); // get the next callback to run @@ -720,8 +719,7 @@ namespace nodegit { } Nan::HandleScope scope; - v8::Local context = Nan::GetCurrentContext(); - node::CallbackScope callbackScope(context->GetIsolate(), Nan::New(), {0, 0}); + node::CallbackScope callbackScope(v8::Isolate::GetCurrent(), Nan::New(), {0, 0}); while (cancelledJobs.size()) { std::shared_ptr cancelledJob = cancelledJobs.front(); diff --git a/generate/templates/templates/nodegit.cc b/generate/templates/templates/nodegit.cc index e43f8b2ae..c65153c3d 100644 --- a/generate/templates/templates/nodegit.cc +++ b/generate/templates/templates/nodegit.cc @@ -102,8 +102,7 @@ NAN_MODULE_INIT(init) { ); Nan::HandleScope scope; - Local context = Nan::GetCurrentContext(); - Isolate *isolate = context->GetIsolate(); + Isolate *isolate = Isolate::GetCurrent(); nodegit::Context *nodegitContext = new nodegit::Context(isolate); Wrapper::InitializeComponent(target, nodegitContext); diff --git a/package-lock.json b/package-lock.json index 0871c370e..556226c36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "@axosoft/nan": "^2.22.0-gk.1", + "@axosoft/nan": "npm:nan@^2.28.0", "fs-extra": "^7.0.0", "json5": "^2.1.0", "lodash": "^4.17.14", @@ -30,13 +30,14 @@ "walk": "^2.3.9" }, "engines": { - "node": "22.x" + "node": "^22 || ^24 || >=26" } }, "node_modules/@axosoft/nan": { - "version": "2.22.0-gk.1", - "resolved": "https://registry.npmjs.org/@axosoft/nan/-/nan-2.22.0-gk.1.tgz", - "integrity": "sha512-C4xrZ5HQoWwoq/WZnKDhf/Jd/czIaa0gsjHV792qUp7b7H+4Xtw1Um10BiiU/zrgmGhQuA92dedU2/rGvKErNg==", + "name": "nan", + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.28.0.tgz", + "integrity": "sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==", "license": "MIT" }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index 81dc858e1..0ebaaa88e 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,10 @@ "lib": "./lib" }, "engines": { - "node": "22.x" + "node": "^22 || ^24 || >=26" }, "dependencies": { - "@axosoft/nan": "^2.22.0-gk.1", + "@axosoft/nan": "npm:nan@^2.28.0", "fs-extra": "^7.0.0", "json5": "^2.1.0", "lodash": "^4.17.14", diff --git a/scripts/Dockerfile.alpine b/scripts/Dockerfile.alpine index 2d380cd02..afceec530 100644 --- a/scripts/Dockerfile.alpine +++ b/scripts/Dockerfile.alpine @@ -1,10 +1,10 @@ -ARG NODE_VERSION=20 -FROM node:${NODE_VERSION}-alpine3.19 +ARG NODE_VERSION=22 +FROM node:${NODE_VERSION}-alpine RUN apk add build-base git krb5-dev libgit2-dev libssh-dev pkgconfig python3 tzdata -# Ensure C++17 is used explicitly for Node.js 20 and define POSIX features -ENV CXXFLAGS="-std=c++17 -D_GNU_SOURCE" +# Define POSIX features; the C++ standard comes from binding.gyp per Node version +ENV CXXFLAGS="-D_GNU_SOURCE" ENV CFLAGS="-std=c17 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L" ENV JOBS="2"