fix(core): ship schema with package build

This commit is contained in:
tommy0103
2026-07-12 00:39:57 +08:00
parent 535d8edb4d
commit 3a6e3a00a7
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
"src/schema.sql" "src/schema.sql"
], ],
"scripts": { "scripts": {
"build": "rm -rf dist && tsc -p tsconfig.build.json", "build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/schema.sql dist/schema.sql",
"typecheck": "tsc --noEmit -p tsconfig.json" "typecheck": "tsc --noEmit -p tsconfig.json"
} }
} }
+20
View File
@@ -0,0 +1,20 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { existsSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { pathToFileURL, fileURLToPath } from 'node:url';
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const coreDist = join(repoRoot, 'packages', 'core', 'dist');
test('build:core emits an importable package with its schema resource', async () => {
execFileSync('npm', ['run', 'build:core'], { cwd: repoRoot, encoding: 'utf8', stdio: 'pipe' });
assert.ok(existsSync(join(coreDist, 'schema.sql')), 'compiled Core is missing schema.sql');
const core = await import(`${pathToFileURL(join(coreDist, 'core.js')).href}?test=${Date.now()}`);
assert.equal(typeof core.buildIndex, 'function');
assert.equal(typeof core.searchText, 'function');
assert.equal(typeof core.executeQuery, 'function');
assert.equal(typeof core.executeAttune, 'function');
});