forked from vlcn-io/cr-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Node.js integration: package, tests, and CI #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sinkingsugar
merged 1 commit into
pure-c-port
from
claude/node-integration-options-Is824
Apr 12, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
|
|
||
| - 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.