feat: migrate runtime from Node.js to Bun

- Replace better-sqlite3 with bun:sqlite (native, no native addon build)
- Change all spawn('node') to spawn('bun') for agent processes
- Update package.json scripts: node→bun, tsx→bun, npm→bun
- Add bun-types for tsc compatibility
- Add bun:sqlite→better-sqlite3 shim for vitest (tests run on Node.js)
- Update Dockerfile: install bun alongside Node.js (CLIs need Node)
- Update setup/platform.ts: getNodePath() resolves bun binary
- Remove better-sqlite3 from production dependencies (devDep only for tests)
This commit is contained in:
Eyejoker
2026-03-30 23:58:54 +09:00
parent 3e2954ebcf
commit 0112f5a2d6
18 changed files with 713 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
import { describe, it, expect, beforeEach } from 'vitest';
import fs from 'fs';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
/**
* Tests for the environment check step.
@@ -18,7 +18,7 @@ describe('environment detection', () => {
});
describe('registered groups DB query', () => {
let db: Database.Database;
let db: Database;
beforeEach(() => {
db = new Database(':memory:');

View File

@@ -5,7 +5,7 @@
import fs from 'fs';
import path from 'path';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
import { STORE_DIR } from '../src/config.js';
import { logger } from '../src/logger.js';

View File

@@ -5,7 +5,7 @@
import fs from 'fs';
import path from 'path';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
import { STORE_DIR } from '../src/config.js';
import { logger } from '../src/logger.js';

View File

@@ -100,7 +100,7 @@ export function getServiceManager(): ServiceManager {
export function getNodePath(): string {
try {
return execSync('command -v node', { encoding: 'utf-8' }).trim();
return execSync('command -v bun', { encoding: 'utf-8' }).trim();
} catch {
return process.execPath;
}

View File

@@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach } from 'vitest';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
/**
* Tests for the register step.
@@ -9,7 +9,7 @@ import Database from 'better-sqlite3';
* apostrophe in names, .env updates.
*/
function createTestDb(): Database.Database {
function createTestDb(): Database {
const db = new Database(':memory:');
db.exec(`CREATE TABLE IF NOT EXISTS registered_groups (
jid TEXT NOT NULL,
@@ -29,7 +29,7 @@ function createTestDb(): Database.Database {
}
describe('parameterized SQL registration', () => {
let db: Database.Database;
let db: Database;
beforeEach(() => {
db = createTestDb();

View File

@@ -7,7 +7,7 @@
import fs from 'fs';
import path from 'path';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
import { STORE_DIR } from '../src/config.js';
import { isValidGroupFolder } from '../src/group-folder.js';

View File

@@ -13,7 +13,7 @@ import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import Database from 'better-sqlite3';
import { Database } from 'bun:sqlite';
import { STORE_DIR } from '../src/config.js';
import { readEnvFile } from '../src/env.js';