dev-doc 0.1.0 → 0.2.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 +28 -52
- package/dist/api.d.ts +59 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +50 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.js +169 -78
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -12,6 +12,18 @@ AI-powered codebase analyzer using Claude AI to generate comprehensive documenta
|
|
|
12
12
|
- 📝 **Structured Output**: Generates Markdown or JSON documentation
|
|
13
13
|
- ⚙️ **Highly Configurable**: Customize ignored directories, file extensions, and more
|
|
14
14
|
|
|
15
|
+
## ⚠️ Important Note
|
|
16
|
+
|
|
17
|
+
**This package requires backend infrastructure to function.**
|
|
18
|
+
|
|
19
|
+
Currently, the CLI requires environment variables (`CLAUDE_API_KEY` and `MONGODB_URI`) that must be configured server-side.
|
|
20
|
+
|
|
21
|
+
For a public npm package, you need to:
|
|
22
|
+
1. Deploy a backend API service (see [DEPLOYMENT_ARCHITECTURE.md](./DEPLOYMENT_ARCHITECTURE.md))
|
|
23
|
+
2. Modify the CLI to call your backend API instead of requiring env vars
|
|
24
|
+
|
|
25
|
+
See [DEPLOYMENT_ARCHITECTURE.md](./DEPLOYMENT_ARCHITECTURE.md) for full details.
|
|
26
|
+
|
|
15
27
|
## Installation
|
|
16
28
|
|
|
17
29
|
```bash
|
|
@@ -28,38 +40,22 @@ npx dev-doc ./src
|
|
|
28
40
|
|
|
29
41
|
### Basic Usage
|
|
30
42
|
|
|
43
|
+
Simply provide the directory path you want to analyze:
|
|
44
|
+
|
|
31
45
|
```bash
|
|
32
46
|
dev-doc ./src
|
|
33
47
|
```
|
|
34
48
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
dev-doc ./src \
|
|
39
|
-
--model claude-3-5-sonnet-20241022 \
|
|
40
|
-
--format markdown \
|
|
41
|
-
--ignore test,dist,node_modules \
|
|
42
|
-
--output docs/analysis.md
|
|
43
|
-
```
|
|
49
|
+
The analysis will be automatically saved to the database - you don't need to specify any output options.
|
|
44
50
|
|
|
45
51
|
### CLI Options
|
|
46
52
|
|
|
47
|
-
-
|
|
48
|
-
- `-m, --model <model>`: Claude model to use (default: `claude-3-5-sonnet-20241022`)
|
|
49
|
-
- `-f, --format <format>`: Output format: `markdown` or `json` (default: `markdown`)
|
|
50
|
-
- `-o, --output <file>`: Output file path (default: stdout)
|
|
53
|
+
- `[directory]`: Directory to analyze (default: current directory)
|
|
51
54
|
- `--ignore <dirs>`: Comma-separated directories to ignore (default: `node_modules,.git,dist,build,.next`)
|
|
52
|
-
- `--extensions <exts>`: Comma-separated file extensions (default: `ts,js,tsx,jsx,json,md`)
|
|
53
|
-
- `--max-chars <number>`: Maximum characters per chunk (default: `12000`)
|
|
54
|
-
- `--max-tokens <number>`: Maximum tokens per API request (default: `800`)
|
|
55
|
-
|
|
56
|
-
## Environment Variables
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
**Note:** All AI processing is handled automatically - no API keys or configuration needed from end users!
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
export CLAUDE_API_KEY="your-api-key-here"
|
|
62
|
-
```
|
|
58
|
+
> **For Package Owners:** Credentials must be set as environment variables in the deployment environment. See [SECURITY.md](./SECURITY.md) for details.
|
|
63
59
|
|
|
64
60
|
## Examples
|
|
65
61
|
|
|
@@ -69,46 +65,26 @@ export CLAUDE_API_KEY="your-api-key-here"
|
|
|
69
65
|
dev-doc .
|
|
70
66
|
```
|
|
71
67
|
|
|
72
|
-
###
|
|
68
|
+
### Analyze Specific Directory
|
|
73
69
|
|
|
74
70
|
```bash
|
|
75
|
-
dev-doc ./src
|
|
71
|
+
dev-doc ./src
|
|
76
72
|
```
|
|
77
73
|
|
|
78
|
-
###
|
|
74
|
+
### Ignore Additional Directories
|
|
79
75
|
|
|
80
76
|
```bash
|
|
81
|
-
dev-doc ./
|
|
82
|
-
--ignore node_modules,dist,tests \
|
|
83
|
-
--extensions ts,js,json \
|
|
84
|
-
--max-chars 10000 \
|
|
85
|
-
--output backend-analysis.md
|
|
77
|
+
dev-doc ./src --ignore node_modules,dist,tests,.next
|
|
86
78
|
```
|
|
87
79
|
|
|
88
|
-
## Output
|
|
89
|
-
|
|
90
|
-
### Markdown Format
|
|
80
|
+
## Output
|
|
91
81
|
|
|
92
|
-
The
|
|
93
|
-
- **Statistics**: Total files and
|
|
82
|
+
The analysis is automatically saved to the database. The generated documentation includes:
|
|
83
|
+
- **Statistics**: Total files analyzed and cached
|
|
94
84
|
- **Technology Stack**: Detected frameworks and libraries
|
|
95
85
|
- **Project Summary**: High-level architecture and insights
|
|
96
86
|
- **File-by-File Analysis**: Detailed analysis for each file
|
|
97
|
-
|
|
98
|
-
### JSON Format
|
|
99
|
-
|
|
100
|
-
The JSON output contains structured data:
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"summary": "...",
|
|
104
|
-
"framework": "...",
|
|
105
|
-
"fileAnalyses": [...],
|
|
106
|
-
"stats": {
|
|
107
|
-
"totalFiles": 10,
|
|
108
|
-
"totalChunks": 15
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
87
|
+
- **API Documentation**: Endpoints, relationships, and authentication flows
|
|
112
88
|
|
|
113
89
|
## How It Works
|
|
114
90
|
|
|
@@ -116,10 +92,10 @@ The JSON output contains structured data:
|
|
|
116
92
|
2. **Change Detection**: Compares file hashes with cache to identify changed files
|
|
117
93
|
3. **Caching**: Uses cached results for unchanged files (dramatically faster on subsequent runs)
|
|
118
94
|
4. **Parallel Processing**: Analyzes multiple files concurrently (3 by default)
|
|
119
|
-
5. **Chunking**: Large files are split into manageable chunks
|
|
95
|
+
5. **Chunking**: Large files are split into manageable chunks for optimal processing
|
|
120
96
|
6. **AI Analysis**: Each chunk is sent to Claude AI for analysis
|
|
121
97
|
7. **Summarization**: Project-level summary is generated from all file analyses
|
|
122
|
-
8. **
|
|
98
|
+
8. **Storage**: Results are automatically saved to the database
|
|
123
99
|
|
|
124
100
|
## Performance
|
|
125
101
|
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface ApiResponse<T> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data?: T;
|
|
4
|
+
error?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface StatusResponse {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
quota: {
|
|
10
|
+
analysesPerMonth: number;
|
|
11
|
+
used: number;
|
|
12
|
+
remaining: number;
|
|
13
|
+
};
|
|
14
|
+
usage: {
|
|
15
|
+
totalAnalyses: number;
|
|
16
|
+
lastAnalysisAt?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface AnalyzeRequest {
|
|
20
|
+
files: Array<{
|
|
21
|
+
path: string;
|
|
22
|
+
relativePath: string;
|
|
23
|
+
content: string;
|
|
24
|
+
}>;
|
|
25
|
+
directory: string;
|
|
26
|
+
ignoreDirs?: string[];
|
|
27
|
+
fileExtensions?: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface AnalyzeResponse {
|
|
30
|
+
success: boolean;
|
|
31
|
+
result: {
|
|
32
|
+
summary: string;
|
|
33
|
+
framework?: string;
|
|
34
|
+
fileAnalyses: Array<{
|
|
35
|
+
path: string;
|
|
36
|
+
relativePath: string;
|
|
37
|
+
analysis: string;
|
|
38
|
+
chunks: number;
|
|
39
|
+
}>;
|
|
40
|
+
stats: {
|
|
41
|
+
totalFiles: number;
|
|
42
|
+
totalChunks: number;
|
|
43
|
+
analyzedFiles: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
quota?: {
|
|
47
|
+
hasQuota: boolean;
|
|
48
|
+
remaining: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check API key status
|
|
53
|
+
*/
|
|
54
|
+
export declare function checkStatus(): Promise<StatusResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Analyze codebase via API
|
|
57
|
+
*/
|
|
58
|
+
export declare function analyzeCodebase(request: AnalyzeRequest): Promise<AnalyzeResponse>;
|
|
59
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QACL,gBAAgB,EAAE,MAAM,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,KAAK,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC;YACjB,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC,CAAC;QACH,KAAK,EAAE;YACL,UAAU,EAAE,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;YACpB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;IACF,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,OAAO,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,CAmB3D;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAqB1B"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkStatus = checkStatus;
|
|
4
|
+
exports.analyzeCodebase = analyzeCodebase;
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
// Hardcoded API URL - this is public and can't be hidden
|
|
7
|
+
const API_URL = "https://dev-doc-726dc734499e.herokuapp.com"; // TODO: Update to your actual API URL when deployed
|
|
8
|
+
/**
|
|
9
|
+
* Check API key status
|
|
10
|
+
*/
|
|
11
|
+
async function checkStatus() {
|
|
12
|
+
const apiKey = (0, config_1.getApiKey)();
|
|
13
|
+
if (!apiKey) {
|
|
14
|
+
throw new Error("No API key found. Run 'dev-doc add-key <api-key>' first.");
|
|
15
|
+
}
|
|
16
|
+
const response = await fetch(`${API_URL}/api/v1/auth/status/apikey`, {
|
|
17
|
+
method: "GET",
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${apiKey}`,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const error = await response.json().catch(() => ({ message: "Status check failed" }));
|
|
24
|
+
throw new Error(error.message || `HTTP ${response.status}: ${response.statusText}`);
|
|
25
|
+
}
|
|
26
|
+
return await response.json();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Analyze codebase via API
|
|
30
|
+
*/
|
|
31
|
+
async function analyzeCodebase(request) {
|
|
32
|
+
const apiKey = (0, config_1.getApiKey)();
|
|
33
|
+
if (!apiKey) {
|
|
34
|
+
throw new Error("No API key found. Run 'dev-doc add-key <api-key>' first.");
|
|
35
|
+
}
|
|
36
|
+
const response = await fetch(`${API_URL}/api/v1/analyze/apikey`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/json",
|
|
40
|
+
Authorization: `Bearer ${apiKey}`,
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify(request),
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const error = await response.json().catch(() => ({ message: "Analysis failed" }));
|
|
46
|
+
throw new Error(error.message || `HTTP ${response.status}: ${response.statusText}`);
|
|
47
|
+
}
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;AA8DA,kCAmBC;AAKD,0CAuBC;AA7GD,qCAAqC;AAErC,yDAAyD;AACzD,MAAM,OAAO,GAAG,4CAA4C,CAAC,CAAC,oDAAoD;AAwDlH;;GAEG;AACI,KAAK,UAAU,WAAW;IAC/B,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,QAAQ,GA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AC,OAAO,IAAI,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAqB,CAAC;AAClD,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -38,112 +38,203 @@ require("dotenv/config");
|
|
|
38
38
|
const commander_1 = require("commander");
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const scanner_1 = require("./scanner");
|
|
42
|
+
const config_1 = require("./config");
|
|
43
|
+
const api_1 = require("./api");
|
|
43
44
|
const program = new commander_1.Command();
|
|
45
|
+
// Hardcoded API URL - this is public anyway and can't be hidden
|
|
46
|
+
const API_URL = "https://dev-doc-726dc734499e.herokuapp.com"; // TODO: Update to your actual API URL when deployed
|
|
44
47
|
program
|
|
45
48
|
.name("dev-doc")
|
|
46
49
|
.description("AI-powered codebase analyzer using Claude AI")
|
|
47
|
-
.version("0.1.0")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
.
|
|
52
|
-
.
|
|
50
|
+
.version("0.1.0");
|
|
51
|
+
// Add API key command
|
|
52
|
+
program
|
|
53
|
+
.command("add-key")
|
|
54
|
+
.alias("set-key")
|
|
55
|
+
.description("Add your API key (get it from https://dev-doc-726dc734499e.herokuapp.com/register)")
|
|
56
|
+
.argument("<api-key>", "Your API key from the website")
|
|
57
|
+
.action(async (apiKey) => {
|
|
58
|
+
try {
|
|
59
|
+
// Validate format (basic check)
|
|
60
|
+
if (!apiKey || apiKey.trim().length < 10) {
|
|
61
|
+
console.error("\n❌ Invalid API key format");
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
// Save API key
|
|
65
|
+
(0, config_1.setApiKey)(apiKey.trim());
|
|
66
|
+
// Verify the key works
|
|
67
|
+
console.log("🔐 Verifying API key...");
|
|
68
|
+
const status = await (0, api_1.checkStatus)();
|
|
69
|
+
console.log("\n✅ API key added successfully!");
|
|
70
|
+
console.log(`\n📊 Quota: ${status.quota.analysesPerMonth} analyses per month`);
|
|
71
|
+
console.log(`📈 Used: ${status.quota.used} / ${status.quota.analysesPerMonth}`);
|
|
72
|
+
console.log(`📉 Remaining: ${status.quota.remaining}`);
|
|
73
|
+
console.log(`\n💡 You can now run: dev-doc ./src`);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("\n❌ Failed to add API key:", error instanceof Error ? error.message : error);
|
|
77
|
+
console.error("\n💡 Make sure:");
|
|
78
|
+
console.error(" 1. Your API key is correct");
|
|
79
|
+
console.error(" 2. You registered at https://dev-doc-726dc734499e.herokuapp.com/register");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// Login command (alias for add-key for convenience)
|
|
84
|
+
program
|
|
85
|
+
.command("login")
|
|
86
|
+
.description("Login with your API key (alias for 'add-key')")
|
|
87
|
+
.argument("<api-key>", "Your API key from the website")
|
|
88
|
+
.action(async (apiKey) => {
|
|
89
|
+
try {
|
|
90
|
+
// Validate format (basic check)
|
|
91
|
+
if (!apiKey || apiKey.trim().length < 10) {
|
|
92
|
+
console.error("\n❌ Invalid API key format");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
// Save API key
|
|
96
|
+
(0, config_1.setApiKey)(apiKey.trim());
|
|
97
|
+
// Verify the key works
|
|
98
|
+
console.log("🔐 Verifying API key...");
|
|
99
|
+
const status = await (0, api_1.checkStatus)();
|
|
100
|
+
console.log("\n✅ Login successful!");
|
|
101
|
+
console.log(`\n📊 Quota: ${status.quota.analysesPerMonth} analyses per month`);
|
|
102
|
+
console.log(`📈 Used: ${status.quota.used} / ${status.quota.analysesPerMonth}`);
|
|
103
|
+
console.log(`📉 Remaining: ${status.quota.remaining}`);
|
|
104
|
+
console.log(`\n💡 You can now run: dev-doc ./src`);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error("\n❌ Login failed:", error instanceof Error ? error.message : error);
|
|
108
|
+
console.error("\n💡 Make sure:");
|
|
109
|
+
console.error(" 1. Your API key is correct");
|
|
110
|
+
console.error(" 2. You registered at https://dev-doc-726dc734499e.herokuapp.com/register");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
// Status command
|
|
115
|
+
program
|
|
116
|
+
.command("status")
|
|
117
|
+
.description("Check your API key status and usage")
|
|
118
|
+
.action(async () => {
|
|
119
|
+
try {
|
|
120
|
+
const status = await (0, api_1.checkStatus)();
|
|
121
|
+
console.log("\n📊 Account Status");
|
|
122
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
123
|
+
console.log(`API Key: ${status.apiKey}...`);
|
|
124
|
+
console.log(`\nQuota:`);
|
|
125
|
+
console.log(` Total: ${status.quota.analysesPerMonth} analyses/month`);
|
|
126
|
+
console.log(` Used: ${status.quota.used}`);
|
|
127
|
+
console.log(` Remaining: ${status.quota.remaining}`);
|
|
128
|
+
console.log(`\nUsage:`);
|
|
129
|
+
console.log(` Total Analyses: ${status.usage.totalAnalyses}`);
|
|
130
|
+
if (status.usage.lastAnalysisAt) {
|
|
131
|
+
console.log(` Last Analysis: ${new Date(status.usage.lastAnalysisAt).toLocaleString()}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error("\n❌ Status check failed:", error instanceof Error ? error.message : error);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
// Shared analyze action function
|
|
140
|
+
const analyzeAction = async (directory, options) => {
|
|
53
141
|
try {
|
|
54
142
|
const targetDir = path.resolve(directory);
|
|
55
143
|
if (!fs.existsSync(targetDir)) {
|
|
56
|
-
console.error(
|
|
144
|
+
console.error(`❌ Error: Directory "${targetDir}" does not exist`);
|
|
57
145
|
process.exit(1);
|
|
58
146
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.error("
|
|
63
|
-
console.error("
|
|
64
|
-
console.error("
|
|
147
|
+
// Check for API key
|
|
148
|
+
const apiKey = (0, config_1.getApiKey)();
|
|
149
|
+
if (!apiKey) {
|
|
150
|
+
console.error("\n❌ No API key found!");
|
|
151
|
+
console.error("\n💡 To get started:");
|
|
152
|
+
console.error(" 1. Register at: https://dev-doc-726dc734499e.herokuapp.com/register");
|
|
153
|
+
console.error(" 2. Add your API key: dev-doc add-key <your-api-key>");
|
|
154
|
+
console.error(" 3. Or use: dev-doc login <your-api-key>");
|
|
65
155
|
process.exit(1);
|
|
66
156
|
}
|
|
67
157
|
const startTime = Date.now();
|
|
68
158
|
const startTimeString = new Date().toLocaleString();
|
|
69
159
|
console.log("🚀 Starting codebase analysis...");
|
|
70
|
-
console.log(`⏰ Start time: ${startTimeString}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
maxCharsPerChunk: 12000,
|
|
160
|
+
console.log(`⏰ Start time: ${startTimeString}`);
|
|
161
|
+
console.log(`📁 Directory: ${targetDir}\n`);
|
|
162
|
+
// Scan files
|
|
163
|
+
console.log("📂 Scanning files...");
|
|
164
|
+
const files = (0, scanner_1.readCodebase)(targetDir, {
|
|
76
165
|
ignoreDirs: options.ignore ? options.ignore.split(",").map((d) => d.trim()) : ["node_modules", ".git", "dist", "build", ".next"],
|
|
77
166
|
fileExtensions: ["ts", "js", "tsx", "jsx", "json", "md"],
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const analyzer = new analyzer_1.CodebaseAnalyzer(analyzerOptions);
|
|
83
|
-
const result = await analyzer.analyze(targetDir);
|
|
84
|
-
// Always save to MongoDB automatically (completely hidden from user)
|
|
85
|
-
const mongoUri = process.env.MONGODB_URI || "mongodb+srv://curtiscrentsil0_db_user:0QgU9UkeSFd4K8BP@devdoc.ptwfvgr.mongodb.net/devdoc?appName=devdoc";
|
|
86
|
-
try {
|
|
87
|
-
// Extract database name from URI
|
|
88
|
-
let databaseName = "devdoc";
|
|
89
|
-
try {
|
|
90
|
-
const uri = new URL(mongoUri);
|
|
91
|
-
const pathParts = uri.pathname.split('/').filter(p => p);
|
|
92
|
-
if (pathParts.length > 0) {
|
|
93
|
-
databaseName = pathParts[0];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
// URI parsing failed, use default
|
|
98
|
-
}
|
|
99
|
-
const mongoConfig = {
|
|
100
|
-
connectionString: mongoUri,
|
|
101
|
-
database: databaseName,
|
|
102
|
-
};
|
|
103
|
-
const mongoStorage = new mongodb_1.MongoDBStorage(mongoConfig);
|
|
104
|
-
await mongoStorage.connect();
|
|
105
|
-
await mongoStorage.saveDocumentation(targetDir, result, "1.0.0");
|
|
106
|
-
await mongoStorage.disconnect();
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
// Silently fail - completely hidden from user
|
|
110
|
-
}
|
|
111
|
-
// Optional: Write to file if requested
|
|
112
|
-
if (options.output) {
|
|
113
|
-
const outputPath = path.resolve(options.output);
|
|
114
|
-
const outputDir = path.dirname(outputPath);
|
|
115
|
-
if (!fs.existsSync(outputDir)) {
|
|
116
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
117
|
-
}
|
|
118
|
-
// Read existing markdown for incremental updates
|
|
119
|
-
let existingMarkdown;
|
|
120
|
-
if (fs.existsSync(outputPath)) {
|
|
121
|
-
try {
|
|
122
|
-
existingMarkdown = fs.readFileSync(outputPath, "utf8");
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
// Ignore errors reading existing file
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const output = analyzer.formatMarkdown(result, existingMarkdown);
|
|
129
|
-
fs.writeFileSync(outputPath, output, "utf8");
|
|
130
|
-
console.log(`\n📄 Analysis saved to: ${outputPath}`);
|
|
167
|
+
});
|
|
168
|
+
if (files.length === 0) {
|
|
169
|
+
console.error("\n❌ No files found to analyze");
|
|
170
|
+
process.exit(1);
|
|
131
171
|
}
|
|
172
|
+
console.log(`✅ Found ${files.length} files\n`);
|
|
173
|
+
// Send to backend API
|
|
174
|
+
console.log("🤖 Analyzing with AI...");
|
|
175
|
+
const response = await (0, api_1.analyzeCodebase)({
|
|
176
|
+
files: files.map((f) => ({
|
|
177
|
+
path: f.path,
|
|
178
|
+
relativePath: f.relativePath,
|
|
179
|
+
content: f.content,
|
|
180
|
+
})),
|
|
181
|
+
directory: targetDir,
|
|
182
|
+
ignoreDirs: options.ignore ? options.ignore.split(",").map((d) => d.trim()) : undefined,
|
|
183
|
+
fileExtensions: ["ts", "js", "tsx", "jsx", "json", "md"],
|
|
184
|
+
});
|
|
132
185
|
const endTime = Date.now();
|
|
133
186
|
const endTimeString = new Date().toLocaleString();
|
|
134
187
|
const duration = ((endTime - startTime) / 1000).toFixed(2);
|
|
135
188
|
const minutes = Math.floor(parseFloat(duration) / 60);
|
|
136
189
|
const seconds = (parseFloat(duration) % 60).toFixed(2);
|
|
137
190
|
const durationString = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
191
|
+
// Display results
|
|
192
|
+
console.log("\n" + "=".repeat(60));
|
|
193
|
+
console.log("📊 ANALYSIS RESULTS");
|
|
194
|
+
console.log("=".repeat(60));
|
|
195
|
+
if (response.result.framework) {
|
|
196
|
+
console.log(`\n🎯 Framework: ${response.result.framework}`);
|
|
197
|
+
}
|
|
198
|
+
console.log(`\n📈 Statistics:`);
|
|
199
|
+
console.log(` - Total Files: ${response.result.stats.totalFiles}`);
|
|
200
|
+
console.log(` - Analyzed: ${response.result.stats.analyzedFiles}`);
|
|
201
|
+
console.log(` - Total Chunks: ${response.result.stats.totalChunks}`);
|
|
202
|
+
if (response.quota) {
|
|
203
|
+
console.log(`\n📊 Quota:`);
|
|
204
|
+
console.log(` - Remaining: ${response.quota.remaining} analyses`);
|
|
205
|
+
}
|
|
206
|
+
console.log(`\n⏱️ Duration: ${durationString}`);
|
|
207
|
+
console.log(`\n📝 Summary:`);
|
|
208
|
+
console.log("-".repeat(60));
|
|
209
|
+
console.log(response.result.summary);
|
|
210
|
+
console.log("-".repeat(60));
|
|
138
211
|
console.log(`\n✅ Analysis complete!`);
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(` - Cached: ${result.stats.cachedFiles} files`);
|
|
141
|
-
console.log(` - Duration: ${durationString}`);
|
|
212
|
+
console.log(`\n💡 Results have been saved to the database.`);
|
|
142
213
|
}
|
|
143
214
|
catch (error) {
|
|
144
215
|
console.error("\n❌ Error:", error instanceof Error ? error.message : error);
|
|
216
|
+
if (error instanceof Error && error.message.includes("401")) {
|
|
217
|
+
console.error("\n💡 Your API key may be invalid. Try: dev-doc add-key <your-api-key>");
|
|
218
|
+
console.error(" Or get a new key at: https://dev-doc-726dc734499e.herokuapp.com/register");
|
|
219
|
+
}
|
|
220
|
+
else if (error instanceof Error && error.message.includes("429")) {
|
|
221
|
+
console.error("\n💡 You've reached your quota limit. Check status: dev-doc status");
|
|
222
|
+
}
|
|
145
223
|
process.exit(1);
|
|
146
224
|
}
|
|
147
|
-
}
|
|
225
|
+
};
|
|
226
|
+
// Analyze command
|
|
227
|
+
program
|
|
228
|
+
.command("analyze")
|
|
229
|
+
.alias("a")
|
|
230
|
+
.description("Analyze a codebase (default command)")
|
|
231
|
+
.argument("[directory]", "Directory to analyze", process.cwd())
|
|
232
|
+
.option("--ignore <dirs>", "Directories to ignore (comma-separated)", "node_modules,.git,dist,build,.next")
|
|
233
|
+
.action(analyzeAction);
|
|
234
|
+
// Default command (analyze)
|
|
235
|
+
program
|
|
236
|
+
.argument("[directory]", "Directory to analyze", process.cwd())
|
|
237
|
+
.option("--ignore <dirs>", "Directories to ignore (comma-separated)", "node_modules,.git,dist,build,.next")
|
|
238
|
+
.action(analyzeAction);
|
|
148
239
|
program.parse();
|
|
149
240
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yBAAuB;AACvB,yCAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yBAAuB;AACvB,yCAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyC;AACzC,qCAAgD;AAChD,+BAAqD;AAErD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,gEAAgE;AAChE,MAAM,OAAO,GAAG,4CAA4C,CAAC,CAAC,oDAAoD;AAElH,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,8CAA8C,CAAC;KAC3D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,sBAAsB;AACtB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,KAAK,CAAC,SAAS,CAAC;KAChB,WAAW,CAAC,oFAAoF,CAAC;KACjG,QAAQ,CAAC,WAAW,EAAE,+BAA+B,CAAC;KACtD,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;IAC/B,IAAI,CAAC;QACH,gCAAgC;QAChC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACzC,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,eAAe;QACf,IAAA,kBAAS,EAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAEzB,uBAAuB;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,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEJ,kBAAkB;AAClB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,KAAK,CAAC,GAAG,CAAC;KACV,WAAW,CAAC,sCAAsC,CAAC;KACnD,QAAQ,CAAC,aAAa,EAAE,sBAAsB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KAC9D,MAAM,CAAC,iBAAiB,EAAE,yCAAyC,EAAE,oCAAoC,CAAC;KAC1G,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,4BAA4B;AAC5B,OAAO;KACJ,QAAQ,CAAC,aAAa,EAAE,sBAAsB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KAC9D,MAAM,CAAC,iBAAiB,EAAE,yCAAyC,EAAE,oCAAoC,CAAC;KAC1G,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Get the config directory path
|
|
6
|
+
*/
|
|
7
|
+
export declare function getConfigDir(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Get the config file path
|
|
10
|
+
*/
|
|
11
|
+
export declare function getConfigFile(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Load configuration from file
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadConfig(): Config;
|
|
16
|
+
/**
|
|
17
|
+
* Save configuration to file
|
|
18
|
+
*/
|
|
19
|
+
export declare function saveConfig(config: Config): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get API key from config
|
|
22
|
+
*/
|
|
23
|
+
export declare function getApiKey(): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Set API key in config
|
|
26
|
+
*/
|
|
27
|
+
export declare function setApiKey(apiKey: string): void;
|
|
28
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAUnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAe/C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAG9C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getConfigDir = getConfigDir;
|
|
37
|
+
exports.getConfigFile = getConfigFile;
|
|
38
|
+
exports.loadConfig = loadConfig;
|
|
39
|
+
exports.saveConfig = saveConfig;
|
|
40
|
+
exports.getApiKey = getApiKey;
|
|
41
|
+
exports.setApiKey = setApiKey;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const CONFIG_DIR = path.join(os.homedir(), ".dev-doc");
|
|
46
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
47
|
+
/**
|
|
48
|
+
* Get the config directory path
|
|
49
|
+
*/
|
|
50
|
+
function getConfigDir() {
|
|
51
|
+
return CONFIG_DIR;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the config file path
|
|
55
|
+
*/
|
|
56
|
+
function getConfigFile() {
|
|
57
|
+
return CONFIG_FILE;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load configuration from file
|
|
61
|
+
*/
|
|
62
|
+
function loadConfig() {
|
|
63
|
+
try {
|
|
64
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
65
|
+
const content = fs.readFileSync(CONFIG_FILE, "utf8");
|
|
66
|
+
return JSON.parse(content);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.warn("Failed to load config:", error);
|
|
71
|
+
}
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Save configuration to file
|
|
76
|
+
*/
|
|
77
|
+
function saveConfig(config) {
|
|
78
|
+
try {
|
|
79
|
+
// Ensure config directory exists
|
|
80
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
81
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
// Load existing config and merge
|
|
84
|
+
const existing = loadConfig();
|
|
85
|
+
const merged = { ...existing, ...config };
|
|
86
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2), "utf8");
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new Error(`Failed to save config: ${error instanceof Error ? error.message : error}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get API key from config
|
|
94
|
+
*/
|
|
95
|
+
function getApiKey() {
|
|
96
|
+
const config = loadConfig();
|
|
97
|
+
return config.apiKey;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Set API key in config
|
|
101
|
+
*/
|
|
102
|
+
function setApiKey(apiKey) {
|
|
103
|
+
saveConfig({ apiKey });
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oCAEC;AAKD,sCAEC;AAKD,gCAUC;AAKD,gCAeC;AAKD,8BAGC;AAKD,8BAEC;AAzED,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAMz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AAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dev-doc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "AI-powered codebase analyzer using Claude AI to generate documentation and insights",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"start": "node dist/cli.js",
|
|
12
12
|
"dev": "ts-node src/cli.ts",
|
|
13
|
-
"test:backend": "ts-node src/cli.ts test-backend/src --format markdown --output test-backend/ANALYSIS.md",
|
|
14
|
-
"test:backend:db": "ts-node src/cli.ts test-backend/src --format markdown --output test-backend/ANALYSIS.md --save-to-db",
|
|
15
13
|
"prepublishOnly": "npm run build"
|
|
16
14
|
},
|
|
17
15
|
"keywords": [
|
|
@@ -29,10 +27,8 @@
|
|
|
29
27
|
"url": ""
|
|
30
28
|
},
|
|
31
29
|
"dependencies": {
|
|
32
|
-
"@anthropic-ai/sdk": "^0.24.0",
|
|
33
30
|
"commander": "^11.1.0",
|
|
34
|
-
"dotenv": "^16.6.1"
|
|
35
|
-
"mongodb": "^6.21.0"
|
|
31
|
+
"dotenv": "^16.6.1"
|
|
36
32
|
},
|
|
37
33
|
"devDependencies": {
|
|
38
34
|
"@types/node": "^20.10.0",
|