ready-to-ship 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/ENABLE_2FA.md +90 -0
- package/ENABLE_2FA_SECURITY_KEY.md +109 -0
- package/GO_LIVE.md +187 -0
- package/LICENSE +22 -0
- package/PUBLISH.md +110 -0
- package/PUBLISH_STEPS.md +106 -0
- package/QUICKSTART.md +71 -0
- package/README.md +196 -0
- package/UNIQUE_FEATURES.md +114 -0
- package/package.json +53 -0
- package/publish.sh +64 -0
- package/src/cli.js +155 -0
- package/src/modules/api.js +152 -0
- package/src/modules/auth.js +152 -0
- package/src/modules/database.js +178 -0
- package/src/modules/dependencies.js +151 -0
- package/src/modules/env.js +117 -0
- package/src/modules/project.js +175 -0
- package/src/modules/report.js +118 -0
- package/src/modules/security.js +149 -0
- package/src/utils/fileHelpers.js +95 -0
- package/src/utils/fixHelpers.js +203 -0
- package/src/utils/logHelpers.js +77 -0
- package/src/utils/parseHelpers.js +151 -0
- package/templates/.github/workflows/ready-to-ship.yml +35 -0
- package/templates/README.md +23 -0
- package/templates/github-actions.yml +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# š Ready-to-Ship CLI
|
|
2
|
+
|
|
3
|
+
**Validate a backend project before deployment like a senior engineer would.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ready-to-ship)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
> **The only CLI that combines environment, auth, API, security, dependencies, and database validation in one tool.**
|
|
9
|
+
|
|
10
|
+
## ⨠Features
|
|
11
|
+
|
|
12
|
+
- ā
**Environment Validation** - Check `.env` files, missing variables, weak secrets, type validation
|
|
13
|
+
- š **Auth Validation** - Detect unprotected routes, JWT configuration, middleware checks
|
|
14
|
+
- š **API Validation** - Health endpoints, route consistency, HTTP method patterns
|
|
15
|
+
- š **Project Validation** - Structure, README, error handling, best practices
|
|
16
|
+
- š **Security Validation** - CORS, security headers, rate limiting, vulnerability detection
|
|
17
|
+
- š¦ **Dependencies Validation** - Package health, lock files, outdated packages
|
|
18
|
+
- šļø **Database Validation** - Connection handling, pooling, migration files
|
|
19
|
+
- š§ **Auto-Fix Suggestions** - Get actionable fixes for common issues
|
|
20
|
+
- š **Comprehensive Reports** - Combined verdict with detailed insights
|
|
21
|
+
- šÆ **CI/CD Ready** - GitHub Actions templates included
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g ready-to-ship
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or use with npx (no installation needed):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx ready-to-ship <command>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Individual Checks
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Check environment variables
|
|
41
|
+
npx ready-to-ship env
|
|
42
|
+
|
|
43
|
+
# Check authentication & route protection
|
|
44
|
+
npx ready-to-ship auth
|
|
45
|
+
|
|
46
|
+
# Check API endpoints
|
|
47
|
+
npx ready-to-ship api
|
|
48
|
+
|
|
49
|
+
# Check project structure
|
|
50
|
+
npx ready-to-ship project
|
|
51
|
+
|
|
52
|
+
# Check security configurations
|
|
53
|
+
npx ready-to-ship security
|
|
54
|
+
|
|
55
|
+
# Check dependencies
|
|
56
|
+
npx ready-to-ship dependencies
|
|
57
|
+
|
|
58
|
+
# Check database configuration
|
|
59
|
+
npx ready-to-ship database
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Auto-Fix
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Get fix suggestions
|
|
66
|
+
npx ready-to-ship fix
|
|
67
|
+
|
|
68
|
+
# Apply fixes automatically (creates files)
|
|
69
|
+
npx ready-to-ship fix --apply
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Full Report
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Generate comprehensive report
|
|
76
|
+
npx ready-to-ship report
|
|
77
|
+
|
|
78
|
+
# With verbose output
|
|
79
|
+
npx ready-to-ship report --verbose
|
|
80
|
+
|
|
81
|
+
# Export to JSON
|
|
82
|
+
npx ready-to-ship report --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Options
|
|
86
|
+
|
|
87
|
+
- `-p, --path <path>` - Specify project path (default: current directory)
|
|
88
|
+
- `--json` - Export results to JSON (report command only)
|
|
89
|
+
- `--verbose` - Show detailed logs (report command only)
|
|
90
|
+
|
|
91
|
+
## What It Checks
|
|
92
|
+
|
|
93
|
+
### š¹ ENV Module
|
|
94
|
+
- Missing environment variables (compared to `.env.example`)
|
|
95
|
+
- Weak secrets (short JWT_SECRET, etc.)
|
|
96
|
+
- Unused variables
|
|
97
|
+
- Type validation (URL, email, number)
|
|
98
|
+
|
|
99
|
+
### š¹ AUTH Module
|
|
100
|
+
- Unprotected sensitive routes
|
|
101
|
+
- Missing auth middleware
|
|
102
|
+
- JWT expiry configuration
|
|
103
|
+
- Route protection patterns
|
|
104
|
+
|
|
105
|
+
### š¹ API Module
|
|
106
|
+
- Health endpoint presence
|
|
107
|
+
- Route consistency
|
|
108
|
+
- HTTP method patterns
|
|
109
|
+
- RESTful API best practices
|
|
110
|
+
|
|
111
|
+
### š¹ PROJECT Module
|
|
112
|
+
- `.env.example` existence
|
|
113
|
+
- README presence and quality
|
|
114
|
+
- Project structure
|
|
115
|
+
- Error handling middleware
|
|
116
|
+
|
|
117
|
+
### š¹ SECURITY Module
|
|
118
|
+
- CORS configuration
|
|
119
|
+
- Security headers (Helmet.js)
|
|
120
|
+
- Rate limiting
|
|
121
|
+
- Common security anti-patterns
|
|
122
|
+
- eval() usage detection
|
|
123
|
+
|
|
124
|
+
### š¹ DEPENDENCIES Module
|
|
125
|
+
- Lock file presence
|
|
126
|
+
- Outdated packages
|
|
127
|
+
- Security package recommendations
|
|
128
|
+
- Dependency count analysis
|
|
129
|
+
|
|
130
|
+
### š¹ DATABASE Module
|
|
131
|
+
- Database connection configuration
|
|
132
|
+
- Connection error handling
|
|
133
|
+
- Connection pooling
|
|
134
|
+
- Migration files
|
|
135
|
+
- Database type detection
|
|
136
|
+
|
|
137
|
+
## Example Output
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
========================
|
|
141
|
+
READY-TO-SHIP REPORT
|
|
142
|
+
========================
|
|
143
|
+
|
|
144
|
+
ENV: ā
PASS
|
|
145
|
+
AUTH: ā FAIL
|
|
146
|
+
API: ā
PASS
|
|
147
|
+
PROJECT: ā FAIL
|
|
148
|
+
|
|
149
|
+
FINAL VERDICT: ā NOT READY
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## šÆ Why Ready-to-Ship?
|
|
153
|
+
|
|
154
|
+
**Most validation tools only check one thing.** Ready-to-Ship is the **only CLI** that combines:
|
|
155
|
+
- ā
Environment validation
|
|
156
|
+
- ā
Security checks
|
|
157
|
+
- ā
Auth validation
|
|
158
|
+
- ā
API health
|
|
159
|
+
- ā
Dependencies analysis
|
|
160
|
+
- ā
Database configuration
|
|
161
|
+
- ā
Auto-fix suggestions
|
|
162
|
+
|
|
163
|
+
**All in one command.** Save hours of manual review before every deployment.
|
|
164
|
+
|
|
165
|
+
## š CI/CD Integration
|
|
166
|
+
|
|
167
|
+
Add to your GitHub Actions workflow:
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
- name: Run Ready-to-Ship
|
|
171
|
+
run: npx ready-to-ship report --json
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
See `templates/.github/workflows/ready-to-ship.yml` for a complete example.
|
|
175
|
+
|
|
176
|
+
## š Roadmap
|
|
177
|
+
|
|
178
|
+
- [ ] OpenAPI/Swagger spec validation
|
|
179
|
+
- [ ] Docker/container readiness checks
|
|
180
|
+
- [ ] Performance hints
|
|
181
|
+
- [ ] Logging setup validation
|
|
182
|
+
- [ ] VSCode extension
|
|
183
|
+
- [ ] Slack/Discord webhook integration
|
|
184
|
+
|
|
185
|
+
## š¤ Contributing
|
|
186
|
+
|
|
187
|
+
Contributions welcome! Please feel free to submit a Pull Request.
|
|
188
|
+
|
|
189
|
+
## š License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
192
|
+
|
|
193
|
+
## ā Star History
|
|
194
|
+
|
|
195
|
+
If you find this tool useful, please consider giving it a star on GitHub!
|
|
196
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# šÆ What Makes Ready-to-Ship Unique
|
|
2
|
+
|
|
3
|
+
## Comparison with Existing Tools
|
|
4
|
+
|
|
5
|
+
Most validation tools only check **one thing**:
|
|
6
|
+
- `dotenv-safe` - Only checks env variables
|
|
7
|
+
- `eslint-plugin-security` - Only code security
|
|
8
|
+
- `npm audit` - Only dependency vulnerabilities
|
|
9
|
+
- `helmet` - Only security headers (runtime)
|
|
10
|
+
|
|
11
|
+
**Ready-to-Ship combines ALL of these + more in one tool.**
|
|
12
|
+
|
|
13
|
+
## Unique Features
|
|
14
|
+
|
|
15
|
+
### 1. **Comprehensive Validation (7 Modules)**
|
|
16
|
+
- ā
Environment (env vars, secrets, types)
|
|
17
|
+
- ā
Authentication (route protection, JWT)
|
|
18
|
+
- ā
API (health endpoints, consistency)
|
|
19
|
+
- ā
Project (structure, README, error handling)
|
|
20
|
+
- ā
Security (CORS, headers, rate limiting)
|
|
21
|
+
- ā
Dependencies (lock files, outdated packages)
|
|
22
|
+
- ā
Database (connection, pooling, migrations)
|
|
23
|
+
|
|
24
|
+
**No other tool does all of this.**
|
|
25
|
+
|
|
26
|
+
### 2. **Auto-Fix Suggestions**
|
|
27
|
+
Not just detection - **actionable fixes**:
|
|
28
|
+
- Creates `.env.example` if missing
|
|
29
|
+
- Generates README template
|
|
30
|
+
- Suggests security package installations
|
|
31
|
+
- Provides code snippets for fixes
|
|
32
|
+
|
|
33
|
+
### 3. **Zero Configuration**
|
|
34
|
+
Works immediately on any Node.js project:
|
|
35
|
+
- No config files needed
|
|
36
|
+
- Auto-detects project structure
|
|
37
|
+
- Smart pattern matching
|
|
38
|
+
- Framework agnostic
|
|
39
|
+
|
|
40
|
+
### 4. **Beautiful Human-Readable Output**
|
|
41
|
+
- ā
/ā Visual indicators
|
|
42
|
+
- Colored output (chalk)
|
|
43
|
+
- Clear error messages
|
|
44
|
+
- Actionable suggestions
|
|
45
|
+
|
|
46
|
+
### 5. **CI/CD Ready**
|
|
47
|
+
- GitHub Actions templates included
|
|
48
|
+
- JSON export for automation
|
|
49
|
+
- Exit codes for CI integration
|
|
50
|
+
- Artifact upload support
|
|
51
|
+
|
|
52
|
+
### 6. **Extensible Architecture**
|
|
53
|
+
Easy to add new modules:
|
|
54
|
+
- Modular design
|
|
55
|
+
- Shared utilities
|
|
56
|
+
- Consistent API
|
|
57
|
+
- Plugin-ready
|
|
58
|
+
|
|
59
|
+
### 7. **Smart Detection**
|
|
60
|
+
- Auto-detects frameworks (Express, Fastify, Koa, NestJS)
|
|
61
|
+
- Detects database types (MongoDB, PostgreSQL, MySQL, Redis)
|
|
62
|
+
- Finds route files automatically
|
|
63
|
+
- Identifies security patterns
|
|
64
|
+
|
|
65
|
+
## Market Positioning
|
|
66
|
+
|
|
67
|
+
### Target Users
|
|
68
|
+
- **Node.js developers** - Individual developers
|
|
69
|
+
- **SaaS startups** - Small teams without dedicated DevOps
|
|
70
|
+
- **Agencies** - Multiple client projects
|
|
71
|
+
- **Open source maintainers** - Project quality checks
|
|
72
|
+
|
|
73
|
+
### Use Cases
|
|
74
|
+
1. **Pre-deployment checks** - Before pushing to production
|
|
75
|
+
2. **Code review** - Automated quality checks
|
|
76
|
+
3. **CI/CD integration** - Automated validation
|
|
77
|
+
4. **Onboarding** - New team member project review
|
|
78
|
+
5. **Audit** - Security and best practices audit
|
|
79
|
+
|
|
80
|
+
## Competitive Advantages
|
|
81
|
+
|
|
82
|
+
1. **All-in-One** - No need to run 5+ different tools
|
|
83
|
+
2. **Time Saving** - Saves hours of manual review
|
|
84
|
+
3. **Cost Effective** - Free, open source
|
|
85
|
+
4. **Easy to Use** - Single command, zero config
|
|
86
|
+
5. **Actionable** - Not just warnings, but fixes
|
|
87
|
+
6. **Beautiful** - Great developer experience
|
|
88
|
+
|
|
89
|
+
## Why It Will Be Popular
|
|
90
|
+
|
|
91
|
+
1. **Solves Real Problem** - Every backend dev needs this
|
|
92
|
+
2. **Saves Time** - Catches issues before production
|
|
93
|
+
3. **Prevents Costly Mistakes** - Security, env, auth issues
|
|
94
|
+
4. **Shareable** - Teams will recommend it
|
|
95
|
+
5. **Extensible** - Community can add modules
|
|
96
|
+
6. **Well Documented** - Easy to understand and use
|
|
97
|
+
|
|
98
|
+
## Growth Strategy
|
|
99
|
+
|
|
100
|
+
1. **Launch** - Publish to npm, GitHub
|
|
101
|
+
2. **Content** - Blog posts, tutorials
|
|
102
|
+
3. **Community** - Reddit, Twitter, Dev.to
|
|
103
|
+
4. **Word of Mouth** - Developers share tools that save time
|
|
104
|
+
5. **Iterate** - Add features based on feedback
|
|
105
|
+
|
|
106
|
+
## Success Indicators
|
|
107
|
+
|
|
108
|
+
- ā
1000+ npm downloads/week
|
|
109
|
+
- ā
500+ GitHub stars
|
|
110
|
+
- ā
Featured in awesome-nodejs lists
|
|
111
|
+
- ā
Blog posts and tutorials
|
|
112
|
+
- ā
Community contributions
|
|
113
|
+
- ā
Used by major projects
|
|
114
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ready-to-ship",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "š Validate a backend project before deployment like a senior engineer would. Comprehensive checks for env, auth, API, security, dependencies, and database configuration.",
|
|
5
|
+
"main": "src/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ready-to-ship": "src/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node src/cli.js",
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cli",
|
|
15
|
+
"validation",
|
|
16
|
+
"backend",
|
|
17
|
+
"deployment",
|
|
18
|
+
"env",
|
|
19
|
+
"auth",
|
|
20
|
+
"api",
|
|
21
|
+
"readiness",
|
|
22
|
+
"security",
|
|
23
|
+
"dependencies",
|
|
24
|
+
"database",
|
|
25
|
+
"devops",
|
|
26
|
+
"ci-cd",
|
|
27
|
+
"pre-deployment",
|
|
28
|
+
"backend-validator",
|
|
29
|
+
"production-ready",
|
|
30
|
+
"code-review",
|
|
31
|
+
"automation"
|
|
32
|
+
],
|
|
33
|
+
"author": "Aakash Singh <aakashskilldevelopment@gmail.com>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/TheAakashSingh/ready-to-ship.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/TheAakashSingh/ready-to-ship/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/TheAakashSingh/ready-to-ship#readme",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"chalk": "^4.1.2",
|
|
45
|
+
"commander": "^9.4.1",
|
|
46
|
+
"dotenv": "^16.3.1",
|
|
47
|
+
"fs-extra": "^11.1.1",
|
|
48
|
+
"glob": "^10.3.10"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=14.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/publish.sh
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Quick publish script for ready-to-ship CLI
|
|
3
|
+
|
|
4
|
+
echo "š Ready-to-Ship CLI - Publishing to npm"
|
|
5
|
+
echo "=========================================="
|
|
6
|
+
echo ""
|
|
7
|
+
|
|
8
|
+
# Check if logged in
|
|
9
|
+
echo "1. Checking npm login..."
|
|
10
|
+
if ! npm whoami &> /dev/null; then
|
|
11
|
+
echo "ā Not logged in to npm"
|
|
12
|
+
echo " Run: npm login"
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
echo "ā
Logged in as: $(npm whoami)"
|
|
17
|
+
echo ""
|
|
18
|
+
|
|
19
|
+
# Check package name availability
|
|
20
|
+
echo "2. Checking package name availability..."
|
|
21
|
+
if npm view ready-to-ship &> /dev/null; then
|
|
22
|
+
echo "ā Package name 'ready-to-ship' is already taken"
|
|
23
|
+
echo " Consider using: @$(npm whoami)/ready-to-ship"
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
echo "ā
Package name 'ready-to-ship' is available!"
|
|
28
|
+
echo ""
|
|
29
|
+
|
|
30
|
+
# Dry run
|
|
31
|
+
echo "3. Running dry-run (packaging test)..."
|
|
32
|
+
npm pack --dry-run
|
|
33
|
+
echo ""
|
|
34
|
+
|
|
35
|
+
# Ask for confirmation
|
|
36
|
+
read -p "4. Ready to publish? (y/n) " -n 1 -r
|
|
37
|
+
echo ""
|
|
38
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
39
|
+
echo "ā Publishing cancelled"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Publish
|
|
44
|
+
echo "5. Publishing to npm..."
|
|
45
|
+
npm publish
|
|
46
|
+
|
|
47
|
+
if [ $? -eq 0 ]; then
|
|
48
|
+
echo ""
|
|
49
|
+
echo "š SUCCESS! Your package is now live!"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "Install it with:"
|
|
52
|
+
echo " npm install -g ready-to-ship"
|
|
53
|
+
echo ""
|
|
54
|
+
echo "Or use with npx:"
|
|
55
|
+
echo " npx ready-to-ship report"
|
|
56
|
+
echo ""
|
|
57
|
+
echo "View on npm:"
|
|
58
|
+
echo " https://www.npmjs.com/package/ready-to-ship"
|
|
59
|
+
else
|
|
60
|
+
echo ""
|
|
61
|
+
echo "ā Publishing failed. Check the error above."
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const envModule = require('./modules/env');
|
|
6
|
+
const authModule = require('./modules/auth');
|
|
7
|
+
const apiModule = require('./modules/api');
|
|
8
|
+
const projectModule = require('./modules/project');
|
|
9
|
+
const securityModule = require('./modules/security');
|
|
10
|
+
const dependenciesModule = require('./modules/dependencies');
|
|
11
|
+
const databaseModule = require('./modules/database');
|
|
12
|
+
const reportModule = require('./modules/report');
|
|
13
|
+
const { generateFixes } = require('./utils/fixHelpers');
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.name('ready-to-ship')
|
|
17
|
+
.description('Validate a backend project before deployment like a senior engineer would')
|
|
18
|
+
.version('1.0.0');
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command('env')
|
|
22
|
+
.description('Validate .env and env usage')
|
|
23
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const result = await envModule.validate(options.path);
|
|
26
|
+
process.exit(result.passed ? 0 : 1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.command('auth')
|
|
31
|
+
.description('Check auth middleware & route protection')
|
|
32
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
33
|
+
.action(async (options) => {
|
|
34
|
+
const result = await authModule.validate(options.path);
|
|
35
|
+
process.exit(result.passed ? 0 : 1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.command('api')
|
|
40
|
+
.description('Check health endpoint + route consistency')
|
|
41
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
42
|
+
.action(async (options) => {
|
|
43
|
+
const result = await apiModule.validate(options.path);
|
|
44
|
+
process.exit(result.passed ? 0 : 1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
program
|
|
48
|
+
.command('project')
|
|
49
|
+
.description('Check project structure, README, .env.example, error handling')
|
|
50
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
51
|
+
.action(async (options) => {
|
|
52
|
+
const result = await projectModule.validate(options.path);
|
|
53
|
+
process.exit(result.passed ? 0 : 1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
program
|
|
57
|
+
.command('security')
|
|
58
|
+
.description('Check security configurations (CORS, headers, rate limiting)')
|
|
59
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
60
|
+
.action(async (options) => {
|
|
61
|
+
const result = await securityModule.validate(options.path);
|
|
62
|
+
process.exit(result.passed ? 0 : 1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
program
|
|
66
|
+
.command('dependencies')
|
|
67
|
+
.description('Check dependencies for vulnerabilities and best practices')
|
|
68
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
const result = await dependenciesModule.validate(options.path);
|
|
71
|
+
process.exit(result.passed ? 0 : 1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
program
|
|
75
|
+
.command('database')
|
|
76
|
+
.description('Validate database configuration and connection handling')
|
|
77
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
78
|
+
.action(async (options) => {
|
|
79
|
+
const result = await databaseModule.validate(options.path);
|
|
80
|
+
process.exit(result.passed ? 0 : 1);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
program
|
|
84
|
+
.command('report')
|
|
85
|
+
.description('Generate final summary combining all checks')
|
|
86
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
87
|
+
.option('--json', 'Export results to JSON')
|
|
88
|
+
.option('--verbose', 'Show detailed logs')
|
|
89
|
+
.option('--skip <modules>', 'Skip specific modules (comma-separated)', (value) => value.split(','))
|
|
90
|
+
.action(async (options) => {
|
|
91
|
+
const result = await reportModule.generate(options.path, {
|
|
92
|
+
json: options.json,
|
|
93
|
+
verbose: options.verbose,
|
|
94
|
+
skip: options.skip || []
|
|
95
|
+
});
|
|
96
|
+
process.exit(result.passed ? 0 : 1);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
program
|
|
100
|
+
.command('fix')
|
|
101
|
+
.description('Generate auto-fix suggestions for common issues')
|
|
102
|
+
.option('-p, --path <path>', 'Project path (default: current directory)', process.cwd())
|
|
103
|
+
.option('--apply', 'Apply fixes automatically (creates files)')
|
|
104
|
+
.action(async (options) => {
|
|
105
|
+
const { generateFixes, applyFixes } = require('./utils/fixHelpers');
|
|
106
|
+
|
|
107
|
+
// Run all checks to get issues
|
|
108
|
+
const results = {
|
|
109
|
+
env: await envModule.validate(options.path),
|
|
110
|
+
auth: await authModule.validate(options.path),
|
|
111
|
+
api: await apiModule.validate(options.path),
|
|
112
|
+
project: await projectModule.validate(options.path),
|
|
113
|
+
security: await securityModule.validate(options.path)
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Collect all issues
|
|
117
|
+
const allIssues = [];
|
|
118
|
+
Object.values(results).forEach(result => {
|
|
119
|
+
if (result.issues) allIssues.push(...result.issues);
|
|
120
|
+
if (result.warnings) allIssues.push(...result.warnings);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Generate fixes
|
|
124
|
+
const fixes = await generateFixes(allIssues, options.path);
|
|
125
|
+
|
|
126
|
+
if (fixes.length === 0) {
|
|
127
|
+
console.log(chalk.green('\nā
No fixes needed!'));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log(chalk.cyan('\nš§ AUTO-FIX SUGGESTIONS\n'));
|
|
132
|
+
|
|
133
|
+
if (options.apply) {
|
|
134
|
+
const applied = await applyFixes(fixes, options.path, false);
|
|
135
|
+
applied.forEach(fix => {
|
|
136
|
+
if (fix.status === 'created') {
|
|
137
|
+
console.log(chalk.green(`ā
Created: ${fix.filePath}`));
|
|
138
|
+
} else if (fix.status === 'suggestion') {
|
|
139
|
+
console.log(chalk.yellow(`š” ${fix.description}`));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
fixes.forEach((fix, index) => {
|
|
144
|
+
console.log(chalk.yellow(`\n${index + 1}. ${fix.description}`));
|
|
145
|
+
if (fix.type === 'create_file') {
|
|
146
|
+
console.log(chalk.gray(` Would create: ${fix.file}`));
|
|
147
|
+
console.log(chalk.gray(' Run with --apply to create this file'));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
console.log(chalk.cyan('\nš” Run with --apply to automatically create files'));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
program.parse();
|
|
155
|
+
|