diff --git a/packages/plugins/driver-memory/vitest.config.ts b/packages/plugins/driver-memory/vitest.config.ts new file mode 100644 index 000000000..fcded82ed --- /dev/null +++ b/packages/plugins/driver-memory/vitest.config.ts @@ -0,0 +1,22 @@ +// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. + +import { defineConfig } from 'vitest/config'; +import path from 'path'; + +export default defineConfig({ + test: { + globals: true, + environment: 'node', + }, + resolve: { + alias: { + '@objectstack/core': path.resolve(__dirname, '../../core/src/index.ts'), + '@objectstack/spec/api': path.resolve(__dirname, '../../spec/src/api/index.ts'), + '@objectstack/spec/contracts': path.resolve(__dirname, '../../spec/src/contracts/index.ts'), + '@objectstack/spec/data': path.resolve(__dirname, '../../spec/src/data/index.ts'), + '@objectstack/spec/kernel': path.resolve(__dirname, '../../spec/src/kernel/index.ts'), + '@objectstack/spec/system': path.resolve(__dirname, '../../spec/src/system/index.ts'), + '@objectstack/spec': path.resolve(__dirname, '../../spec/src/index.ts'), + }, + }, +}); diff --git a/packages/plugins/plugin-auth/src/auth-plugin.test.ts b/packages/plugins/plugin-auth/src/auth-plugin.test.ts index cd9855fc0..63b42523d 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.test.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.test.ts @@ -137,6 +137,7 @@ describe('AuthPlugin', () => { it('should register routes with HTTP server on kernel:ready', async () => { const mockRawApp = { all: vi.fn(), + get: vi.fn(), }; const mockHttpServer = { @@ -173,6 +174,7 @@ describe('AuthPlugin', () => { it('should log via ctx.logger when better-auth returns a 500 response', async () => { const mockRawApp = { all: vi.fn(), + get: vi.fn(), }; const mockHttpServer = { @@ -270,7 +272,7 @@ describe('AuthPlugin', () => { }); it('should auto-detect baseUrl from http-server port when port differs', async () => { - const mockRawApp = { all: vi.fn() }; + const mockRawApp = { all: vi.fn(), get: vi.fn() }; const mockHttpServer = { post: vi.fn(), get: vi.fn(), put: vi.fn(), delete: vi.fn(), patch: vi.fn(), use: vi.fn(), @@ -306,7 +308,7 @@ describe('AuthPlugin', () => { (mockContext.registerService as any).mockClear(); await localPlugin.init(mockContext); - const mockRawApp = { all: vi.fn() }; + const mockRawApp = { all: vi.fn(), get: vi.fn() }; const mockHttpServer = { post: vi.fn(), get: vi.fn(), put: vi.fn(), delete: vi.fn(), patch: vi.fn(), use: vi.fn(), @@ -338,7 +340,7 @@ describe('AuthPlugin', () => { (mockContext.registerService as any).mockClear(); await localPlugin.init(mockContext); - const mockRawApp = { all: vi.fn() }; + const mockRawApp = { all: vi.fn(), get: vi.fn() }; const mockHttpServer = { post: vi.fn(), get: vi.fn(), put: vi.fn(), delete: vi.fn(), patch: vi.fn(), use: vi.fn(), @@ -400,6 +402,7 @@ describe('AuthPlugin', () => { const mockRawApp = { all: vi.fn(), + get: vi.fn(), }; const mockHttpServer = { diff --git a/packages/plugins/plugin-hono-server/src/hono-plugin.test.ts b/packages/plugins/plugin-hono-server/src/hono-plugin.test.ts index 8c2b2d69f..23e4354fe 100644 --- a/packages/plugins/plugin-hono-server/src/hono-plugin.test.ts +++ b/packages/plugins/plugin-hono-server/src/hono-plugin.test.ts @@ -27,6 +27,7 @@ vi.mock('./adapter', () => ({ close: vi.fn(), getRawApp: vi.fn().mockReturnValue({ get: vi.fn(), + use: vi.fn(), }) }; }) diff --git a/packages/plugins/plugin-hono-server/vitest.config.ts b/packages/plugins/plugin-hono-server/vitest.config.ts new file mode 100644 index 000000000..fcded82ed --- /dev/null +++ b/packages/plugins/plugin-hono-server/vitest.config.ts @@ -0,0 +1,22 @@ +// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. + +import { defineConfig } from 'vitest/config'; +import path from 'path'; + +export default defineConfig({ + test: { + globals: true, + environment: 'node', + }, + resolve: { + alias: { + '@objectstack/core': path.resolve(__dirname, '../../core/src/index.ts'), + '@objectstack/spec/api': path.resolve(__dirname, '../../spec/src/api/index.ts'), + '@objectstack/spec/contracts': path.resolve(__dirname, '../../spec/src/contracts/index.ts'), + '@objectstack/spec/data': path.resolve(__dirname, '../../spec/src/data/index.ts'), + '@objectstack/spec/kernel': path.resolve(__dirname, '../../spec/src/kernel/index.ts'), + '@objectstack/spec/system': path.resolve(__dirname, '../../spec/src/system/index.ts'), + '@objectstack/spec': path.resolve(__dirname, '../../spec/src/index.ts'), + }, + }, +}); diff --git a/packages/services/service-ai/vitest.config.ts b/packages/services/service-ai/vitest.config.ts new file mode 100644 index 000000000..2b2203c2b --- /dev/null +++ b/packages/services/service-ai/vitest.config.ts @@ -0,0 +1,23 @@ +// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. + +import { defineConfig } from 'vitest/config'; +import path from 'path'; + +export default defineConfig({ + test: { + globals: true, + environment: 'node', + }, + resolve: { + alias: { + '@objectstack/core': path.resolve(__dirname, '../../core/src/index.ts'), + '@objectstack/spec/ai': path.resolve(__dirname, '../../spec/src/ai/index.ts'), + '@objectstack/spec/api': path.resolve(__dirname, '../../spec/src/api/index.ts'), + '@objectstack/spec/contracts': path.resolve(__dirname, '../../spec/src/contracts/index.ts'), + '@objectstack/spec/data': path.resolve(__dirname, '../../spec/src/data/index.ts'), + '@objectstack/spec/kernel': path.resolve(__dirname, '../../spec/src/kernel/index.ts'), + '@objectstack/spec/system': path.resolve(__dirname, '../../spec/src/system/index.ts'), + '@objectstack/spec': path.resolve(__dirname, '../../spec/src/index.ts'), + }, + }, +}); diff --git a/packages/spec/scripts/build-schemas.ts b/packages/spec/scripts/build-schemas.ts index 2308d41ec..32934e380 100644 --- a/packages/spec/scripts/build-schemas.ts +++ b/packages/spec/scripts/build-schemas.ts @@ -80,10 +80,36 @@ function writeFileWithRetry(filePath: string, content: string, retries = MAX_RET // Clean output directory ensures no stale files remain if (fs.existsSync(OUT_DIR)) { console.log(`Cleaning output directory: ${OUT_DIR}`); - fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: MAX_RETRIES, retryDelay: RETRY_DELAY_BASE_MS }); - + + // Use a more robust cleanup with multiple retries and longer delays + // to handle filesystem race conditions in CI environments + for (let attempt = 0; attempt < MAX_RETRIES * 2; attempt++) { + try { + // Try removing with native Node.js rmSync + if (fs.existsSync(OUT_DIR)) { + fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: RETRY_DELAY_BASE_MS * 2 }); + } + + // Verify the directory is actually gone + if (!fs.existsSync(OUT_DIR)) { + break; + } + + // If still exists, wait before retrying with exponential backoff + sleepSync(RETRY_DELAY_BASE_MS * (attempt + 1)); + } catch (error) { + // If this is the last attempt, log but continue (we'll try to work with what's there) + if (attempt === (MAX_RETRIES * 2 - 1)) { + console.warn(`Warning: Failed to fully clean directory after ${attempt + 1} attempts:`, error); + // Try to continue anyway - ensureDir will create missing parts + break; + } + // Wait before retry with exponential backoff + sleepSync(RETRY_DELAY_BASE_MS * (attempt + 1)); + } + } + // Wait a bit to ensure file system has synced - // This prevents ENOENT errors on some file systems, particularly in CI environments sleepSync(FS_SYNC_DELAY_MS); }