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.
Files changed (182) hide show
  1. package/README.md +181 -0
  2. package/dist/bin.js +5755 -0
  3. package/dist/templates/monorepo/CLAUDE.md +164 -0
  4. package/dist/templates/monorepo/LICENSE +21 -0
  5. package/dist/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
  6. package/dist/templates/monorepo/README.md +74 -0
  7. package/dist/templates/monorepo/SYNC_VERIFICATION.md +1 -0
  8. package/dist/templates/monorepo/apps/example/package.json +19 -0
  9. package/dist/templates/monorepo/apps/example/src/index.ts +23 -0
  10. package/dist/templates/monorepo/apps/example/src/types/index.ts +7 -0
  11. package/dist/templates/monorepo/apps/example/src/utils/index.ts +7 -0
  12. package/dist/templates/monorepo/core/packages/main/package.json +41 -0
  13. package/dist/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
  14. package/dist/templates/monorepo/core/packages/main/src/index.ts +80 -0
  15. package/dist/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
  16. package/dist/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
  17. package/dist/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
  18. package/dist/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
  19. package/dist/templates/monorepo/core/packages/utils/package.json +43 -0
  20. package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
  21. package/dist/templates/monorepo/core/packages/utils/src/index.ts +2 -0
  22. package/dist/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
  23. package/dist/templates/monorepo/core/packages/utils/src/result.ts +146 -0
  24. package/dist/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
  25. package/dist/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
  26. package/dist/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
  27. package/dist/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
  28. package/dist/templates/monorepo/oxlint.json +14 -0
  29. package/dist/templates/monorepo/package.json +39 -0
  30. package/dist/templates/monorepo/tsconfig.json +35 -0
  31. package/dist/templates/telegram-bot/.oxlintrc.json +33 -0
  32. package/dist/templates/telegram-bot/.prettierignore +5 -0
  33. package/dist/templates/telegram-bot/.prettierrc +26 -0
  34. package/dist/templates/telegram-bot/CLAUDE.deploy.md +356 -0
  35. package/dist/templates/telegram-bot/CLAUDE.dev.md +266 -0
  36. package/dist/templates/telegram-bot/CLAUDE.md +280 -0
  37. package/dist/templates/telegram-bot/Dockerfile +46 -0
  38. package/dist/templates/telegram-bot/README.md +245 -0
  39. package/dist/templates/telegram-bot/apps/.gitkeep +0 -0
  40. package/dist/templates/telegram-bot/bun.lock +208 -0
  41. package/dist/templates/telegram-bot/core/.env.example +71 -0
  42. package/dist/templates/telegram-bot/core/README.md +1067 -0
  43. package/dist/templates/telegram-bot/core/package.json +15 -0
  44. package/dist/templates/telegram-bot/core/src/config/env.ts +131 -0
  45. package/dist/templates/telegram-bot/core/src/config/index.ts +97 -0
  46. package/dist/templates/telegram-bot/core/src/config/logging.ts +110 -0
  47. package/dist/templates/telegram-bot/core/src/handlers/control.ts +85 -0
  48. package/dist/templates/telegram-bot/core/src/handlers/health.ts +83 -0
  49. package/dist/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
  50. package/dist/templates/telegram-bot/core/src/index.ts +161 -0
  51. package/dist/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
  52. package/dist/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
  53. package/dist/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
  54. package/dist/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
  55. package/dist/templates/telegram-bot/core/src/types/bot.ts +92 -0
  56. package/dist/templates/telegram-bot/core/src/types/constants.ts +50 -0
  57. package/dist/templates/telegram-bot/core/src/types/result.ts +1 -0
  58. package/dist/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
  59. package/dist/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
  60. package/dist/templates/telegram-bot/core/src/utils/commands.ts +63 -0
  61. package/dist/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
  62. package/dist/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
  63. package/dist/templates/telegram-bot/core/src/utils/memory.ts +33 -0
  64. package/dist/templates/telegram-bot/core/src/utils/result.ts +26 -0
  65. package/dist/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
  66. package/dist/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
  67. package/dist/templates/telegram-bot/core/tsconfig.json +9 -0
  68. package/dist/templates/telegram-bot/docker-compose.yml +37 -0
  69. package/dist/templates/telegram-bot/docs/cli-commands.md +377 -0
  70. package/dist/templates/telegram-bot/docs/development.md +363 -0
  71. package/dist/templates/telegram-bot/docs/environment.md +460 -0
  72. package/dist/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
  73. package/dist/templates/telegram-bot/docs/examples/simple-command.md +207 -0
  74. package/dist/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
  75. package/dist/templates/telegram-bot/docs/getting-started.md +223 -0
  76. package/dist/templates/telegram-bot/docs/troubleshooting.md +489 -0
  77. package/dist/templates/telegram-bot/package.json +49 -0
  78. package/dist/templates/telegram-bot/packages/utils/package.json +12 -0
  79. package/dist/templates/telegram-bot/packages/utils/src/index.ts +2 -0
  80. package/dist/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
  81. package/dist/templates/telegram-bot/packages/utils/src/result.ts +80 -0
  82. package/dist/templates/telegram-bot/tools/README.md +47 -0
  83. package/dist/templates/telegram-bot/tools/commands/doctor.ts +460 -0
  84. package/dist/templates/telegram-bot/tools/commands/index.ts +35 -0
  85. package/dist/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
  86. package/dist/templates/telegram-bot/tools/commands/setup.ts +368 -0
  87. package/dist/templates/telegram-bot/tools/commands/status.ts +140 -0
  88. package/dist/templates/telegram-bot/tools/index.ts +16 -0
  89. package/dist/templates/telegram-bot/tools/package.json +12 -0
  90. package/dist/templates/telegram-bot/tools/utils/index.ts +13 -0
  91. package/dist/templates/telegram-bot/tsconfig.json +22 -0
  92. package/dist/templates/telegram-bot/vitest.config.ts +29 -0
  93. package/package.json +35 -0
  94. package/templates/monorepo/CLAUDE.md +164 -0
  95. package/templates/monorepo/LICENSE +21 -0
  96. package/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
  97. package/templates/monorepo/README.md +74 -0
  98. package/templates/monorepo/apps/example/package.json +19 -0
  99. package/templates/monorepo/apps/example/src/index.ts +23 -0
  100. package/templates/monorepo/apps/example/src/types/index.ts +7 -0
  101. package/templates/monorepo/apps/example/src/utils/index.ts +7 -0
  102. package/templates/monorepo/core/packages/main/package.json +41 -0
  103. package/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
  104. package/templates/monorepo/core/packages/main/src/index.ts +80 -0
  105. package/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
  106. package/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
  107. package/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
  108. package/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
  109. package/templates/monorepo/core/packages/utils/package.json +43 -0
  110. package/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
  111. package/templates/monorepo/core/packages/utils/src/index.ts +2 -0
  112. package/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
  113. package/templates/monorepo/core/packages/utils/src/result.ts +146 -0
  114. package/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
  115. package/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
  116. package/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
  117. package/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
  118. package/templates/monorepo/oxlint.json +14 -0
  119. package/templates/monorepo/package.json +39 -0
  120. package/templates/monorepo/tsconfig.json +35 -0
  121. package/templates/telegram-bot/.oxlintrc.json +33 -0
  122. package/templates/telegram-bot/.prettierignore +5 -0
  123. package/templates/telegram-bot/.prettierrc +26 -0
  124. package/templates/telegram-bot/CLAUDE.deploy.md +356 -0
  125. package/templates/telegram-bot/CLAUDE.dev.md +266 -0
  126. package/templates/telegram-bot/CLAUDE.md +280 -0
  127. package/templates/telegram-bot/Dockerfile +46 -0
  128. package/templates/telegram-bot/README.md +245 -0
  129. package/templates/telegram-bot/apps/.gitkeep +0 -0
  130. package/templates/telegram-bot/bun.lock +208 -0
  131. package/templates/telegram-bot/core/.env.example +71 -0
  132. package/templates/telegram-bot/core/README.md +1067 -0
  133. package/templates/telegram-bot/core/package.json +15 -0
  134. package/templates/telegram-bot/core/src/config/env.ts +131 -0
  135. package/templates/telegram-bot/core/src/config/index.ts +97 -0
  136. package/templates/telegram-bot/core/src/config/logging.ts +110 -0
  137. package/templates/telegram-bot/core/src/handlers/control.ts +85 -0
  138. package/templates/telegram-bot/core/src/handlers/health.ts +83 -0
  139. package/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
  140. package/templates/telegram-bot/core/src/index.ts +161 -0
  141. package/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
  142. package/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
  143. package/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
  144. package/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
  145. package/templates/telegram-bot/core/src/types/bot.ts +92 -0
  146. package/templates/telegram-bot/core/src/types/constants.ts +50 -0
  147. package/templates/telegram-bot/core/src/types/result.ts +1 -0
  148. package/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
  149. package/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
  150. package/templates/telegram-bot/core/src/utils/commands.ts +63 -0
  151. package/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
  152. package/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
  153. package/templates/telegram-bot/core/src/utils/memory.ts +33 -0
  154. package/templates/telegram-bot/core/src/utils/result.ts +26 -0
  155. package/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
  156. package/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
  157. package/templates/telegram-bot/core/tsconfig.json +9 -0
  158. package/templates/telegram-bot/docker-compose.yml +37 -0
  159. package/templates/telegram-bot/docs/cli-commands.md +377 -0
  160. package/templates/telegram-bot/docs/development.md +363 -0
  161. package/templates/telegram-bot/docs/environment.md +460 -0
  162. package/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
  163. package/templates/telegram-bot/docs/examples/simple-command.md +207 -0
  164. package/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
  165. package/templates/telegram-bot/docs/getting-started.md +223 -0
  166. package/templates/telegram-bot/docs/troubleshooting.md +489 -0
  167. package/templates/telegram-bot/package.json +49 -0
  168. package/templates/telegram-bot/packages/utils/package.json +12 -0
  169. package/templates/telegram-bot/packages/utils/src/index.ts +2 -0
  170. package/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
  171. package/templates/telegram-bot/packages/utils/src/result.ts +80 -0
  172. package/templates/telegram-bot/tools/README.md +47 -0
  173. package/templates/telegram-bot/tools/commands/doctor.ts +460 -0
  174. package/templates/telegram-bot/tools/commands/index.ts +35 -0
  175. package/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
  176. package/templates/telegram-bot/tools/commands/setup.ts +368 -0
  177. package/templates/telegram-bot/tools/commands/status.ts +140 -0
  178. package/templates/telegram-bot/tools/index.ts +16 -0
  179. package/templates/telegram-bot/tools/package.json +12 -0
  180. package/templates/telegram-bot/tools/utils/index.ts +13 -0
  181. package/templates/telegram-bot/tsconfig.json +22 -0
  182. package/templates/telegram-bot/vitest.config.ts +29 -0
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bun
2
+ import { Command } from 'commander'
3
+ import pkg from '../package.json' with { type: 'json' }
4
+ import { registerCommands } from './commands/index.js'
5
+
6
+ const program = new Command()
7
+
8
+ program
9
+ .name('mks-bot')
10
+ .description((pkg as { description?: string }).description ?? 'mks-telegram-bot CLI tools')
11
+ .version((pkg as { version?: string }).version ?? '0.1.0')
12
+ .configureHelp({ helpWidth: 80 })
13
+
14
+ await registerCommands(program)
15
+
16
+ program.parse()
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@mks2508/telegram-bot-tools",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "dependencies": {
6
+ "@mks2508/telegram-bot-utils": "workspace:*",
7
+ "chalk": "^5.6.2",
8
+ "commander": "^14.0.2",
9
+ "dotenv": "^17.2.3",
10
+ "glob": "^13.0.0"
11
+ }
12
+ }
@@ -0,0 +1,13 @@
1
+ import { config as loadEnv } from 'dotenv'
2
+
3
+ export interface ConfigOptions {
4
+ envPath?: string
5
+ required?: string[]
6
+ }
7
+
8
+ export function loadBotConfig(options: ConfigOptions = {}) {
9
+ if (options.envPath) {
10
+ return loadEnv({ path: options.envPath })
11
+ }
12
+ return loadEnv()
13
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "target": "ESNext",
5
+ "module": "Preserve",
6
+ "moduleDetection": "force",
7
+ "allowJs": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "verbatimModuleSyntax": true,
11
+ "noEmit": true,
12
+ "strict": true,
13
+ "skipLibCheck": true,
14
+ "noFallthroughCasesInSwitch": true,
15
+ "noUncheckedIndexedAccess": true,
16
+ "noImplicitOverride": true,
17
+ "noUnusedLocals": false,
18
+ "noUnusedParameters": false,
19
+ "noPropertyAccessFromIndexSignature": false
20
+ },
21
+ "exclude": ["node_modules", "**/node_modules", "**/dist"]
22
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Bun test configuration
3
+ * @see https://bun.sh/docs/test/configuration
4
+ */
5
+
6
+ export default {
7
+ // Test files matching pattern
8
+ testMatch: [
9
+ '**/*.test.ts',
10
+ '**/*.spec.ts',
11
+ ],
12
+ // Files to ignore
13
+ ignore: [
14
+ '**/node_modules/**',
15
+ '**/dist/**',
16
+ '**/.next/**',
17
+ ],
18
+ // Preload files before tests
19
+ // preload: ['./test/setup.ts'],
20
+ // Coverage configuration
21
+ coverageThreshold: {
22
+ global: {
23
+ branches: 80,
24
+ functions: 80,
25
+ lines: 80,
26
+ statements: 80,
27
+ },
28
+ },
29
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "create-bunspace",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Multi-template project scaffolder for Bun",
6
+ "author": "MKS2508",
7
+ "license": "MIT",
8
+ "bin": {
9
+ "create-bunspace": "./dist/bin.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "templates"
14
+ ],
15
+ "engines": {
16
+ "bun": ">=1.0.0"
17
+ },
18
+ "scripts": {
19
+ "build": "bun build ./bin.ts --outdir ./dist --target bun",
20
+ "prebuild": "node scripts/embed-templates.js",
21
+ "postbuild": "echo '✅ Build complete with templates'",
22
+ "dev": "bun run ./bin.ts",
23
+ "typecheck": "tsc --noEmit",
24
+ "templates:list": "bun run ./dist/bin.js templates list",
25
+ "templates:sync": "bun run ./dist/bin.js templates sync"
26
+ },
27
+ "dependencies": {
28
+ "kleur": "^4.1.5",
29
+ "prompts": "^2.4.2"
30
+ },
31
+ "devDependencies": {
32
+ "@types/bun": "latest",
33
+ "@types/prompts": "^2.4.9"
34
+ }
35
+ }
@@ -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
+ [![Use this template](https://img.shields.io/badge/Use_this_template-📦-blue?logo=github)](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,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
+ }