diff --git a/packages/core/package.json b/packages/core/package.json index 9c09405..594dd16 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -23,7 +23,7 @@ "src/schema.sql" ], "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" } } diff --git a/tests/core-package-build.test.mjs b/tests/core-package-build.test.mjs new file mode 100644 index 0000000..a964261 --- /dev/null +++ b/tests/core-package-build.test.mjs @@ -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'); +});