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,37 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
bot-local:
|
|
5
|
+
build: .
|
|
6
|
+
container_name: mks-bot-local
|
|
7
|
+
environment:
|
|
8
|
+
- TG_ENV=local
|
|
9
|
+
env_file:
|
|
10
|
+
- core/.env.local
|
|
11
|
+
volumes:
|
|
12
|
+
- ./core/src:/app/core/src:ro
|
|
13
|
+
- ./core/logs:/app/core/logs
|
|
14
|
+
command: bun run --watch src/index.ts
|
|
15
|
+
working_dir: /app/core
|
|
16
|
+
|
|
17
|
+
bot-staging:
|
|
18
|
+
build: .
|
|
19
|
+
container_name: mks-bot-staging
|
|
20
|
+
environment:
|
|
21
|
+
- TG_ENV=staging
|
|
22
|
+
env_file:
|
|
23
|
+
- core/.env.staging
|
|
24
|
+
ports:
|
|
25
|
+
- "3001:3000"
|
|
26
|
+
restart: on-failure
|
|
27
|
+
|
|
28
|
+
bot-production:
|
|
29
|
+
build: .
|
|
30
|
+
container_name: mks-bot-prod
|
|
31
|
+
environment:
|
|
32
|
+
- TG_ENV=production
|
|
33
|
+
env_file:
|
|
34
|
+
- core/.env.production
|
|
35
|
+
ports:
|
|
36
|
+
- "3000:3000"
|
|
37
|
+
restart: unless-stopped
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# CLI Commands
|
|
2
|
+
|
|
3
|
+
Referencia completa de comandos CLI disponibles para gestionar el bot.
|
|
4
|
+
|
|
5
|
+
## Setup Command
|
|
6
|
+
|
|
7
|
+
Configura el entorno del bot de forma interactiva.
|
|
8
|
+
|
|
9
|
+
### Uso Básico
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run setup
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Flags
|
|
16
|
+
|
|
17
|
+
| Flag | Descripción | Default |
|
|
18
|
+
| ---- | ----------- | ------- |
|
|
19
|
+
| `-t, --token <value>` | Bot token de @BotFather | Prompt interactivo |
|
|
20
|
+
| `-m, --mode <polling\|webhook>` | Modo de operación | Prompt interactivo |
|
|
21
|
+
| `-e, --environment <local\|staging\|production>` | Entorno objetivo | `local` |
|
|
22
|
+
|
|
23
|
+
### Ejemplos
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Setup interactivo completo
|
|
27
|
+
bun run setup
|
|
28
|
+
|
|
29
|
+
# Setup no-interactivo
|
|
30
|
+
bun run setup --token "123:ABC" --mode polling --environment local
|
|
31
|
+
|
|
32
|
+
# Setup para staging
|
|
33
|
+
bun run setup --environment staging
|
|
34
|
+
|
|
35
|
+
# Setup con token pre-proveedor
|
|
36
|
+
bun run setup --token "123:ABC"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Qué Hace
|
|
40
|
+
|
|
41
|
+
1. **Copia** `.env.example` a `.env.{environment}`
|
|
42
|
+
2. **Pregunta** por bot token, modo, y opciones
|
|
43
|
+
3. **Valida** el token contra Telegram API
|
|
44
|
+
4. **Configura** todos los campos necesarios
|
|
45
|
+
5. **Muestra** próximos pasos
|
|
46
|
+
|
|
47
|
+
### Flujo Interactivo
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
ℹ mks-telegram-bot Setup
|
|
51
|
+
|
|
52
|
+
ℹ To get a bot token, open Telegram and talk to @BotFather:
|
|
53
|
+
1. Send /newbot
|
|
54
|
+
2. Choose a name for your bot
|
|
55
|
+
3. Choose a username (must end in "bot")
|
|
56
|
+
4. Copy the token provided
|
|
57
|
+
|
|
58
|
+
? Enter your bot token: ********************************
|
|
59
|
+
|
|
60
|
+
? Select bot operation mode: (Use arrow keys)
|
|
61
|
+
❯ Polling (recommended for development)
|
|
62
|
+
Webhook (recommended for production)
|
|
63
|
+
|
|
64
|
+
? Select environment: (Use arrow keys)
|
|
65
|
+
❯ Local (development)
|
|
66
|
+
Staging (testing)
|
|
67
|
+
Production
|
|
68
|
+
|
|
69
|
+
? Enter instance name: (mks-bot)
|
|
70
|
+
|
|
71
|
+
✓ Environment configured: core/.env.local
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Doctor Command
|
|
75
|
+
|
|
76
|
+
Diagnostica la configuración del bot y el entorno.
|
|
77
|
+
|
|
78
|
+
### Uso
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bun run doctor
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Checks Realizados
|
|
85
|
+
|
|
86
|
+
| Check | Descripción |
|
|
87
|
+
| ----- | ----------- |
|
|
88
|
+
| Node.js version | Versión >= 20 |
|
|
89
|
+
| Bun installation | Bun está instalado |
|
|
90
|
+
| Dependencies | Todas las dependencias instaladas |
|
|
91
|
+
| Environment files | Archivos .env existen |
|
|
92
|
+
| Environment variables | Variables requeridas seteadas |
|
|
93
|
+
| Bot token validation | Token válido contra Telegram API |
|
|
94
|
+
| Temp directory | core/tmp es writable |
|
|
95
|
+
| Logs directory | core/logs existe |
|
|
96
|
+
| Port availability | Puerto 3000 disponible |
|
|
97
|
+
| Git ignore | .env files excluidos |
|
|
98
|
+
|
|
99
|
+
### Output
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
mks-telegram-bot Diagnostics
|
|
103
|
+
|
|
104
|
+
✓ Node.js version Node.js v20.x.x (requires >= 20)
|
|
105
|
+
✓ Bun installation Bun is installed
|
|
106
|
+
✓ Dependencies All dependencies installed
|
|
107
|
+
✓ Environment files Found: .env.local
|
|
108
|
+
✓ Environment variables Required variables set
|
|
109
|
+
✓ Bot token validation Bot token is valid
|
|
110
|
+
✓ Temp directory core/tmp is writable
|
|
111
|
+
✓ Logs directory core/logs exists
|
|
112
|
+
✓ Port availability Port 3000 is available
|
|
113
|
+
✓ Git ignore .env files are excluded from git
|
|
114
|
+
|
|
115
|
+
Summary:
|
|
116
|
+
✓ Passed: 10
|
|
117
|
+
⚠ Warnings: 0
|
|
118
|
+
✗ Failed: 0
|
|
119
|
+
|
|
120
|
+
✓ All checks passed! Your bot is ready to run.
|
|
121
|
+
|
|
122
|
+
Next steps:
|
|
123
|
+
1. Run: bun run dev
|
|
124
|
+
2. Send /start to your bot
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Status Command
|
|
128
|
+
|
|
129
|
+
Muestra las instancias del bot corriendo actualmente.
|
|
130
|
+
|
|
131
|
+
### Uso
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bun run cli status
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Flags
|
|
138
|
+
|
|
139
|
+
| Flag | Descripción |
|
|
140
|
+
| ---- | ----------- |
|
|
141
|
+
| `-j, --json` | Output como JSON |
|
|
142
|
+
|
|
143
|
+
### Ejemplos
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Tabla formateada
|
|
147
|
+
bun run cli status
|
|
148
|
+
|
|
149
|
+
# JSON
|
|
150
|
+
bun run cli status --json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Output (Tabla)
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
┌─────────┬──────────┬─────────────┬────────────┬────────┬────────┐
|
|
157
|
+
│ (index) │ PID │ Environment │ Name │ Status │ Uptime │
|
|
158
|
+
├─────────┼──────────┼─────────────┼────────────┼────────┼────────┤
|
|
159
|
+
│ 0 │ 12345 │ 'production'│ 'mks-bot..' │'✓ Run' │ '2h30m'│
|
|
160
|
+
└─────────┴──────────┴─────────────┴────────────┴────────┴────────┘
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Output (JSON)
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
"pid": 12345,
|
|
169
|
+
"instanceId": "1734567890-abc123",
|
|
170
|
+
"environment": "production",
|
|
171
|
+
"instanceName": "mks-bot-prod",
|
|
172
|
+
"startTime": "2025-01-06T10:30:00.000Z",
|
|
173
|
+
"nodeVersion": "v1.3.0",
|
|
174
|
+
"cwd": "/app",
|
|
175
|
+
"running": true,
|
|
176
|
+
"uptime": "2h30m"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Ngrok Command
|
|
182
|
+
|
|
183
|
+
Inicia ngrok tunnel con configuración automática de webhook.
|
|
184
|
+
|
|
185
|
+
### Uso
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
bun run ngrok
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Flags
|
|
192
|
+
|
|
193
|
+
| Flag | Descripción | Default |
|
|
194
|
+
| ---- | ----------- | ------- |
|
|
195
|
+
| `-p, --port <port>` | Puerto a forward | `3000` |
|
|
196
|
+
| `-e, --environment <env>` | Entorno: local/staging/production | `local` |
|
|
197
|
+
| `-w, --webhook-url` | Auto-update webhook URL en .env | `false` |
|
|
198
|
+
| `-s, --start-bot` | Auto-start bot después de ngrok | `false` |
|
|
199
|
+
| `-f, --force` | Force start aún si hay conflicto | `false` |
|
|
200
|
+
|
|
201
|
+
### Ejemplos
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Ngrok con configuración básica
|
|
205
|
+
bun run ngrok
|
|
206
|
+
|
|
207
|
+
# Ngrok con auto-update de webhook
|
|
208
|
+
bun run ngrok --webhook-url
|
|
209
|
+
|
|
210
|
+
# Ngrok y arrancar bot automáticamente
|
|
211
|
+
bun run ngrok --start-bot
|
|
212
|
+
|
|
213
|
+
# Ngrok para staging
|
|
214
|
+
bun run ngrok --environment staging
|
|
215
|
+
|
|
216
|
+
# Force start (ignorar conflictos)
|
|
217
|
+
bun run ngrok --force
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Flujo
|
|
221
|
+
|
|
222
|
+
1. **Carga** el archivo `.env.{environment}` correspondiente
|
|
223
|
+
2. **Detecta** conflictos con instancias existentes
|
|
224
|
+
3. **Inicia** ngrok tunnel
|
|
225
|
+
4. **Opcionalmente** actualiza `TG_WEBHOOK_URL` en el .env
|
|
226
|
+
5. **Opcionalmente** inicia el bot con `TG_ENV` configurado
|
|
227
|
+
|
|
228
|
+
### Output
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
ℹ Starting ngrok tunnel...
|
|
232
|
+
✓ ngrok tunnel started: https://abc123.ngrok.io
|
|
233
|
+
✓ Webhook URL updated in core/.env.local
|
|
234
|
+
ℹ You can now start the bot with: TG_ENV=local bun run dev
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Comandos de Desarrollo
|
|
238
|
+
|
|
239
|
+
Aunque no son comandos CLI separados, estos scripts están disponibles:
|
|
240
|
+
|
|
241
|
+
### `bun run dev`
|
|
242
|
+
|
|
243
|
+
Arranca el bot en modo desarrollo con hot reload.
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
bun run dev
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- Usa `bun --watch` para recarga automática
|
|
250
|
+
- Carga `.env.local` por defecto
|
|
251
|
+
- Logs en consola con Better Logger
|
|
252
|
+
|
|
253
|
+
### `bun run start`
|
|
254
|
+
|
|
255
|
+
Arranca el bot en modo producción.
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
bun run start
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
- Sin hot reload
|
|
262
|
+
- Respeta `TG_ENV` para seleccionar entorno
|
|
263
|
+
- Logs mínimos (`warn`+)
|
|
264
|
+
|
|
265
|
+
### `bun run build`
|
|
266
|
+
|
|
267
|
+
Verifica tipo y lint.
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
bun run build
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Ejecuta:
|
|
274
|
+
- `bun run typecheck` - TypeScript type checking
|
|
275
|
+
- `bun run lint` - Oxlint checking
|
|
276
|
+
|
|
277
|
+
### `bun run typecheck`
|
|
278
|
+
|
|
279
|
+
Type-check con tsgo.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
bun run typecheck
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### `bun run lint`
|
|
286
|
+
|
|
287
|
+
Lint con oxlint.
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
bun run lint
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### `bun run test`
|
|
294
|
+
|
|
295
|
+
Ejecuta tests con Bun.
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
bun test
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Scripts de Utilidad
|
|
302
|
+
|
|
303
|
+
### `bun run clean`
|
|
304
|
+
|
|
305
|
+
Limpia node_modules del workspace.
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
bun run clean
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### `bun run clean:logs`
|
|
312
|
+
|
|
313
|
+
Limpia logs y lock files.
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
bun run clean:logs
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Elimina:
|
|
320
|
+
- `core/logs/*`
|
|
321
|
+
- `core/tmp/*.lock`
|
|
322
|
+
- `core/tmp/*.pid`
|
|
323
|
+
|
|
324
|
+
### `bun run clean:all`
|
|
325
|
+
|
|
326
|
+
Limpia todo: node_modules, logs, tmp.
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
bun run clean:all
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Comandos Multi-Entorno
|
|
333
|
+
|
|
334
|
+
### Setup para Entornos Específicos
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
# Setup local (default)
|
|
338
|
+
bun run setup
|
|
339
|
+
|
|
340
|
+
# Setup staging
|
|
341
|
+
bun run setup:staging
|
|
342
|
+
|
|
343
|
+
# Setup production
|
|
344
|
+
bun run setup:production
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Arrancar en Entornos Específicos
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
# Local (default)
|
|
351
|
+
bun run start
|
|
352
|
+
|
|
353
|
+
# Staging
|
|
354
|
+
TG_ENV=staging bun run start
|
|
355
|
+
|
|
356
|
+
# Production
|
|
357
|
+
TG_ENV=production bun run start
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### ngrok para Entornos
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Local (default)
|
|
364
|
+
bun run ngrok
|
|
365
|
+
|
|
366
|
+
# Staging (con test bot)
|
|
367
|
+
bun run ngrok --environment staging
|
|
368
|
+
|
|
369
|
+
# Production (con webhook URL update)
|
|
370
|
+
bun run ngrok --environment production --webhook-url
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Referencias
|
|
374
|
+
|
|
375
|
+
- [Getting Started](./getting-started.md) - Guía de inicio
|
|
376
|
+
- [Environment](./environment.md) - Variables de entorno
|
|
377
|
+
- [Development](./development.md) - Flujo de desarrollo
|