fix: update build config and improve e2e adapter handling

Added dynamic inclusion of dependencies as external packages and switched build platform to browser. Streamlined e2e adapter test setup, improved type safety, and standardized console output for better clarity.
This commit is contained in:
dswbx
2025-09-15 09:25:32 +02:00
parent 50c5383138
commit d2de642c17
4 changed files with 15 additions and 12 deletions

View File

@@ -61,8 +61,11 @@ function delayTypes() {
watcher_timeout = setTimeout(buildTypes, 1000); watcher_timeout = setTimeout(buildTypes, 1000);
} }
const dependencies = Object.keys(pkg.dependencies);
// collection of always-external packages // collection of always-external packages
const external = [ const external = [
...dependencies,
"bun:test", "bun:test",
"node:test", "node:test",
"node:assert/strict", "node:assert/strict",
@@ -87,7 +90,7 @@ async function buildApi() {
external: [...external], external: [...external],
metafile: true, metafile: true,
target: "esnext", target: "esnext",
platform: "neutral", platform: "browser",
format: ["esm"], format: ["esm"],
splitting: false, splitting: false,
loader: { loader: {

View File

@@ -17,7 +17,7 @@ async function run(
}); });
// Read from stdout // Read from stdout
const reader = proc.stdout.getReader(); const reader = (proc.stdout as ReadableStream).getReader();
const decoder = new TextDecoder(); const decoder = new TextDecoder();
// Function to read chunks // Function to read chunks
@@ -30,7 +30,7 @@ async function run(
const text = decoder.decode(value); const text = decoder.decode(value);
if (!resolveCalled) { if (!resolveCalled) {
console.log(c.dim(text.replace(/\n$/, ""))); console.info(c.dim(text.replace(/\n$/, "")));
} }
onChunk( onChunk(
text, text,
@@ -189,21 +189,21 @@ const adapters = {
async function testAdapter(name: keyof typeof adapters) { async function testAdapter(name: keyof typeof adapters) {
const config = adapters[name]; const config = adapters[name];
console.log("adapter", c.cyan(name)); console.info("adapter", c.cyan(name));
await config.clean(); await config.clean();
const { proc, data } = await config.start(); const { proc, data } = await config.start();
console.log("proc:", proc.pid, "data:", c.cyan(data)); console.info("proc:", proc.pid, "data:", c.cyan(data));
//proc.kill();process.exit(0); //proc.kill();process.exit(0);
const add_env = "env" in config && config.env ? config.env : ""; const add_env = "env" in config && config.env ? config.env : "";
await $`TEST_URL=${data} TEST_ADAPTER=${name} ${add_env} bun run test:e2e`; await $`TEST_URL=${data} TEST_ADAPTER=${name} ${add_env} bun run test:e2e`;
console.log("DONE!"); console.info("DONE!");
while (!proc.killed) { while (!proc.killed) {
proc.kill("SIGINT"); proc.kill("SIGINT");
await Bun.sleep(250); await Bun.sleep(250);
console.log("Waiting for process to exit..."); console.info("Waiting for process to exit...");
} }
} }

View File

@@ -30,7 +30,7 @@
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias", "build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias",
"updater": "bun x npm-check-updates -ui", "updater": "bun x npm-check-updates -ui",
"cli": "LOCAL=1 bun src/cli/index.ts", "cli": "LOCAL=1 bun src/cli/index.ts",
"prepublishOnly": "bun run types && bun run test && bun run test:node && bun run test:e2e && bun run build:all && cp ../README.md ./", "prepublishOnly": "bun run types && bun run test && bun run test:node && VITE_DB_URL=:memory: bun run test:e2e && bun run build:all && cp ../README.md ./",
"postpublish": "rm -f README.md", "postpublish": "rm -f README.md",
"test": "ALL_TESTS=1 bun test --bail", "test": "ALL_TESTS=1 bun test --bail",
"test:all": "bun run test && bun run test:node", "test:all": "bun run test && bun run test:node",
@@ -39,8 +39,8 @@
"test:adapters": "bun test src/adapter/**/*.adapter.spec.ts --bail", "test:adapters": "bun test src/adapter/**/*.adapter.spec.ts --bail",
"test:coverage": "ALL_TESTS=1 bun test --bail --coverage", "test:coverage": "ALL_TESTS=1 bun test --bail --coverage",
"test:vitest:coverage": "vitest run --coverage", "test:vitest:coverage": "vitest run --coverage",
"test:e2e": "VITE_DB_URL=:memory: playwright test", "test:e2e": "playwright test",
"test:e2e:adapters": "VITE_DB_URL=:memory: bun run e2e/adapters.ts", "test:e2e:adapters": "bun run e2e/adapters.ts",
"test:e2e:ui": "VITE_DB_URL=:memory: playwright test --ui", "test:e2e:ui": "VITE_DB_URL=:memory: playwright test --ui",
"test:e2e:debug": "VITE_DB_URL=:memory: playwright test --debug", "test:e2e:debug": "VITE_DB_URL=:memory: playwright test --debug",
"test:e2e:report": "VITE_DB_URL=:memory: playwright show-report", "test:e2e:report": "VITE_DB_URL=:memory: playwright show-report",
@@ -71,6 +71,7 @@
"oauth4webapi": "^2.11.1", "oauth4webapi": "^2.11.1",
"object-path-immutable": "^4.1.2", "object-path-immutable": "^4.1.2",
"radix-ui": "^1.1.3", "radix-ui": "^1.1.3",
"picocolors": "^1.1.1",
"swr": "^2.3.3" "swr": "^2.3.3"
}, },
"devDependencies": { "devDependencies": {
@@ -108,7 +109,6 @@
"libsql-stateless-easy": "^1.8.0", "libsql-stateless-easy": "^1.8.0",
"open": "^10.1.0", "open": "^10.1.0",
"openapi-types": "^12.1.3", "openapi-types": "^12.1.3",
"picocolors": "^1.1.1",
"postcss": "^8.5.3", "postcss": "^8.5.3",
"postcss-preset-mantine": "^1.17.0", "postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1", "postcss-simple-vars": "^7.0.1",

View File

@@ -43,7 +43,7 @@ export type ApiOptions = {
} & ( } & (
| { | {
token?: string; token?: string;
user?: TApiUser; user?: TApiUser | null;
} }
| { | {
request: Request; request: Request;