@singhaman21/cleansweep 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/LICENSE +21 -0
- package/README.md +447 -0
- package/USAGE.md +81 -0
- package/delete.sh +489 -0
- package/dist/bin/cli.d.ts +7 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +114 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/core/deletionEngine.d.ts +47 -0
- package/dist/core/deletionEngine.d.ts.map +1 -0
- package/dist/core/deletionEngine.js +184 -0
- package/dist/core/deletionEngine.js.map +1 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fileUtils.d.ts +54 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +232 -0
- package/dist/utils/fileUtils.js.map +1 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +110 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/prompts.d.ts +17 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +86 -0
- package/dist/utils/prompts.js.map +1 -0
- package/package.json +49 -0
- package/src/bin/cli.ts +130 -0
- package/src/core/deletionEngine.ts +219 -0
- package/src/types.ts +30 -0
- package/src/utils/fileUtils.ts +218 -0
- package/src/utils/logger.ts +91 -0
- package/src/utils/prompts.ts +54 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deletion Engine for cleansweep
|
|
4
|
+
* Core logic for collecting and processing deletions
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DeletionEngine = void 0;
|
|
8
|
+
const fileUtils_1 = require("../utils/fileUtils");
|
|
9
|
+
const prompts_1 = require("../utils/prompts");
|
|
10
|
+
class DeletionEngine {
|
|
11
|
+
constructor(config, logger) {
|
|
12
|
+
this.itemsToDelete = [];
|
|
13
|
+
this.deletedItems = [];
|
|
14
|
+
this.failedDeletions = [];
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Collects all items (files/folders) that match the specified patterns
|
|
20
|
+
* and stores them in the itemsToDelete array
|
|
21
|
+
*/
|
|
22
|
+
async collectItemsToDelete() {
|
|
23
|
+
this.itemsToDelete = [];
|
|
24
|
+
const allItems = [];
|
|
25
|
+
// Process file patterns
|
|
26
|
+
if (this.config.filesPattern) {
|
|
27
|
+
const files = await (0, fileUtils_1.findFiles)(this.config.filesPattern, this.config.maxDepth);
|
|
28
|
+
allItems.push(...files);
|
|
29
|
+
}
|
|
30
|
+
// Process folder patterns
|
|
31
|
+
if (this.config.foldersPattern) {
|
|
32
|
+
const dirs = await (0, fileUtils_1.findDirectories)(this.config.foldersPattern, this.config.maxDepth);
|
|
33
|
+
allItems.push(...dirs);
|
|
34
|
+
}
|
|
35
|
+
// Process types pattern (can match both files and directories)
|
|
36
|
+
if (this.config.typesPattern) {
|
|
37
|
+
const items = await (0, fileUtils_1.findItems)(this.config.typesPattern, this.config.maxDepth);
|
|
38
|
+
allItems.push(...items);
|
|
39
|
+
}
|
|
40
|
+
// Filter out excluded items and remove duplicates
|
|
41
|
+
const uniqueItems = [...new Set(allItems)];
|
|
42
|
+
for (const item of uniqueItems) {
|
|
43
|
+
if (!(0, fileUtils_1.shouldExclude)(item, this.config.excludePatterns)) {
|
|
44
|
+
this.itemsToDelete.push(item);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Sort for consistent output
|
|
48
|
+
this.itemsToDelete.sort();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Displays a preview of all items that will be deleted
|
|
52
|
+
*/
|
|
53
|
+
displayPreview() {
|
|
54
|
+
if (this.itemsToDelete.length === 0) {
|
|
55
|
+
this.logger.log('No items found matching the specified patterns.', 'INFO');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.logger.log(`Preview: Items that will be deleted (${this.itemsToDelete.length} items):`, 'INFO');
|
|
59
|
+
if (this.config.outputFormat === 'json') {
|
|
60
|
+
const items = this.itemsToDelete.map(path => ({ path }));
|
|
61
|
+
console.log(JSON.stringify({ items }, null, 2));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
for (const item of this.itemsToDelete) {
|
|
65
|
+
console.log(` - ${item}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Deletes a single item (file or directory) with appropriate logging
|
|
71
|
+
* @param item - Path of the item to delete
|
|
72
|
+
*/
|
|
73
|
+
async deleteItem(item) {
|
|
74
|
+
// Skip if dry run
|
|
75
|
+
if (this.config.dryRun) {
|
|
76
|
+
this.logger.log(`Would delete: ${item}`, 'INFO');
|
|
77
|
+
this.deletedItems.push(item);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Interactive confirmation
|
|
81
|
+
if (this.config.interactive) {
|
|
82
|
+
const confirmed = await (0, prompts_1.confirmDeletion)(item, this.config.force);
|
|
83
|
+
if (!confirmed) {
|
|
84
|
+
this.logger.log(`Skipped: ${item}`, 'INFO');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Perform deletion
|
|
89
|
+
if ((0, fileUtils_1.isDirectory)(item)) {
|
|
90
|
+
if ((0, fileUtils_1.deleteItem)(item)) {
|
|
91
|
+
this.logger.log(`Deleted directory: ${item}`, 'INFO');
|
|
92
|
+
this.deletedItems.push(item);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.logger.log(`Failed to delete directory: ${item}`, 'ERROR');
|
|
96
|
+
this.failedDeletions.push(item);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if ((0, fileUtils_1.isFile)(item)) {
|
|
100
|
+
if ((0, fileUtils_1.deleteItem)(item)) {
|
|
101
|
+
this.logger.log(`Deleted file: ${item}`, 'INFO');
|
|
102
|
+
this.deletedItems.push(item);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.logger.log(`Failed to delete file: ${item}`, 'ERROR');
|
|
106
|
+
this.failedDeletions.push(item);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.logger.log(`Item not found or already deleted: ${item}`, 'WARNING');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Processes all collected items for deletion based on the current mode
|
|
115
|
+
*/
|
|
116
|
+
async processDeletions() {
|
|
117
|
+
if (this.itemsToDelete.length === 0) {
|
|
118
|
+
this.logger.log('No items to delete.', 'INFO');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Show preview if requested
|
|
122
|
+
if (this.config.preview) {
|
|
123
|
+
this.displayPreview();
|
|
124
|
+
if (!this.config.dryRun && !this.config.force) {
|
|
125
|
+
const proceed = await (0, prompts_1.confirmProceed)();
|
|
126
|
+
if (!proceed) {
|
|
127
|
+
this.logger.log('Deletion cancelled by user.', 'INFO');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Process each item
|
|
133
|
+
for (const item of this.itemsToDelete) {
|
|
134
|
+
await this.deleteItem(item);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the deletion summary
|
|
139
|
+
* @returns DeletionResult object with statistics
|
|
140
|
+
*/
|
|
141
|
+
getSummary() {
|
|
142
|
+
return {
|
|
143
|
+
totalItems: this.itemsToDelete.length,
|
|
144
|
+
deleted: this.deletedItems.length,
|
|
145
|
+
failed: this.failedDeletions.length,
|
|
146
|
+
dryRun: this.config.dryRun,
|
|
147
|
+
failedItems: this.failedDeletions.length > 0 ? this.failedDeletions : undefined
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Prints a summary of the deletion operation
|
|
152
|
+
*/
|
|
153
|
+
printSummary() {
|
|
154
|
+
const summary = this.getSummary();
|
|
155
|
+
if (this.config.outputFormat === 'json') {
|
|
156
|
+
console.log(JSON.stringify({ summary }, null, 2));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
this.logger.log('=== Deletion Summary ===', 'INFO');
|
|
160
|
+
this.logger.log(`Total items found: ${summary.totalItems}`, 'INFO');
|
|
161
|
+
if (summary.dryRun) {
|
|
162
|
+
this.logger.log(`Items that would be deleted: ${summary.deleted}`, 'INFO');
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.logger.log(`Items successfully deleted: ${summary.deleted}`, 'INFO');
|
|
166
|
+
}
|
|
167
|
+
if (summary.failed > 0 && summary.failedItems) {
|
|
168
|
+
this.logger.log(`Failed deletions: ${summary.failed}`, 'ERROR');
|
|
169
|
+
for (const item of summary.failedItems) {
|
|
170
|
+
this.logger.log(` - ${item}`, 'ERROR');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets the exit code based on deletion results
|
|
177
|
+
* @returns 0 for success, 1 for failures
|
|
178
|
+
*/
|
|
179
|
+
getExitCode() {
|
|
180
|
+
return this.failedDeletions.length > 0 ? 1 : 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.DeletionEngine = DeletionEngine;
|
|
184
|
+
//# sourceMappingURL=deletionEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deletionEngine.js","sourceRoot":"","sources":["../../src/core/deletionEngine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kDAQ4B;AAC5B,8CAAmE;AAEnE,MAAa,cAAc;IAOzB,YAAY,MAAc,EAAE,MAAc;QA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AC,CAAC;gBAC1C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF;AAvMD,wCAuMC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for cleansweep
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'INFO' | 'WARNING' | 'ERROR';
|
|
5
|
+
export type OutputFormat = 'plain' | 'json';
|
|
6
|
+
export interface Config {
|
|
7
|
+
dryRun: boolean;
|
|
8
|
+
interactive: boolean;
|
|
9
|
+
force: boolean;
|
|
10
|
+
preview: boolean;
|
|
11
|
+
logFile?: string;
|
|
12
|
+
outputFormat: OutputFormat;
|
|
13
|
+
maxDepth?: number;
|
|
14
|
+
filesPattern?: string;
|
|
15
|
+
foldersPattern?: string;
|
|
16
|
+
typesPattern?: string;
|
|
17
|
+
excludePatterns: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface DeletionResult {
|
|
20
|
+
totalItems: number;
|
|
21
|
+
deleted: number;
|
|
22
|
+
failed: number;
|
|
23
|
+
dryRun: boolean;
|
|
24
|
+
failedItems?: string[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File utility functions for cleansweep
|
|
3
|
+
* Handles file system operations and pattern matching
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a given path should be excluded based on exclusion patterns
|
|
7
|
+
* @param filePath - Path to check
|
|
8
|
+
* @param excludePatterns - Array of exclusion patterns
|
|
9
|
+
* @returns true if should be excluded, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
export declare function shouldExclude(filePath: string, excludePatterns: string[]): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Finds files matching a pattern with optional depth limit
|
|
14
|
+
* @param pattern - Glob pattern to match
|
|
15
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
16
|
+
* @param currentDir - Current directory to search in
|
|
17
|
+
* @returns Array of matching file paths
|
|
18
|
+
*/
|
|
19
|
+
export declare function findFiles(pattern: string, maxDepth?: number, currentDir?: string): Promise<string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Finds directories matching a pattern with optional depth limit
|
|
22
|
+
* @param pattern - Glob pattern to match
|
|
23
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
24
|
+
* @param currentDir - Current directory to search in
|
|
25
|
+
* @returns Array of matching directory paths
|
|
26
|
+
*/
|
|
27
|
+
export declare function findDirectories(pattern: string, maxDepth?: number, currentDir?: string): Promise<string[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Finds both files and directories matching a pattern
|
|
30
|
+
* @param pattern - Glob pattern to match
|
|
31
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
32
|
+
* @param currentDir - Current directory to search in
|
|
33
|
+
* @returns Array of matching paths
|
|
34
|
+
*/
|
|
35
|
+
export declare function findItems(pattern: string, maxDepth?: number, currentDir?: string): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Deletes a file or directory
|
|
38
|
+
* @param itemPath - Path to the item to delete
|
|
39
|
+
* @returns true if successful, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
export declare function deleteItem(itemPath: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a path exists and is a file
|
|
44
|
+
* @param itemPath - Path to check
|
|
45
|
+
* @returns true if exists and is a file
|
|
46
|
+
*/
|
|
47
|
+
export declare function isFile(itemPath: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a path exists and is a directory
|
|
50
|
+
* @param itemPath - Path to check
|
|
51
|
+
* @returns true if exists and is a directory
|
|
52
|
+
*/
|
|
53
|
+
export declare function isDirectory(itemPath: string): boolean;
|
|
54
|
+
//# sourceMappingURL=fileUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAQlF;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,GAAE,MAAsB,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,GAAE,MAAsB,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,GAAE,MAAsB,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC,CAoCnB;AAiBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAgBpD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOhD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOrD"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File utility functions for cleansweep
|
|
4
|
+
* Handles file system operations and pattern matching
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.shouldExclude = shouldExclude;
|
|
41
|
+
exports.findFiles = findFiles;
|
|
42
|
+
exports.findDirectories = findDirectories;
|
|
43
|
+
exports.findItems = findItems;
|
|
44
|
+
exports.deleteItem = deleteItem;
|
|
45
|
+
exports.isFile = isFile;
|
|
46
|
+
exports.isDirectory = isDirectory;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const glob_1 = require("glob");
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a given path should be excluded based on exclusion patterns
|
|
52
|
+
* @param filePath - Path to check
|
|
53
|
+
* @param excludePatterns - Array of exclusion patterns
|
|
54
|
+
* @returns true if should be excluded, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
function shouldExclude(filePath, excludePatterns) {
|
|
57
|
+
for (const pattern of excludePatterns) {
|
|
58
|
+
// Check if path contains the pattern or basename matches
|
|
59
|
+
if (filePath.includes(pattern) || path.basename(filePath) === pattern) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Finds files matching a pattern with optional depth limit
|
|
67
|
+
* @param pattern - Glob pattern to match
|
|
68
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
69
|
+
* @param currentDir - Current directory to search in
|
|
70
|
+
* @returns Array of matching file paths
|
|
71
|
+
*/
|
|
72
|
+
async function findFiles(pattern, maxDepth, currentDir = process.cwd()) {
|
|
73
|
+
const options = {
|
|
74
|
+
cwd: currentDir,
|
|
75
|
+
absolute: false,
|
|
76
|
+
nodir: true
|
|
77
|
+
};
|
|
78
|
+
if (maxDepth !== undefined) {
|
|
79
|
+
options.maxDepth = maxDepth;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const files = await (0, glob_1.glob)(pattern, options);
|
|
83
|
+
return files.map(file => path.relative(process.cwd(), path.resolve(currentDir, file)));
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Finds directories matching a pattern with optional depth limit
|
|
91
|
+
* @param pattern - Glob pattern to match
|
|
92
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
93
|
+
* @param currentDir - Current directory to search in
|
|
94
|
+
* @returns Array of matching directory paths
|
|
95
|
+
*/
|
|
96
|
+
async function findDirectories(pattern, maxDepth, currentDir = process.cwd()) {
|
|
97
|
+
const directories = [];
|
|
98
|
+
/**
|
|
99
|
+
* Recursively search for directories
|
|
100
|
+
*/
|
|
101
|
+
function searchDir(dir, currentDepth = 0) {
|
|
102
|
+
if (maxDepth !== undefined && currentDepth > maxDepth) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
const fullPath = path.join(dir, entry.name);
|
|
109
|
+
const relativePath = path.relative(process.cwd(), fullPath);
|
|
110
|
+
if (entry.isDirectory()) {
|
|
111
|
+
// Check if directory name matches pattern
|
|
112
|
+
if (matchesPattern(entry.name, pattern)) {
|
|
113
|
+
directories.push(relativePath);
|
|
114
|
+
}
|
|
115
|
+
// Recursively search subdirectories
|
|
116
|
+
searchDir(fullPath, currentDepth + 1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
// Skip directories we can't read
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
searchDir(currentDir);
|
|
126
|
+
return directories;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Finds both files and directories matching a pattern
|
|
130
|
+
* @param pattern - Glob pattern to match
|
|
131
|
+
* @param maxDepth - Maximum depth to search (optional)
|
|
132
|
+
* @param currentDir - Current directory to search in
|
|
133
|
+
* @returns Array of matching paths
|
|
134
|
+
*/
|
|
135
|
+
async function findItems(pattern, maxDepth, currentDir = process.cwd()) {
|
|
136
|
+
const items = [];
|
|
137
|
+
/**
|
|
138
|
+
* Recursively search for items
|
|
139
|
+
*/
|
|
140
|
+
function searchDir(dir, currentDepth = 0) {
|
|
141
|
+
if (maxDepth !== undefined && currentDepth > maxDepth) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
146
|
+
for (const entry of entries) {
|
|
147
|
+
const fullPath = path.join(dir, entry.name);
|
|
148
|
+
const relativePath = path.relative(process.cwd(), fullPath);
|
|
149
|
+
// Check if name matches pattern
|
|
150
|
+
if (matchesPattern(entry.name, pattern)) {
|
|
151
|
+
items.push(relativePath);
|
|
152
|
+
}
|
|
153
|
+
// Recursively search subdirectories
|
|
154
|
+
if (entry.isDirectory()) {
|
|
155
|
+
searchDir(fullPath, currentDepth + 1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
// Skip directories we can't read
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
searchDir(currentDir);
|
|
165
|
+
return items;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Simple pattern matching (converts glob to regex-like matching)
|
|
169
|
+
* @param name - Name to check
|
|
170
|
+
* @param pattern - Pattern to match against
|
|
171
|
+
* @returns true if matches, false otherwise
|
|
172
|
+
*/
|
|
173
|
+
function matchesPattern(name, pattern) {
|
|
174
|
+
// Convert glob pattern to regex
|
|
175
|
+
const regexPattern = pattern
|
|
176
|
+
.replace(/\*/g, '.*')
|
|
177
|
+
.replace(/\?/g, '.');
|
|
178
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
179
|
+
return regex.test(name);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Deletes a file or directory
|
|
183
|
+
* @param itemPath - Path to the item to delete
|
|
184
|
+
* @returns true if successful, false otherwise
|
|
185
|
+
*/
|
|
186
|
+
function deleteItem(itemPath) {
|
|
187
|
+
try {
|
|
188
|
+
const fullPath = path.resolve(itemPath);
|
|
189
|
+
const stat = fs.statSync(fullPath);
|
|
190
|
+
if (stat.isDirectory()) {
|
|
191
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
else if (stat.isFile()) {
|
|
195
|
+
fs.unlinkSync(fullPath);
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Checks if a path exists and is a file
|
|
206
|
+
* @param itemPath - Path to check
|
|
207
|
+
* @returns true if exists and is a file
|
|
208
|
+
*/
|
|
209
|
+
function isFile(itemPath) {
|
|
210
|
+
try {
|
|
211
|
+
const stat = fs.statSync(itemPath);
|
|
212
|
+
return stat.isFile();
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Checks if a path exists and is a directory
|
|
220
|
+
* @param itemPath - Path to check
|
|
221
|
+
* @returns true if exists and is a directory
|
|
222
|
+
*/
|
|
223
|
+
function isDirectory(itemPath) {
|
|
224
|
+
try {
|
|
225
|
+
const stat = fs.statSync(itemPath);
|
|
226
|
+
return stat.isDirectory();
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=fileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYH,sCAQC;AASD,8BAqBC;AASD,0CAuCC;AASD,8BAwCC;AAsBD,gCAgBC;AAOD,wBAOC;AAOD,kCAOC;AAnND,uCAAyB;AACzB,2CAA6B;AAC7B,+BAA4B;AAE5B;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,QAAgB,EAAE,eAAyB;IACvE,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,yDAAyD;QACzD,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,SAAS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ACxB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,MAAM,CAAC,QAAgB;IACrC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,QAAgB;IAC1C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for cleansweep
|
|
3
|
+
* Handles logging to console and log files with timestamps
|
|
4
|
+
*/
|
|
5
|
+
import { LogLevel, OutputFormat } from '../types';
|
|
6
|
+
export declare class Logger {
|
|
7
|
+
private logFile?;
|
|
8
|
+
private outputFormat;
|
|
9
|
+
constructor(logFile?: string, outputFormat?: OutputFormat);
|
|
10
|
+
/**
|
|
11
|
+
* Logs a message with timestamp to both console and log file (if specified)
|
|
12
|
+
* @param message - Message to log
|
|
13
|
+
* @param level - Log level (INFO, WARNING, ERROR)
|
|
14
|
+
*/
|
|
15
|
+
log(message: string, level?: LogLevel): void;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the log file with header information
|
|
18
|
+
* @param config - Configuration object with all settings
|
|
19
|
+
*/
|
|
20
|
+
initializeLogFile(config: {
|
|
21
|
+
dryRun: boolean;
|
|
22
|
+
interactive: boolean;
|
|
23
|
+
force: boolean;
|
|
24
|
+
filesPattern?: string;
|
|
25
|
+
foldersPattern?: string;
|
|
26
|
+
typesPattern?: string;
|
|
27
|
+
excludePatterns: string[];
|
|
28
|
+
maxDepth?: number;
|
|
29
|
+
}): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElD,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,YAAY,CAAe;gBAEvB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,GAAE,YAAsB;IAKlE;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,QAAiB,GAAG,IAAI;IA0BpD;;;OAGG;IACH,iBAAiB,CAAC,MAAM,EAAE;QACxB,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,EAAE,OAAO,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI;CA2BT"}
|