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
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# create-bunspace
|
|
2
|
+
|
|
3
|
+
> Multi-template project scaffolder for Bun with git submodule templates
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/create-bunspace)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
CLI scaffolder to create new projects from templates. Supports multiple templates via git submodules with automatic synchronization.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Create a new project (default: monorepo)
|
|
14
|
+
bun create bunspace my-project
|
|
15
|
+
|
|
16
|
+
# Create with specific template
|
|
17
|
+
bun create bunspace my-bot --template telegram-bot
|
|
18
|
+
|
|
19
|
+
# Create with all options
|
|
20
|
+
bun create bunspace my-app --template monorepo --yes --no-git
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Available Templates
|
|
24
|
+
|
|
25
|
+
| Template | Description |
|
|
26
|
+
|----------|-------------|
|
|
27
|
+
| **monorepo** | Bun monorepo for npm packages with workspaces |
|
|
28
|
+
| **telegram-bot** | Production-ready Telegram bot with Telegraf and TypeScript |
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Basic Usage
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Interactive mode (prompts for template and config)
|
|
36
|
+
bun create bunspace my-project
|
|
37
|
+
|
|
38
|
+
# Skip prompts with defaults
|
|
39
|
+
bun create bunspace my-project --yes
|
|
40
|
+
|
|
41
|
+
# Specific template
|
|
42
|
+
bun create bunspace my-project --template telegram-bot
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Options
|
|
46
|
+
|
|
47
|
+
| Option | Alias | Description |
|
|
48
|
+
|--------|-------|-------------|
|
|
49
|
+
| `--template <name>` | `-t` | Template to use (monorepo, telegram-bot) |
|
|
50
|
+
| `--scope <scope>` | `-s` | npm scope (e.g., @my-org) |
|
|
51
|
+
| `--description <text>` | `-d` | Project description |
|
|
52
|
+
| `--author <name>` | `-a` | Author name |
|
|
53
|
+
| `--dir <path>` | | Target directory |
|
|
54
|
+
| `--yes` | `-y` | Skip prompts, use defaults |
|
|
55
|
+
| `--no-git` | | Don't initialize git |
|
|
56
|
+
| `--no-install` | | Don't run bun install |
|
|
57
|
+
| `--help` | `-h` | Show help |
|
|
58
|
+
|
|
59
|
+
### Examples
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Monorepo with defaults
|
|
63
|
+
bun create bunspace my-lib
|
|
64
|
+
|
|
65
|
+
# Telegram bot with prompts
|
|
66
|
+
bun create bunspace my-bot --template telegram-bot
|
|
67
|
+
|
|
68
|
+
# Skip all prompts
|
|
69
|
+
bun create bunspace my-app -t monorepo -y
|
|
70
|
+
|
|
71
|
+
# Custom scope and description
|
|
72
|
+
bun create bunspace my-app --scope @mycompany --description "My app"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Template Management
|
|
76
|
+
|
|
77
|
+
The scaffolder uses git submodules for templates, allowing easy updates:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# List templates and their git status
|
|
81
|
+
bun run templates:list
|
|
82
|
+
|
|
83
|
+
# Sync all templates to latest
|
|
84
|
+
bun run templates:sync
|
|
85
|
+
|
|
86
|
+
# Sync specific template
|
|
87
|
+
bun run templates:sync monorepo
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Clone repository
|
|
94
|
+
git clone https://github.com/MKS2508/mks-scaffolder.git
|
|
95
|
+
cd mks-scaffolder
|
|
96
|
+
|
|
97
|
+
# Install dependencies
|
|
98
|
+
bun install
|
|
99
|
+
|
|
100
|
+
# Run CLI directly
|
|
101
|
+
bun run dev my-project --template monorepo
|
|
102
|
+
|
|
103
|
+
# Build
|
|
104
|
+
bun run build
|
|
105
|
+
|
|
106
|
+
# Type check
|
|
107
|
+
bun run typecheck
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## How It Works
|
|
111
|
+
|
|
112
|
+
1. **Template Resolution**: Checks git submodules first (`templates/`), falls back to embedded templates (`dist/templates/`)
|
|
113
|
+
2. **Placeholder Replacement**: Replaces `{{PLACEHOLDER}}` patterns in template files
|
|
114
|
+
3. **Project Generation**: Copies files, replaces placeholders, and optionally runs `bun install`
|
|
115
|
+
|
|
116
|
+
## Template System
|
|
117
|
+
|
|
118
|
+
### Adding a New Template
|
|
119
|
+
|
|
120
|
+
1. Add as git submodule:
|
|
121
|
+
```bash
|
|
122
|
+
git submodule add <repo-url> templates/<name>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. Update `scripts/embed-templates.js` to include the new template
|
|
126
|
+
|
|
127
|
+
3. Add template choice to `src/prompts.ts:selectTemplate()`
|
|
128
|
+
|
|
129
|
+
4. Add placeholder generation to `src/generator.ts:generatePlaceholders()`
|
|
130
|
+
|
|
131
|
+
### Placeholder Syntax
|
|
132
|
+
|
|
133
|
+
Templates use `{{PLACEHOLDER}}` syntax for variable substitution:
|
|
134
|
+
|
|
135
|
+
**Monorepo Template:**
|
|
136
|
+
- `{{NAME}}` - Project name
|
|
137
|
+
- `{{SCOPE}}` - npm scope (without @)
|
|
138
|
+
- `{{DESCRIPTION}}` - Project description
|
|
139
|
+
- `{{AUTHOR}}` - Author name
|
|
140
|
+
- `{{YEAR}}` - Current year
|
|
141
|
+
|
|
142
|
+
**Telegram Bot Template:**
|
|
143
|
+
- `{{BOT_NAME}}` - Bot name
|
|
144
|
+
- `{{BOT_SCOPE}}` - npm scope (without @)
|
|
145
|
+
- `{{BOT_DESCRIPTION}}` - Bot description
|
|
146
|
+
- `{{TG_BOT_TOKEN}}` - Bot token
|
|
147
|
+
- `{{AUTHOR}}` - Author name
|
|
148
|
+
- `{{YEAR}}` - Current year
|
|
149
|
+
|
|
150
|
+
## Architecture
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
mks-scaffolder/
|
|
154
|
+
├── bin.ts # Executable entry point
|
|
155
|
+
├── src/
|
|
156
|
+
│ ├── cli.ts # Main CLI orchestration
|
|
157
|
+
│ ├── generator.ts # Project generation
|
|
158
|
+
│ ├── template-manager.ts # Git submodule management
|
|
159
|
+
│ ├── prompts.ts # Interactive prompts
|
|
160
|
+
│ ├── types.ts # TypeScript definitions
|
|
161
|
+
│ └── utils.ts # Utilities
|
|
162
|
+
├── scripts/
|
|
163
|
+
│ └── embed-templates.js # Copies templates to dist/
|
|
164
|
+
├── templates/
|
|
165
|
+
│ ├── monorepo/ # Submodule: mks-bun-monorepo
|
|
166
|
+
│ └── telegram-bot/ # Submodule: mks-telegram-bot
|
|
167
|
+
└── dist/
|
|
168
|
+
└── bin.js # Built CLI (for npm publishing)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Documentation
|
|
172
|
+
|
|
173
|
+
- [CLAUDE.md](./CLAUDE.md) - Developer documentation and architecture guide
|
|
174
|
+
|
|
175
|
+
## Contributing
|
|
176
|
+
|
|
177
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT © [MKS2508](https://github.com/MKS2508)
|