Skip to content
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/node-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
pull_request:
push:
branches: [pure-c-port]
name: "node-integration-tests"
jobs:
test:
name: Node.js on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "22"

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow pins Node to major version "22", but these tests require Node >= 22.5 for node:sqlite. To avoid CI picking an older 22.x on some runners/caches, set an explicit minimum (e.g. 22.5.0) or a constraint that guarantees >=22.5.

Suggested change
node-version: "22"
node-version: "22.5.0"

Copilot uses AI. Check for mistakes.

- name: Build extension
run: |
cd core
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

- name: Run Node.js integration tests
run: |
cd core
node --test test/integration.test.mjs
4 changes: 4 additions & 0 deletions core/nodejs-helper.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// CJS entry point — see nodejs-helper.js for usage examples.
const { join } = require("node:path");
const extensionPath = join(__dirname, "dist", "crsqlite");
module.exports = { extensionPath };
1 change: 1 addition & 0 deletions core/nodejs-helper.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/** Absolute path to the cr-sqlite loadable extension (without file extension). */
export declare const extensionPath: string;
23 changes: 18 additions & 5 deletions core/nodejs-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
// Exports the path to the extension for those using
// crsqlite in a Node.js environment.
import * as url from "url";
import { join } from "path";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
// Exports the path to the cr-sqlite loadable extension.
// Usage with node:sqlite (Node >= 22.5):
//
// import { extensionPath } from '@anthropic/crsqlite';
// import { DatabaseSync } from 'node:sqlite';
// const db = new DatabaseSync(':memory:', { allowExtension: true });
// db.loadExtension(extensionPath);
//
// Usage with better-sqlite3:
//
// import { extensionPath } from '@anthropic/crsqlite';
// import Database from 'better-sqlite3';
// const db = new Database(':memory:');
// db.loadExtension(extensionPath);

import { fileURLToPath } from "node:url";
import { join, dirname } from "node:path";

const __dirname = dirname(fileURLToPath(import.meta.url));
export const extensionPath = join(__dirname, "dist", "crsqlite");
133 changes: 0 additions & 133 deletions core/nodejs-install-helper.js

This file was deleted.

43 changes: 43 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@anthropic/crsqlite",
"version": "0.1.0",
"description": "cr-sqlite loadable extension for Node.js — CRDT-based multi-master replication for SQLite",
"type": "module",
"main": "nodejs-helper.cjs",
"module": "nodejs-helper.js",
"exports": {
".": {
"import": "./nodejs-helper.js",
"require": "./nodejs-helper.cjs"
}
},
"types": "nodejs-helper.d.ts",
"files": [
"nodejs-helper.js",
"nodejs-helper.cjs",
"nodejs-helper.d.ts",
"dist/"
],
"scripts": {
"build": "cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build && mkdir -p dist && cp build/crsqlite.* dist/",
"test": "node --test test/integration.test.mjs",
"test:c": "cd build && ctest --output-on-failure"
},
"engines": {
"node": ">=22.5.0"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/shards-lang/cr-sqlite.git",
"directory": "core"
},
"keywords": [
"sqlite",
"crdt",
"replication",
"sync",
"multi-master",
"extension"
]
}
Loading
Loading