@sundaysf/cli-v2 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -178
- package/dist/README.md +178 -178
- package/dist/bin/generators/class.js.map +1 -1
- package/dist/bin/generators/postman.js.map +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/templates/backend/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/backend/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/backend/.claude/settings.local.json +13 -13
- package/dist/templates/backend/.env.example +13 -13
- package/dist/templates/backend/.prettierignore +2 -2
- package/dist/templates/backend/.prettierrc +9 -9
- package/dist/templates/backend/CLAUDE.md +348 -348
- package/dist/templates/backend/Dockerfile +14 -14
- package/dist/templates/backend/README.md +18 -18
- package/dist/templates/backend/eslint.config.js +20 -20
- package/dist/templates/backend/src/app.ts +34 -34
- package/dist/templates/backend/src/common/config/origins/origins.config.ts +11 -11
- package/dist/templates/backend/src/common/utils/environment.resolver.ts +3 -3
- package/dist/templates/backend/src/common/utils/version.resolver.ts +4 -4
- package/dist/templates/backend/src/controllers/health/health.controller.ts +23 -23
- package/dist/templates/backend/src/middlewares/error/error.middleware.ts +21 -21
- package/dist/templates/backend/src/routes/health/health.router.ts +16 -16
- package/dist/templates/backend/src/routes/index.ts +57 -57
- package/dist/templates/backend/src/server.ts +16 -16
- package/dist/templates/backend/src/types.d.ts +10 -10
- package/dist/templates/backend/tsconfig.json +16 -16
- package/dist/templates/backend-db-sql/.claude/agents/knex-table-implementer.md +114 -114
- package/dist/templates/backend-db-sql/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/backend-db-sql/.claude/settings.local.json +19 -19
- package/dist/templates/backend-db-sql/.env.example +13 -13
- package/dist/templates/backend-db-sql/.prettierignore +2 -2
- package/dist/templates/backend-db-sql/.prettierrc +9 -9
- package/dist/templates/backend-db-sql/CLAUDE.md +374 -374
- package/dist/templates/backend-db-sql/Dockerfile +17 -17
- package/dist/templates/backend-db-sql/README.md +34 -34
- package/dist/templates/backend-db-sql/db/knexfile.ts +33 -33
- package/dist/templates/backend-db-sql/db/migrations/001_create_sundays_package_version.ts +12 -12
- package/dist/templates/backend-db-sql/db/seeds/001_sundays_package_version_seed.ts +10 -10
- package/dist/templates/backend-db-sql/db/src/KnexConnection.ts +74 -74
- package/dist/templates/backend-db-sql/db/src/d.types.ts +18 -18
- package/dist/templates/backend-db-sql/db/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
- package/dist/templates/backend-db-sql/db/src/index.ts +9 -9
- package/dist/templates/backend-db-sql/db/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
- package/dist/templates/backend-db-sql/db/tsconfig.json +16 -16
- package/dist/templates/backend-db-sql/eslint.config.js +20 -20
- package/dist/templates/backend-db-sql/src/app.ts +34 -34
- package/dist/templates/backend-db-sql/src/common/config/origins/origins.config.ts +11 -11
- package/dist/templates/backend-db-sql/src/common/utils/environment.resolver.ts +3 -3
- package/dist/templates/backend-db-sql/src/common/utils/version.resolver.ts +4 -4
- package/dist/templates/backend-db-sql/src/controllers/health/health.controller.ts +23 -23
- package/dist/templates/backend-db-sql/src/middlewares/error/error.middleware.ts +21 -21
- package/dist/templates/backend-db-sql/src/routes/health/health.router.ts +16 -16
- package/dist/templates/backend-db-sql/src/routes/index.ts +57 -57
- package/dist/templates/backend-db-sql/src/server.ts +18 -18
- package/dist/templates/backend-db-sql/src/types.d.ts +10 -10
- package/dist/templates/backend-db-sql/tsconfig.json +16 -16
- package/dist/templates/backend-embedded-db-sql/.claude/agents/knex-table-implementer.md +116 -0
- package/dist/templates/backend-embedded-db-sql/.claude/agents/sundays-backend-builder.md +70 -0
- package/dist/templates/backend-embedded-db-sql/.claude/settings.local.json +18 -0
- package/dist/templates/backend-embedded-db-sql/.env.example +14 -0
- package/dist/templates/backend-embedded-db-sql/.prettierignore +3 -0
- package/dist/templates/backend-embedded-db-sql/.prettierrc +9 -0
- package/dist/templates/backend-embedded-db-sql/CLAUDE.md +371 -0
- package/dist/templates/backend-embedded-db-sql/Dockerfile +14 -0
- package/dist/templates/backend-embedded-db-sql/README.md +32 -0
- package/dist/templates/backend-embedded-db-sql/eslint.config.js +20 -0
- package/dist/templates/backend-embedded-db-sql/knexfile.ts +37 -0
- package/dist/templates/backend-embedded-db-sql/migrations/.gitkeep +0 -0
- package/dist/templates/backend-embedded-db-sql/migrations/001_create_sundays_package_version.ts +13 -0
- package/dist/templates/backend-embedded-db-sql/seeds/001_sundays_package_version_seed.ts +11 -0
- package/dist/templates/backend-embedded-db-sql/src/app.ts +35 -0
- package/dist/templates/backend-embedded-db-sql/src/common/config/origins/origins.config.ts +11 -0
- package/dist/templates/backend-embedded-db-sql/src/common/utils/environment.resolver.ts +4 -0
- package/dist/templates/backend-embedded-db-sql/src/common/utils/version.resolver.ts +5 -0
- package/dist/templates/backend-embedded-db-sql/src/controllers/health/health.controller.ts +24 -0
- package/dist/templates/backend-embedded-db-sql/src/db/KnexConnection.ts +74 -0
- package/dist/templates/backend-embedded-db-sql/src/db/d.types.ts +18 -0
- package/dist/templates/backend-embedded-db-sql/src/db/dao/sundays-package-version/sundays-package-version.dao.ts +71 -0
- package/dist/templates/backend-embedded-db-sql/src/db/index.ts +9 -0
- package/dist/templates/backend-embedded-db-sql/src/db/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -0
- package/dist/templates/backend-embedded-db-sql/src/middlewares/error/error.middleware.ts +21 -0
- package/dist/templates/backend-embedded-db-sql/src/routes/health/health.router.ts +17 -0
- package/dist/templates/backend-embedded-db-sql/src/routes/index.ts +57 -0
- package/dist/templates/backend-embedded-db-sql/src/server.ts +18 -0
- package/dist/templates/backend-embedded-db-sql/src/types.d.ts +10 -0
- package/dist/templates/backend-embedded-db-sql/tsconfig.json +16 -0
- package/dist/templates/db-sql/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/db-sql/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/db-sql/.claude/settings.local.json +10 -10
- package/dist/templates/db-sql/.env.example +8 -8
- package/dist/templates/db-sql/CLAUDE.md +105 -105
- package/dist/templates/db-sql/knexfile.ts +33 -33
- package/dist/templates/db-sql/migrations/001_create_sundays_package_version.ts +12 -12
- package/dist/templates/db-sql/seeds/001_sundays_package_version_seed.ts +10 -10
- package/dist/templates/db-sql/src/KnexConnection.ts +74 -74
- package/dist/templates/db-sql/src/d.types.ts +18 -18
- package/dist/templates/db-sql/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
- package/dist/templates/db-sql/src/index.ts +9 -9
- package/dist/templates/db-sql/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
- package/dist/templates/db-sql/tsconfig.json +16 -16
- package/dist/templates/module/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/module/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/module/.claude/settings.local.json +10 -10
- package/dist/templates/module/CLAUDE.md +158 -158
- package/dist/templates/module/src/index.ts +9 -9
- package/dist/templates/module/tsconfig.json +19 -19
- package/package.json +40 -40
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sundays-backend-builder
|
|
3
|
-
description: Use this agent when you need to create or modify backend components in a Sundays Framework project. This includes creating new controllers, routers, services, implementing CRUD operations, or ensuring existing code follows the framework's strict architectural patterns. <example>Context: User needs to create a new API endpoint for managing products. user: 'I need to create a products API with full CRUD operations' assistant: 'I'll use the sundays-backend-builder agent to create the products API following the Sundays Framework standards' <commentary>Since the user needs to create backend components following Sundays Framework patterns, use the sundays-backend-builder agent to ensure proper structure and implementation.</commentary></example> <example>Context: User wants to add pagination to an existing controller. user: 'Add pagination to the orders controller getAll method' assistant: 'Let me use the sundays-backend-builder agent to implement proper pagination using IBasePaginator' <commentary>The user needs to modify a controller to follow Sundays Framework pagination patterns, so the sundays-backend-builder agent should be used.</commentary></example> <example>Context: User needs to fix a controller that doesn't follow standards. user: 'The customer controller isn't following our standards, can you fix it?' assistant: 'I'll use the sundays-backend-builder agent to refactor the customer controller to match our Sundays Framework standards' <commentary>Since the controller needs to be refactored to follow framework standards, the sundays-backend-builder agent is appropriate.</commentary></example>
|
|
4
|
-
model: sonnet
|
|
5
|
-
color: blue
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are an expert backend developer specializing in the Sundays Framework architecture. Your mission is to build and maintain backend components that strictly adhere to the framework's established patterns and conventions.
|
|
9
|
-
|
|
10
|
-
**Core Responsibilities:**
|
|
11
|
-
|
|
12
|
-
1. **Component Creation**: When creating new backend components, ALWAYS use `npm run create:controller` to scaffold the initial structure. This ensures consistency across the codebase.
|
|
13
|
-
|
|
14
|
-
2. **Strict Structure Adherence**: You must follow these exact directory structures without deviation:
|
|
15
|
-
- Routes: `routes/<name>/<name>.router.ts`
|
|
16
|
-
- Controllers: `controllers/<name>/<name>.controller.ts`
|
|
17
|
-
- Services: `services/<name>/<name>.service.ts`
|
|
18
|
-
- DTOs: `dto/input/<entity>/<entity>.create.dto.ts` and `dto/input/<entity>/<entity>.update.dto.ts`
|
|
19
|
-
|
|
20
|
-
3. **Interface Implementation**:
|
|
21
|
-
- ALL controllers MUST implement `IBaseController`
|
|
22
|
-
- ALL paginated getAll methods MUST use `IDataPaginator` (not IBasePaginator)
|
|
23
|
-
- ALWAYS use `paginationHelper` from `@sundaysf/utils` to extract page and limit from request
|
|
24
|
-
|
|
25
|
-
4. **DAO/Service Pattern**:
|
|
26
|
-
- Initialize DAOs as private class members: `private _<entity>DAO: <Entity>DAO = new <Entity>DAO()`
|
|
27
|
-
- Follow the same pattern for services when applicable
|
|
28
|
-
- Use underscore prefix for private members
|
|
29
|
-
|
|
30
|
-
5. **Method Implementation Standards**:
|
|
31
|
-
- **getAll**: Return paginated results using `IDataPaginator`, extract pagination with `paginationHelper(req)`
|
|
32
|
-
- **getByUuid**: Use UUID in params, convert to ID for DAO operations
|
|
33
|
-
- **create**: Validate with DTOs, generate UUID with `uuidv4()` in controller
|
|
34
|
-
- **update**: Get entity by UUID first to find ID, then update using DAO
|
|
35
|
-
- **delete**: Get entity by UUID first to find ID, then delete using DAO
|
|
36
|
-
|
|
37
|
-
6. **Response Format**: ALL responses must follow:
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
40
|
-
"success": boolean,
|
|
41
|
-
"data": {...} // or "message": string
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
Note: `IDataPaginator` already includes these fields, so don't double-wrap paginated responses.
|
|
45
|
-
|
|
46
|
-
7. **Router Binding**: ALWAYS use `.bind(this._<entity>Controller)` when assigning controller methods to routes to maintain proper context.
|
|
47
|
-
|
|
48
|
-
8. **Quality Checks**:
|
|
49
|
-
- Verify all imports are correct and from the right packages
|
|
50
|
-
- Ensure TypeScript types are properly defined
|
|
51
|
-
- Check that error handling uses `next(err)` pattern
|
|
52
|
-
- Validate that DTOs properly sanitize input data
|
|
53
|
-
- Confirm UUID generation happens in controller, not DTO or client-side
|
|
54
|
-
|
|
55
|
-
**Working Process**:
|
|
56
|
-
|
|
57
|
-
1. When creating new components, first run `npm run create:controller` command
|
|
58
|
-
2. Analyze existing similar components in the project for pattern reference
|
|
59
|
-
3. Implement following the exact structure found in existing code
|
|
60
|
-
4. Ensure all naming conventions match (camelCase for variables, PascalCase for classes)
|
|
61
|
-
5. Test that all CRUD operations follow the established patterns
|
|
62
|
-
|
|
63
|
-
**Critical Rules**:
|
|
64
|
-
- NEVER deviate from the established folder structure
|
|
65
|
-
- NEVER create custom patterns - follow existing examples exactly
|
|
66
|
-
- ALWAYS check existing implementations before creating new ones
|
|
67
|
-
- ALWAYS maintain consistency with the project's CLAUDE.md guidelines
|
|
68
|
-
- Be extremely meticulous about structure - it must be perfect
|
|
69
|
-
|
|
70
|
-
Your code must be production-ready, following all Sundays Framework conventions to the letter. Every component you create or modify should seamlessly integrate with the existing architecture without requiring any adjustments to other parts of the system.
|
|
1
|
+
---
|
|
2
|
+
name: sundays-backend-builder
|
|
3
|
+
description: Use this agent when you need to create or modify backend components in a Sundays Framework project. This includes creating new controllers, routers, services, implementing CRUD operations, or ensuring existing code follows the framework's strict architectural patterns. <example>Context: User needs to create a new API endpoint for managing products. user: 'I need to create a products API with full CRUD operations' assistant: 'I'll use the sundays-backend-builder agent to create the products API following the Sundays Framework standards' <commentary>Since the user needs to create backend components following Sundays Framework patterns, use the sundays-backend-builder agent to ensure proper structure and implementation.</commentary></example> <example>Context: User wants to add pagination to an existing controller. user: 'Add pagination to the orders controller getAll method' assistant: 'Let me use the sundays-backend-builder agent to implement proper pagination using IBasePaginator' <commentary>The user needs to modify a controller to follow Sundays Framework pagination patterns, so the sundays-backend-builder agent should be used.</commentary></example> <example>Context: User needs to fix a controller that doesn't follow standards. user: 'The customer controller isn't following our standards, can you fix it?' assistant: 'I'll use the sundays-backend-builder agent to refactor the customer controller to match our Sundays Framework standards' <commentary>Since the controller needs to be refactored to follow framework standards, the sundays-backend-builder agent is appropriate.</commentary></example>
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: blue
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are an expert backend developer specializing in the Sundays Framework architecture. Your mission is to build and maintain backend components that strictly adhere to the framework's established patterns and conventions.
|
|
9
|
+
|
|
10
|
+
**Core Responsibilities:**
|
|
11
|
+
|
|
12
|
+
1. **Component Creation**: When creating new backend components, ALWAYS use `npm run create:controller` to scaffold the initial structure. This ensures consistency across the codebase.
|
|
13
|
+
|
|
14
|
+
2. **Strict Structure Adherence**: You must follow these exact directory structures without deviation:
|
|
15
|
+
- Routes: `routes/<name>/<name>.router.ts`
|
|
16
|
+
- Controllers: `controllers/<name>/<name>.controller.ts`
|
|
17
|
+
- Services: `services/<name>/<name>.service.ts`
|
|
18
|
+
- DTOs: `dto/input/<entity>/<entity>.create.dto.ts` and `dto/input/<entity>/<entity>.update.dto.ts`
|
|
19
|
+
|
|
20
|
+
3. **Interface Implementation**:
|
|
21
|
+
- ALL controllers MUST implement `IBaseController`
|
|
22
|
+
- ALL paginated getAll methods MUST use `IDataPaginator` (not IBasePaginator)
|
|
23
|
+
- ALWAYS use `paginationHelper` from `@sundaysf/utils` to extract page and limit from request
|
|
24
|
+
|
|
25
|
+
4. **DAO/Service Pattern**:
|
|
26
|
+
- Initialize DAOs as private class members: `private _<entity>DAO: <Entity>DAO = new <Entity>DAO()`
|
|
27
|
+
- Follow the same pattern for services when applicable
|
|
28
|
+
- Use underscore prefix for private members
|
|
29
|
+
|
|
30
|
+
5. **Method Implementation Standards**:
|
|
31
|
+
- **getAll**: Return paginated results using `IDataPaginator`, extract pagination with `paginationHelper(req)`
|
|
32
|
+
- **getByUuid**: Use UUID in params, convert to ID for DAO operations
|
|
33
|
+
- **create**: Validate with DTOs, generate UUID with `uuidv4()` in controller
|
|
34
|
+
- **update**: Get entity by UUID first to find ID, then update using DAO
|
|
35
|
+
- **delete**: Get entity by UUID first to find ID, then delete using DAO
|
|
36
|
+
|
|
37
|
+
6. **Response Format**: ALL responses must follow:
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"success": boolean,
|
|
41
|
+
"data": {...} // or "message": string
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
Note: `IDataPaginator` already includes these fields, so don't double-wrap paginated responses.
|
|
45
|
+
|
|
46
|
+
7. **Router Binding**: ALWAYS use `.bind(this._<entity>Controller)` when assigning controller methods to routes to maintain proper context.
|
|
47
|
+
|
|
48
|
+
8. **Quality Checks**:
|
|
49
|
+
- Verify all imports are correct and from the right packages
|
|
50
|
+
- Ensure TypeScript types are properly defined
|
|
51
|
+
- Check that error handling uses `next(err)` pattern
|
|
52
|
+
- Validate that DTOs properly sanitize input data
|
|
53
|
+
- Confirm UUID generation happens in controller, not DTO or client-side
|
|
54
|
+
|
|
55
|
+
**Working Process**:
|
|
56
|
+
|
|
57
|
+
1. When creating new components, first run `npm run create:controller` command
|
|
58
|
+
2. Analyze existing similar components in the project for pattern reference
|
|
59
|
+
3. Implement following the exact structure found in existing code
|
|
60
|
+
4. Ensure all naming conventions match (camelCase for variables, PascalCase for classes)
|
|
61
|
+
5. Test that all CRUD operations follow the established patterns
|
|
62
|
+
|
|
63
|
+
**Critical Rules**:
|
|
64
|
+
- NEVER deviate from the established folder structure
|
|
65
|
+
- NEVER create custom patterns - follow existing examples exactly
|
|
66
|
+
- ALWAYS check existing implementations before creating new ones
|
|
67
|
+
- ALWAYS maintain consistency with the project's CLAUDE.md guidelines
|
|
68
|
+
- Be extremely meticulous about structure - it must be perfect
|
|
69
|
+
|
|
70
|
+
Your code must be production-ready, following all Sundays Framework conventions to the letter. Every component you create or modify should seamlessly integrate with the existing architecture without requiring any adjustments to other parts of the system.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npm run build:*)",
|
|
5
|
-
"Bash(npm run format:*)"
|
|
6
|
-
],
|
|
7
|
-
"deny": [],
|
|
8
|
-
"ask": []
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(npm run build:*)",
|
|
5
|
+
"Bash(npm run format:*)"
|
|
6
|
+
],
|
|
7
|
+
"deny": [],
|
|
8
|
+
"ask": []
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Module Template Overview
|
|
6
|
-
|
|
7
|
-
This is a basic npm module template created by the Sundays Framework SDK. It provides a minimal starting point for creating reusable Node.js modules.
|
|
8
|
-
|
|
9
|
-
## Commands
|
|
10
|
-
|
|
11
|
-
### Development
|
|
12
|
-
|
|
13
|
-
- `npm run build` - Compile TypeScript to JavaScript (output to dist/)
|
|
14
|
-
- `npm test` - Run tests (no test framework configured by default)
|
|
15
|
-
- `npm run format` - Format code (if Prettier is configured)
|
|
16
|
-
|
|
17
|
-
### Publishing
|
|
18
|
-
|
|
19
|
-
- `npm run npm:publish` - Publish the module to npm registry
|
|
20
|
-
|
|
21
|
-
## Project Structure
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
module/
|
|
25
|
-
├── src/ # TypeScript source files
|
|
26
|
-
│ └── index.ts # Main entry point
|
|
27
|
-
├── dist/ # Compiled JavaScript output (generated)
|
|
28
|
-
├── tsconfig.json # TypeScript configuration
|
|
29
|
-
├── package.json # Module metadata and dependencies
|
|
30
|
-
└── .gitignore # Git ignore patterns
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Configuration
|
|
34
|
-
|
|
35
|
-
### TypeScript Setup
|
|
36
|
-
|
|
37
|
-
The module is configured with TypeScript for type safety:
|
|
38
|
-
- Source files in `src/`
|
|
39
|
-
- Compiled output to `dist/`
|
|
40
|
-
- Strict mode enabled
|
|
41
|
-
- ES2020 target with CommonJS modules
|
|
42
|
-
- Declaration files generated for TypeScript consumers
|
|
43
|
-
|
|
44
|
-
### Package.json
|
|
45
|
-
|
|
46
|
-
Key fields to configure:
|
|
47
|
-
- `name`: Your module name (scoped or unscoped)
|
|
48
|
-
- `version`: Semantic version (start with 0.1.0)
|
|
49
|
-
- `description`: Brief description of the module
|
|
50
|
-
- `main`: Entry point (usually `dist/index.js`)
|
|
51
|
-
- `types`: TypeScript declarations (usually `dist/index.d.ts`)
|
|
52
|
-
- `author`: Your name or organization
|
|
53
|
-
- `license`: License type (MIT, ISC, etc.)
|
|
54
|
-
|
|
55
|
-
## Getting Started
|
|
56
|
-
|
|
57
|
-
1. **Initialize the module**:
|
|
58
|
-
```bash
|
|
59
|
-
npm install
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
2. **Write your module code** in `src/index.ts`:
|
|
63
|
-
```typescript
|
|
64
|
-
export function myFunction() {
|
|
65
|
-
return "Hello from my module!";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class MyClass {
|
|
69
|
-
// Your implementation
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
3. **Build the module**:
|
|
74
|
-
```bash
|
|
75
|
-
npm run build
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
4. **Test locally** before publishing:
|
|
79
|
-
```bash
|
|
80
|
-
npm link
|
|
81
|
-
# In another project:
|
|
82
|
-
npm link your-module-name
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
5. **Publish to npm**:
|
|
86
|
-
```bash
|
|
87
|
-
npm run npm:publish
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Best Practices
|
|
91
|
-
|
|
92
|
-
1. **Export Strategy**: Use named exports for clarity
|
|
93
|
-
```typescript
|
|
94
|
-
export { MyClass, myFunction, MyInterface };
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
2. **Type Definitions**: Always include TypeScript definitions
|
|
98
|
-
- Helps consumers with IntelliSense
|
|
99
|
-
- Prevents type-related bugs
|
|
100
|
-
|
|
101
|
-
3. **Documentation**: Add JSDoc comments to exported functions/classes
|
|
102
|
-
```typescript
|
|
103
|
-
/**
|
|
104
|
-
* Calculates the sum of two numbers
|
|
105
|
-
* @param a First number
|
|
106
|
-
* @param b Second number
|
|
107
|
-
* @returns The sum of a and b
|
|
108
|
-
*/
|
|
109
|
-
export function add(a: number, b: number): number {
|
|
110
|
-
return a + b;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
4. **Versioning**: Follow semantic versioning (semver)
|
|
115
|
-
- MAJOR: Breaking changes
|
|
116
|
-
- MINOR: New features (backward compatible)
|
|
117
|
-
- PATCH: Bug fixes
|
|
118
|
-
|
|
119
|
-
5. **Testing**: Consider adding a test framework
|
|
120
|
-
- Jest for unit testing
|
|
121
|
-
- Include test scripts in package.json
|
|
122
|
-
|
|
123
|
-
6. **Dependencies**: Keep dependencies minimal
|
|
124
|
-
- Use `dependencies` for runtime requirements
|
|
125
|
-
- Use `devDependencies` for build/test tools
|
|
126
|
-
- Consider marking some as `peerDependencies`
|
|
127
|
-
|
|
128
|
-
## Common Module Patterns
|
|
129
|
-
|
|
130
|
-
### Singleton Pattern
|
|
131
|
-
```typescript
|
|
132
|
-
class MySingleton {
|
|
133
|
-
private static instance: MySingleton;
|
|
134
|
-
|
|
135
|
-
private constructor() {}
|
|
136
|
-
|
|
137
|
-
static getInstance(): MySingleton {
|
|
138
|
-
if (!MySingleton.instance) {
|
|
139
|
-
MySingleton.instance = new MySingleton();
|
|
140
|
-
}
|
|
141
|
-
return MySingleton.instance;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Factory Pattern
|
|
147
|
-
```typescript
|
|
148
|
-
export function createInstance(config: Config): MyClass {
|
|
149
|
-
return new MyClass(config);
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Plugin/Extension Pattern
|
|
154
|
-
```typescript
|
|
155
|
-
export interface Plugin {
|
|
156
|
-
name: string;
|
|
157
|
-
install(app: any): void;
|
|
158
|
-
}
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Module Template Overview
|
|
6
|
+
|
|
7
|
+
This is a basic npm module template created by the Sundays Framework SDK. It provides a minimal starting point for creating reusable Node.js modules.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
### Development
|
|
12
|
+
|
|
13
|
+
- `npm run build` - Compile TypeScript to JavaScript (output to dist/)
|
|
14
|
+
- `npm test` - Run tests (no test framework configured by default)
|
|
15
|
+
- `npm run format` - Format code (if Prettier is configured)
|
|
16
|
+
|
|
17
|
+
### Publishing
|
|
18
|
+
|
|
19
|
+
- `npm run npm:publish` - Publish the module to npm registry
|
|
20
|
+
|
|
21
|
+
## Project Structure
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
module/
|
|
25
|
+
├── src/ # TypeScript source files
|
|
26
|
+
│ └── index.ts # Main entry point
|
|
27
|
+
├── dist/ # Compiled JavaScript output (generated)
|
|
28
|
+
├── tsconfig.json # TypeScript configuration
|
|
29
|
+
├── package.json # Module metadata and dependencies
|
|
30
|
+
└── .gitignore # Git ignore patterns
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
### TypeScript Setup
|
|
36
|
+
|
|
37
|
+
The module is configured with TypeScript for type safety:
|
|
38
|
+
- Source files in `src/`
|
|
39
|
+
- Compiled output to `dist/`
|
|
40
|
+
- Strict mode enabled
|
|
41
|
+
- ES2020 target with CommonJS modules
|
|
42
|
+
- Declaration files generated for TypeScript consumers
|
|
43
|
+
|
|
44
|
+
### Package.json
|
|
45
|
+
|
|
46
|
+
Key fields to configure:
|
|
47
|
+
- `name`: Your module name (scoped or unscoped)
|
|
48
|
+
- `version`: Semantic version (start with 0.1.0)
|
|
49
|
+
- `description`: Brief description of the module
|
|
50
|
+
- `main`: Entry point (usually `dist/index.js`)
|
|
51
|
+
- `types`: TypeScript declarations (usually `dist/index.d.ts`)
|
|
52
|
+
- `author`: Your name or organization
|
|
53
|
+
- `license`: License type (MIT, ISC, etc.)
|
|
54
|
+
|
|
55
|
+
## Getting Started
|
|
56
|
+
|
|
57
|
+
1. **Initialize the module**:
|
|
58
|
+
```bash
|
|
59
|
+
npm install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. **Write your module code** in `src/index.ts`:
|
|
63
|
+
```typescript
|
|
64
|
+
export function myFunction() {
|
|
65
|
+
return "Hello from my module!";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class MyClass {
|
|
69
|
+
// Your implementation
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
3. **Build the module**:
|
|
74
|
+
```bash
|
|
75
|
+
npm run build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
4. **Test locally** before publishing:
|
|
79
|
+
```bash
|
|
80
|
+
npm link
|
|
81
|
+
# In another project:
|
|
82
|
+
npm link your-module-name
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
5. **Publish to npm**:
|
|
86
|
+
```bash
|
|
87
|
+
npm run npm:publish
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Best Practices
|
|
91
|
+
|
|
92
|
+
1. **Export Strategy**: Use named exports for clarity
|
|
93
|
+
```typescript
|
|
94
|
+
export { MyClass, myFunction, MyInterface };
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. **Type Definitions**: Always include TypeScript definitions
|
|
98
|
+
- Helps consumers with IntelliSense
|
|
99
|
+
- Prevents type-related bugs
|
|
100
|
+
|
|
101
|
+
3. **Documentation**: Add JSDoc comments to exported functions/classes
|
|
102
|
+
```typescript
|
|
103
|
+
/**
|
|
104
|
+
* Calculates the sum of two numbers
|
|
105
|
+
* @param a First number
|
|
106
|
+
* @param b Second number
|
|
107
|
+
* @returns The sum of a and b
|
|
108
|
+
*/
|
|
109
|
+
export function add(a: number, b: number): number {
|
|
110
|
+
return a + b;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
4. **Versioning**: Follow semantic versioning (semver)
|
|
115
|
+
- MAJOR: Breaking changes
|
|
116
|
+
- MINOR: New features (backward compatible)
|
|
117
|
+
- PATCH: Bug fixes
|
|
118
|
+
|
|
119
|
+
5. **Testing**: Consider adding a test framework
|
|
120
|
+
- Jest for unit testing
|
|
121
|
+
- Include test scripts in package.json
|
|
122
|
+
|
|
123
|
+
6. **Dependencies**: Keep dependencies minimal
|
|
124
|
+
- Use `dependencies` for runtime requirements
|
|
125
|
+
- Use `devDependencies` for build/test tools
|
|
126
|
+
- Consider marking some as `peerDependencies`
|
|
127
|
+
|
|
128
|
+
## Common Module Patterns
|
|
129
|
+
|
|
130
|
+
### Singleton Pattern
|
|
131
|
+
```typescript
|
|
132
|
+
class MySingleton {
|
|
133
|
+
private static instance: MySingleton;
|
|
134
|
+
|
|
135
|
+
private constructor() {}
|
|
136
|
+
|
|
137
|
+
static getInstance(): MySingleton {
|
|
138
|
+
if (!MySingleton.instance) {
|
|
139
|
+
MySingleton.instance = new MySingleton();
|
|
140
|
+
}
|
|
141
|
+
return MySingleton.instance;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Factory Pattern
|
|
147
|
+
```typescript
|
|
148
|
+
export function createInstance(config: Config): MyClass {
|
|
149
|
+
return new MyClass(config);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Plugin/Extension Pattern
|
|
154
|
+
```typescript
|
|
155
|
+
export interface Plugin {
|
|
156
|
+
name: string;
|
|
157
|
+
install(app: any): void;
|
|
158
|
+
}
|
|
159
159
|
```
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sundays Framework Module
|
|
3
|
-
*
|
|
4
|
-
* Replace this with your module exports.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const hello = (): string => {
|
|
8
|
-
return 'Hello from Sundays module';
|
|
9
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Sundays Framework Module
|
|
3
|
+
*
|
|
4
|
+
* Replace this with your module exports.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const hello = (): string => {
|
|
8
|
+
return 'Hello from Sundays module';
|
|
9
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["ES2022"],
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*"],
|
|
18
|
-
"exclude": ["node_modules", "dist"]
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sundaysf/cli-v2",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Sundays Framework CLI - Project scaffolding and CRUD code generation",
|
|
5
|
-
"main": "./dist/bin/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"build": "gulp build",
|
|
9
|
-
"prepublishOnly": "npm run build"
|
|
10
|
-
},
|
|
11
|
-
"bin": {
|
|
12
|
-
"sundaysf": "./dist/bin/index.js"
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=18.0.0"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist/",
|
|
20
|
-
"README.md",
|
|
21
|
-
"LICENSE"
|
|
22
|
-
],
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"commander": "^11.0.0",
|
|
25
|
-
"fs-extra": "^11.1.1",
|
|
26
|
-
"inquirer": "^9.2.7",
|
|
27
|
-
"ora": "^8.2.0",
|
|
28
|
-
"ts-case-convert": "^2.1.0",
|
|
29
|
-
"uuid": "^11.1.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"gulp": "^5.0.0",
|
|
33
|
-
"gulp-if": "^3.0.0",
|
|
34
|
-
"gulp-sourcemaps": "^3.0.0",
|
|
35
|
-
"gulp-terser": "^2.1.0",
|
|
36
|
-
"through2": "^4.0.2"
|
|
37
|
-
},
|
|
38
|
-
"author": "Pablo Dominguez",
|
|
39
|
-
"license": "MIT"
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@sundaysf/cli-v2",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Sundays Framework CLI - Project scaffolding and CRUD code generation",
|
|
5
|
+
"main": "./dist/bin/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest",
|
|
8
|
+
"build": "gulp build",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"sundaysf": "./dist/bin/index.js"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18.0.0"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"commander": "^11.0.0",
|
|
25
|
+
"fs-extra": "^11.1.1",
|
|
26
|
+
"inquirer": "^9.2.7",
|
|
27
|
+
"ora": "^8.2.0",
|
|
28
|
+
"ts-case-convert": "^2.1.0",
|
|
29
|
+
"uuid": "^11.1.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"gulp": "^5.0.0",
|
|
33
|
+
"gulp-if": "^3.0.0",
|
|
34
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
35
|
+
"gulp-terser": "^2.1.0",
|
|
36
|
+
"through2": "^4.0.2"
|
|
37
|
+
},
|
|
38
|
+
"author": "Pablo Dominguez",
|
|
39
|
+
"license": "MIT"
|
|
40
|
+
}
|