Skip to content

Commit d9440db

Browse files
committed
chore: reorganize tests
1 parent 8091741 commit d9440db

20 files changed

+528
-55
lines changed

CLAUDE.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## important-instruction-reminders
6+
7+
- Do what has been asked; nothing more, nothing less.
8+
- NEVER create files unless they're absolutely necessary for achieving your goal.
9+
- ALWAYS prefer editing an existing file to creating a new one.
10+
11+
## Project Overview
12+
13+
Pandino is an OSGi-style framework for TypeScript that provides modular architecture, service registry, and dynamic dependency injection. The project follows a monorepo structure with multiple packages managed by pnpm workspaces.
14+
15+
## Common Development Commands
16+
17+
### Build Commands
18+
- `pnpm build` - Build all packages recursively
19+
- `pnpm build:dev` - Build all packages in development mode
20+
- `pnpm build:pandino` - Build only the core pandino package
21+
- `pnpm build:react-hooks` - Build only the React hooks package
22+
23+
### Testing Commands
24+
- `pnpm test` - Run all tests using Vitest
25+
- `pnpm test:watch` - Run tests in watch mode
26+
- `pnpm test:coverage` - Run tests with coverage report
27+
- `vitest run --reporter=verbose` - Run tests with detailed output
28+
- Individual package tests: `cd packages/<package-name> && pnpm test`
29+
30+
### Development Commands
31+
- `pnpm dev:example` - Start the example application
32+
- `pnpm lint` - Run oxlint for code linting
33+
- `pnpm format:write` - Format code using Biome
34+
35+
### Package Management
36+
- Uses pnpm workspaces with packages in `packages/` directory
37+
- Node.js >=22 and pnpm >=10 required
38+
- Workspace dependencies use `workspace:*` protocol
39+
40+
## Project Architecture
41+
42+
### Core Packages Structure
43+
- `packages/pandino/` - Core framework (service registry, bundles, lifecycle management)
44+
- `packages/react-hooks/` - React integration with hooks and components
45+
- `packages/decorators/` - Decorators for Service Component Runtime (SCR)
46+
- `packages/rollup-bundle-plugin/` - Rollup plugin for bundle automation
47+
- `packages/example/` - Example application demonstrating usage
48+
49+
### Key Architectural Concepts
50+
51+
**Service Registry Pattern**: Central registry where services are registered by interface and discovered dynamically using LDAP-style filters.
52+
53+
**Bundle System**: Self-contained modules with independent lifecycles. Each bundle has an activator that manages service registration/cleanup.
54+
55+
**Service Component Runtime (SCR)**: Declarative service management using decorators (`@Component`, `@Service`, `@Reference`, `@Activate`).
56+
57+
**Dynamic Dependencies**: Services can start in any order - dependencies are resolved automatically when services become available.
58+
59+
### Core Framework Structure (`packages/pandino/src/`)
60+
- `framework/` - Core framework implementation and bootstrap
61+
- `services/` - Built-in services (service registry, event admin, etc.)
62+
- `bundle/` - Bundle management and lifecycle
63+
- `types/` - TypeScript interfaces and type definitions
64+
- `test/` - Test utilities and setup
65+
66+
## Development Patterns
67+
68+
### Service Definition Pattern
69+
```typescript
70+
// 1. Define interface
71+
interface MyService {
72+
doSomething(): void;
73+
}
74+
75+
// 2. Implement with SCR decorators
76+
@Component({ name: 'my.service', immediate: true })
77+
@Service({ interfaces: ['MyService'] })
78+
class MyServiceImpl implements MyService {
79+
@Reference({ interface: 'DependencyService' })
80+
private dependency?: DependencyService;
81+
82+
@Activate
83+
activate(context: ComponentContext): void {
84+
// Initialization logic
85+
}
86+
}
87+
```
88+
89+
### Bundle Activator Pattern
90+
```typescript
91+
export class BundleActivator {
92+
async start(context: BundleContext): Promise<void> {
93+
// Register services, event listeners
94+
}
95+
96+
async stop(context: BundleContext): Promise<void> {
97+
// Cleanup
98+
}
99+
}
100+
```
101+
102+
## Testing Configuration
103+
104+
- Vitest configuration in root and individual packages
105+
- Uses jsdom environment for DOM-related tests
106+
- Coverage reports with @vitest/coverage-v8
107+
- Test files follow `*.test.ts` pattern
108+
109+
## Code Quality Tools
110+
111+
### Formatting & Linting
112+
- **Biome**: Code formatting with 2-space indentation, 120 character line width
113+
- **oxlint**: Fast linting (Biome linter disabled in favor of oxlint)
114+
- **TypeScript**: Strict type checking with multiple tsconfig files
115+
116+
### Import Organization
117+
- Biome automatically organizes imports
118+
- Use `reflect-metadata` for decorator support
119+
- Peer dependency on `@pandino/decorators`
120+
121+
## Build System
122+
123+
- **Vite**: Module bundling with TypeScript support
124+
- **vite-plugin-dts**: Automatic TypeScript declaration generation
125+
- **Dual Format**: Generates both ESM and CJS outputs
126+
- **Type Exports**: Proper TypeScript module resolution support
127+
128+
## Key Files for Understanding
129+
- `packages/pandino/src/framework/framework.ts` - Core framework implementation
130+
- `packages/pandino/src/services/` - Built-in service implementations
131+
- `packages/pandino/src/types/` - Type definitions for the entire system
132+
- Root `package.json` - Workspace configuration and scripts
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, beforeEach } from 'vitest';
2-
import { ComponentResourceProcessor } from '../component-resource-processor';
3-
import type { Bundle } from '../../../framework/interfaces';
4-
import { BundleModule } from '../../../types/bundle-metadata';
2+
import { ComponentResourceProcessor } from '../../component-resource-processor';
3+
import type { Bundle } from '../../../../framework/interfaces';
4+
import { BundleModule } from '../../../../types/bundle-metadata';
55

