create-bunspace 0.1.0
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 +181 -0
- package/dist/bin.js +5755 -0
- package/dist/templates/monorepo/CLAUDE.md +164 -0
- package/dist/templates/monorepo/LICENSE +21 -0
- package/dist/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
- package/dist/templates/monorepo/README.md +74 -0
- package/dist/templates/monorepo/SYNC_VERIFICATION.md +1 -0
- package/dist/templates/monorepo/apps/example/package.json +19 -0
- package/dist/templates/monorepo/apps/example/src/index.ts +23 -0
- package/dist/templates/monorepo/apps/example/src/types/index.ts +7 -0
- package/dist/templates/monorepo/apps/example/src/utils/index.ts +7 -0
- package/dist/templates/monorepo/core/packages/main/package.json +41 -0
- package/dist/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
- package/dist/templates/monorepo/core/packages/main/src/index.ts +80 -0
- package/dist/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
- package/dist/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
- package/dist/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
- package/dist/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
- package/dist/templates/monorepo/core/packages/utils/package.json +43 -0
- package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
- package/dist/templates/monorepo/core/packages/utils/src/index.ts +2 -0
- package/dist/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
- package/dist/templates/monorepo/core/packages/utils/src/result.ts +146 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
- package/dist/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
- package/dist/templates/monorepo/oxlint.json +14 -0
- package/dist/templates/monorepo/package.json +39 -0
- package/dist/templates/monorepo/tsconfig.json +35 -0
- package/dist/templates/telegram-bot/.oxlintrc.json +33 -0
- package/dist/templates/telegram-bot/.prettierignore +5 -0
- package/dist/templates/telegram-bot/.prettierrc +26 -0
- package/dist/templates/telegram-bot/CLAUDE.deploy.md +356 -0
- package/dist/templates/telegram-bot/CLAUDE.dev.md +266 -0
- package/dist/templates/telegram-bot/CLAUDE.md +280 -0
- package/dist/templates/telegram-bot/Dockerfile +46 -0
- package/dist/templates/telegram-bot/README.md +245 -0
- package/dist/templates/telegram-bot/apps/.gitkeep +0 -0
- package/dist/templates/telegram-bot/bun.lock +208 -0
- package/dist/templates/telegram-bot/core/.env.example +71 -0
- package/dist/templates/telegram-bot/core/README.md +1067 -0
- package/dist/templates/telegram-bot/core/package.json +15 -0
- package/dist/templates/telegram-bot/core/src/config/env.ts +131 -0
- package/dist/templates/telegram-bot/core/src/config/index.ts +97 -0
- package/dist/templates/telegram-bot/core/src/config/logging.ts +110 -0
- package/dist/templates/telegram-bot/core/src/handlers/control.ts +85 -0
- package/dist/templates/telegram-bot/core/src/handlers/health.ts +83 -0
- package/dist/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
- package/dist/templates/telegram-bot/core/src/index.ts +161 -0
- package/dist/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
- package/dist/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
- package/dist/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
- package/dist/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
- package/dist/templates/telegram-bot/core/src/types/bot.ts +92 -0
- package/dist/templates/telegram-bot/core/src/types/constants.ts +50 -0
- package/dist/templates/telegram-bot/core/src/types/result.ts +1 -0
- package/dist/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
- package/dist/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
- package/dist/templates/telegram-bot/core/src/utils/commands.ts +63 -0
- package/dist/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
- package/dist/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
- package/dist/templates/telegram-bot/core/src/utils/memory.ts +33 -0
- package/dist/templates/telegram-bot/core/src/utils/result.ts +26 -0
- package/dist/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
- package/dist/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
- package/dist/templates/telegram-bot/core/tsconfig.json +9 -0
- package/dist/templates/telegram-bot/docker-compose.yml +37 -0
- package/dist/templates/telegram-bot/docs/cli-commands.md +377 -0
- package/dist/templates/telegram-bot/docs/development.md +363 -0
- package/dist/templates/telegram-bot/docs/environment.md +460 -0
- package/dist/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
- package/dist/templates/telegram-bot/docs/examples/simple-command.md +207 -0
- package/dist/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
- package/dist/templates/telegram-bot/docs/getting-started.md +223 -0
- package/dist/templates/telegram-bot/docs/troubleshooting.md +489 -0
- package/dist/templates/telegram-bot/package.json +49 -0
- package/dist/templates/telegram-bot/packages/utils/package.json +12 -0
- package/dist/templates/telegram-bot/packages/utils/src/index.ts +2 -0
- package/dist/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
- package/dist/templates/telegram-bot/packages/utils/src/result.ts +80 -0
- package/dist/templates/telegram-bot/tools/README.md +47 -0
- package/dist/templates/telegram-bot/tools/commands/doctor.ts +460 -0
- package/dist/templates/telegram-bot/tools/commands/index.ts +35 -0
- package/dist/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
- package/dist/templates/telegram-bot/tools/commands/setup.ts +368 -0
- package/dist/templates/telegram-bot/tools/commands/status.ts +140 -0
- package/dist/templates/telegram-bot/tools/index.ts +16 -0
- package/dist/templates/telegram-bot/tools/package.json +12 -0
- package/dist/templates/telegram-bot/tools/utils/index.ts +13 -0
- package/dist/templates/telegram-bot/tsconfig.json +22 -0
- package/dist/templates/telegram-bot/vitest.config.ts +29 -0
- package/package.json +35 -0
- package/templates/monorepo/CLAUDE.md +164 -0
- package/templates/monorepo/LICENSE +21 -0
- package/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
- package/templates/monorepo/README.md +74 -0
- package/templates/monorepo/apps/example/package.json +19 -0
- package/templates/monorepo/apps/example/src/index.ts +23 -0
- package/templates/monorepo/apps/example/src/types/index.ts +7 -0
- package/templates/monorepo/apps/example/src/utils/index.ts +7 -0
- package/templates/monorepo/core/packages/main/package.json +41 -0
- package/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
- package/templates/monorepo/core/packages/main/src/index.ts +80 -0
- package/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
- package/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
- package/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
- package/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
- package/templates/monorepo/core/packages/utils/package.json +43 -0
- package/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
- package/templates/monorepo/core/packages/utils/src/index.ts +2 -0
- package/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
- package/templates/monorepo/core/packages/utils/src/result.ts +146 -0
- package/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
- package/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
- package/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
- package/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
- package/templates/monorepo/oxlint.json +14 -0
- package/templates/monorepo/package.json +39 -0
- package/templates/monorepo/tsconfig.json +35 -0
- package/templates/telegram-bot/.oxlintrc.json +33 -0
- package/templates/telegram-bot/.prettierignore +5 -0
- package/templates/telegram-bot/.prettierrc +26 -0
- package/templates/telegram-bot/CLAUDE.deploy.md +356 -0
- package/templates/telegram-bot/CLAUDE.dev.md +266 -0
- package/templates/telegram-bot/CLAUDE.md +280 -0
- package/templates/telegram-bot/Dockerfile +46 -0
- package/templates/telegram-bot/README.md +245 -0
- package/templates/telegram-bot/apps/.gitkeep +0 -0
- package/templates/telegram-bot/bun.lock +208 -0
- package/templates/telegram-bot/core/.env.example +71 -0
- package/templates/telegram-bot/core/README.md +1067 -0
- package/templates/telegram-bot/core/package.json +15 -0
- package/templates/telegram-bot/core/src/config/env.ts +131 -0
- package/templates/telegram-bot/core/src/config/index.ts +97 -0
- package/templates/telegram-bot/core/src/config/logging.ts +110 -0
- package/templates/telegram-bot/core/src/handlers/control.ts +85 -0
- package/templates/telegram-bot/core/src/handlers/health.ts +83 -0
- package/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
- package/templates/telegram-bot/core/src/index.ts +161 -0
- package/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
- package/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
- package/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
- package/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
- package/templates/telegram-bot/core/src/types/bot.ts +92 -0
- package/templates/telegram-bot/core/src/types/constants.ts +50 -0
- package/templates/telegram-bot/core/src/types/result.ts +1 -0
- package/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
- package/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
- package/templates/telegram-bot/core/src/utils/commands.ts +63 -0
- package/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
- package/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
- package/templates/telegram-bot/core/src/utils/memory.ts +33 -0
- package/templates/telegram-bot/core/src/utils/result.ts +26 -0
- package/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
- package/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
- package/templates/telegram-bot/core/tsconfig.json +9 -0
- package/templates/telegram-bot/docker-compose.yml +37 -0
- package/templates/telegram-bot/docs/cli-commands.md +377 -0
- package/templates/telegram-bot/docs/development.md +363 -0
- package/templates/telegram-bot/docs/environment.md +460 -0
- package/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
- package/templates/telegram-bot/docs/examples/simple-command.md +207 -0
- package/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
- package/templates/telegram-bot/docs/getting-started.md +223 -0
- package/templates/telegram-bot/docs/troubleshooting.md +489 -0
- package/templates/telegram-bot/package.json +49 -0
- package/templates/telegram-bot/packages/utils/package.json +12 -0
- package/templates/telegram-bot/packages/utils/src/index.ts +2 -0
- package/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
- package/templates/telegram-bot/packages/utils/src/result.ts +80 -0
- package/templates/telegram-bot/tools/README.md +47 -0
- package/templates/telegram-bot/tools/commands/doctor.ts +460 -0
- package/templates/telegram-bot/tools/commands/index.ts +35 -0
- package/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
- package/templates/telegram-bot/tools/commands/setup.ts +368 -0
- package/templates/telegram-bot/tools/commands/status.ts +140 -0
- package/templates/telegram-bot/tools/index.ts +16 -0
- package/templates/telegram-bot/tools/package.json +12 -0
- package/templates/telegram-bot/tools/utils/index.ts +13 -0
- package/templates/telegram-bot/tsconfig.json +22 -0
- package/templates/telegram-bot/vitest.config.ts +29 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## CRITICAL: Development Guidelines
|
|
6
|
+
|
|
7
|
+
**ALL development MUST follow the rules in `MUST-FOLLOW-GUIDELINES.md`**
|
|
8
|
+
|
|
9
|
+
Before making ANY code changes, read and understand:
|
|
10
|
+
- `/MUST-FOLLOW-GUIDELINES.md` - Source of truth for coding standards
|
|
11
|
+
|
|
12
|
+
**Key Rules Overview:**
|
|
13
|
+
- JSDoc completo profesional obligatorio
|
|
14
|
+
- Result pattern siempre ({{SCOPE}}/utils/result)
|
|
15
|
+
- Logging via {{SCOPE}}/utils/logger (NUNCA console.log)
|
|
16
|
+
- Validacion con Arktype
|
|
17
|
+
- Nomenclatura: prefijo I para interfaces
|
|
18
|
+
- Estructura: src/types/ y src/utils/ con barrel exports
|
|
19
|
+
- Async/await preferido sobre Promise chaining
|
|
20
|
+
|
|
21
|
+
## Monorepo Stack
|
|
22
|
+
|
|
23
|
+
This is a Bun-based monorepo for npm packages.
|
|
24
|
+
|
|
25
|
+
**Core Stack:**
|
|
26
|
+
- **Runtime**: Bun (package manager & runtime)
|
|
27
|
+
- **Workspaces**: Bun workspaces (`workspace:*` protocol)
|
|
28
|
+
- **Bundling**: Rolldown (`rolldown` v1.0.0-beta.58)
|
|
29
|
+
- **Linting**: Oxlint (OxC-based linter)
|
|
30
|
+
- **Formatting**: Prettier with `prettier-plugin-organize-imports`
|
|
31
|
+
- **Type Checking**: TSGO (@typescript/native-preview v7.0.0-dev)
|
|
32
|
+
- **Validation**: Arktype (schema validation)
|
|
33
|
+
- **Versioning**: Changesets
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Development - all workspaces
|
|
39
|
+
bun run dev # Start dev mode for all packages
|
|
40
|
+
|
|
41
|
+
# Build - all workspaces
|
|
42
|
+
bun run build # Build all packages
|
|
43
|
+
|
|
44
|
+
# Type checking
|
|
45
|
+
bun run typecheck # Type check all packages
|
|
46
|
+
|
|
47
|
+
# Linting (Oxlint only - no ESLint)
|
|
48
|
+
bun run lint # Run oxlint
|
|
49
|
+
bun run lint:fix # Auto-fix oxlint issues
|
|
50
|
+
|
|
51
|
+
# Formatting (Prettier)
|
|
52
|
+
bun run format # Format all files
|
|
53
|
+
bun run format:check # Check formatting
|
|
54
|
+
|
|
55
|
+
# Clean everything
|
|
56
|
+
bun run clean # Remove node_modules, dist, .turbo
|
|
57
|
+
|
|
58
|
+
# Changesets (versioning)
|
|
59
|
+
bun run changeset # Create a changeset
|
|
60
|
+
bun run changeset:version # Apply changesets and bump versions
|
|
61
|
+
bun run changeset:publish # Publish packages to npm
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Monorepo Structure
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
├── core/
|
|
68
|
+
│ └── packages/
|
|
69
|
+
│ ├── utils/ # Shared utilities package
|
|
70
|
+
│ │ ├── src/
|
|
71
|
+
│ │ │ ├── logger.ts # Logging wrapper (@mks2508/better-logger)
|
|
72
|
+
│ │ │ ├── result.ts # Result wrapper (@mks2508/no-throw)
|
|
73
|
+
│ │ │ └── index.ts # Barrel export
|
|
74
|
+
│ │ ├── rolldown.config.ts
|
|
75
|
+
│ │ └── package.json
|
|
76
|
+
│ └── main/ # Main library package
|
|
77
|
+
│ ├── src/
|
|
78
|
+
│ └── package.json # Depends on utils via workspace:*
|
|
79
|
+
└── apps/
|
|
80
|
+
└── example/ # Example app
|
|
81
|
+
└── package.json # Depends on utils via workspace:*
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Workspace Pattern:**
|
|
85
|
+
- Packages in `core/packages/*` and `apps/*` are auto-discovered
|
|
86
|
+
- Internal dependencies use `"{{SCOPE}}/package": "workspace:*"`
|
|
87
|
+
- Root `package.json` defines shared devDependencies
|
|
88
|
+
|
|
89
|
+
## Shared Utilities Pattern
|
|
90
|
+
|
|
91
|
+
The `{{SCOPE}}/utils` package provides shared wrappers:
|
|
92
|
+
|
|
93
|
+
### Logger (`{{SCOPE}}/utils/logger`)
|
|
94
|
+
|
|
95
|
+
Wrapper around `@mks2508/better-logger` with preset configured:
|
|
96
|
+
```typescript
|
|
97
|
+
import { createLogger } from '{{SCOPE}}/utils/logger';
|
|
98
|
+
|
|
99
|
+
const log = createLogger('ComponentName');
|
|
100
|
+
log.info('Message');
|
|
101
|
+
log.success('Success!');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Result (`{{SCOPE}}/utils/result`)
|
|
105
|
+
|
|
106
|
+
Wrapper around `@mks2508/no-throw` with domain-specific error codes:
|
|
107
|
+
```typescript
|
|
108
|
+
import { ok, tryCatch, createAppError, type Result } from '{{SCOPE}}/utils/result';
|
|
109
|
+
|
|
110
|
+
const result: Result<string> = ok('success');
|
|
111
|
+
const error = createAppError('NetworkError', 'Failed to fetch');
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Tool Configuration Files
|
|
115
|
+
|
|
116
|
+
### Root TypeScript/TSGO (`tsconfig.json`)
|
|
117
|
+
- Target: ES2022, Module: ESNext
|
|
118
|
+
- Strict mode enabled
|
|
119
|
+
- `moduleResolution: "bundler"`
|
|
120
|
+
- Key options: `verbatimModuleSyntax: true`, `declaration: true`
|
|
121
|
+
- Compiler: TSGO (@typescript/native-preview) for faster type checking
|
|
122
|
+
|
|
123
|
+
### Validation (Arktype)
|
|
124
|
+
Schema validation using Arktype for performance:
|
|
125
|
+
```typescript
|
|
126
|
+
import { type } from 'arktype';
|
|
127
|
+
|
|
128
|
+
export const OptionsSchema = type({
|
|
129
|
+
url: 'string',
|
|
130
|
+
timeout: 'number.optional',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const result = OptionsSchema(options);
|
|
134
|
+
if (result instanceof type.errors) {
|
|
135
|
+
return err(result.summary());
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Oxlint (`oxlint.json`)
|
|
140
|
+
- Categories: `correctness`, `suspicious`, `perf`, `style` -> "warn"
|
|
141
|
+
- `restriction` -> "off"
|
|
142
|
+
- Env: `node`, `es2021`
|
|
143
|
+
|
|
144
|
+
### Prettier (`.prettierrc`)
|
|
145
|
+
- 100 char width, 2 spaces, single quotes
|
|
146
|
+
- Plugin: `prettier-plugin-organize-imports`
|
|
147
|
+
- Trailing commas: es5
|
|
148
|
+
|
|
149
|
+
## Workspace Dependencies
|
|
150
|
+
|
|
151
|
+
When adding a new package dependency:
|
|
152
|
+
|
|
153
|
+
1. **For shared packages**: Add to appropriate `core/packages/*/package.json`
|
|
154
|
+
2. **For workspace deps**: Use `"{{SCOPE}}/name": "workspace:*"`
|
|
155
|
+
3. **For external deps**: Add to root `package.json` devDependencies if used across multiple packages
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
bun install # Install/resolves workspace dependencies
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Build Output Patterns
|
|
162
|
+
|
|
163
|
+
- **Rolldown**: Generates JS + sourcemaps, separate `tsc --emitDeclarationOnly` for types
|
|
164
|
+
- Always ESM-first, CJS as optional compatibility layer
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) {{YEAR}} {{AUTHOR}}
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# MUST-FOLLOW-GUIDELINES.md
|
|
2
|
+
|
|
3
|
+
> **IMPORTANTE**: Este documento es la fuente de verdad para todas las reglas de desarrollo en este proyecto.
|
|
4
|
+
> **El incumplimiento de estas reglas sera motivo de correccion obligatoria en code review.**
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Stack Definitivo
|
|
9
|
+
|
|
10
|
+
| Herramienta | Version/Configuracion | Uso |
|
|
11
|
+
|-------------|----------------------|-----|
|
|
12
|
+
| **Runtime** | Bun v1.1.43+ | Package manager + runtime |
|
|
13
|
+
| **Bundling** | Rolldown v1.0.0-beta.58 | Build de packages |
|
|
14
|
+
| **Type Checking** | TSGO v7.0.0-dev (@typescript/native-preview) | TypeScript compiler |
|
|
15
|
+
| **Linting** | Oxlint v0.11.1 | Linting rapido (OxC-based) |
|
|
16
|
+
| **Formatting** | Prettier v3.4.2 + organize-imports | Formato de codigo |
|
|
17
|
+
| **Validation** | Arktype | Validacion de esquemas |
|
|
18
|
+
| **Versioning** | Changesets v2.27.11 | Versionado de packages |
|
|
19
|
+
| **Logging** | @mks2508/better-logger v4.0.0 | Logging estructurado |
|
|
20
|
+
| **Error Handling** | @mks2508/no-throw v0.1.0 | Result pattern |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Estructura de Carpetas Obligatoria
|
|
25
|
+
|
|
26
|
+
### Root del Monorepo
|
|
27
|
+
```
|
|
28
|
+
{{NAME}}/
|
|
29
|
+
├── docs/ # Documentacion del proyecto
|
|
30
|
+
├── tools/ # Scripts y herramientas de desarrollo
|
|
31
|
+
├── core/
|
|
32
|
+
│ └── packages/
|
|
33
|
+
│ ├── main/
|
|
34
|
+
│ └── utils/
|
|
35
|
+
└── apps/
|
|
36
|
+
└── example/
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Estructura de un Package
|
|
40
|
+
```
|
|
41
|
+
core/packages/main/
|
|
42
|
+
├── src/
|
|
43
|
+
│ ├── utils/ # Utilidades locales del package
|
|
44
|
+
│ │ └── index.ts # Barrel export
|
|
45
|
+
│ ├── types/ # Tipos del dominio del package
|
|
46
|
+
│ │ ├── *.types.ts # Tipos especificos
|
|
47
|
+
│ │ ├── constants.ts # Constantes del package
|
|
48
|
+
│ │ └── index.ts # Barrel export
|
|
49
|
+
│ ├── *.ts # Codigo fuente principal
|
|
50
|
+
│ └── index.ts # Export principal
|
|
51
|
+
├── dist/ # Build output
|
|
52
|
+
├── package.json
|
|
53
|
+
├── rolldown.config.ts
|
|
54
|
+
└── tsconfig.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## REGLA 1: JSDoc Completo Profesional
|
|
60
|
+
|
|
61
|
+
### Requerimientos Obligatorios
|
|
62
|
+
|
|
63
|
+
TODA funcion, clase, metodo, interface, type, y constante exportada DEBE tener JSDoc completo:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
/**
|
|
67
|
+
* Descripcion clara y concisa de que hace y por que.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Codigo ejecutable que demuestra uso tipico
|
|
72
|
+
* const result = await myFunction('example');
|
|
73
|
+
* if (result.isErr()) {
|
|
74
|
+
* log.error('Failed', result.error);
|
|
75
|
+
* return;
|
|
76
|
+
* }
|
|
77
|
+
* console.log(result.value);
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param paramName - Descripcion del parametro
|
|
81
|
+
* @returns Result<T, E> Descripcion del valor de retorno
|
|
82
|
+
* @throws {AppError} Cuando y por que se lanza este error
|
|
83
|
+
* @see {@link IOptions} Referencias a tipos relacionados
|
|
84
|
+
*/
|
|
85
|
+
export async function myFunction(
|
|
86
|
+
param: string,
|
|
87
|
+
options?: IOptions
|
|
88
|
+
): Promise<Result<string, AppError>> {
|
|
89
|
+
// ...
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Tags Obligatorios
|
|
94
|
+
|
|
95
|
+
| Tag | Cuando usar | Formato |
|
|
96
|
+
|-----|-------------|---------|
|
|
97
|
+
| `@description` | Siempre | Primera linea (implicita) |
|
|
98
|
+
| `@param` | Cada parametro | `@param name - Description` |
|
|
99
|
+
| `@returns` | Siempre | `@returns Type - Description` |
|
|
100
|
+
| `@example` | Funciones publicas | Codigo TypeScript ejecutable |
|
|
101
|
+
| `@throws` | Si puede lanzar | `@throws {ErrorType} Cuando` |
|
|
102
|
+
| `@see` | Referencias | `@see {@link ISomething}` |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## REGLA 2: Logging - NUNCA console.log
|
|
107
|
+
|
|
108
|
+
### Obligatorio
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { createLogger } from '{{SCOPE}}/utils/logger';
|
|
112
|
+
|
|
113
|
+
const log = createLogger('MyComponent');
|
|
114
|
+
|
|
115
|
+
// CORRECTO
|
|
116
|
+
log.info('Started');
|
|
117
|
+
log.success('Completed');
|
|
118
|
+
log.warn('High memory usage');
|
|
119
|
+
log.error('Failed to connect', { error });
|
|
120
|
+
log.critical('System failure');
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Prohibido
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// INCORRECTO
|
|
127
|
+
console.log('Started');
|
|
128
|
+
console.error('Failed');
|
|
129
|
+
console.info('Info');
|
|
130
|
+
console.warn('Warning');
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## REGLA 3: Result Pattern - SIEMPRE
|
|
136
|
+
|
|
137
|
+
### Obligatorio
|
|
138
|
+
|
|
139
|
+
TODA operacion que pueda fallar DEBE usar `Result<T, E>` del package `{{SCOPE}}/utils/result`:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import {
|
|
143
|
+
ok,
|
|
144
|
+
tryCatch,
|
|
145
|
+
type Result
|
|
146
|
+
} from '{{SCOPE}}/utils/result';
|
|
147
|
+
import {
|
|
148
|
+
createAppError,
|
|
149
|
+
AppErrorCode
|
|
150
|
+
} from '{{SCOPE}}/utils/result';
|
|
151
|
+
|
|
152
|
+
async function fetchData(
|
|
153
|
+
url: string
|
|
154
|
+
): Promise<Result<string, AppError>> {
|
|
155
|
+
const result = await tryCatch(
|
|
156
|
+
async () => {
|
|
157
|
+
const response = await fetch(url);
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
throw new Error(`HTTP ${response.status}`);
|
|
160
|
+
}
|
|
161
|
+
return await response.text();
|
|
162
|
+
},
|
|
163
|
+
AppErrorCode.NetworkError
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
if (result.isErr()) {
|
|
167
|
+
return createAppError(
|
|
168
|
+
AppErrorCode.NetworkError,
|
|
169
|
+
`Failed to fetch from ${url}`,
|
|
170
|
+
result.error
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return ok(result.value);
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## REGLA 4: Nomenclatura - Prefijo I
|
|
181
|
+
|
|
182
|
+
### Interfaces
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// CORRECTO - Prefijo I
|
|
186
|
+
export interface IOptions {
|
|
187
|
+
url: string;
|
|
188
|
+
timeout?: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface ICallback {
|
|
192
|
+
onSuccess: () => void;
|
|
193
|
+
onError: (error: Error) => void;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Types (sin prefijo)
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// CORRECTO - Sin prefijo
|
|
201
|
+
export type Options = {
|
|
202
|
+
url: string;
|
|
203
|
+
timeout?: number;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export type ErrorCode =
|
|
207
|
+
| 'NETWORK_ERROR'
|
|
208
|
+
| 'NOT_FOUND'
|
|
209
|
+
| 'PERMISSION_DENIED';
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## REGLA 5: Barrel Exports - SIEMPRE
|
|
215
|
+
|
|
216
|
+
TODA carpeta con multiples archivos DEBE tener un `index.ts` que exporte todo:
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// src/types/index.ts
|
|
220
|
+
export * from './main.types';
|
|
221
|
+
export * from './constants';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## REGLA 6: Async/Await - Preferencia
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
// CORRECTO - Async/await
|
|
230
|
+
async function processFile(path: string): Promise<void> {
|
|
231
|
+
const content = await readFile(path);
|
|
232
|
+
const processed = await transform(content);
|
|
233
|
+
await writeFile(path, processed);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// INCORRECTO - Promise chaining
|
|
237
|
+
function processFile(path: string) {
|
|
238
|
+
return readFile(path)
|
|
239
|
+
.then(content => transform(content))
|
|
240
|
+
.then(processed => writeFile(path, processed));
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Checklist Pre-Commit
|
|
247
|
+
|
|
248
|
+
Antes de hacer commit de codigo, verificar:
|
|
249
|
+
|
|
250
|
+
- [ ] Todo codigo nuevo tiene JSDoc completo
|
|
251
|
+
- [ ] No hay `console.log/debug/error/info/warn`
|
|
252
|
+
- [ ] Todo lo que puede fallar usa `Result<T, E>`
|
|
253
|
+
- [ ] Interfaces tienen prefijo `I`
|
|
254
|
+
- [ ] Barrel exports en todas las carpetas
|
|
255
|
+
- [ ] Async/await en lugar de Promise chaining
|
|
256
|
+
- [ ] `bun run typecheck` pasa
|
|
257
|
+
- [ ] `bun run lint` pasa
|
|
258
|
+
- [ ] `bun run format` aplicado
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Fuentes de Referencia
|
|
263
|
+
|
|
264
|
+
- **CLAUDE.md** - Guia de arquitectura del monorepo
|
|
265
|
+
- **@mks2508/better-logger** - Documentacion del logger
|
|
266
|
+
- **@mks2508/no-throw** - Documentacion del Result pattern
|
|
267
|
+
- **Arktype** - https://arktype.io/
|
|
268
|
+
- **Rolldown** - https://rollup.rs/
|
|
269
|
+
- **Oxlint** - https://oxlint.com/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# mks-bun-monorepo
|
|
2
|
+
|
|
3
|
+
[](https://github.com/MKS2508/mks-bun-monorepo/generate)
|
|
4
|
+
|
|
5
|
+
> Modern Bun monorepo template for npm packages with TypeScript, workspaces, and best practices.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
Click "Use this template" to create a new repository, or use via CLI:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun create bun-mono my-lib --template monorepo
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Bun Workspaces**: Fast package management with native workspaces
|
|
18
|
+
- **TypeScript**: Strict mode with tsgo for lightning-fast type checking
|
|
19
|
+
- **Code Quality**: Prettier + Oxlint for consistent formatting and linting
|
|
20
|
+
- **Version Management**: Changesets for automated versioning and publishing
|
|
21
|
+
- **Modern Tooling**: Better Logger, no-throw, arktype
|
|
22
|
+
|
|
23
|
+
## Template Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
my-monorepo/
|
|
27
|
+
├── core/
|
|
28
|
+
│ └── packages/ # Main packages (e.g., core library)
|
|
29
|
+
├── apps/ # Applications (examples, docs)
|
|
30
|
+
└── package.json # Workspace root
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Scripts
|
|
34
|
+
|
|
35
|
+
| Command | Description |
|
|
36
|
+
|---------|-------------|
|
|
37
|
+
| `bun run dev` | Start all packages in dev mode |
|
|
38
|
+
| `bun run build` | Build all packages |
|
|
39
|
+
| `bun run typecheck` | Type-check with tsgo |
|
|
40
|
+
| `bun run lint` | Lint with Oxlint |
|
|
41
|
+
| `bun run format` | Format with Prettier |
|
|
42
|
+
| `bun run changeset` | Create a changeset |
|
|
43
|
+
| `bun run changeset:version` | Apply changesets and bump versions |
|
|
44
|
+
| `bun run changeset:publish` | Publish packages to npm |
|
|
45
|
+
|
|
46
|
+
## Placeholder Variables
|
|
47
|
+
|
|
48
|
+
This template uses the following placeholders (auto-replaced by CLI):
|
|
49
|
+
|
|
50
|
+
- `{{NAME}}` - Project name (e.g., "my-lib")
|
|
51
|
+
- `{{SCOPE}}` - npm scope without @ (e.g., "my-org")
|
|
52
|
+
- `{{DESCRIPTION}}` - Project description
|
|
53
|
+
- `{{AUTHOR}}` - Author name
|
|
54
|
+
- `{{YEAR}}` - Current year
|
|
55
|
+
|
|
56
|
+
## Tech Stack
|
|
57
|
+
|
|
58
|
+
| Tool | Version | Purpose |
|
|
59
|
+
| ------ | ------- | ------- |
|
|
60
|
+
| **Bun** | 1.3+ | Runtime & package manager |
|
|
61
|
+
| **TypeScript** | 5.9+ | Language |
|
|
62
|
+
| **tsgo** | native-preview | Type checking |
|
|
63
|
+
| **Oxlint** | latest | Linting |
|
|
64
|
+
| **Prettier** | 3.4+ | Formatting |
|
|
65
|
+
| **Changesets** | latest | Version management |
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
- [CLAUDE.md](./CLAUDE.md) - Project documentation
|
|
70
|
+
- [MUST-FOLLOW-GUIDELINES.md](./MUST-FOLLOW-GUIDELINES.md) - Development guidelines
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# SYNC TEST 1767746400
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{SCOPE}}/example-app",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "bun --watch src/index.ts",
|
|
8
|
+
"build": "bun build src/index.ts --outdir ./dist",
|
|
9
|
+
"typecheck": "tsgo --noEmit",
|
|
10
|
+
"start": "bun run dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"{{SCOPE}}/core": "workspace:*",
|
|
14
|
+
"{{SCOPE}}/utils": "workspace:*"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^22.10.5"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { greet, createGreeter } from '{{SCOPE}}/core';
|
|
2
|
+
import { createLogger } from '{{SCOPE}}/utils/logger';
|
|
3
|
+
|
|
4
|
+
const log = createLogger('Example');
|
|
5
|
+
|
|
6
|
+
log.info('Starting example app...');
|
|
7
|
+
|
|
8
|
+
// Simple greeting
|
|
9
|
+
const result = greet('World');
|
|
10
|
+
|
|
11
|
+
if (result.isOk()) {
|
|
12
|
+
log.success(result.value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Custom greeter
|
|
16
|
+
const spanishGreeter = createGreeter({ prefix: 'Hola' });
|
|
17
|
+
const spanishResult = spanishGreeter('Mundo');
|
|
18
|
+
|
|
19
|
+
if (spanishResult.isOk()) {
|
|
20
|
+
log.success(spanishResult.value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
log.info('Example completed!');
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{SCOPE}}/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "{{DESCRIPTION}}",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "bun --watch src/index.ts",
|
|
23
|
+
"build": "rolldown --config rolldown.config.ts && tsgo --emitDeclarationOnly",
|
|
24
|
+
"typecheck": "tsgo --noEmit",
|
|
25
|
+
"lint": "oxlint",
|
|
26
|
+
"test": "bun test"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"{{SCOPE}}/utils": "workspace:*"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.10.5",
|
|
33
|
+
"rolldown": "^1.0.0-beta.58"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
input: './src/index.ts',
|
|
6
|
+
output: {
|
|
7
|
+
dir: './dist',
|
|
8
|
+
format: 'esm',
|
|
9
|
+
exports: 'named',
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
},
|
|
12
|
+
external: ['{{SCOPE}}/utils'],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
input: './src/index.ts',
|
|
16
|
+
output: {
|
|
17
|
+
file: './dist/index.cjs',
|
|
18
|
+
format: 'cjs',
|
|
19
|
+
exports: 'named',
|
|
20
|
+
sourcemap: true,
|
|
21
|
+
},
|
|
22
|
+
external: ['{{SCOPE}}/utils'],
|
|
23
|
+
},
|
|
24
|
+
]);
|