kodevu 0.1.67 → 0.1.69
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/package.json +7 -2
- package/src/logger.js +21 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kodevu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Poll SVN revisions or Git commits, send each change diff to a reviewer CLI, and write configurable review reports.",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"start": "node src/index.js",
|
|
17
|
-
"check": "node --check src/index.js && node --check src/config.js && node --check src/review-runner.js && node --check src/svn-client.js && node --check src/git-client.js && node --check src/vcs-client.js && node --check src/shell.js && node --check src/progress-ui.js"
|
|
17
|
+
"check": "node --check src/index.js && node --check src/config.js && node --check src/review-runner.js && node --check src/svn-client.js && node --check src/git-client.js && node --check src/vcs-client.js && node --check src/shell.js && node --check src/progress-ui.js",
|
|
18
|
+
"lint": "eslint . --ext .js",
|
|
19
|
+
"lint:fix": "eslint . --ext .js --fix"
|
|
18
20
|
},
|
|
19
21
|
"engines": {
|
|
20
22
|
"node": ">=20"
|
|
@@ -23,5 +25,8 @@
|
|
|
23
25
|
"cross-spawn": "^7.0.6",
|
|
24
26
|
"fast-xml-parser": "^5.2.5",
|
|
25
27
|
"iconv-lite": "^0.6.3"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"eslint": "^10.1.0"
|
|
26
31
|
}
|
|
27
32
|
}
|
package/src/logger.js
CHANGED
|
@@ -78,7 +78,7 @@ class Logger {
|
|
|
78
78
|
const date = formatDate(new Date()).split(" ")[0];
|
|
79
79
|
this.logFile = path.join(config.logsDir, `run-${date}.log`);
|
|
80
80
|
|
|
81
|
-
// Simple rotation:
|
|
81
|
+
// Simple rotation: Keep the most recent 7 log files
|
|
82
82
|
this.#cleanupOldLogs(config.logsDir);
|
|
83
83
|
this.initialized = true;
|
|
84
84
|
} catch (err) {
|
|
@@ -161,21 +161,32 @@ class Logger {
|
|
|
161
161
|
].join("-");
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
164
|
#cleanupOldLogs(logsDir) {
|
|
167
165
|
try {
|
|
168
166
|
const files = fs.readdirSync(logsDir);
|
|
169
|
-
const now = Date.now();
|
|
170
|
-
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
171
167
|
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
const logFiles = files
|
|
169
|
+
.filter((file) => file.startsWith("run-") && file.endsWith(".log"))
|
|
170
|
+
.map((file) => {
|
|
174
171
|
const filePath = path.join(logsDir, file);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
try {
|
|
173
|
+
const stats = fs.statSync(filePath);
|
|
174
|
+
return { file, path: filePath, mtime: stats.mtimeMs };
|
|
175
|
+
} catch {
|
|
176
|
+
return null;
|
|
178
177
|
}
|
|
178
|
+
})
|
|
179
|
+
.filter(Boolean)
|
|
180
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
181
|
+
|
|
182
|
+
const KEEP_COUNT = 7;
|
|
183
|
+
const toRemove = logFiles.slice(KEEP_COUNT);
|
|
184
|
+
|
|
185
|
+
for (const entry of toRemove) {
|
|
186
|
+
try {
|
|
187
|
+
fs.unlinkSync(entry.path);
|
|
188
|
+
} catch {
|
|
189
|
+
// Ignore individual deletion errors
|
|
179
190
|
}
|
|
180
191
|
}
|
|
181
192
|
} catch (err) {
|