@empline/preflight 1.1.14 → 1.1.15
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/dist/checks/auth/session-provider-wrapper.d.ts +47 -0
- package/dist/checks/auth/session-provider-wrapper.d.ts.map +1 -0
- package/dist/checks/auth/session-provider-wrapper.js +286 -0
- package/dist/checks/auth/session-provider-wrapper.js.map +1 -0
- package/dist/checks/database/prisma-upsert-safety.d.ts +39 -0
- package/dist/checks/database/prisma-upsert-safety.d.ts.map +1 -0
- package/dist/checks/database/prisma-upsert-safety.js +220 -0
- package/dist/checks/database/prisma-upsert-safety.js.map +1 -0
- package/dist/checks/dependencies/dependency-health-monitor.d.ts +49 -0
- package/dist/checks/dependencies/dependency-health-monitor.d.ts.map +1 -0
- package/dist/checks/dependencies/dependency-health-monitor.js +323 -0
- package/dist/checks/dependencies/dependency-health-monitor.js.map +1 -0
- package/dist/checks/file-hygiene-validation.d.ts +31 -0
- package/dist/checks/file-hygiene-validation.d.ts.map +1 -0
- package/dist/checks/file-hygiene-validation.js +934 -0
- package/dist/checks/file-hygiene-validation.js.map +1 -0
- package/dist/checks/organization/file-cleanup-validation.d.ts +22 -0
- package/dist/checks/organization/file-cleanup-validation.d.ts.map +1 -0
- package/dist/checks/organization/file-cleanup-validation.js +1121 -0
- package/dist/checks/organization/file-cleanup-validation.js.map +1 -0
- package/dist/checks/runtime/tailwind-runtime-check.d.ts +36 -0
- package/dist/checks/runtime/tailwind-runtime-check.d.ts.map +1 -0
- package/dist/checks/runtime/tailwind-runtime-check.js +264 -0
- package/dist/checks/runtime/tailwind-runtime-check.js.map +1 -0
- package/dist/checks/shipping-integration-validation.d.ts +28 -0
- package/dist/checks/shipping-integration-validation.d.ts.map +1 -0
- package/dist/checks/shipping-integration-validation.js +409 -0
- package/dist/checks/shipping-integration-validation.js.map +1 -0
- package/dist/checks/system/layout-constants-sync.d.ts +36 -0
- package/dist/checks/system/layout-constants-sync.d.ts.map +1 -0
- package/dist/checks/system/layout-constants-sync.js +642 -0
- package/dist/checks/system/layout-constants-sync.js.map +1 -0
- package/dist/checks/system/preflight-circular-dependency-detector.d.ts +26 -0
- package/dist/checks/system/preflight-circular-dependency-detector.d.ts.map +1 -0
- package/dist/checks/system/preflight-circular-dependency-detector.js +310 -0
- package/dist/checks/system/preflight-circular-dependency-detector.js.map +1 -0
- package/dist/checks/system/preflight-execution-benchmarks.d.ts +24 -0
- package/dist/checks/system/preflight-execution-benchmarks.d.ts.map +1 -0
- package/dist/checks/system/preflight-execution-benchmarks.js +282 -0
- package/dist/checks/system/preflight-execution-benchmarks.js.map +1 -0
- package/dist/checks/system/preflight-tag-taxonomy-validator.d.ts +27 -0
- package/dist/checks/system/preflight-tag-taxonomy-validator.d.ts.map +1 -0
- package/dist/checks/system/preflight-tag-taxonomy-validator.js +361 -0
- package/dist/checks/system/preflight-tag-taxonomy-validator.js.map +1 -0
- package/dist/utils/console-chars.d.ts +16 -0
- package/dist/utils/console-chars.d.ts.map +1 -1
- package/dist/utils/console-chars.js +10 -0
- package/dist/utils/console-chars.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* File Cleanup Validation Preflight
|
|
5
|
+
*
|
|
6
|
+
* Detects and reports files/folders that can be safely removed:
|
|
7
|
+
* - Temporary report files
|
|
8
|
+
* - Old backup directories
|
|
9
|
+
* - Empty directories
|
|
10
|
+
* - Duplicate config files
|
|
11
|
+
* - Build artifacts that shouldn't be committed
|
|
12
|
+
* - Log files and debug outputs
|
|
13
|
+
*
|
|
14
|
+
* BLOCKING: Prevents builds when cleanup is needed
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.tags = exports.description = exports.blocking = exports.category = exports.name = exports.id = void 0;
|
|
21
|
+
exports.run = run;
|
|
22
|
+
const fs_1 = __importDefault(require("fs"));
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const console_chars_1 = require("../../utils/console-chars");
|
|
25
|
+
const universal_progress_reporter_1 = require("../system/universal-progress-reporter");
|
|
26
|
+
// Check metadata
|
|
27
|
+
exports.id = "organization/file-cleanup-validation";
|
|
28
|
+
exports.name = "File Cleanup Validation";
|
|
29
|
+
exports.category = "organization";
|
|
30
|
+
exports.blocking = false;
|
|
31
|
+
exports.description = "File Cleanup Validation Preflight";
|
|
32
|
+
exports.tags = ["organization", "validation"];
|
|
33
|
+
const projectRoot = process.cwd();
|
|
34
|
+
// Patterns for files that should be cleaned up
|
|
35
|
+
const CLEANUP_PATTERNS = {
|
|
36
|
+
// Temporary report files (root level)
|
|
37
|
+
TEMP_REPORTS: [
|
|
38
|
+
/^consistency_report\.txt$/,
|
|
39
|
+
/^coverage_final\.txt$/,
|
|
40
|
+
/^coverage_report_v\d+\.txt$/,
|
|
41
|
+
/^current_test_output\.txt$/,
|
|
42
|
+
/^current_violations.*\.txt$/,
|
|
43
|
+
/^design_report\.txt$/,
|
|
44
|
+
/^dry_report.*\.txt$/,
|
|
45
|
+
/^final_verification\.txt$/,
|
|
46
|
+
/^fix_log\.txt$/,
|
|
47
|
+
/^framework-clean-log\.txt$/,
|
|
48
|
+
/^gaps\.txt$/,
|
|
49
|
+
/^latest_coverage_report\.txt$/,
|
|
50
|
+
/^lint_.*\.txt$/,
|
|
51
|
+
/^lint-summary\.txt$/,
|
|
52
|
+
/^preflight_.*\.txt$/,
|
|
53
|
+
/^preflight_.*\.log$/,
|
|
54
|
+
/^prisma-check\.txt$/,
|
|
55
|
+
/^secrets\.log$/,
|
|
56
|
+
/^shared_report\.txt$/,
|
|
57
|
+
/^test_output.*\.txt$/,
|
|
58
|
+
/^tsc.*output.*\.txt$/,
|
|
59
|
+
/^unified_report\.txt$/,
|
|
60
|
+
/^cycles\.log$/,
|
|
61
|
+
/^tokenization-.*\.txt$/,
|
|
62
|
+
/^eslint-.*\.txt$/,
|
|
63
|
+
/^missing-.*\.txt$/,
|
|
64
|
+
/^nested-.*\.txt$/,
|
|
65
|
+
/^page-template-.*\.txt$/,
|
|
66
|
+
/^temp-.*\.txt$/,
|
|
67
|
+
],
|
|
68
|
+
// Build artifacts that shouldn't be committed
|
|
69
|
+
BUILD_ARTIFACTS: [
|
|
70
|
+
/^\.tsbuildinfo$/,
|
|
71
|
+
/^tsconfig\..*\.tsbuildinfo$/,
|
|
72
|
+
/^debug-plugins\.(cjs|mjs)$/,
|
|
73
|
+
/^eng\.traineddata$/, // OCR training data
|
|
74
|
+
/^\.next\/trace$/,
|
|
75
|
+
/^\.next\/trace-build$/,
|
|
76
|
+
/^\.next\/turbopack$/,
|
|
77
|
+
],
|
|
78
|
+
// Cache and temporary directories
|
|
79
|
+
CACHE_DIRS: [
|
|
80
|
+
/^\.next\/cache\/.*$/,
|
|
81
|
+
/^\.swc\/plugins\/.*$/,
|
|
82
|
+
/^node_modules\/\.cache\/.*$/,
|
|
83
|
+
/^test-results\/artifacts\/.*$/,
|
|
84
|
+
],
|
|
85
|
+
// Old backup directories (older than 30 days)
|
|
86
|
+
OLD_BACKUPS: [
|
|
87
|
+
/^\.kiro\/steering-backup-\d{4}-\d{2}-\d{2}-\d{6}$/,
|
|
88
|
+
/^\.kiro\/feature-specs-backup-.*$/,
|
|
89
|
+
/^\.kiro\/specs-backup-.*$/,
|
|
90
|
+
/^\.kiro\/settings-backup-.*$/,
|
|
91
|
+
/^\.kiro\/hooks-backup-.*$/,
|
|
92
|
+
/^backups\/tmp$/,
|
|
93
|
+
/^backups\/.*\.bak$/,
|
|
94
|
+
/^backups\/.*\.backup$/,
|
|
95
|
+
/^backups\/reference-data\/.*\.json\.old$/,
|
|
96
|
+
/^backups\/prisma\/.*\.sql\.old$/,
|
|
97
|
+
/^backups\/pre-deployment\/.*\.old$/,
|
|
98
|
+
/^.*\.prisma\.backup$/,
|
|
99
|
+
/^.*\.json\.backup$/,
|
|
100
|
+
/^.*\.js\.backup$/,
|
|
101
|
+
/^.*\.ts\.backup$/,
|
|
102
|
+
/^.*\.tsx\.backup$/,
|
|
103
|
+
/^.*\.css\.backup$/,
|
|
104
|
+
/^.*\.md\.backup$/,
|
|
105
|
+
/^.*\.yml\.backup$/,
|
|
106
|
+
/^.*\.yaml\.backup$/,
|
|
107
|
+
/^.*\.config\.backup$/,
|
|
108
|
+
],
|
|
109
|
+
// Report directories with old files
|
|
110
|
+
REPORT_DIRS: [
|
|
111
|
+
/^reports\/cleanup-report-\d+\.json$/,
|
|
112
|
+
/^reports\/eslint-errors\.json$/,
|
|
113
|
+
/^reports\/logs\/.*\.log$/,
|
|
114
|
+
/^reports\/logs\/.*\.txt$/,
|
|
115
|
+
/^reports\/logs\/.*\.json$/,
|
|
116
|
+
/^reports\/typecheck\/.*\.txt$/,
|
|
117
|
+
/^reports\/typecheck\/.*\.log$/,
|
|
118
|
+
/^reports\/analysis\/.*\.txt$/,
|
|
119
|
+
/^reports\/analysis\/.*\.json$/,
|
|
120
|
+
/^reports\/performance\/.*\.json$/,
|
|
121
|
+
/^reports\/security\/.*\.json$/,
|
|
122
|
+
/^reports\/accessibility\/.*\.json$/,
|
|
123
|
+
/^reports\/seo\/.*\.json$/,
|
|
124
|
+
/^reports\/bundle\/.*\.html$/,
|
|
125
|
+
/^reports\/coverage\/.*\.json$/,
|
|
126
|
+
/^reports\/lighthouse\/.*\.json$/,
|
|
127
|
+
],
|
|
128
|
+
// Test artifacts and logs
|
|
129
|
+
TEST_ARTIFACTS: [
|
|
130
|
+
/^test-results\/.*\.log$/,
|
|
131
|
+
/^test-results\/junit\.xml$/,
|
|
132
|
+
/^test-results\/results\.json$/,
|
|
133
|
+
/^test-results\/e2e-slowest\.json$/,
|
|
134
|
+
/^test-results\/account-profile-targeted.*\.log$/,
|
|
135
|
+
/^test-results\/targeted-e2e\.log$/,
|
|
136
|
+
/^test-results\/dev-server\.log$/,
|
|
137
|
+
/^test-results\/artifacts\/.*$/,
|
|
138
|
+
/^test-results\/html\/.*$/,
|
|
139
|
+
/^playwright-report\/.*$/,
|
|
140
|
+
/^coverage\/.*$/,
|
|
141
|
+
/^storybook-static\/.*$/,
|
|
142
|
+
/^.*-test-report\.html$/,
|
|
143
|
+
/^.*-coverage\.json$/,
|
|
144
|
+
/^.*-trace\.zip$/,
|
|
145
|
+
/^.*-screenshots\.zip$/,
|
|
146
|
+
/^.*-videos\.zip$/,
|
|
147
|
+
/^mutation-testing-report\.html$/,
|
|
148
|
+
/^integration-test-logs\.txt$/,
|
|
149
|
+
/^e2e-test-artifacts\.zip$/,
|
|
150
|
+
/^performance-test-results\.json$/,
|
|
151
|
+
],
|
|
152
|
+
// Development artifacts
|
|
153
|
+
DEV_ARTIFACTS: [
|
|
154
|
+
/^\.env\.vercel\.local$/,
|
|
155
|
+
/^\.env\.preview$/,
|
|
156
|
+
/^\.env\.playwright$/,
|
|
157
|
+
/^runtime-errors\.json$/,
|
|
158
|
+
/^\.playwright-storage\.json$/,
|
|
159
|
+
/^preflight-results\.json$/,
|
|
160
|
+
/^workspace-state\.json$/,
|
|
161
|
+
/^session-data\.json$/,
|
|
162
|
+
/^user-preferences\.json$/,
|
|
163
|
+
/^recent-files\.json$/,
|
|
164
|
+
/^search-history\.json$/,
|
|
165
|
+
/^command-history\.txt$/,
|
|
166
|
+
/^editor-state\.json$/,
|
|
167
|
+
/^breakpoints\.json$/,
|
|
168
|
+
/^debug-output\.txt$/,
|
|
169
|
+
/^debug-trace\.log$/,
|
|
170
|
+
/^memory-usage\.log$/,
|
|
171
|
+
/^cpu-profile\.json$/,
|
|
172
|
+
/^heap-snapshot\.heapsnapshot$/,
|
|
173
|
+
/^flame-graph\.html$/,
|
|
174
|
+
/^profiling-results\.json$/,
|
|
175
|
+
/^benchmark-results\.txt$/,
|
|
176
|
+
/^load-test-results\.json$/,
|
|
177
|
+
/^stress-test-output\.txt$/,
|
|
178
|
+
],
|
|
179
|
+
// Package manager artifacts
|
|
180
|
+
PACKAGE_ARTIFACTS: [
|
|
181
|
+
/^pnpm-debug\.log.*$/,
|
|
182
|
+
/^npm-debug\.log.*$/,
|
|
183
|
+
/^yarn-debug\.log.*$/,
|
|
184
|
+
/^yarn-error\.log.*$/,
|
|
185
|
+
/^lerna-debug\.log.*$/,
|
|
186
|
+
/^\.pnpm-debug\.log$/,
|
|
187
|
+
/^\.npm-debug\.log$/,
|
|
188
|
+
/^\.yarn-integrity$/,
|
|
189
|
+
/^\.yarn-metadata\.json$/,
|
|
190
|
+
],
|
|
191
|
+
// Empty or near-empty files
|
|
192
|
+
EMPTY_FILES: [
|
|
193
|
+
/^\.env\..*$/, // Check for empty env files
|
|
194
|
+
/^.*\.tmp$/,
|
|
195
|
+
/^.*\.temp$/,
|
|
196
|
+
/^.*\.bak$/,
|
|
197
|
+
/^.*\.backup$/,
|
|
198
|
+
/^.*\.old$/,
|
|
199
|
+
/^.*\.orig$/,
|
|
200
|
+
/^.*~$/,
|
|
201
|
+
],
|
|
202
|
+
// Large files that might be artifacts (>50MB)
|
|
203
|
+
LARGE_FILES: [
|
|
204
|
+
/^.*\.(dump|sql\.gz|tar\.gz|zip|7z|rar)$/,
|
|
205
|
+
/^.*\.heapsnapshot$/,
|
|
206
|
+
/^.*\.cpuprofile$/,
|
|
207
|
+
/^.*\.trace$/,
|
|
208
|
+
],
|
|
209
|
+
// IDE and editor artifacts
|
|
210
|
+
IDE_ARTIFACTS: [
|
|
211
|
+
/^\.DS_Store$/,
|
|
212
|
+
/^Thumbs\.db$/,
|
|
213
|
+
/^desktop\.ini$/,
|
|
214
|
+
/^\.vscode\/settings\.json\.backup$/,
|
|
215
|
+
/^\.idea\/workspace\.xml$/,
|
|
216
|
+
/^\.idea\/tasks\.xml$/,
|
|
217
|
+
/^\.idea\/usage\.statistics\.xml$/,
|
|
218
|
+
/^\.idea\/shelf\/.*$/,
|
|
219
|
+
/^\.vs\/.*$/,
|
|
220
|
+
],
|
|
221
|
+
// Version control artifacts
|
|
222
|
+
VCS_ARTIFACTS: [
|
|
223
|
+
/^\.git\/hooks\/.*\.sample$/,
|
|
224
|
+
/^\.git\/logs\/.*$/,
|
|
225
|
+
/^\.git\/refs\/remotes\/.*$/,
|
|
226
|
+
/^\.gitignore\.backup$/,
|
|
227
|
+
/^\.gitattributes\.backup$/,
|
|
228
|
+
],
|
|
229
|
+
// Documentation artifacts
|
|
230
|
+
DOC_ARTIFACTS: [
|
|
231
|
+
/^.*\.md\.backup$/,
|
|
232
|
+
/^.*\.md\.tmp$/,
|
|
233
|
+
/^README\.md\.old$/,
|
|
234
|
+
/^CHANGELOG\.md\.backup$/,
|
|
235
|
+
/^docs\/.*\.tmp$/,
|
|
236
|
+
],
|
|
237
|
+
};
|
|
238
|
+
// Directories that should be checked for emptiness
|
|
239
|
+
const CHECK_EMPTY_DIRS = [
|
|
240
|
+
"backups/tmp",
|
|
241
|
+
"reports/logs",
|
|
242
|
+
"reports/typecheck",
|
|
243
|
+
".kiro/feature-specs",
|
|
244
|
+
".kiro/specs",
|
|
245
|
+
"test-results/artifacts",
|
|
246
|
+
"coverage",
|
|
247
|
+
"playwright-report",
|
|
248
|
+
".next/cache",
|
|
249
|
+
".swc/plugins",
|
|
250
|
+
"node_modules/.cache",
|
|
251
|
+
"storybook-static",
|
|
252
|
+
"temp",
|
|
253
|
+
"tmp",
|
|
254
|
+
"logs",
|
|
255
|
+
"debug",
|
|
256
|
+
"profiling",
|
|
257
|
+
"benchmarks",
|
|
258
|
+
"artifacts",
|
|
259
|
+
"dist/temp",
|
|
260
|
+
"build/temp",
|
|
261
|
+
"public/temp",
|
|
262
|
+
"static/temp",
|
|
263
|
+
".vercel/cache",
|
|
264
|
+
".vs/temp",
|
|
265
|
+
".vscode/temp",
|
|
266
|
+
"prisma/migrations/.tmp",
|
|
267
|
+
"prisma/temp",
|
|
268
|
+
".git/hooks/temp",
|
|
269
|
+
".github/temp",
|
|
270
|
+
"docs/temp",
|
|
271
|
+
"styles/temp",
|
|
272
|
+
"types/temp",
|
|
273
|
+
"contexts/temp",
|
|
274
|
+
"hooks/temp",
|
|
275
|
+
"email-templates/temp",
|
|
276
|
+
"scripts/temp",
|
|
277
|
+
"lib/temp",
|
|
278
|
+
"app/temp",
|
|
279
|
+
"components/temp",
|
|
280
|
+
"packages/temp",
|
|
281
|
+
"stories/temp",
|
|
282
|
+
];
|
|
283
|
+
// Additional directories to scan for cleanup
|
|
284
|
+
const SCAN_DIRECTORIES = [
|
|
285
|
+
".next",
|
|
286
|
+
".swc",
|
|
287
|
+
"test-results",
|
|
288
|
+
"reports",
|
|
289
|
+
"backups",
|
|
290
|
+
"coverage",
|
|
291
|
+
"playwright-report",
|
|
292
|
+
"storybook-static",
|
|
293
|
+
".kiro",
|
|
294
|
+
"node_modules/.cache",
|
|
295
|
+
".vercel",
|
|
296
|
+
".vs",
|
|
297
|
+
".vscode",
|
|
298
|
+
"packages",
|
|
299
|
+
"scripts/temp",
|
|
300
|
+
"scripts/logs",
|
|
301
|
+
"lib/temp",
|
|
302
|
+
"app/temp",
|
|
303
|
+
"components/temp",
|
|
304
|
+
"prisma/migrations/.tmp",
|
|
305
|
+
"prisma/temp",
|
|
306
|
+
".git/hooks",
|
|
307
|
+
".git/logs",
|
|
308
|
+
".github/temp",
|
|
309
|
+
"docs/temp",
|
|
310
|
+
"public/temp",
|
|
311
|
+
"styles/temp",
|
|
312
|
+
"types/temp",
|
|
313
|
+
"contexts/temp",
|
|
314
|
+
"hooks/temp",
|
|
315
|
+
"email-templates/temp",
|
|
316
|
+
];
|
|
317
|
+
// Files that are known to be safe to delete (whitelist)
|
|
318
|
+
const SAFE_TO_DELETE = [
|
|
319
|
+
// Temporary reports
|
|
320
|
+
"consistency_report.txt",
|
|
321
|
+
"coverage_final.txt",
|
|
322
|
+
"coverage_report_v2.txt",
|
|
323
|
+
"current_test_output.txt",
|
|
324
|
+
"current_violations.txt",
|
|
325
|
+
"current_violations_v2.txt",
|
|
326
|
+
"design_report.txt",
|
|
327
|
+
"dry_report.txt",
|
|
328
|
+
"dry_report_clean.txt",
|
|
329
|
+
"dry_report_latest.txt",
|
|
330
|
+
"final_verification.txt",
|
|
331
|
+
"fix_log.txt",
|
|
332
|
+
"framework-clean-log.txt",
|
|
333
|
+
"gaps.txt",
|
|
334
|
+
"latest_coverage_report.txt",
|
|
335
|
+
"lint_listings.txt",
|
|
336
|
+
"lint_output.txt",
|
|
337
|
+
"lint_single.txt",
|
|
338
|
+
"lint-summary.txt",
|
|
339
|
+
"preflight_check_2.txt",
|
|
340
|
+
"preflight_colors_final.txt",
|
|
341
|
+
"preflight_colors_final_v2.txt",
|
|
342
|
+
"preflight_colors_v2.txt",
|
|
343
|
+
"preflight_colors_v3.txt",
|
|
344
|
+
"preflight_colors_v4.txt",
|
|
345
|
+
"preflight_final_check.txt",
|
|
346
|
+
"preflight_full_report.txt",
|
|
347
|
+
"preflight_log.txt",
|
|
348
|
+
"preflight_log_2.txt",
|
|
349
|
+
"preflight_log_3.txt",
|
|
350
|
+
"preflight_output.log",
|
|
351
|
+
"preflight_output.txt",
|
|
352
|
+
"preflight-results.json",
|
|
353
|
+
"violations.txt",
|
|
354
|
+
"violations_v2.txt",
|
|
355
|
+
"prisma-check.txt",
|
|
356
|
+
"secrets.log",
|
|
357
|
+
"shared_report.txt",
|
|
358
|
+
"test_output.txt",
|
|
359
|
+
"test_output_2.txt",
|
|
360
|
+
"test_output_3.txt",
|
|
361
|
+
"test_output_shipping.txt",
|
|
362
|
+
"tsc_output_3.txt",
|
|
363
|
+
"tsc-output.txt",
|
|
364
|
+
"tsc-output2.txt",
|
|
365
|
+
"unified_report.txt",
|
|
366
|
+
"cycles.log",
|
|
367
|
+
// Build artifacts
|
|
368
|
+
"debug-plugins.cjs",
|
|
369
|
+
"debug-plugins.mjs",
|
|
370
|
+
"eng.traineddata",
|
|
371
|
+
"tsconfig.preflight.blocking.tsbuildinfo",
|
|
372
|
+
"tsconfig.tsbuildinfo",
|
|
373
|
+
"tsconfig.typecheck.tsbuildinfo",
|
|
374
|
+
// Additional temporary files
|
|
375
|
+
"tokenization-report.txt",
|
|
376
|
+
"eslint-errors.txt",
|
|
377
|
+
"missing-imports.txt",
|
|
378
|
+
"nested-components.txt",
|
|
379
|
+
"page-template-violations.txt",
|
|
380
|
+
"temp-analysis.txt",
|
|
381
|
+
"build-errors.log",
|
|
382
|
+
"type-errors.log",
|
|
383
|
+
"migration-errors.log",
|
|
384
|
+
"seed-errors.log",
|
|
385
|
+
"deployment-errors.log",
|
|
386
|
+
"performance-report.txt",
|
|
387
|
+
"bundle-analysis.txt",
|
|
388
|
+
"dependency-audit.txt",
|
|
389
|
+
"security-scan.txt",
|
|
390
|
+
"accessibility-report.txt",
|
|
391
|
+
"seo-analysis.txt",
|
|
392
|
+
"lighthouse-report.json",
|
|
393
|
+
"webpack-bundle-analyzer-report.html",
|
|
394
|
+
"coverage-summary.json",
|
|
395
|
+
"test-results-summary.json",
|
|
396
|
+
"e2e-test-report.html",
|
|
397
|
+
"visual-regression-report.html",
|
|
398
|
+
"performance-budget-report.json",
|
|
399
|
+
"unused-dependencies.txt",
|
|
400
|
+
"duplicate-code-report.txt",
|
|
401
|
+
"code-complexity-report.txt",
|
|
402
|
+
"technical-debt-report.txt",
|
|
403
|
+
"refactoring-opportunities.txt",
|
|
404
|
+
// Development and debugging files
|
|
405
|
+
"debug-output.txt",
|
|
406
|
+
"debug-trace.log",
|
|
407
|
+
"memory-usage.log",
|
|
408
|
+
"cpu-profile.json",
|
|
409
|
+
"heap-snapshot.heapsnapshot",
|
|
410
|
+
"flame-graph.html",
|
|
411
|
+
"profiling-results.json",
|
|
412
|
+
"benchmark-results.txt",
|
|
413
|
+
"load-test-results.json",
|
|
414
|
+
"stress-test-output.txt",
|
|
415
|
+
// Build and deployment artifacts
|
|
416
|
+
"build-manifest.json",
|
|
417
|
+
"deployment-log.txt",
|
|
418
|
+
"rollback-plan.txt",
|
|
419
|
+
"migration-plan.txt",
|
|
420
|
+
"database-backup-log.txt",
|
|
421
|
+
"environment-diff.txt",
|
|
422
|
+
"config-validation.txt",
|
|
423
|
+
"health-check-results.json",
|
|
424
|
+
// Code analysis and quality reports
|
|
425
|
+
"sonarqube-report.json",
|
|
426
|
+
"codeclimate-report.json",
|
|
427
|
+
"eslint-report.html",
|
|
428
|
+
"prettier-check.txt",
|
|
429
|
+
"type-coverage-report.txt",
|
|
430
|
+
"import-analysis.json",
|
|
431
|
+
"circular-dependencies.txt",
|
|
432
|
+
"dead-code-report.txt",
|
|
433
|
+
"bundle-size-analysis.json",
|
|
434
|
+
// Testing artifacts
|
|
435
|
+
"jest-coverage.json",
|
|
436
|
+
"playwright-trace.zip",
|
|
437
|
+
"test-screenshots.zip",
|
|
438
|
+
"test-videos.zip",
|
|
439
|
+
"mutation-testing-report.html",
|
|
440
|
+
"integration-test-logs.txt",
|
|
441
|
+
"e2e-test-artifacts.zip",
|
|
442
|
+
"performance-test-results.json",
|
|
443
|
+
// Temporary workspace files
|
|
444
|
+
"workspace-state.json",
|
|
445
|
+
"session-data.json",
|
|
446
|
+
"user-preferences.json",
|
|
447
|
+
"recent-files.json",
|
|
448
|
+
"search-history.json",
|
|
449
|
+
"command-history.txt",
|
|
450
|
+
"editor-state.json",
|
|
451
|
+
"breakpoints.json",
|
|
452
|
+
// Package manager and dependency files
|
|
453
|
+
"npm-shrinkwrap.json.backup",
|
|
454
|
+
"package-lock.json.backup",
|
|
455
|
+
"yarn.lock.backup",
|
|
456
|
+
"pnpm-lock.yaml.backup",
|
|
457
|
+
"node_modules.tar.gz",
|
|
458
|
+
"dependencies-audit.json",
|
|
459
|
+
"outdated-packages.txt",
|
|
460
|
+
"security-audit.json",
|
|
461
|
+
// Reports/logs directory files (older than 7 days)
|
|
462
|
+
"eslint-result.json",
|
|
463
|
+
"final-check.txt",
|
|
464
|
+
"final-warnings.txt",
|
|
465
|
+
"improved-warnings.txt",
|
|
466
|
+
"remaining-warnings.txt",
|
|
467
|
+
"typescript-errors-remaining.txt",
|
|
468
|
+
"warnings-full.txt",
|
|
469
|
+
"warnings-verbose.txt",
|
|
470
|
+
"tsc-stderr.txt",
|
|
471
|
+
"tsc-stdout.txt",
|
|
472
|
+
// Additional analysis and build reports
|
|
473
|
+
"analysis_report.txt",
|
|
474
|
+
"build_analysis.txt",
|
|
475
|
+
"bundle_report.txt",
|
|
476
|
+
"component_analysis.txt",
|
|
477
|
+
"dependency_analysis.txt",
|
|
478
|
+
"import_analysis.txt",
|
|
479
|
+
"performance_analysis.txt",
|
|
480
|
+
"security_analysis.txt",
|
|
481
|
+
"type_analysis.txt",
|
|
482
|
+
"ui_analysis.txt",
|
|
483
|
+
"validation_report.txt",
|
|
484
|
+
"verification_report.txt",
|
|
485
|
+
"cleanup_report.txt",
|
|
486
|
+
"migration_report.txt",
|
|
487
|
+
"refactor_report.txt",
|
|
488
|
+
"optimization_report.txt",
|
|
489
|
+
"quality_report.txt",
|
|
490
|
+
"standards_report.txt",
|
|
491
|
+
"compliance_report.txt",
|
|
492
|
+
"audit_report.txt",
|
|
493
|
+
"review_report.txt",
|
|
494
|
+
"inspection_report.txt",
|
|
495
|
+
// Development server and runtime logs
|
|
496
|
+
"dev-server.log",
|
|
497
|
+
"next-dev.log",
|
|
498
|
+
"webpack-dev.log",
|
|
499
|
+
"vite-dev.log",
|
|
500
|
+
"turbo-dev.log",
|
|
501
|
+
"runtime-errors.log",
|
|
502
|
+
"console-output.log",
|
|
503
|
+
"network-requests.log",
|
|
504
|
+
"api-calls.log",
|
|
505
|
+
"database-queries.log",
|
|
506
|
+
// Backup and archive files (older than 60 days)
|
|
507
|
+
"schema.prisma.backup",
|
|
508
|
+
"package.json.backup",
|
|
509
|
+
"tsconfig.json.backup",
|
|
510
|
+
"next.config.js.backup",
|
|
511
|
+
"tailwind.config.ts.backup",
|
|
512
|
+
"eslint.config.mjs.backup",
|
|
513
|
+
"prettier.config.js.backup",
|
|
514
|
+
"jest.config.js.backup",
|
|
515
|
+
"playwright.config.ts.backup",
|
|
516
|
+
"vitest.config.ts.backup",
|
|
517
|
+
// Temporary build and deployment files
|
|
518
|
+
"build-cache.json",
|
|
519
|
+
"deployment-cache.json",
|
|
520
|
+
"upload-cache.json",
|
|
521
|
+
"download-cache.json",
|
|
522
|
+
"sync-cache.json",
|
|
523
|
+
"validation-cache.json",
|
|
524
|
+
"verification-cache.json",
|
|
525
|
+
"optimization-cache.json",
|
|
526
|
+
"compression-cache.json",
|
|
527
|
+
"minification-cache.json",
|
|
528
|
+
"recent-files.json",
|
|
529
|
+
"search-history.json",
|
|
530
|
+
"command-history.txt",
|
|
531
|
+
"editor-state.json",
|
|
532
|
+
"breakpoints.json",
|
|
533
|
+
// Package manager and dependency files
|
|
534
|
+
"npm-shrinkwrap.json.backup",
|
|
535
|
+
"package-lock.json.backup",
|
|
536
|
+
"yarn.lock.backup",
|
|
537
|
+
"pnpm-lock.yaml.backup",
|
|
538
|
+
"node_modules.tar.gz",
|
|
539
|
+
"dependencies-audit.json",
|
|
540
|
+
"outdated-packages.txt",
|
|
541
|
+
"security-audit.json",
|
|
542
|
+
// Test-results specific files (found in current repo)
|
|
543
|
+
"account-profile-targeted.log",
|
|
544
|
+
"account-profile-targeted2.log",
|
|
545
|
+
"account-profile-targeted3.log",
|
|
546
|
+
"account-profile-targeted4.log",
|
|
547
|
+
"account-profile-targeted5.log",
|
|
548
|
+
"account-profile-targeted6.log",
|
|
549
|
+
"account-profile-targeted7.log",
|
|
550
|
+
"dev-server.log",
|
|
551
|
+
"e2e-slowest.json",
|
|
552
|
+
"junit.xml",
|
|
553
|
+
"results.json",
|
|
554
|
+
"targeted-e2e.log",
|
|
555
|
+
// Next.js build artifacts (found in current repo)
|
|
556
|
+
"trace",
|
|
557
|
+
"trace-build",
|
|
558
|
+
"turbopack",
|
|
559
|
+
// Additional development artifacts
|
|
560
|
+
"preflight-results.json",
|
|
561
|
+
"playwright-storage.json",
|
|
562
|
+
"vercel-build.log",
|
|
563
|
+
"next-build.log",
|
|
564
|
+
"prisma-generate.log",
|
|
565
|
+
"migration-status.json",
|
|
566
|
+
"seed-status.json",
|
|
567
|
+
"backup-status.json",
|
|
568
|
+
"deployment-status.json",
|
|
569
|
+
// IDE and OS artifacts
|
|
570
|
+
".DS_Store",
|
|
571
|
+
"Thumbs.db",
|
|
572
|
+
"desktop.ini",
|
|
573
|
+
".directory",
|
|
574
|
+
"Icon\r",
|
|
575
|
+
"ehthumbs.db",
|
|
576
|
+
"ehthumbs_vista.db",
|
|
577
|
+
// Version control artifacts
|
|
578
|
+
".gitignore.backup",
|
|
579
|
+
".gitattributes.backup",
|
|
580
|
+
"git-hooks.backup",
|
|
581
|
+
// Documentation artifacts
|
|
582
|
+
"README.md.backup",
|
|
583
|
+
"CHANGELOG.md.backup",
|
|
584
|
+
"docs-backup.zip",
|
|
585
|
+
"api-docs.html",
|
|
586
|
+
"component-docs.html",
|
|
587
|
+
// Configuration backups
|
|
588
|
+
"tsconfig.json.backup",
|
|
589
|
+
"package.json.backup",
|
|
590
|
+
"next.config.js.backup",
|
|
591
|
+
"tailwind.config.ts.backup",
|
|
592
|
+
"eslint.config.mjs.backup",
|
|
593
|
+
"prettier.config.js.backup",
|
|
594
|
+
"jest.config.js.backup",
|
|
595
|
+
"playwright.config.ts.backup",
|
|
596
|
+
// Temporary analysis files
|
|
597
|
+
"bundle-analyzer-report.html",
|
|
598
|
+
"dependency-graph.json",
|
|
599
|
+
"import-map.json",
|
|
600
|
+
"component-usage.json",
|
|
601
|
+
"route-analysis.json",
|
|
602
|
+
"performance-metrics.json",
|
|
603
|
+
"accessibility-audit.json",
|
|
604
|
+
"seo-audit.json",
|
|
605
|
+
"security-audit-report.json",
|
|
606
|
+
// Build optimization artifacts
|
|
607
|
+
"webpack-stats.json",
|
|
608
|
+
"turbopack-stats.json",
|
|
609
|
+
"build-optimization.log",
|
|
610
|
+
"chunk-analysis.json",
|
|
611
|
+
"tree-shaking-report.json",
|
|
612
|
+
"code-splitting-report.json",
|
|
613
|
+
];
|
|
614
|
+
function getFileStats(filePath) {
|
|
615
|
+
try {
|
|
616
|
+
const stats = fs_1.default.statSync(filePath);
|
|
617
|
+
return {
|
|
618
|
+
sizeKB: Math.round(stats.size / 1024),
|
|
619
|
+
lastModified: stats.mtime,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function isDirectoryEmpty(dirPath) {
|
|
627
|
+
try {
|
|
628
|
+
const files = fs_1.default.readdirSync(dirPath);
|
|
629
|
+
return files.length === 0;
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function isOlderThanDays(filePath, days) {
|
|
636
|
+
const stats = getFileStats(filePath);
|
|
637
|
+
if (!stats)
|
|
638
|
+
return false;
|
|
639
|
+
const daysDiff = (Date.now() - stats.lastModified.getTime()) / (1000 * 60 * 60 * 24);
|
|
640
|
+
return daysDiff > days;
|
|
641
|
+
}
|
|
642
|
+
function scanForCleanupIssues() {
|
|
643
|
+
const issues = [];
|
|
644
|
+
let rootFiles = [];
|
|
645
|
+
// Check root directory for temporary files
|
|
646
|
+
try {
|
|
647
|
+
rootFiles = fs_1.default.readdirSync(projectRoot);
|
|
648
|
+
for (const file of rootFiles) {
|
|
649
|
+
const filePath = path_1.default.join(projectRoot, file);
|
|
650
|
+
const stats = getFileStats(filePath);
|
|
651
|
+
if (!stats)
|
|
652
|
+
continue;
|
|
653
|
+
// Check against cleanup patterns
|
|
654
|
+
for (const [category, patterns] of Object.entries(CLEANUP_PATTERNS)) {
|
|
655
|
+
for (const pattern of patterns) {
|
|
656
|
+
if (pattern.test(file)) {
|
|
657
|
+
const severity = SAFE_TO_DELETE.includes(file) ? "warning" : "error";
|
|
658
|
+
issues.push({
|
|
659
|
+
type: "file",
|
|
660
|
+
path: file,
|
|
661
|
+
reason: `Temporary ${category.toLowerCase().replace("_", " ")} file`,
|
|
662
|
+
severity,
|
|
663
|
+
sizeKB: stats.sizeKB,
|
|
664
|
+
lastModified: stats.lastModified,
|
|
665
|
+
});
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
// Check for very large files that might be artifacts
|
|
671
|
+
if (stats.sizeKB > 10000) {
|
|
672
|
+
// > 10MB
|
|
673
|
+
issues.push({
|
|
674
|
+
type: "file",
|
|
675
|
+
path: file,
|
|
676
|
+
reason: `Large file (${stats.sizeKB}KB) - possible build artifact`,
|
|
677
|
+
severity: "warning",
|
|
678
|
+
sizeKB: stats.sizeKB,
|
|
679
|
+
lastModified: stats.lastModified,
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
console.error("Error scanning root directory:", error);
|
|
686
|
+
}
|
|
687
|
+
// Recursively scan additional directories for cleanup opportunities
|
|
688
|
+
for (const scanDir of SCAN_DIRECTORIES) {
|
|
689
|
+
const fullScanPath = path_1.default.join(projectRoot, scanDir);
|
|
690
|
+
if (fs_1.default.existsSync(fullScanPath)) {
|
|
691
|
+
try {
|
|
692
|
+
scanDirectoryRecursively(fullScanPath, scanDir, issues);
|
|
693
|
+
}
|
|
694
|
+
catch (error) {
|
|
695
|
+
console.error(`Error scanning directory ${scanDir}:`, error);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
// Check for old backup directories
|
|
700
|
+
try {
|
|
701
|
+
const kiroDir = path_1.default.join(projectRoot, ".kiro");
|
|
702
|
+
if (fs_1.default.existsSync(kiroDir)) {
|
|
703
|
+
const kiroContents = fs_1.default.readdirSync(kiroDir);
|
|
704
|
+
for (const item of kiroContents) {
|
|
705
|
+
if (item.startsWith("steering-backup-")) {
|
|
706
|
+
const backupPath = path_1.default.join(kiroDir, item);
|
|
707
|
+
if (isOlderThanDays(backupPath, 30)) {
|
|
708
|
+
issues.push({
|
|
709
|
+
type: "directory",
|
|
710
|
+
path: `.kiro/${item}`,
|
|
711
|
+
reason: "Old steering backup (>30 days)",
|
|
712
|
+
severity: "warning",
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
catch (error) {
|
|
720
|
+
console.error("Error scanning .kiro directory:", error);
|
|
721
|
+
}
|
|
722
|
+
// Check for empty directories
|
|
723
|
+
for (const dirPath of CHECK_EMPTY_DIRS) {
|
|
724
|
+
const fullPath = path_1.default.join(projectRoot, dirPath);
|
|
725
|
+
if (fs_1.default.existsSync(fullPath) && isDirectoryEmpty(fullPath)) {
|
|
726
|
+
issues.push({
|
|
727
|
+
type: "directory",
|
|
728
|
+
path: dirPath,
|
|
729
|
+
reason: "Empty directory",
|
|
730
|
+
severity: "info",
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
// Check reports directory for old files
|
|
735
|
+
try {
|
|
736
|
+
const reportsDir = path_1.default.join(projectRoot, "reports");
|
|
737
|
+
if (fs_1.default.existsSync(reportsDir)) {
|
|
738
|
+
const reportFiles = fs_1.default.readdirSync(reportsDir);
|
|
739
|
+
for (const file of reportFiles) {
|
|
740
|
+
if (file.startsWith("cleanup-report-") && file.endsWith(".json")) {
|
|
741
|
+
const filePath = path_1.default.join(reportsDir, file);
|
|
742
|
+
if (isOlderThanDays(filePath, 7)) {
|
|
743
|
+
// Older than 1 week
|
|
744
|
+
const stats = getFileStats(filePath);
|
|
745
|
+
issues.push({
|
|
746
|
+
type: "file",
|
|
747
|
+
path: `reports/${file}`,
|
|
748
|
+
reason: "Old cleanup report (>7 days)",
|
|
749
|
+
severity: "info",
|
|
750
|
+
sizeKB: stats?.sizeKB,
|
|
751
|
+
lastModified: stats?.lastModified,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
catch (error) {
|
|
759
|
+
console.error("Error scanning reports directory:", error);
|
|
760
|
+
}
|
|
761
|
+
// Check for duplicate config files
|
|
762
|
+
try {
|
|
763
|
+
const configFiles = rootFiles.filter((f) => f.startsWith(".eslintrc"));
|
|
764
|
+
if (configFiles.length > 1) {
|
|
765
|
+
issues.push({
|
|
766
|
+
type: "file",
|
|
767
|
+
path: configFiles.join(", "),
|
|
768
|
+
reason: "Multiple ESLint config files detected - should use only one",
|
|
769
|
+
severity: "warning",
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
catch (error) {
|
|
774
|
+
console.error("Error checking config files:", error);
|
|
775
|
+
}
|
|
776
|
+
return issues;
|
|
777
|
+
}
|
|
778
|
+
function scanDirectoryRecursively(dirPath, relativePath, issues, depth = 0) {
|
|
779
|
+
// Limit recursion depth to prevent infinite loops
|
|
780
|
+
if (depth > 5)
|
|
781
|
+
return;
|
|
782
|
+
try {
|
|
783
|
+
const items = fs_1.default.readdirSync(dirPath);
|
|
784
|
+
for (const item of items) {
|
|
785
|
+
const itemPath = path_1.default.join(dirPath, item);
|
|
786
|
+
const relativeItemPath = path_1.default.join(relativePath, item);
|
|
787
|
+
const stats = fs_1.default.statSync(itemPath);
|
|
788
|
+
if (stats.isDirectory()) {
|
|
789
|
+
// Check if directory should be cleaned up
|
|
790
|
+
if (shouldCleanupDirectory(item, itemPath)) {
|
|
791
|
+
issues.push({
|
|
792
|
+
type: "directory",
|
|
793
|
+
path: relativeItemPath,
|
|
794
|
+
reason: "Build artifact directory",
|
|
795
|
+
severity: "warning",
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
// Recursively scan subdirectory
|
|
800
|
+
scanDirectoryRecursively(itemPath, relativeItemPath, issues, depth + 1);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else if (stats.isFile()) {
|
|
804
|
+
// Check if file should be cleaned up
|
|
805
|
+
const sizeKB = Math.round(stats.size / 1024);
|
|
806
|
+
const lastModified = stats.mtime;
|
|
807
|
+
if (shouldCleanupFile(item, itemPath, sizeKB)) {
|
|
808
|
+
issues.push({
|
|
809
|
+
type: "file",
|
|
810
|
+
path: relativeItemPath,
|
|
811
|
+
reason: getFileCleanupReason(item, sizeKB),
|
|
812
|
+
severity: "warning",
|
|
813
|
+
sizeKB,
|
|
814
|
+
lastModified,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
console.error(`Error scanning directory ${dirPath}:`, error);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function shouldCleanupDirectory(dirName, dirPath) {
|
|
825
|
+
// Cache directories
|
|
826
|
+
if (dirName === "cache" || dirName === ".cache")
|
|
827
|
+
return true;
|
|
828
|
+
// Build artifact directories
|
|
829
|
+
if (dirName === "trace" || dirName === "trace-build" || dirName === "turbopack")
|
|
830
|
+
return true;
|
|
831
|
+
// Test result directories (if old)
|
|
832
|
+
if (dirName === "artifacts" && isOlderThanDays(dirPath, 7))
|
|
833
|
+
return true;
|
|
834
|
+
// Coverage directories (if old)
|
|
835
|
+
if (dirName === "lcov-report" && isOlderThanDays(dirPath, 7))
|
|
836
|
+
return true;
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
function shouldCleanupFile(fileName, filePath, sizeKB) {
|
|
840
|
+
// Log files
|
|
841
|
+
if (fileName.endsWith(".log") && isOlderThanDays(filePath, 7))
|
|
842
|
+
return true;
|
|
843
|
+
// Debug files
|
|
844
|
+
if (fileName.includes("debug") && fileName.endsWith(".txt"))
|
|
845
|
+
return true;
|
|
846
|
+
// Temporary files
|
|
847
|
+
if (fileName.startsWith("temp-") || fileName.startsWith("tmp-"))
|
|
848
|
+
return true;
|
|
849
|
+
// Large files that might be artifacts (>100MB)
|
|
850
|
+
if (sizeKB > 100000)
|
|
851
|
+
return true;
|
|
852
|
+
// Build cache files
|
|
853
|
+
if (fileName.endsWith(".tsbuildinfo") && isOlderThanDays(filePath, 1))
|
|
854
|
+
return true;
|
|
855
|
+
// Package manager lock files (duplicates)
|
|
856
|
+
if ((fileName === "package-lock.json" || fileName === "yarn.lock") &&
|
|
857
|
+
fs_1.default.existsSync(path_1.default.join(path_1.default.dirname(filePath), "pnpm-lock.yaml")))
|
|
858
|
+
return true;
|
|
859
|
+
// IDE artifacts
|
|
860
|
+
if (fileName === ".DS_Store" || fileName === "Thumbs.db" || fileName === "desktop.ini")
|
|
861
|
+
return true;
|
|
862
|
+
// Backup files
|
|
863
|
+
if (fileName.endsWith(".backup") || fileName.endsWith(".bak") || fileName.endsWith(".old"))
|
|
864
|
+
return true;
|
|
865
|
+
// Profiling and debugging artifacts
|
|
866
|
+
if (fileName.endsWith(".heapsnapshot") || fileName.endsWith(".cpuprofile"))
|
|
867
|
+
return true;
|
|
868
|
+
// Test artifacts (old)
|
|
869
|
+
if ((fileName.includes("test-") || fileName.includes("spec-")) &&
|
|
870
|
+
fileName.endsWith(".json") &&
|
|
871
|
+
isOlderThanDays(filePath, 7))
|
|
872
|
+
return true;
|
|
873
|
+
// Coverage files (old)
|
|
874
|
+
if (fileName.includes("coverage") && isOlderThanDays(filePath, 7))
|
|
875
|
+
return true;
|
|
876
|
+
// Report files (old)
|
|
877
|
+
if (fileName.includes("report") &&
|
|
878
|
+
(fileName.endsWith(".html") || fileName.endsWith(".json")) &&
|
|
879
|
+
isOlderThanDays(filePath, 14))
|
|
880
|
+
return true;
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
function getFileCleanupReason(fileName, sizeKB) {
|
|
884
|
+
if (fileName.endsWith(".log"))
|
|
885
|
+
return "Old log file";
|
|
886
|
+
if (fileName.includes("debug"))
|
|
887
|
+
return "Debug file";
|
|
888
|
+
if (fileName.startsWith("temp-") || fileName.startsWith("tmp-"))
|
|
889
|
+
return "Temporary file";
|
|
890
|
+
if (sizeKB > 100000)
|
|
891
|
+
return `Large file (${sizeKB}KB) - possible artifact`;
|
|
892
|
+
if (fileName.endsWith(".tsbuildinfo"))
|
|
893
|
+
return "Old TypeScript build cache";
|
|
894
|
+
if (fileName === "package-lock.json" || fileName === "yarn.lock")
|
|
895
|
+
return "Duplicate package manager lock file";
|
|
896
|
+
if (fileName === ".DS_Store" || fileName === "Thumbs.db")
|
|
897
|
+
return "OS-generated file";
|
|
898
|
+
if (fileName.endsWith(".backup") || fileName.endsWith(".bak"))
|
|
899
|
+
return "Backup file";
|
|
900
|
+
if (fileName.endsWith(".heapsnapshot") || fileName.endsWith(".cpuprofile"))
|
|
901
|
+
return "Profiling artifact";
|
|
902
|
+
if (fileName.includes("test-") && fileName.endsWith(".json"))
|
|
903
|
+
return "Old test artifact";
|
|
904
|
+
if (fileName.includes("coverage"))
|
|
905
|
+
return "Old coverage file";
|
|
906
|
+
if (fileName.includes("report"))
|
|
907
|
+
return "Old report file";
|
|
908
|
+
return "Cleanup candidate";
|
|
909
|
+
}
|
|
910
|
+
function generateCleanupScript(issues) {
|
|
911
|
+
const safeToDelete = issues.filter((issue) => issue.severity === "warning" &&
|
|
912
|
+
(issue.type === "file" ? SAFE_TO_DELETE.includes(path_1.default.basename(issue.path)) : true));
|
|
913
|
+
if (safeToDelete.length === 0)
|
|
914
|
+
return "";
|
|
915
|
+
const script = [
|
|
916
|
+
"#!/bin/bash",
|
|
917
|
+
"# Auto-generated cleanup script",
|
|
918
|
+
"# Run with: bash cleanup-safe-files.sh",
|
|
919
|
+
"",
|
|
920
|
+
'echo "🧹 Cleaning up temporary files..."',
|
|
921
|
+
'echo "================================="',
|
|
922
|
+
"",
|
|
923
|
+
"# Set error handling",
|
|
924
|
+
"set -e",
|
|
925
|
+
"",
|
|
926
|
+
"# Track cleanup statistics",
|
|
927
|
+
"FILES_DELETED=0",
|
|
928
|
+
"DIRS_DELETED=0",
|
|
929
|
+
"SPACE_RECLAIMED=0",
|
|
930
|
+
"",
|
|
931
|
+
"# Function to safely delete file",
|
|
932
|
+
"delete_file() {",
|
|
933
|
+
' local file="$1"',
|
|
934
|
+
' local reason="$2"',
|
|
935
|
+
' local size="$3"',
|
|
936
|
+
" ",
|
|
937
|
+
' if [ -f "$file" ]; then',
|
|
938
|
+
' echo "${emoji.wrench} Removing $file ($reason)"',
|
|
939
|
+
' rm -f "$file"',
|
|
940
|
+
" FILES_DELETED=$((FILES_DELETED + 1))",
|
|
941
|
+
' if [ -n "$size" ]; then',
|
|
942
|
+
" SPACE_RECLAIMED=$((SPACE_RECLAIMED + size))",
|
|
943
|
+
" fi",
|
|
944
|
+
" fi",
|
|
945
|
+
"}",
|
|
946
|
+
"",
|
|
947
|
+
"# Function to safely delete directory",
|
|
948
|
+
"delete_dir() {",
|
|
949
|
+
' local dir="$1"',
|
|
950
|
+
' local reason="$2"',
|
|
951
|
+
" ",
|
|
952
|
+
' if [ -d "$dir" ]; then',
|
|
953
|
+
' echo "${emoji.folder} Removing directory $dir ($reason)"',
|
|
954
|
+
' rm -rf "$dir"',
|
|
955
|
+
" DIRS_DELETED=$((DIRS_DELETED + 1))",
|
|
956
|
+
" fi",
|
|
957
|
+
"}",
|
|
958
|
+
"",
|
|
959
|
+
"# Clean up files and directories",
|
|
960
|
+
];
|
|
961
|
+
for (const issue of safeToDelete) {
|
|
962
|
+
if (issue.type === "file") {
|
|
963
|
+
const sizeKB = issue.sizeKB || 0;
|
|
964
|
+
script.push(`delete_file "${issue.path}" "${issue.reason}" ${sizeKB}`);
|
|
965
|
+
}
|
|
966
|
+
else {
|
|
967
|
+
script.push(`delete_dir "${issue.path}" "${issue.reason}"`);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
script.push("", "# Clean up additional patterns", "# Old log files", 'find . -name "*.log" -type f -mtime +7 -not -path "./node_modules/*" -not -path "./.git/*" -exec rm -f {} \\; 2>/dev/null || true', "", "# Old TypeScript build info files", 'find . -name "*.tsbuildinfo" -type f -mtime +1 -not -path "./node_modules/*" -exec rm -f {} \\; 2>/dev/null || true', "", "# Empty cache directories", "find .next/cache -type d -empty -delete 2>/dev/null || true", "find .swc/plugins -type d -empty -delete 2>/dev/null || true", "", "# Calculate space reclaimed in MB", "SPACE_MB=$((SPACE_RECLAIMED / 1024))", "", "# Summary", 'echo ""', 'echo "${emoji.chart} Cleanup Summary"', 'echo "=================="', 'echo "Files deleted: $FILES_DELETED"', 'echo "Directories deleted: $DIRS_DELETED"', 'echo "Space reclaimed: ${SPACE_MB}MB (${SPACE_RECLAIMED}KB)"', 'echo ""', 'echo "${emoji.success} Cleanup complete!"');
|
|
971
|
+
return script.join("\n");
|
|
972
|
+
}
|
|
973
|
+
function generatePowerShellCleanupScript(issues) {
|
|
974
|
+
const safeToDelete = issues.filter((issue) => issue.severity === "warning" &&
|
|
975
|
+
(issue.type === "file" ? SAFE_TO_DELETE.includes(path_1.default.basename(issue.path)) : true));
|
|
976
|
+
if (safeToDelete.length === 0)
|
|
977
|
+
return "";
|
|
978
|
+
const script = [
|
|
979
|
+
"# Auto-generated PowerShell cleanup script",
|
|
980
|
+
"# Run with: powershell -ExecutionPolicy Bypass -File cleanup-safe-files.ps1",
|
|
981
|
+
"",
|
|
982
|
+
'Write-Host "🧹 Cleaning up temporary files..." -ForegroundColor Cyan',
|
|
983
|
+
'Write-Host "=================================" -ForegroundColor Cyan',
|
|
984
|
+
"",
|
|
985
|
+
"# Set error handling",
|
|
986
|
+
'$ErrorActionPreference = "Continue"',
|
|
987
|
+
"",
|
|
988
|
+
"# Track cleanup statistics",
|
|
989
|
+
"$FilesDeleted = 0",
|
|
990
|
+
"$DirsDeleted = 0",
|
|
991
|
+
"$SpaceReclaimed = 0",
|
|
992
|
+
"",
|
|
993
|
+
"# Function to safely delete file",
|
|
994
|
+
"function Remove-SafeFile {",
|
|
995
|
+
" param(",
|
|
996
|
+
" [string]$FilePath,",
|
|
997
|
+
" [string]$Reason,",
|
|
998
|
+
" [int]$SizeKB = 0",
|
|
999
|
+
" )",
|
|
1000
|
+
" ",
|
|
1001
|
+
" if (Test-Path $FilePath -PathType Leaf) {",
|
|
1002
|
+
' Write-Host "${emoji.wrench} Removing $FilePath ($Reason)" -ForegroundColor Yellow',
|
|
1003
|
+
" Remove-Item $FilePath -Force -ErrorAction SilentlyContinue",
|
|
1004
|
+
" $script:FilesDeleted++",
|
|
1005
|
+
" $script:SpaceReclaimed += $SizeKB",
|
|
1006
|
+
" }",
|
|
1007
|
+
"}",
|
|
1008
|
+
"",
|
|
1009
|
+
"# Function to safely delete directory",
|
|
1010
|
+
"function Remove-SafeDirectory {",
|
|
1011
|
+
" param(",
|
|
1012
|
+
" [string]$DirPath,",
|
|
1013
|
+
" [string]$Reason",
|
|
1014
|
+
" )",
|
|
1015
|
+
" ",
|
|
1016
|
+
" if (Test-Path $DirPath -PathType Container) {",
|
|
1017
|
+
' Write-Host "${emoji.folder} Removing directory $DirPath ($Reason)" -ForegroundColor Yellow',
|
|
1018
|
+
" Remove-Item $DirPath -Recurse -Force -ErrorAction SilentlyContinue",
|
|
1019
|
+
" $script:DirsDeleted++",
|
|
1020
|
+
" }",
|
|
1021
|
+
"}",
|
|
1022
|
+
"",
|
|
1023
|
+
"# Clean up files and directories",
|
|
1024
|
+
];
|
|
1025
|
+
for (const issue of safeToDelete) {
|
|
1026
|
+
if (issue.type === "file") {
|
|
1027
|
+
const sizeKB = issue.sizeKB || 0;
|
|
1028
|
+
script.push(`Remove-SafeFile "${issue.path}" "${issue.reason}" ${sizeKB}`);
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
script.push(`Remove-SafeDirectory "${issue.path}" "${issue.reason}"`);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
script.push("", "# Clean up additional patterns", "# Old log files", 'Get-ChildItem -Path . -Filter "*.log" -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-7) -and $_.FullName -notmatch "node_modules|\.git" } | Remove-Item -Force -ErrorAction SilentlyContinue', "", "# Old TypeScript build info files", 'Get-ChildItem -Path . -Filter "*.tsbuildinfo" -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-1) -and $_.FullName -notmatch "node_modules" } | Remove-Item -Force -ErrorAction SilentlyContinue', "", "# Empty cache directories", 'if (Test-Path ".next/cache") {', ' Get-ChildItem ".next/cache" -Directory | Where-Object { (Get-ChildItem $_.FullName).Count -eq 0 } | Remove-Item -Force -ErrorAction SilentlyContinue', "}", 'if (Test-Path ".swc/plugins") {', ' Get-ChildItem ".swc/plugins" -Directory | Where-Object { (Get-ChildItem $_.FullName).Count -eq 0 } | Remove-Item -Force -ErrorAction SilentlyContinue', "}", "", "# Calculate space reclaimed in MB", "$SpaceMB = [math]::Round($SpaceReclaimed / 1024, 2)", "", "# Summary", 'Write-Host ""', 'Write-Host "${emoji.chart} Cleanup Summary" -ForegroundColor Green', 'Write-Host "==================" -ForegroundColor Green', 'Write-Host "Files deleted: $FilesDeleted" -ForegroundColor Green', 'Write-Host "Directories deleted: $DirsDeleted" -ForegroundColor Green', 'Write-Host "Space reclaimed: ${SpaceMB}MB (${SpaceReclaimed}KB)" -ForegroundColor Green', 'Write-Host ""', 'Write-Host "${emoji.success} Cleanup complete!" -ForegroundColor Green');
|
|
1035
|
+
return script.join("\n");
|
|
1036
|
+
}
|
|
1037
|
+
async function run() {
|
|
1038
|
+
const reporter = (0, universal_progress_reporter_1.createUniversalProgressReporter)(exports.name);
|
|
1039
|
+
console.log("🧹 File Cleanup Validation");
|
|
1040
|
+
console.log("==========================\n");
|
|
1041
|
+
const issues = scanForCleanupIssues();
|
|
1042
|
+
if (issues.length === 0) {
|
|
1043
|
+
console.log(`${console_chars_1.emoji.success} No cleanup issues found - repository is clean!`);
|
|
1044
|
+
process.exit(0);
|
|
1045
|
+
}
|
|
1046
|
+
// Group issues by severity
|
|
1047
|
+
const errors = issues.filter((i) => i.severity === "error");
|
|
1048
|
+
const warnings = issues.filter((i) => i.severity === "warning");
|
|
1049
|
+
const info = issues.filter((i) => i.severity === "info");
|
|
1050
|
+
let totalSizeKB = 0;
|
|
1051
|
+
if (errors.length > 0) {
|
|
1052
|
+
console.log(`${console_chars_1.emoji.error} ERRORS (must be fixed):`);
|
|
1053
|
+
for (const issue of errors) {
|
|
1054
|
+
console.log(` ${issue.path} - ${issue.reason}`);
|
|
1055
|
+
if (issue.sizeKB) {
|
|
1056
|
+
console.log(` Size: ${issue.sizeKB}KB, Modified: ${issue.lastModified?.toLocaleDateString()}`);
|
|
1057
|
+
totalSizeKB += issue.sizeKB;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
console.log("");
|
|
1061
|
+
}
|
|
1062
|
+
if (warnings.length > 0) {
|
|
1063
|
+
console.log(`${console_chars_1.emoji.warning} WARNINGS (recommended cleanup):`);
|
|
1064
|
+
for (const issue of warnings) {
|
|
1065
|
+
console.log(` ${issue.path} - ${issue.reason}`);
|
|
1066
|
+
if (issue.sizeKB) {
|
|
1067
|
+
console.log(` Size: ${issue.sizeKB}KB, Modified: ${issue.lastModified?.toLocaleDateString()}`);
|
|
1068
|
+
totalSizeKB += issue.sizeKB;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
console.log("");
|
|
1072
|
+
}
|
|
1073
|
+
if (info.length > 0) {
|
|
1074
|
+
console.log(`${console_chars_1.emoji.info} INFO (optional cleanup):`);
|
|
1075
|
+
for (const issue of info) {
|
|
1076
|
+
console.log(` ${issue.path} - ${issue.reason}`);
|
|
1077
|
+
if (issue.sizeKB) {
|
|
1078
|
+
console.log(` Size: ${issue.sizeKB}KB, Modified: ${issue.lastModified?.toLocaleDateString()}`);
|
|
1079
|
+
totalSizeKB += issue.sizeKB;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
console.log("");
|
|
1083
|
+
}
|
|
1084
|
+
console.log(`${console_chars_1.emoji.chart} Summary: ${issues.length} cleanup opportunities found`);
|
|
1085
|
+
if (totalSizeKB > 0) {
|
|
1086
|
+
console.log(`💾 Total reclaimable space: ${Math.round(totalSizeKB / 1024)}MB`);
|
|
1087
|
+
}
|
|
1088
|
+
// Generate cleanup script for safe files
|
|
1089
|
+
const cleanupScript = generateCleanupScript(issues);
|
|
1090
|
+
if (cleanupScript) {
|
|
1091
|
+
fs_1.default.writeFileSync(path_1.default.join(projectRoot, "cleanup-safe-files.sh"), cleanupScript);
|
|
1092
|
+
console.log(`\n${console_chars_1.emoji.wrench} Generated cleanup-safe-files.sh for automatic cleanup`);
|
|
1093
|
+
console.log(" Run: bash cleanup-safe-files.sh");
|
|
1094
|
+
}
|
|
1095
|
+
// Generate PowerShell cleanup script
|
|
1096
|
+
const powershellScript = generatePowerShellCleanupScript(issues);
|
|
1097
|
+
if (powershellScript) {
|
|
1098
|
+
fs_1.default.writeFileSync(path_1.default.join(projectRoot, "cleanup-safe-files.ps1"), powershellScript);
|
|
1099
|
+
console.log(`${console_chars_1.emoji.wrench} Generated cleanup-safe-files.ps1 for Windows cleanup`);
|
|
1100
|
+
console.log(" Run: powershell -ExecutionPolicy Bypass -File cleanup-safe-files.ps1");
|
|
1101
|
+
}
|
|
1102
|
+
// Exit with error if there are blocking issues
|
|
1103
|
+
if (errors.length > 0) {
|
|
1104
|
+
console.log(`\n${console_chars_1.emoji.error} Build blocked due to cleanup issues`);
|
|
1105
|
+
console.log(" Fix errors above or run cleanup script");
|
|
1106
|
+
process.exit(1);
|
|
1107
|
+
}
|
|
1108
|
+
if (warnings.length > 5) {
|
|
1109
|
+
console.log(`\n${console_chars_1.emoji.warning} Many cleanup opportunities found`);
|
|
1110
|
+
console.log(" Consider running cleanup script to reduce repository size");
|
|
1111
|
+
}
|
|
1112
|
+
process.exit(0);
|
|
1113
|
+
}
|
|
1114
|
+
// Allow direct execution
|
|
1115
|
+
if (require.main === module) {
|
|
1116
|
+
run().catch((err) => {
|
|
1117
|
+
console.error("Error:", err);
|
|
1118
|
+
process.exit(1);
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
//# sourceMappingURL=file-cleanup-validation.js.map
|