@morojs/cli 1.0.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 +300 -0
- package/bin/cli.js +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +426 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.d.ts +17 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +334 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/database.d.ts +38 -0
- package/dist/commands/database.d.ts.map +1 -0
- package/dist/commands/database.js +523 -0
- package/dist/commands/database.js.map +1 -0
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +166 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/dev.d.ts +27 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +216 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1061 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/middleware.d.ts +11 -0
- package/dist/commands/middleware.d.ts.map +1 -0
- package/dist/commands/middleware.js +229 -0
- package/dist/commands/middleware.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +23 -0
- package/dist/logger.js.map +1 -0
- package/dist/module-stub-generator.d.ts +16 -0
- package/dist/module-stub-generator.d.ts.map +1 -0
- package/dist/module-stub-generator.js +505 -0
- package/dist/module-stub-generator.js.map +1 -0
- package/dist/utils/terminal.d.ts +11 -0
- package/dist/utils/terminal.d.ts.map +1 -0
- package/dist/utils/terminal.js +43 -0
- package/dist/utils/terminal.js.map +1 -0
- package/package.json +97 -0
package/README.md
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# @morojs/cli
|
|
2
|
+
|
|
3
|
+
**MoroJS Framework - Comprehensive Development Toolkit**
|
|
4
|
+
|
|
5
|
+
The official CLI for the MoroJS framework, providing a complete set of tools for building modern, high-performance APIs and microservices.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Project Initialization** - Create new projects with intelligent defaults
|
|
10
|
+
- **Advanced Module Generation** - Create modules with built-in middleware and features
|
|
11
|
+
- **Configuration Management** - Generate and validate MoroJS configurations
|
|
12
|
+
- **Database Management** - Setup adapters, run migrations, and seed data
|
|
13
|
+
- **Multi-Runtime Deployment** - Deploy to Vercel, AWS Lambda, Cloudflare Workers
|
|
14
|
+
- **Middleware Management** - Add and configure built-in middleware
|
|
15
|
+
- **Development Tools** - Dev server, build, lint, test commands
|
|
16
|
+
- **Security Scanning** - Built-in security analysis tools
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install globally
|
|
22
|
+
npm install -g @morojs/cli
|
|
23
|
+
|
|
24
|
+
# Create a new project
|
|
25
|
+
morojs-cli init my-api --runtime=node --database=postgresql --features=auth,cors,docs
|
|
26
|
+
|
|
27
|
+
# Navigate to project
|
|
28
|
+
cd my-api
|
|
29
|
+
|
|
30
|
+
# Start development server
|
|
31
|
+
npm run dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
### Project Management
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Initialize new project
|
|
40
|
+
morojs-cli init <project-name> [options]
|
|
41
|
+
-r, --runtime <type> Runtime adapter (node|vercel-edge|aws-lambda|cloudflare-workers)
|
|
42
|
+
-d, --database <type> Database adapter (mysql|postgresql|sqlite|mongodb|redis|drizzle)
|
|
43
|
+
-f, --features <list> Features (auth,cors,helmet,compression,websocket,docs)
|
|
44
|
+
-t, --template <type> Template (api|fullstack|microservice)
|
|
45
|
+
--skip-git Skip Git initialization
|
|
46
|
+
--skip-install Skip npm install
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Module Development
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Create advanced module
|
|
53
|
+
morojs-cli module create <name> [options]
|
|
54
|
+
-f, --features <list> Features (websocket,database,auth,cache,validation,docs)
|
|
55
|
+
-d, --database <type> Database adapter type
|
|
56
|
+
-m, --middleware <list> Built-in middleware (auth,cors,rate-limit,cache,validation)
|
|
57
|
+
-r, --routes <pattern> Route patterns (crud,rest,graphql)
|
|
58
|
+
--auth-roles <roles> Authentication roles
|
|
59
|
+
--with-tests Generate test files
|
|
60
|
+
--with-docs Generate API documentation
|
|
61
|
+
|
|
62
|
+
# List modules
|
|
63
|
+
morojs-cli module list
|
|
64
|
+
|
|
65
|
+
# Legacy module generation
|
|
66
|
+
morojs-cli generate <name> --features=websocket,database
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Configuration
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Generate configuration
|
|
73
|
+
morojs-cli config init [options]
|
|
74
|
+
-e, --environment <env> Environment (development|staging|production)
|
|
75
|
+
-d, --database <type> Primary database type
|
|
76
|
+
-r, --runtime <type> Runtime adapter type
|
|
77
|
+
|
|
78
|
+
# Validate configuration
|
|
79
|
+
morojs-cli config validate
|
|
80
|
+
|
|
81
|
+
# Generate .env template
|
|
82
|
+
morojs-cli config env --environment=production
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Database Management
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Setup database adapter
|
|
89
|
+
morojs-cli db setup <type> [options]
|
|
90
|
+
-h, --host <host> Database host
|
|
91
|
+
-p, --port <port> Database port
|
|
92
|
+
-u, --username <user> Database username
|
|
93
|
+
-d, --database <db> Database name
|
|
94
|
+
--with-migrations Generate migration system
|
|
95
|
+
--with-seeds Generate seed system
|
|
96
|
+
|
|
97
|
+
# Run migrations
|
|
98
|
+
morojs-cli db migrate --up|--down|--reset
|
|
99
|
+
|
|
100
|
+
# Seed database
|
|
101
|
+
morojs-cli db seed --environment=development
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Middleware Management
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Add middleware
|
|
108
|
+
morojs-cli middleware add <type> [options]
|
|
109
|
+
-c, --config <json> Middleware configuration
|
|
110
|
+
|
|
111
|
+
# List available middleware
|
|
112
|
+
morojs-cli middleware list
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Deployment
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Vercel Edge deployment
|
|
119
|
+
morojs-cli deploy vercel --domain=myapi.vercel.app
|
|
120
|
+
|
|
121
|
+
# AWS Lambda deployment
|
|
122
|
+
morojs-cli deploy lambda --region=us-west-2 --memory=1024
|
|
123
|
+
|
|
124
|
+
# Cloudflare Workers deployment
|
|
125
|
+
morojs-cli deploy workers --name=my-worker
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Development Tools
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Development server with hot reload
|
|
132
|
+
morojs-cli dev --port=3000 --watch=./modules
|
|
133
|
+
|
|
134
|
+
# Build for production
|
|
135
|
+
morojs-cli build --target=lambda --minify
|
|
136
|
+
|
|
137
|
+
# Lint and format code
|
|
138
|
+
morojs-cli lint --fix
|
|
139
|
+
|
|
140
|
+
# Run tests
|
|
141
|
+
morojs-cli test --watch --coverage
|
|
142
|
+
|
|
143
|
+
# Security scan
|
|
144
|
+
morojs-cli security:scan
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Project Templates
|
|
148
|
+
|
|
149
|
+
### API Server
|
|
150
|
+
```bash
|
|
151
|
+
morojs-cli init my-api --template=api --runtime=node --database=postgresql
|
|
152
|
+
```
|
|
153
|
+
Perfect for REST APIs, GraphQL servers, and backend services.
|
|
154
|
+
|
|
155
|
+
### Microservice
|
|
156
|
+
```bash
|
|
157
|
+
morojs-cli init my-service --template=microservice --runtime=vercel-edge
|
|
158
|
+
```
|
|
159
|
+
Lightweight services optimized for serverless deployment.
|
|
160
|
+
|
|
161
|
+
### Full-stack
|
|
162
|
+
```bash
|
|
163
|
+
morojs-cli init my-app --template=fullstack --features=auth,websocket,docs
|
|
164
|
+
```
|
|
165
|
+
Complete application with frontend integration support.
|
|
166
|
+
|
|
167
|
+
## Runtime Adapters
|
|
168
|
+
|
|
169
|
+
| Runtime | Description | Deploy Command |
|
|
170
|
+
|---------|-------------|----------------|
|
|
171
|
+
| **Node.js** | Traditional server deployment | `node dist/index.js` |
|
|
172
|
+
| **Vercel Edge** | Edge runtime with global distribution | `morojs-cli deploy vercel` |
|
|
173
|
+
| **AWS Lambda** | Serverless functions with auto-scaling | `morojs-cli deploy lambda` |
|
|
174
|
+
| **Cloudflare Workers** | Edge workers with V8 isolates | `morojs-cli deploy workers` |
|
|
175
|
+
|
|
176
|
+
## Database Support
|
|
177
|
+
|
|
178
|
+
- **PostgreSQL** - Full-featured relational database
|
|
179
|
+
- **MySQL/MariaDB** - Popular relational database
|
|
180
|
+
- **SQLite** - Lightweight embedded database
|
|
181
|
+
- **MongoDB** - Document-oriented database
|
|
182
|
+
- **Redis** - In-memory data structure store
|
|
183
|
+
- **Drizzle ORM** - Type-safe database toolkit
|
|
184
|
+
|
|
185
|
+
## Built-in Middleware
|
|
186
|
+
|
|
187
|
+
- **Authentication** - JWT, Session, OAuth support
|
|
188
|
+
- **CORS** - Cross-Origin Resource Sharing
|
|
189
|
+
- **Rate Limiting** - Request throttling and protection
|
|
190
|
+
- **Caching** - Response caching (Memory, Redis, File)
|
|
191
|
+
- **Validation** - Zod-based request validation
|
|
192
|
+
- **Security Headers** - Helmet.js integration
|
|
193
|
+
- **Compression** - Gzip/Brotli response compression
|
|
194
|
+
- **Session Management** - Secure session handling
|
|
195
|
+
- **CSRF Protection** - Cross-Site Request Forgery prevention
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
### Create a User Management API
|
|
200
|
+
```bash
|
|
201
|
+
# Initialize project
|
|
202
|
+
morojs-cli init user-api --runtime=node --database=postgresql --features=auth,docs
|
|
203
|
+
|
|
204
|
+
# Create users module
|
|
205
|
+
morojs-cli module create users --features=database,auth,cache --middleware=rate-limit --with-tests
|
|
206
|
+
|
|
207
|
+
# Setup database
|
|
208
|
+
morojs-cli db setup postgresql --host=localhost --database=userapi --with-migrations
|
|
209
|
+
|
|
210
|
+
# Add authentication middleware
|
|
211
|
+
morojs-cli middleware add auth --config='{"strategy":"jwt","expiresIn":"7d"}'
|
|
212
|
+
|
|
213
|
+
# Start development
|
|
214
|
+
npm run dev
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Serverless Microservice
|
|
218
|
+
```bash
|
|
219
|
+
# Create lightweight service
|
|
220
|
+
morojs-cli init payment-service --template=microservice --runtime=aws-lambda --database=redis
|
|
221
|
+
|
|
222
|
+
# Create payment module
|
|
223
|
+
morojs-cli module create payments --features=validation,cache --middleware=rate-limit
|
|
224
|
+
|
|
225
|
+
# Setup deployment
|
|
226
|
+
morojs-cli deploy lambda --region=us-east-1 --memory=512
|
|
227
|
+
|
|
228
|
+
# Deploy
|
|
229
|
+
npm run deploy:lambda
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Full-stack Application
|
|
233
|
+
```bash
|
|
234
|
+
# Create full-stack app
|
|
235
|
+
morojs-cli init chat-app --template=fullstack --features=websocket,auth,docs --database=mongodb
|
|
236
|
+
|
|
237
|
+
# Create chat module
|
|
238
|
+
morojs-cli module create chat --features=websocket,database,auth --with-tests
|
|
239
|
+
|
|
240
|
+
# Create users module
|
|
241
|
+
morojs-cli module create users --features=database,auth,validation --with-tests
|
|
242
|
+
|
|
243
|
+
# Start development
|
|
244
|
+
npm run dev
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Configuration
|
|
248
|
+
|
|
249
|
+
MoroJS CLI respects configuration from multiple sources:
|
|
250
|
+
|
|
251
|
+
1. **Command line arguments** (highest priority)
|
|
252
|
+
2. **Environment variables** (`MORO_*` prefix)
|
|
253
|
+
3. **moro.config.js** configuration file
|
|
254
|
+
4. **package.json** `morojs` field
|
|
255
|
+
5. **Default values** (lowest priority)
|
|
256
|
+
|
|
257
|
+
### Environment Variables
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Logging
|
|
261
|
+
LOG_LEVEL=debug
|
|
262
|
+
MORO_LOG_LEVEL=info
|
|
263
|
+
|
|
264
|
+
# Development
|
|
265
|
+
MORO_DEV_PORT=3000
|
|
266
|
+
MORO_DEV_HOST=localhost
|
|
267
|
+
|
|
268
|
+
# Database
|
|
269
|
+
DATABASE_URL=postgresql://user:pass@localhost:5432/db
|
|
270
|
+
REDIS_URL=redis://localhost:6379
|
|
271
|
+
|
|
272
|
+
# Security
|
|
273
|
+
JWT_SECRET=your-secret-key
|
|
274
|
+
CORS_ORIGIN=https://yourdomain.com
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## 🤝 Contributing
|
|
278
|
+
|
|
279
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
280
|
+
|
|
281
|
+
1. Fork the repository
|
|
282
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
283
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
284
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
285
|
+
5. Open a Pull Request
|
|
286
|
+
|
|
287
|
+
## 📄 License
|
|
288
|
+
|
|
289
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
290
|
+
|
|
291
|
+
## Links
|
|
292
|
+
|
|
293
|
+
- **Documentation**: [https://morojs.com](https://morojs.com)
|
|
294
|
+
- **GitHub**: [https://github.com/Moro-JS/cli](https://github.com/Moro-JS/cli)
|
|
295
|
+
- **NPM**: [https://www.npmjs.com/package/@morojs/cli](https://www.npmjs.com/package/@morojs/cli)
|
|
296
|
+
- **Discord**: [Join our community](https://discord.gg/morojs)
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
**Built with ❤️ by the MoroJS Team**
|
package/bin/cli.js
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAeA,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAoZ5C;AAGD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAG5D"}
|