@sundaysf/cli-v2 1.0.1 → 1.0.5
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/.sundaysrc +7 -0
- 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/.sundaysrc +7 -0
- 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/.sundaysrc +7 -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/frontend-nextjs/.sundaysrc +7 -0
- package/dist/templates/frontend-nextjs/app/globals.css +125 -0
- package/dist/templates/frontend-nextjs/app/layout.tsx +45 -0
- package/dist/templates/frontend-nextjs/app/page.tsx +5 -0
- package/dist/templates/frontend-nextjs/components/project-generator.tsx +558 -0
- package/dist/templates/frontend-nextjs/components/theme-provider.tsx +11 -0
- package/dist/templates/frontend-nextjs/components/ui/accordion.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/alert-dialog.tsx +157 -0
- package/dist/templates/frontend-nextjs/components/ui/alert.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/aspect-ratio.tsx +11 -0
- package/dist/templates/frontend-nextjs/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend-nextjs/components/ui/badge.tsx +46 -0
- package/dist/templates/frontend-nextjs/components/ui/breadcrumb.tsx +109 -0
- package/dist/templates/frontend-nextjs/components/ui/button-group.tsx +83 -0
- package/dist/templates/frontend-nextjs/components/ui/button.tsx +60 -0
- package/dist/templates/frontend-nextjs/components/ui/calendar.tsx +213 -0
- package/dist/templates/frontend-nextjs/components/ui/card.tsx +92 -0
- package/dist/templates/frontend-nextjs/components/ui/carousel.tsx +241 -0
- package/dist/templates/frontend-nextjs/components/ui/chart.tsx +353 -0
- package/dist/templates/frontend-nextjs/components/ui/checkbox.tsx +32 -0
- package/dist/templates/frontend-nextjs/components/ui/collapsible.tsx +33 -0
- package/dist/templates/frontend-nextjs/components/ui/command.tsx +184 -0
- package/dist/templates/frontend-nextjs/components/ui/context-menu.tsx +252 -0
- package/dist/templates/frontend-nextjs/components/ui/dialog.tsx +143 -0
- package/dist/templates/frontend-nextjs/components/ui/drawer.tsx +135 -0
- package/dist/templates/frontend-nextjs/components/ui/dropdown-menu.tsx +257 -0
- package/dist/templates/frontend-nextjs/components/ui/empty.tsx +104 -0
- package/dist/templates/frontend-nextjs/components/ui/field.tsx +244 -0
- package/dist/templates/frontend-nextjs/components/ui/form.tsx +167 -0
- package/dist/templates/frontend-nextjs/components/ui/hover-card.tsx +44 -0
- package/dist/templates/frontend-nextjs/components/ui/input-group.tsx +169 -0
- package/dist/templates/frontend-nextjs/components/ui/input-otp.tsx +77 -0
- package/dist/templates/frontend-nextjs/components/ui/input.tsx +21 -0
- package/dist/templates/frontend-nextjs/components/ui/item.tsx +193 -0
- package/dist/templates/frontend-nextjs/components/ui/kbd.tsx +28 -0
- package/dist/templates/frontend-nextjs/components/ui/label.tsx +24 -0
- package/dist/templates/frontend-nextjs/components/ui/menubar.tsx +276 -0
- package/dist/templates/frontend-nextjs/components/ui/navigation-menu.tsx +166 -0
- package/dist/templates/frontend-nextjs/components/ui/pagination.tsx +127 -0
- package/dist/templates/frontend-nextjs/components/ui/popover.tsx +48 -0
- package/dist/templates/frontend-nextjs/components/ui/progress.tsx +31 -0
- package/dist/templates/frontend-nextjs/components/ui/radio-group.tsx +45 -0
- package/dist/templates/frontend-nextjs/components/ui/resizable.tsx +56 -0
- package/dist/templates/frontend-nextjs/components/ui/scroll-area.tsx +58 -0
- package/dist/templates/frontend-nextjs/components/ui/select.tsx +185 -0
- package/dist/templates/frontend-nextjs/components/ui/separator.tsx +28 -0
- package/dist/templates/frontend-nextjs/components/ui/sheet.tsx +139 -0
- package/dist/templates/frontend-nextjs/components/ui/sidebar.tsx +726 -0
- package/dist/templates/frontend-nextjs/components/ui/skeleton.tsx +13 -0
- package/dist/templates/frontend-nextjs/components/ui/slider.tsx +63 -0
- package/dist/templates/frontend-nextjs/components/ui/sonner.tsx +25 -0
- package/dist/templates/frontend-nextjs/components/ui/spinner.tsx +16 -0
- package/dist/templates/frontend-nextjs/components/ui/switch.tsx +31 -0
- package/dist/templates/frontend-nextjs/components/ui/table.tsx +116 -0
- package/dist/templates/frontend-nextjs/components/ui/tabs.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/textarea.tsx +18 -0
- package/dist/templates/frontend-nextjs/components/ui/toast.tsx +129 -0
- package/dist/templates/frontend-nextjs/components/ui/toaster.tsx +35 -0
- package/dist/templates/frontend-nextjs/components/ui/toggle-group.tsx +73 -0
- package/dist/templates/frontend-nextjs/components/ui/toggle.tsx +47 -0
- package/dist/templates/frontend-nextjs/components/ui/tooltip.tsx +61 -0
- package/dist/templates/frontend-nextjs/components/ui/use-mobile.tsx +19 -0
- package/dist/templates/frontend-nextjs/components/ui/use-toast.ts +191 -0
- package/dist/templates/frontend-nextjs/components.json +21 -0
- package/dist/templates/frontend-nextjs/hooks/use-mobile.ts +19 -0
- package/dist/templates/frontend-nextjs/hooks/use-toast.ts +191 -0
- package/dist/templates/frontend-nextjs/lib/utils.ts +6 -0
- package/dist/templates/frontend-nextjs/next.config.mjs +11 -0
- package/dist/templates/frontend-nextjs/postcss.config.mjs +8 -0
- package/dist/templates/frontend-nextjs/public/apple-icon.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon-dark-32x32.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon-light-32x32.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon.svg +26 -0
- package/dist/templates/frontend-nextjs/public/placeholder-logo.png +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder-logo.svg +1 -0
- package/dist/templates/frontend-nextjs/public/placeholder-user.jpg +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder.jpg +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder.svg +1 -0
- package/dist/templates/frontend-nextjs/styles/globals.css +125 -0
- package/dist/templates/frontend-nextjs/tsconfig.json +27 -0
- 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,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.5",
|
|
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
|
+
}
|