66
describe('ComponentResourceProcessor', () => {
77
let processor: ComponentResourceProcessor;

packages/pandino/src/services/declarative-services/__tests__/scr-osgi-compliance.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/advanced/osgi-compliance.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
2-
import { OSGiFramework } from '../../../framework/framework';
3-
import type { BundleContext } from '../../../framework/interfaces';
4-
import { ServiceComponentRuntime } from '../scr';
2+
import { OSGiFramework } from '../../../../framework/framework';
3+
import type { BundleContext } from '../../../../framework/interfaces';
4+
import { ServiceComponentRuntime } from '../../scr';
55
import { Activate, Component, Reference, Service } from '@pandino/decorators';
66

77
describe('SCR OSGi Specification Compliance', () => {

packages/pandino/src/services/declarative-services/__tests__/configuration.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/configuration/configuration-integration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { beforeEach, describe, expect, it } from 'vitest';
2-
import { OSGiFramework } from '../../../framework/framework';
3-
import type { BundleContext } from '../../../framework/interfaces';
2+
import { OSGiFramework } from '../../../../framework/framework';
3+
import type { BundleContext } from '../../../../framework/interfaces';
44
import { Component, ConfigurationPolicy, Modified, Property } from '@pandino/decorators';
5-
import { getComponentMetadata } from '../reflection';
6-
import { ServiceComponentRuntime } from '../scr';
5+
import { getComponentMetadata } from '../../reflection';
6+
import { ServiceComponentRuntime } from '../../scr';
77

88
describe('Configuration and Properties', () => {
99
let framework: OSGiFramework;

packages/pandino/src/services/declarative-services/__tests__/scr-configuration.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/configuration/scr-configuration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
2-
import { OSGiFramework } from '../../../framework/framework';
3-
import type { BundleContext } from '../../../framework/interfaces';
4-
import { ServiceComponentRuntime } from '../scr';
5-
import type { ConfigurationAdmin } from '../../config-admin';
2+
import { OSGiFramework } from '../../../../framework/framework';
3+
import type { BundleContext } from '../../../../framework/interfaces';
4+
import { ServiceComponentRuntime } from '../../scr';
5+
import type { ConfigurationAdmin } from '../../../config-admin';
66
import { Activate, Component } from '@pandino/decorators';
77

88
describe('SCR Configuration Integration', () => {

packages/pandino/src/services/declarative-services/__tests__/component-lifecycle.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/core/component-registration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { beforeEach, describe, expect, it } from 'vitest';
2-
import { OSGiFramework } from '../../../framework/framework';
3-
import type { BundleContext } from '../../../framework/interfaces';
2+
import { OSGiFramework } from '../../../../framework/framework';
3+
import type { BundleContext } from '../../../../framework/interfaces';
44
import { Activate, Component, Deactivate, Modified, Reference } from '@pandino/decorators';
5-
import { getComponentMetadata } from '../reflection';
6-
import { ServiceComponentRuntime } from '../scr';
5+
import { getComponentMetadata } from '../../reflection';
6+
import { ServiceComponentRuntime } from '../../scr';
77

88
describe('Component Lifecycle', () => {
99
let framework: OSGiFramework;

packages/pandino/src/services/declarative-services/__tests__/scr.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/core/scr-core.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2-
import { OSGiBootstrap } from '../../../framework/bootstrap';
3-
import type { BundleContext } from '../../../framework/interfaces';
2+
import { OSGiBootstrap } from '../../../../framework/bootstrap';
3+
import type { BundleContext } from '../../../../framework/interfaces';
44
import { Component, Service, Reference, Activate, Deactivate } from '@pandino/decorators';
55

66
interface AuxService {

packages/pandino/src/services/declarative-services/__tests__/scr-advanced.test.ts renamed to packages/pandino/src/services/declarative-services/__tests__/core/scr-lifecycle.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
2-
import { OSGiFramework } from '../../../framework/framework';
3-
import type { BundleContext, ServiceReference } from '../../../framework/interfaces';
4-
import { getComponentMetadata } from '../reflection';
5-
import { ServiceComponentRuntime } from '../scr';
2+
import { OSGiFramework } from '../../../../framework/framework';
3+
import type { BundleContext, ServiceReference } from '../../../../framework/interfaces';
4+
import { getComponentMetadata } from '../../reflection';
5+
import { ServiceComponentRuntime } from '../../scr';
66
import { Component, Service } from '@pandino/decorators';
77
import { Activate, Deactivate, Reference } from '@pandino/decorators';
88

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Reflection Helpers > getDecoratorInfo > should retrieve all decorator information in a single call 1`] = `
4+
{
5+
"component": {
6+
"enabled": true,
7+
"factory": {
8+
"id": null,
9+
"isFactory": false,
10+
},
11+
"immediate": true,
12+
"isComponent": true,
13+
"name": "complete.component",
14+
},
15+
"configuration": {
16+
"pid": "complete.config",
17+
"policy": "require",
18+
"properties": {
19+
"service.ranking": 100,
20+
},
21+
},
22+
"customDecorators": {},
23+
"customFieldDecorators": {},
24+
"customMethodDecorators": {},
25+
"lifecycle": {
26+
"activate": "activate",
27+
"deactivate": "deactivate",
28+
"modified": null,
29+
},
30+
"rawMetadata": {
31+
"activate": "activate",
32+
"configurationPid": "complete.config",
33+
"configurationPolicy": "require",
34+
"deactivate": "deactivate",
35+
"enabled": true,
36+
"factory": undefined,
37+
"immediate": true,
38+
"implementation": [Function],
39+
"modified": undefined,
40+
"name": "complete.component",
41+
"properties": {
42+
"service.ranking": 100,
43+
},
44+
"references": [
45+
{
46+
"bind": undefined,
47+
"cardinality": "1..1",
48+
"field": "logger",
49+
"fieldOption": "replace",
50+
"interface": "LogService",
51+
"name": "logger",
52+
"policy": "static",
53+
"policyOption": "reluctant",
54+
"scope": "bundle",
55+
"target": undefined,
56+
"unbind": undefined,
57+
"updated": undefined,
58+
},
59+
],
60+
"scope": "singleton",
61+
"service": {
62+
"interfaces": [
63+
"CompleteService",
64+
],
65+
"scope": "prototype",
66+
},
67+
},
68+
"references": [
69+
{
70+
"bind": undefined,
71+
"cardinality": "1..1",
72+
"field": "logger",
73+
"fieldOption": "replace",
74+
"interface": "LogService",
75+
"name": "logger",
76+
"policy": "static",
77+
"policyOption": "reluctant",
78+
"scope": "bundle",
79+
"target": undefined,
80+
"unbind": undefined,
81+
"updated": undefined,
82+
},
83+
],
84+
"service": {
85+
"interfaces": [
86+
"CompleteService",
87+
],
88+
"scope": "prototype",
89+
},
90+
}
91+
`;
92+
93+
exports[`Reflection Helpers > getDecoratorInfo > should work with non-component classes 1`] = `
94+
{
95+
"component": {
96+
"enabled": false,
97+
"factory": {
98+
"id": null,
99+
"isFactory": false,
100+
},
101+
"immediate": false,
102+
"isComponent": false,
103+
"name": null,
104+
},
105+
"configuration": {
106+
"pid": null,
107+
"policy": "optional",
108+
"properties": {},
109+
},
110+
"customDecorators": {},
111+
"customFieldDecorators": {},
112+
"customMethodDecorators": {},
113+
"lifecycle": {
114+
"activate": null,
115+
"deactivate": null,
116+
"modified": null,
117+
},
118+
"rawMetadata": null,
119+
"references": [],
120+
"service": {
121+
"interfaces": [],
122+
"scope": null,
123+
},
124+
}
125+
`;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'reflect-metadata';
22
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
3-
import { OSGiBootstrap } from '../../../framework/bootstrap';
4-
import type { EventAdmin, EventHandler } from '../../event-admin';
5-
import { Event } from '../../event-admin';
6-
import { ServiceComponentRuntime } from '../scr';
3+
import { OSGiBootstrap } from '../../../../framework/bootstrap';
4+
import type { EventAdmin, EventHandler } from '../../../event-admin';
5+
import { Event } from '../../../event-admin';
6+
import { ServiceComponentRuntime } from '../../scr';
77
import { Component, Service, Activate, Deactivate, Reference } from '@pandino/decorators';
8-
import { getDecoratorInfo } from '../reflection';
8+
import { getDecoratorInfo } from '../../reflection';
99

1010
function Feature(meta: any) {
1111
return function (target: Function) {

0 commit comments

Comments
 (0)