botim-cli 0.0.7
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 +375 -0
- package/bin/cli +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +459 -0
- package/dist/cli.mjs +106 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +13 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Botim CLI Generator
|
|
2
|
+
|
|
3
|
+
A powerful, extensible Command Line Interface (CLI) tool that generates boilerplate code and project scaffolding for React and Vue applications. Built with TypeScript for type safety and maintainability.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **React & Vue Support**: Generate boilerplate for both React and Vue applications
|
|
8
|
+
- **TypeScript First**: Built with TypeScript and supports TypeScript in generated projects
|
|
9
|
+
- **Interactive Prompts**: User-friendly interactive prompts for project configuration
|
|
10
|
+
- **Customizable**: Choose which features to include (routing, state management, testing, linting)
|
|
11
|
+
- **Multiple Package Managers**: Support for npm, yarn, and pnpm
|
|
12
|
+
- **Extensible Architecture**: Plugin system for adding new frameworks and features
|
|
13
|
+
- **Modern Tooling**: Uses Vite as the default build tool for fast development
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Quick Install (Recommended)
|
|
18
|
+
|
|
19
|
+
Use the automated installation script:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Run the installation script
|
|
23
|
+
./QUICK-INSTALL.sh
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This will:
|
|
27
|
+
1. Install dependencies
|
|
28
|
+
2. Build the project
|
|
29
|
+
3. Link it globally (may ask for sudo password)
|
|
30
|
+
4. Verify the installation
|
|
31
|
+
|
|
32
|
+
### Manual Installation
|
|
33
|
+
|
|
34
|
+
#### Option 1: Development (npm link)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install dependencies
|
|
38
|
+
npm install
|
|
39
|
+
|
|
40
|
+
# Build the project
|
|
41
|
+
npm run build
|
|
42
|
+
|
|
43
|
+
# Link globally (may require sudo)
|
|
44
|
+
sudo npm link
|
|
45
|
+
|
|
46
|
+
# Verify
|
|
47
|
+
botim-cli --version
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Option 2: Local Testing (npm run)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Install dependencies
|
|
54
|
+
npm install
|
|
55
|
+
|
|
56
|
+
# Build the project
|
|
57
|
+
npm run build
|
|
58
|
+
|
|
59
|
+
# Run the CLI locally
|
|
60
|
+
npm run cli -- --help
|
|
61
|
+
npm run cli create-react-app my-app
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Option 3: Global Installation from Directory
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Build first
|
|
68
|
+
npm run build
|
|
69
|
+
|
|
70
|
+
# Install globally
|
|
71
|
+
npm install -g .
|
|
72
|
+
|
|
73
|
+
# Or from tarball
|
|
74
|
+
npm pack
|
|
75
|
+
npm install -g botim-cli-generator-1.0.0.tgz
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### After Publishing to npm
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install -g @botim/cli-generator
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Troubleshooting Installation
|
|
85
|
+
|
|
86
|
+
If you encounter permission errors or other issues, see the detailed [INSTALLATION.md](./INSTALLATION.md) guide.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
### Quick Start - Interactive Mode
|
|
91
|
+
|
|
92
|
+
The fastest way to get started is to run the CLI without any arguments:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm run cli
|
|
96
|
+
# or: botim-cli
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This will show an interactive menu where you can:
|
|
100
|
+
- ⚛️ Create a React application
|
|
101
|
+
- 🖖 Create a Vue application
|
|
102
|
+
- 📚 View examples
|
|
103
|
+
- ❓ Show help
|
|
104
|
+
- 🚪 Exit
|
|
105
|
+
|
|
106
|
+
Simply select your choice and the CLI will guide you through the rest!
|
|
107
|
+
|
|
108
|
+
### Getting Help
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Show interactive menu with framework selection
|
|
112
|
+
npm run cli
|
|
113
|
+
# or: botim-cli
|
|
114
|
+
|
|
115
|
+
# Show detailed help
|
|
116
|
+
npm run cli -- --help
|
|
117
|
+
# or: botim-cli --help
|
|
118
|
+
|
|
119
|
+
# Show usage examples
|
|
120
|
+
npm run cli -- examples
|
|
121
|
+
# or: botim-cli examples
|
|
122
|
+
|
|
123
|
+
# Show quick start guide
|
|
124
|
+
npm run cli -- quick-start
|
|
125
|
+
# or: botim-cli quick-start (alias: qs)
|
|
126
|
+
|
|
127
|
+
# Show version
|
|
128
|
+
npm run cli -- -v
|
|
129
|
+
# or: botim-cli -v
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Create a React Application
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Using npm run
|
|
136
|
+
npm run cli create-react-app my-react-app
|
|
137
|
+
|
|
138
|
+
# Or if globally installed
|
|
139
|
+
botim-cli create-react-app my-react-app
|
|
140
|
+
|
|
141
|
+
# Using alias
|
|
142
|
+
botim-cli react my-react-app
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Create a Vue Application
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Using npm run
|
|
149
|
+
npm run cli create-vue-app my-vue-app
|
|
150
|
+
|
|
151
|
+
# Or if globally installed
|
|
152
|
+
botim-cli create-vue-app my-vue-app
|
|
153
|
+
|
|
154
|
+
# Using alias
|
|
155
|
+
botim-cli vue my-vue-app
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Interactive Mode
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Using npm run
|
|
162
|
+
npm run cli create
|
|
163
|
+
|
|
164
|
+
# Or if globally installed
|
|
165
|
+
botim-cli create
|
|
166
|
+
|
|
167
|
+
# Using alias
|
|
168
|
+
botim-cli init
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The interactive mode will prompt you for:
|
|
172
|
+
- Project name
|
|
173
|
+
- Framework (React or Vue)
|
|
174
|
+
- TypeScript support
|
|
175
|
+
- Routing
|
|
176
|
+
- State management
|
|
177
|
+
- Testing setup
|
|
178
|
+
- Linting (ESLint & Prettier)
|
|
179
|
+
- Package manager preference
|
|
180
|
+
|
|
181
|
+
### Available Commands
|
|
182
|
+
|
|
183
|
+
| Command | Alias | Description |
|
|
184
|
+
|---------|-------|-------------|
|
|
185
|
+
| `create` | `init` | Interactive mode - choose framework and features |
|
|
186
|
+
| `create-react-app` | `react` | Create a new React application |
|
|
187
|
+
| `create-vue-app` | `vue` | Create a new Vue application |
|
|
188
|
+
| `examples` | - | Show usage examples and patterns |
|
|
189
|
+
| `quick-start` | `qs` | Show quick start guide |
|
|
190
|
+
| `--help` | `-h` | Display help information |
|
|
191
|
+
| `--version` | `-v` | Display version number |
|
|
192
|
+
|
|
193
|
+
## Project Structure
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
cli/
|
|
197
|
+
├── src/
|
|
198
|
+
│ ├── commands/ # CLI commands
|
|
199
|
+
│ │ ├── create-react-app.ts
|
|
200
|
+
│ │ ├── create-vue-app.ts
|
|
201
|
+
│ │ └── index.ts
|
|
202
|
+
│ ├── templates/ # Project templates
|
|
203
|
+
│ │ ├── react/
|
|
204
|
+
│ │ │ └── template-files/
|
|
205
|
+
│ │ └── vue/
|
|
206
|
+
│ │ └── template-files/
|
|
207
|
+
│ ├── plugins/ # Plugin system
|
|
208
|
+
│ │ ├── plugin-registry.ts
|
|
209
|
+
│ │ ├── plugin-loader.ts
|
|
210
|
+
│ │ └── types.ts
|
|
211
|
+
│ ├── core/ # Core functionality
|
|
212
|
+
│ │ ├── template-engine.ts
|
|
213
|
+
│ │ ├── file-generator.ts
|
|
214
|
+
│ │ └── types.ts
|
|
215
|
+
│ ├── utils/ # Utility functions
|
|
216
|
+
│ │ ├── file-operations.ts
|
|
217
|
+
│ │ ├── prompts.ts
|
|
218
|
+
│ │ └── validators.ts
|
|
219
|
+
│ ├── types/ # TypeScript type definitions
|
|
220
|
+
│ │ └── index.ts
|
|
221
|
+
│ ├── index.ts # Main export
|
|
222
|
+
│ └── cli.ts # CLI entry point
|
|
223
|
+
├── bin/
|
|
224
|
+
│ └── cli # Executable
|
|
225
|
+
├── dist/ # Compiled JavaScript
|
|
226
|
+
├── tsconfig.json
|
|
227
|
+
├── package.json
|
|
228
|
+
└── README.md
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Generated Project Features
|
|
232
|
+
|
|
233
|
+
### React Projects
|
|
234
|
+
|
|
235
|
+
- React 18 with latest features
|
|
236
|
+
- Vite for fast development and building
|
|
237
|
+
- Optional TypeScript support
|
|
238
|
+
- Optional React Router for routing
|
|
239
|
+
- Optional Zustand for state management
|
|
240
|
+
- Optional Vitest & Testing Library for testing
|
|
241
|
+
- Optional ESLint & Prettier for code quality
|
|
242
|
+
- Pre-configured with best practices
|
|
243
|
+
|
|
244
|
+
### Vue Projects
|
|
245
|
+
|
|
246
|
+
- Vue 3 with Composition API
|
|
247
|
+
- Vite for fast development and building
|
|
248
|
+
- Optional TypeScript support
|
|
249
|
+
- Optional Vue Router for routing
|
|
250
|
+
- Optional Pinia for state management
|
|
251
|
+
- Optional Vitest & Testing Library for testing
|
|
252
|
+
- Optional ESLint & Prettier for code quality
|
|
253
|
+
- Pre-configured with best practices
|
|
254
|
+
|
|
255
|
+
## Extensibility
|
|
256
|
+
|
|
257
|
+
### Plugin System
|
|
258
|
+
|
|
259
|
+
The CLI includes a plugin system that allows you to extend its functionality:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { Plugin, PluginContext } from '@botim/cli-generator';
|
|
263
|
+
|
|
264
|
+
const myPlugin: Plugin = {
|
|
265
|
+
name: 'my-custom-plugin',
|
|
266
|
+
version: '1.0.0',
|
|
267
|
+
type: 'template',
|
|
268
|
+
async execute(config, context) {
|
|
269
|
+
// Your plugin logic here
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export default myPlugin;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Adding New Templates
|
|
277
|
+
|
|
278
|
+
1. Create a new directory under `src/templates/`
|
|
279
|
+
2. Add your template files
|
|
280
|
+
3. Create a command in `src/commands/`
|
|
281
|
+
4. Register the command in `src/cli.ts`
|
|
282
|
+
|
|
283
|
+
## Development
|
|
284
|
+
|
|
285
|
+
### Available Scripts
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Build the project
|
|
289
|
+
npm run build
|
|
290
|
+
|
|
291
|
+
# Build and watch for changes
|
|
292
|
+
npm run dev
|
|
293
|
+
|
|
294
|
+
# Type check without emitting
|
|
295
|
+
npm run type-check
|
|
296
|
+
|
|
297
|
+
# Run the CLI locally
|
|
298
|
+
npm run cli -- [command]
|
|
299
|
+
|
|
300
|
+
# Run tests (when implemented)
|
|
301
|
+
npm test
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Project Requirements
|
|
305
|
+
|
|
306
|
+
- Node.js >= 16.0.0
|
|
307
|
+
- npm, yarn, or pnpm
|
|
308
|
+
|
|
309
|
+
### Dependencies
|
|
310
|
+
|
|
311
|
+
**Runtime Dependencies:**
|
|
312
|
+
- `commander` - CLI framework
|
|
313
|
+
- `inquirer` - Interactive prompts
|
|
314
|
+
- `fs-extra` - Enhanced file operations
|
|
315
|
+
- `handlebars` - Template processing
|
|
316
|
+
- `chalk` - Terminal colors
|
|
317
|
+
- `ora` - Spinners and progress indicators
|
|
318
|
+
- `zod` - Runtime validation
|
|
319
|
+
- `which-pm-runs` - Package manager detection
|
|
320
|
+
|
|
321
|
+
**Dev Dependencies:**
|
|
322
|
+
- `typescript` - Type safety
|
|
323
|
+
- `tsup` - Build tool
|
|
324
|
+
- `@types/*` - Type definitions
|
|
325
|
+
|
|
326
|
+
## Architecture
|
|
327
|
+
|
|
328
|
+
### Core Components
|
|
329
|
+
|
|
330
|
+
1. **Template Engine**: Processes and generates projects from templates
|
|
331
|
+
2. **File Generator**: Handles file creation and copying
|
|
332
|
+
3. **Command System**: Implements CLI commands using Commander
|
|
333
|
+
4. **Plugin System**: Extensible architecture for adding new features
|
|
334
|
+
5. **Validation**: Input validation using Zod schemas
|
|
335
|
+
|
|
336
|
+
### Design Principles
|
|
337
|
+
|
|
338
|
+
- **Type Safety**: Full TypeScript support with strict mode
|
|
339
|
+
- **Modularity**: Separated concerns for better maintainability
|
|
340
|
+
- **Extensibility**: Plugin-based architecture for future growth
|
|
341
|
+
- **User Experience**: Interactive prompts and helpful error messages
|
|
342
|
+
- **Best Practices**: Generated projects follow modern web development standards
|
|
343
|
+
|
|
344
|
+
## Future Enhancements
|
|
345
|
+
|
|
346
|
+
- [ ] Add more framework templates (Angular, Svelte, etc.)
|
|
347
|
+
- [ ] Support for different build tools (Webpack, etc.)
|
|
348
|
+
- [ ] Template update mechanism
|
|
349
|
+
- [ ] Community plugin registry
|
|
350
|
+
- [ ] Support for plugins in different languages
|
|
351
|
+
- [ ] CI/CD configuration templates
|
|
352
|
+
- [ ] Docker configuration generation
|
|
353
|
+
- [ ] More testing utilities
|
|
354
|
+
|
|
355
|
+
## Contributing
|
|
356
|
+
|
|
357
|
+
Contributions are welcome! Please follow these steps:
|
|
358
|
+
|
|
359
|
+
1. Fork the repository
|
|
360
|
+
2. Create a feature branch
|
|
361
|
+
3. Make your changes
|
|
362
|
+
4. Write/update tests
|
|
363
|
+
5. Submit a pull request
|
|
364
|
+
|
|
365
|
+
## License
|
|
366
|
+
|
|
367
|
+
ISC
|
|
368
|
+
|
|
369
|
+
## Questions & Support
|
|
370
|
+
|
|
371
|
+
For questions or issues, please visit the project repository.
|
|
372
|
+
|
|
373
|
+
## Acknowledgments
|
|
374
|
+
|
|
375
|
+
Built with modern web development tools and best practices to streamline project initialization and reduce repetitive setup tasks.
|
package/bin/cli
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|