devkill 0.12.2
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.es.md +253 -0
- package/README.id.md +238 -0
- package/README.md +377 -0
- package/README.pt.md +241 -0
- package/README.tr.md +242 -0
- package/lib/cli/cli.controller.d.ts +81 -0
- package/lib/cli/cli.controller.js +760 -0
- package/lib/cli/cli.controller.js.map +1 -0
- package/lib/cli/interfaces/cli-options.interface.d.ts +5 -0
- package/lib/cli/interfaces/cli-options.interface.js +2 -0
- package/lib/cli/interfaces/cli-options.interface.js.map +1 -0
- package/lib/cli/interfaces/command-keys.interface.d.ts +17 -0
- package/lib/cli/interfaces/command-keys.interface.js +2 -0
- package/lib/cli/interfaces/command-keys.interface.js.map +1 -0
- package/lib/cli/interfaces/config.interface.d.ts +17 -0
- package/lib/cli/interfaces/config.interface.js +2 -0
- package/lib/cli/interfaces/config.interface.js.map +1 -0
- package/lib/cli/interfaces/index.d.ts +11 -0
- package/lib/cli/interfaces/index.js +12 -0
- package/lib/cli/interfaces/index.js.map +1 -0
- package/lib/cli/interfaces/json-output.interface.d.ts +30 -0
- package/lib/cli/interfaces/json-output.interface.js +2 -0
- package/lib/cli/interfaces/json-output.interface.js.map +1 -0
- package/lib/cli/interfaces/key-press.interface.d.ts +7 -0
- package/lib/cli/interfaces/key-press.interface.js +2 -0
- package/lib/cli/interfaces/key-press.interface.js.map +1 -0
- package/lib/cli/interfaces/node-version.interface.d.ts +5 -0
- package/lib/cli/interfaces/node-version.interface.js +2 -0
- package/lib/cli/interfaces/node-version.interface.js.map +1 -0
- package/lib/cli/interfaces/stats.interface.d.ts +15 -0
- package/lib/cli/interfaces/stats.interface.js +2 -0
- package/lib/cli/interfaces/stats.interface.js.map +1 -0
- package/lib/cli/interfaces/ui-positions.interface.d.ts +5 -0
- package/lib/cli/interfaces/ui-positions.interface.js +2 -0
- package/lib/cli/interfaces/ui-positions.interface.js.map +1 -0
- package/lib/cli/interfaces/version.interface.d.ts +5 -0
- package/lib/cli/interfaces/version.interface.js +2 -0
- package/lib/cli/interfaces/version.interface.js.map +1 -0
- package/lib/cli/models/start-parameters.model.d.ts +7 -0
- package/lib/cli/models/start-parameters.model.js +25 -0
- package/lib/cli/models/start-parameters.model.js.map +1 -0
- package/lib/cli/services/console.service.d.ts +23 -0
- package/lib/cli/services/console.service.js +87 -0
- package/lib/cli/services/console.service.js.map +1 -0
- package/lib/cli/services/https.service.d.ts +4 -0
- package/lib/cli/services/https.service.js +32 -0
- package/lib/cli/services/https.service.js.map +1 -0
- package/lib/cli/services/index.d.ts +7 -0
- package/lib/cli/services/index.js +8 -0
- package/lib/cli/services/index.js.map +1 -0
- package/lib/cli/services/json-output.service.d.ts +20 -0
- package/lib/cli/services/json-output.service.js +101 -0
- package/lib/cli/services/json-output.service.js.map +1 -0
- package/lib/cli/services/results.service.d.ts +13 -0
- package/lib/cli/services/results.service.js +61 -0
- package/lib/cli/services/results.service.js.map +1 -0
- package/lib/cli/services/scan.service.d.ts +13 -0
- package/lib/cli/services/scan.service.js +79 -0
- package/lib/cli/services/scan.service.js.map +1 -0
- package/lib/cli/services/spinner.service.d.ts +9 -0
- package/lib/cli/services/spinner.service.js +27 -0
- package/lib/cli/services/spinner.service.js.map +1 -0
- package/lib/cli/services/ui.service.d.ts +17 -0
- package/lib/cli/services/ui.service.js +59 -0
- package/lib/cli/services/ui.service.js.map +1 -0
- package/lib/cli/services/update.service.d.ts +15 -0
- package/lib/cli/services/update.service.js +37 -0
- package/lib/cli/services/update.service.js.map +1 -0
- package/lib/cli/ui/base.ui.d.ts +28 -0
- package/lib/cli/ui/base.ui.js +49 -0
- package/lib/cli/ui/base.ui.js.map +1 -0
- package/lib/cli/ui/components/general.ui.d.ts +7 -0
- package/lib/cli/ui/components/general.ui.js +13 -0
- package/lib/cli/ui/components/general.ui.js.map +1 -0
- package/lib/cli/ui/components/header/header-ui.constants.d.ts +7 -0
- package/lib/cli/ui/components/header/header-ui.constants.js +7 -0
- package/lib/cli/ui/components/header/header-ui.constants.js.map +1 -0
- package/lib/cli/ui/components/header/header.ui.d.ts +18 -0
- package/lib/cli/ui/components/header/header.ui.js +96 -0
- package/lib/cli/ui/components/header/header.ui.js.map +1 -0
- package/lib/cli/ui/components/header/stats.ui.d.ts +25 -0
- package/lib/cli/ui/components/header/stats.ui.js +198 -0
- package/lib/cli/ui/components/header/stats.ui.js.map +1 -0
- package/lib/cli/ui/components/header/status.ui.d.ts +33 -0
- package/lib/cli/ui/components/header/status.ui.js +188 -0
- package/lib/cli/ui/components/header/status.ui.js.map +1 -0
- package/lib/cli/ui/components/help/help-command.ui.d.ts +9 -0
- package/lib/cli/ui/components/help/help-command.ui.js +61 -0
- package/lib/cli/ui/components/help/help-command.ui.js.map +1 -0
- package/lib/cli/ui/components/help/help.constants.d.ts +8 -0
- package/lib/cli/ui/components/help/help.constants.js +270 -0
- package/lib/cli/ui/components/help/help.constants.js.map +1 -0
- package/lib/cli/ui/components/help/help.ui.d.ts +30 -0
- package/lib/cli/ui/components/help/help.ui.js +176 -0
- package/lib/cli/ui/components/help/help.ui.js.map +1 -0
- package/lib/cli/ui/components/logs.ui.d.ts +24 -0
- package/lib/cli/ui/components/logs.ui.js +132 -0
- package/lib/cli/ui/components/logs.ui.js.map +1 -0
- package/lib/cli/ui/components/options.ui.d.ts +29 -0
- package/lib/cli/ui/components/options.ui.js +327 -0
- package/lib/cli/ui/components/options.ui.js.map +1 -0
- package/lib/cli/ui/components/profile-picker.ui.d.ts +25 -0
- package/lib/cli/ui/components/profile-picker.ui.js +117 -0
- package/lib/cli/ui/components/profile-picker.ui.js.map +1 -0
- package/lib/cli/ui/components/result-details.ui.d.ts +23 -0
- package/lib/cli/ui/components/result-details.ui.js +182 -0
- package/lib/cli/ui/components/result-details.ui.js.map +1 -0
- package/lib/cli/ui/components/results.ui.d.ts +86 -0
- package/lib/cli/ui/components/results.ui.js +620 -0
- package/lib/cli/ui/components/results.ui.js.map +1 -0
- package/lib/cli/ui/components/warning.ui.d.ts +12 -0
- package/lib/cli/ui/components/warning.ui.js +30 -0
- package/lib/cli/ui/components/warning.ui.js.map +1 -0
- package/lib/cli/ui/heavy.ui.d.ts +18 -0
- package/lib/cli/ui/heavy.ui.js +37 -0
- package/lib/cli/ui/heavy.ui.js.map +1 -0
- package/lib/cli/ui/index.d.ts +14 -0
- package/lib/cli/ui/index.js +15 -0
- package/lib/cli/ui/index.js.map +1 -0
- package/lib/constants/cli.constants.d.ts +14 -0
- package/lib/constants/cli.constants.js +138 -0
- package/lib/constants/cli.constants.js.map +1 -0
- package/lib/constants/index.d.ts +8 -0
- package/lib/constants/index.js +9 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/main.constants.d.ts +96 -0
- package/lib/constants/main.constants.js +79 -0
- package/lib/constants/main.constants.js.map +1 -0
- package/lib/constants/messages.constants.d.ts +31 -0
- package/lib/constants/messages.constants.js +37 -0
- package/lib/constants/messages.constants.js.map +1 -0
- package/lib/constants/options.constants.d.ts +6 -0
- package/lib/constants/options.constants.js +8 -0
- package/lib/constants/options.constants.js.map +1 -0
- package/lib/constants/os-service-map.constants.d.ts +10 -0
- package/lib/constants/os-service-map.constants.js +11 -0
- package/lib/constants/os-service-map.constants.js.map +1 -0
- package/lib/constants/result-descriptions.constants.d.ts +142 -0
- package/lib/constants/result-descriptions.constants.js +203 -0
- package/lib/constants/result-descriptions.constants.js.map +1 -0
- package/lib/constants/sort.result.d.ts +6 -0
- package/lib/constants/sort.result.js +22 -0
- package/lib/constants/sort.result.js.map +1 -0
- package/lib/constants/spinner.constants.d.ts +5 -0
- package/lib/constants/spinner.constants.js +88 -0
- package/lib/constants/spinner.constants.js.map +1 -0
- package/lib/constants/status.constants.d.ts +7 -0
- package/lib/constants/status.constants.js +9 -0
- package/lib/constants/status.constants.js.map +1 -0
- package/lib/constants/update.constants.d.ts +2 -0
- package/lib/constants/update.constants.js +3 -0
- package/lib/constants/update.constants.js.map +1 -0
- package/lib/constants/workers.constants.d.ts +14 -0
- package/lib/constants/workers.constants.js +16 -0
- package/lib/constants/workers.constants.js.map +1 -0
- package/lib/core/constants/global-ignored.constants.d.ts +1 -0
- package/lib/core/constants/global-ignored.constants.js +44 -0
- package/lib/core/constants/global-ignored.constants.js.map +1 -0
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +2 -0
- package/lib/core/constants/index.js.map +1 -0
- package/lib/core/constants/profiles.constants.d.ts +8 -0
- package/lib/core/constants/profiles.constants.js +138 -0
- package/lib/core/constants/profiles.constants.js.map +1 -0
- package/lib/core/devkill.d.ts +25 -0
- package/lib/core/devkill.js +129 -0
- package/lib/core/devkill.js.map +1 -0
- package/lib/core/index.d.ts +4 -0
- package/lib/core/index.js +5 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/interfaces/devkill.interface.d.ts +78 -0
- package/lib/core/interfaces/devkill.interface.js +2 -0
- package/lib/core/interfaces/devkill.interface.js.map +1 -0
- package/lib/core/interfaces/devkillrc-config.interface.d.ts +87 -0
- package/lib/core/interfaces/devkillrc-config.interface.js +12 -0
- package/lib/core/interfaces/devkillrc-config.interface.js.map +1 -0
- package/lib/core/interfaces/file-service.interface.d.ts +76 -0
- package/lib/core/interfaces/file-service.interface.js +2 -0
- package/lib/core/interfaces/file-service.interface.js.map +1 -0
- package/lib/core/interfaces/folder.interface.d.ts +89 -0
- package/lib/core/interfaces/folder.interface.js +2 -0
- package/lib/core/interfaces/folder.interface.js.map +1 -0
- package/lib/core/interfaces/index.d.ts +6 -0
- package/lib/core/interfaces/index.js +7 -0
- package/lib/core/interfaces/index.js.map +1 -0
- package/lib/core/interfaces/logger-service.interface.d.ts +59 -0
- package/lib/core/interfaces/logger-service.interface.js +2 -0
- package/lib/core/interfaces/logger-service.interface.js.map +1 -0
- package/lib/core/interfaces/npkill.interface.d.ts +78 -0
- package/lib/core/interfaces/npkill.interface.js +2 -0
- package/lib/core/interfaces/npkill.interface.js.map +1 -0
- package/lib/core/interfaces/npkillrc-config.interface.d.ts +87 -0
- package/lib/core/interfaces/npkillrc-config.interface.js +12 -0
- package/lib/core/interfaces/npkillrc-config.interface.js.map +1 -0
- package/lib/core/interfaces/profile.interface.d.ts +9 -0
- package/lib/core/interfaces/profile.interface.js +2 -0
- package/lib/core/interfaces/profile.interface.js.map +1 -0
- package/lib/core/interfaces/search-status.model.d.ts +35 -0
- package/lib/core/interfaces/search-status.model.js +48 -0
- package/lib/core/interfaces/search-status.model.js.map +1 -0
- package/lib/core/interfaces/services.interface.d.ts +26 -0
- package/lib/core/interfaces/services.interface.js +2 -0
- package/lib/core/interfaces/services.interface.js.map +1 -0
- package/lib/core/npkill.d.ts +25 -0
- package/lib/core/npkill.js +129 -0
- package/lib/core/npkill.js.map +1 -0
- package/lib/core/services/config/config-merger.d.ts +17 -0
- package/lib/core/services/config/config-merger.js +57 -0
- package/lib/core/services/config/config-merger.js.map +1 -0
- package/lib/core/services/config/config-validator.d.ts +3 -0
- package/lib/core/services/config/config-validator.js +43 -0
- package/lib/core/services/config/config-validator.js.map +1 -0
- package/lib/core/services/config/index.d.ts +4 -0
- package/lib/core/services/config/index.js +5 -0
- package/lib/core/services/config/index.js.map +1 -0
- package/lib/core/services/config/profile-validator.d.ts +6 -0
- package/lib/core/services/config/profile-validator.js +68 -0
- package/lib/core/services/config/profile-validator.js.map +1 -0
- package/lib/core/services/config/property-validators.d.ts +33 -0
- package/lib/core/services/config/property-validators.js +125 -0
- package/lib/core/services/config/property-validators.js.map +1 -0
- package/lib/core/services/config.service.d.ts +37 -0
- package/lib/core/services/config.service.js +100 -0
- package/lib/core/services/config.service.js.map +1 -0
- package/lib/core/services/files/files.service.d.ts +28 -0
- package/lib/core/services/files/files.service.js +207 -0
- package/lib/core/services/files/files.service.js.map +1 -0
- package/lib/core/services/files/files.worker.d.ts +1 -0
- package/lib/core/services/files/files.worker.js +286 -0
- package/lib/core/services/files/files.worker.js.map +1 -0
- package/lib/core/services/files/files.worker.service.d.ts +90 -0
- package/lib/core/services/files/files.worker.service.js +216 -0
- package/lib/core/services/files/files.worker.service.js.map +1 -0
- package/lib/core/services/files/index.d.ts +4 -0
- package/lib/core/services/files/index.js +5 -0
- package/lib/core/services/files/index.js.map +1 -0
- package/lib/core/services/files/unix-files.service.d.ts +9 -0
- package/lib/core/services/files/unix-files.service.js +28 -0
- package/lib/core/services/files/unix-files.service.js.map +1 -0
- package/lib/core/services/files/windows-files.service.d.ts +9 -0
- package/lib/core/services/files/windows-files.service.js +16 -0
- package/lib/core/services/files/windows-files.service.js.map +1 -0
- package/lib/core/services/index.d.ts +5 -0
- package/lib/core/services/index.js +6 -0
- package/lib/core/services/index.js.map +1 -0
- package/lib/core/services/logger.service.d.ts +22 -0
- package/lib/core/services/logger.service.js +84 -0
- package/lib/core/services/logger.service.js.map +1 -0
- package/lib/core/services/profiles.service.d.ts +54 -0
- package/lib/core/services/profiles.service.js +86 -0
- package/lib/core/services/profiles.service.js.map +1 -0
- package/lib/core/services/stream.service.d.ts +12 -0
- package/lib/core/services/stream.service.js +39 -0
- package/lib/core/services/stream.service.js.map +1 -0
- package/lib/dirname.d.ts +2 -0
- package/lib/dirname.js +6 -0
- package/lib/dirname.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/main.d.ts +2 -0
- package/lib/main.js +19 -0
- package/lib/main.js.map +1 -0
- package/lib/utils/get-file-content.d.ts +1 -0
- package/lib/utils/get-file-content.js +6 -0
- package/lib/utils/get-file-content.js.map +1 -0
- package/lib/utils/is-safe-to-delete.d.ts +1 -0
- package/lib/utils/is-safe-to-delete.js +9 -0
- package/lib/utils/is-safe-to-delete.js.map +1 -0
- package/lib/utils/unit-conversions.d.ts +11 -0
- package/lib/utils/unit-conversions.js +54 -0
- package/lib/utils/unit-conversions.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { convertGbToBytes } from '../../utils/unit-conversions.js';
|
|
2
|
+
export class JsonOutputService {
|
|
3
|
+
stdout;
|
|
4
|
+
stderr;
|
|
5
|
+
OUTPUT_VERSION = 1;
|
|
6
|
+
results = [];
|
|
7
|
+
scanStartTime = 0;
|
|
8
|
+
isStreamMode = false;
|
|
9
|
+
constructor(stdout = process.stdout, stderr = process.stderr) {
|
|
10
|
+
this.stdout = stdout;
|
|
11
|
+
this.stderr = stderr;
|
|
12
|
+
}
|
|
13
|
+
initializeSession(streamMode = false) {
|
|
14
|
+
this.results = [];
|
|
15
|
+
this.scanStartTime = Date.now();
|
|
16
|
+
this.isStreamMode = streamMode;
|
|
17
|
+
}
|
|
18
|
+
processResult(folder) {
|
|
19
|
+
if (this.isStreamMode) {
|
|
20
|
+
this.writeStreamResult(folder);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.addResult(folder);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
completeScan() {
|
|
27
|
+
if (!this.isStreamMode && this.results.length > 0) {
|
|
28
|
+
this.writeSimpleResults();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
writeStreamResult(folder) {
|
|
32
|
+
const output = {
|
|
33
|
+
version: this.OUTPUT_VERSION,
|
|
34
|
+
result: this.sanitizeFolderForOutput(folder),
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
this.stdout.write(`${JSON.stringify(output)}\n`);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const errorMessage = error instanceof Error
|
|
41
|
+
? error.message
|
|
42
|
+
: 'Unknown JSON serialization error';
|
|
43
|
+
this.writeError(`Failed to serialize result to JSON: ${errorMessage}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
addResult(folder) {
|
|
47
|
+
this.results.push(this.sanitizeFolderForOutput(folder));
|
|
48
|
+
}
|
|
49
|
+
writeSimpleResults() {
|
|
50
|
+
const runDuration = Date.now() - this.scanStartTime;
|
|
51
|
+
const output = {
|
|
52
|
+
version: this.OUTPUT_VERSION,
|
|
53
|
+
results: this.results,
|
|
54
|
+
meta: {
|
|
55
|
+
resultsCount: this.results.length,
|
|
56
|
+
runDuration,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
this.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const errorMessage = error instanceof Error
|
|
64
|
+
? error.message
|
|
65
|
+
: 'Unknown JSON serialization error';
|
|
66
|
+
this.writeError(`Failed to serialize results to JSON: ${errorMessage}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
writeError(error) {
|
|
70
|
+
const errorMessage = error instanceof Error ? error.message : error;
|
|
71
|
+
const errorOutput = {
|
|
72
|
+
version: this.OUTPUT_VERSION,
|
|
73
|
+
error: true,
|
|
74
|
+
message: errorMessage,
|
|
75
|
+
timestamp: new Date().getDate(),
|
|
76
|
+
};
|
|
77
|
+
this.stderr.write(`${JSON.stringify(errorOutput)}\n`);
|
|
78
|
+
}
|
|
79
|
+
getResultsCount() {
|
|
80
|
+
return this.results.length;
|
|
81
|
+
}
|
|
82
|
+
handleShutdown() {
|
|
83
|
+
if (!this.isStreamMode && this.results.length > 0) {
|
|
84
|
+
this.writeSimpleResults();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
sanitizeFolderForOutput(folder) {
|
|
88
|
+
return {
|
|
89
|
+
path: folder.path,
|
|
90
|
+
size: convertGbToBytes(folder.size),
|
|
91
|
+
modificationTime: folder.modificationTime,
|
|
92
|
+
riskAnalysis: folder.riskAnalysis
|
|
93
|
+
? {
|
|
94
|
+
isSensitive: folder.riskAnalysis.isSensitive,
|
|
95
|
+
reason: folder.riskAnalysis.reason,
|
|
96
|
+
}
|
|
97
|
+
: undefined,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=json-output.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-output.service.js","sourceRoot":"","sources":["../../../src/cli/services/json-output.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AASnE,MAAM,OAAO,iBAAiB;IAOT;IACA;IAPF,cAAc,GAAG,CAAC,CAAC;IAC5B,OAAO,GAA6B,EAAE,CAAC;IACvC,aAAa,GAAG,CAAC,CAAC;IAClB,YAAY,GAAG,KAAK,CAAC;IAE7B,YACmB,SAA6B,OAAO,CAAC,MAAM,EAC3C,SAA6B,OAAO,CAAC,MAAM;QAD3C,WAAM,GAAN,MAAM,CAAqC;QAC3C,WAAM,GAAN,MAAM,CAAqC;IAC3D,CAAC;IAEJ,iBAAiB,CAAC,UAAU,GAAG,KAAK;QAClC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,aAAa,CAAC,MAA0B;QACtC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,MAA0B;QAClD,MAAM,MAAM,GAAqB;YAC/B,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,MAAM,EAAE,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC;SAC7C,CAAC;QAEF,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC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,CAAC;QACpE,MAAM,WAAW,GAAoB;YACnC,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,YAAY;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;SAChC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAEO,uBAAuB,CAC7B,MAA0B;QAE1B,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC;YACnC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,YAAY,EAAE,MAAM,CAAC,YAAY;gBAC/B,CAAC,CAAC;oBACE,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,WAAW;oBAC5C,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;iBACnC;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CliScanFoundFolder, IStats } from '../interfaces/index.js';
|
|
2
|
+
export declare class ResultsService {
|
|
3
|
+
results: CliScanFoundFolder[];
|
|
4
|
+
private sizeUnit;
|
|
5
|
+
private statsDirty;
|
|
6
|
+
private cachedStats;
|
|
7
|
+
addResult(result: CliScanFoundFolder): void;
|
|
8
|
+
sortResults(method: string): void;
|
|
9
|
+
reset(): void;
|
|
10
|
+
invalidateStats(): void;
|
|
11
|
+
setSizeUnit(sizeUnit: 'auto' | 'mb' | 'gb'): void;
|
|
12
|
+
getStats(): IStats;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { FOLDER_SORT } from '../../constants/sort.result.js';
|
|
3
|
+
import { formatSize } from '../../utils/unit-conversions.js';
|
|
4
|
+
export class ResultsService {
|
|
5
|
+
results = [];
|
|
6
|
+
sizeUnit = 'auto';
|
|
7
|
+
statsDirty = true;
|
|
8
|
+
cachedStats = null;
|
|
9
|
+
addResult(result) {
|
|
10
|
+
this.results.push(result);
|
|
11
|
+
this.statsDirty = true;
|
|
12
|
+
}
|
|
13
|
+
sortResults(method) {
|
|
14
|
+
this.results = this.results.sort(FOLDER_SORT[method]);
|
|
15
|
+
this.statsDirty = true;
|
|
16
|
+
}
|
|
17
|
+
reset() {
|
|
18
|
+
this.results = [];
|
|
19
|
+
this.statsDirty = true;
|
|
20
|
+
this.cachedStats = null;
|
|
21
|
+
}
|
|
22
|
+
invalidateStats() {
|
|
23
|
+
this.statsDirty = true;
|
|
24
|
+
}
|
|
25
|
+
setSizeUnit(sizeUnit) {
|
|
26
|
+
this.sizeUnit = sizeUnit;
|
|
27
|
+
}
|
|
28
|
+
getStats() {
|
|
29
|
+
if (!this.statsDirty && this.cachedStats !== null) {
|
|
30
|
+
return this.cachedStats;
|
|
31
|
+
}
|
|
32
|
+
let spaceReleased = 0;
|
|
33
|
+
const typeCounts = new Map();
|
|
34
|
+
const totalSpace = this.results.reduce((total, folder) => {
|
|
35
|
+
if (folder.status === 'deleted') {
|
|
36
|
+
spaceReleased += folder.size;
|
|
37
|
+
}
|
|
38
|
+
const folderType = path.basename(folder.path);
|
|
39
|
+
typeCounts.set(folderType, (typeCounts.get(folderType) || 0) + 1);
|
|
40
|
+
return total + folder.size;
|
|
41
|
+
}, 0);
|
|
42
|
+
const formattedTotal = formatSize(totalSpace, this.sizeUnit);
|
|
43
|
+
const formattedReleased = formatSize(spaceReleased, this.sizeUnit);
|
|
44
|
+
const resultsTypesCount = Array.from(typeCounts.entries())
|
|
45
|
+
.map(([type, count]) => ({ type, count }))
|
|
46
|
+
.sort((a, b) => {
|
|
47
|
+
if (b.count !== a.count) {
|
|
48
|
+
return b.count - a.count;
|
|
49
|
+
}
|
|
50
|
+
return a.type.localeCompare(b.type);
|
|
51
|
+
});
|
|
52
|
+
this.cachedStats = {
|
|
53
|
+
spaceReleased: formattedReleased.text,
|
|
54
|
+
totalSpace: formattedTotal.text,
|
|
55
|
+
resultsTypesCount,
|
|
56
|
+
};
|
|
57
|
+
this.statsDirty = false;
|
|
58
|
+
return this.cachedStats;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=results.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.service.js","sourceRoot":"","sources":["../../../src/cli/services/results.service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAO7D,MAAM,OAAO,cAAc;IACzB,OAAO,GAAyB,EAAE,CAAC;IAC3B,QAAQ,GAAyB,MAAM,CAAC;IACxC,UAAU,GAAG,IAAI,CAAC;IAClB,WAAW,GAAkB,IAAI,CAAC;IAE1C,SAAS,CAAC,MAA0B;QAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC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AE,CACrB;aACE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;aACzC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACb,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;YAC3B,CAAC;YACD,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,WAAW,GAAG;YACjB,aAAa,EAAE,iBAAiB,CAAC,IAAI;YACrC,UAAU,EAAE,cAAc,CAAC,IAAI;YAC/B,iBAAiB;SAClB,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Devkill } from '@core/devkill';
|
|
2
|
+
import { type Observable } from 'rxjs';
|
|
3
|
+
import type { CliScanFoundFolder, IConfig } from '../interfaces';
|
|
4
|
+
export interface CalculateFolderStatsOptions {
|
|
5
|
+
getModificationTimeForSensitiveResults: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class ScanService {
|
|
8
|
+
private readonly npkill;
|
|
9
|
+
constructor(npkill: Devkill);
|
|
10
|
+
scan(config: IConfig): Observable<CliScanFoundFolder>;
|
|
11
|
+
calculateFolderStats(nodeFolder: CliScanFoundFolder, options?: CalculateFolderStatsOptions): Observable<CliScanFoundFolder>;
|
|
12
|
+
private isExcludedDangerousDirectory;
|
|
13
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { catchError, filter, firstValueFrom, map, of, switchMap, tap, timeout, } from 'rxjs';
|
|
4
|
+
import { convertBytesToGb } from '../../utils/unit-conversions.js';
|
|
5
|
+
export class ScanService {
|
|
6
|
+
npkill;
|
|
7
|
+
constructor(npkill) {
|
|
8
|
+
this.npkill = npkill;
|
|
9
|
+
}
|
|
10
|
+
scan(config) {
|
|
11
|
+
const { targets, exclude, sortBy } = config;
|
|
12
|
+
const params = {
|
|
13
|
+
targets,
|
|
14
|
+
exclude,
|
|
15
|
+
performRiskAnalysis: true,
|
|
16
|
+
sortBy: sortBy,
|
|
17
|
+
};
|
|
18
|
+
const results$ = this.npkill.startScan$(config.folderRoot, params);
|
|
19
|
+
const nonExcludedResults$ = results$.pipe(filter((path) => !this.isExcludedDangerousDirectory(path, config.excludeSensitiveResults)));
|
|
20
|
+
return nonExcludedResults$.pipe(map(({ path, riskAnalysis }) => ({
|
|
21
|
+
path,
|
|
22
|
+
size: 0,
|
|
23
|
+
modificationTime: -1,
|
|
24
|
+
riskAnalysis,
|
|
25
|
+
status: 'live',
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
calculateFolderStats(nodeFolder, options = {
|
|
29
|
+
/** Saves resources by not scanning a result that is probably not of interest. */
|
|
30
|
+
getModificationTimeForSensitiveResults: false,
|
|
31
|
+
}) {
|
|
32
|
+
return this.npkill.getSize$(nodeFolder.path).pipe(timeout(30000), // 30 seconds timeout
|
|
33
|
+
catchError(() => {
|
|
34
|
+
// If size calculation fails or times out, keep size as 0 but mark as calculated
|
|
35
|
+
nodeFolder.size = 0;
|
|
36
|
+
nodeFolder.modificationTime = 1; // 1 = calculated, -1 = not calculated
|
|
37
|
+
return of({ size: 0, unit: 'bytes' });
|
|
38
|
+
}), tap(({ size }) => {
|
|
39
|
+
nodeFolder.size = convertBytesToGb(size);
|
|
40
|
+
}), switchMap(async () => {
|
|
41
|
+
if (nodeFolder.riskAnalysis?.isSensitive &&
|
|
42
|
+
!options.getModificationTimeForSensitiveResults) {
|
|
43
|
+
nodeFolder.modificationTime = -1;
|
|
44
|
+
return nodeFolder;
|
|
45
|
+
}
|
|
46
|
+
const parentFolder = join(nodeFolder.path, '../');
|
|
47
|
+
const normalizedParent = parentFolder.replace(/\\/g, '/').toLowerCase();
|
|
48
|
+
const normalizedHome = os.homedir().replace(/\\/g, '/').toLowerCase();
|
|
49
|
+
const isDirectChildOfHome = normalizedHome && normalizedParent === normalizedHome;
|
|
50
|
+
// If it's directly under HOME, skip modification time calculation
|
|
51
|
+
if (isDirectChildOfHome) {
|
|
52
|
+
nodeFolder.modificationTime = -1;
|
|
53
|
+
return nodeFolder;
|
|
54
|
+
}
|
|
55
|
+
// For other folders, scan the parent folder for modification time
|
|
56
|
+
try {
|
|
57
|
+
const result = await firstValueFrom(this.npkill.getNewestFile$(parentFolder).pipe(timeout(10000), // 10 seconds timeout for modification time
|
|
58
|
+
catchError(() => of(null))));
|
|
59
|
+
nodeFolder.modificationTime = result ? result.timestamp : 1;
|
|
60
|
+
return nodeFolder;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
nodeFolder.modificationTime = 1;
|
|
64
|
+
return nodeFolder;
|
|
65
|
+
}
|
|
66
|
+
}), catchError(() => {
|
|
67
|
+
// Final fallback: mark as calculated with default values
|
|
68
|
+
nodeFolder.modificationTime = 1;
|
|
69
|
+
if (nodeFolder.size === undefined || nodeFolder.size === null) {
|
|
70
|
+
nodeFolder.size = 0;
|
|
71
|
+
}
|
|
72
|
+
return of(nodeFolder);
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
isExcludedDangerousDirectory(scanResult, excludeSensitiveResults) {
|
|
76
|
+
return Boolean(excludeSensitiveResults && scanResult.riskAnalysis?.isSensitive);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=scan.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.service.js","sourceRoot":"","sources":["../../../src/cli/services/scan.service.ts"],"names":[],"mappings":"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AAG,MAAM,cAAc,CACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,IAAI,CAC3C,OAAO,CAAC,KAAK,CAAC,EAAE,2CAA2C;gBAC3D,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAC3B,CACF,CAAC;gBAEF,UAAU,CAAC,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,OAAO,UAAU,CAAC;YACpB,CAAC;YAAC,MAAM,CAAC;gBACP,UAAU,CAAC,gBAAgB,GAAG,CAAC,CAAC;gBAChC,OAAO,UAAU,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,EACF,UAAU,CAAC,GAAG,EAAE;YACd,yDAAyD;YACzD,UAAU,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAChC,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBAC9D,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,4BAA4B,CAClC,UAA2B,EAC3B,uBAAgC;QAEhC,OAAO,OAAO,CACZ,uBAAuB,IAAI,UAAU,CAAC,YAAY,EAAE,WAAW,CAChE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class SpinnerService {
|
|
2
|
+
spinner = [];
|
|
3
|
+
count = -1;
|
|
4
|
+
setSpinner(spinner) {
|
|
5
|
+
this.spinner = spinner;
|
|
6
|
+
this.reset();
|
|
7
|
+
}
|
|
8
|
+
nextFrame() {
|
|
9
|
+
this.updateCount();
|
|
10
|
+
return this.spinner[this.count];
|
|
11
|
+
}
|
|
12
|
+
reset() {
|
|
13
|
+
this.count = -1;
|
|
14
|
+
}
|
|
15
|
+
updateCount() {
|
|
16
|
+
if (this.isLastFrame()) {
|
|
17
|
+
this.count = 0;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
++this.count;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
isLastFrame() {
|
|
24
|
+
return this.count === this.spinner.length - 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=spinner.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.service.js","sourceRoot":"","sources":["../../../src/cli/services/spinner.service.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAc;IACjB,OAAO,GAAa,EAAE,CAAC;IACvB,KAAK,GAAG,CAAC,CAAC,CAAC;IAEnB,UAAU,CAAC,OAAiB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,SAAS;QACP,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAClB,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,EAAE,IAAI,CAAC,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseUi, Position } from '../ui/index.js';
|
|
2
|
+
export declare class UiService {
|
|
3
|
+
stdin: NodeJS.ReadStream;
|
|
4
|
+
uiComponents: BaseUi[];
|
|
5
|
+
setRawMode(set?: boolean): void;
|
|
6
|
+
setCursorVisible(visible: boolean): void;
|
|
7
|
+
add(component: BaseUi): void;
|
|
8
|
+
remove(baseUiId: string): void;
|
|
9
|
+
renderAll(): void;
|
|
10
|
+
setFreezeAll(freeze: boolean): void;
|
|
11
|
+
setVisibleAll(visible: boolean): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
print(text: string): void;
|
|
14
|
+
printAt(message: string, position: Position): void;
|
|
15
|
+
setCursorAt({ x, y }: Position): void;
|
|
16
|
+
clearLine(row: number): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import ansiEscapes from 'ansi-escapes';
|
|
2
|
+
export class UiService {
|
|
3
|
+
stdin = process.stdin;
|
|
4
|
+
// public stdout: NodeJS.WriteStream = process.stdout;
|
|
5
|
+
uiComponents = [];
|
|
6
|
+
setRawMode(set = true) {
|
|
7
|
+
if (this.stdin.isTTY) {
|
|
8
|
+
this.stdin.setRawMode(set);
|
|
9
|
+
}
|
|
10
|
+
process.stdin.resume();
|
|
11
|
+
}
|
|
12
|
+
setCursorVisible(visible) {
|
|
13
|
+
const instruction = visible
|
|
14
|
+
? ansiEscapes.cursorShow
|
|
15
|
+
: ansiEscapes.cursorHide;
|
|
16
|
+
this.print(instruction);
|
|
17
|
+
}
|
|
18
|
+
add(component) {
|
|
19
|
+
this.uiComponents.push(component);
|
|
20
|
+
}
|
|
21
|
+
remove(baseUiId) {
|
|
22
|
+
this.uiComponents = this.uiComponents.filter((c) => c.id !== baseUiId);
|
|
23
|
+
}
|
|
24
|
+
renderAll() {
|
|
25
|
+
this.clear();
|
|
26
|
+
this.uiComponents.forEach((component) => {
|
|
27
|
+
if (component.visible) {
|
|
28
|
+
component.render();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
setFreezeAll(freeze) {
|
|
33
|
+
this.uiComponents.forEach((component) => {
|
|
34
|
+
component.freezed = freeze;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
setVisibleAll(visible) {
|
|
38
|
+
this.uiComponents.forEach((component) => {
|
|
39
|
+
component.setVisible(visible);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
clear() {
|
|
43
|
+
this.print(ansiEscapes.clearTerminal);
|
|
44
|
+
}
|
|
45
|
+
print(text) {
|
|
46
|
+
process.stdout.write.bind(process.stdout)(text);
|
|
47
|
+
}
|
|
48
|
+
printAt(message, position) {
|
|
49
|
+
this.setCursorAt(position);
|
|
50
|
+
this.print(message);
|
|
51
|
+
}
|
|
52
|
+
setCursorAt({ x, y }) {
|
|
53
|
+
this.print(ansiEscapes.cursorTo(x, y));
|
|
54
|
+
}
|
|
55
|
+
clearLine(row) {
|
|
56
|
+
this.printAt(ansiEscapes.eraseLine, { x: 0, y: row });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ui.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.service.js","sourceRoot":"","sources":["../../../src/cli/services/ui.service.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAGvC,MAAM,OAAO,SAAS;IACpB,KAAK,GAAsB,OAAO,CAAC,KAAK,CAAC;IACzC,sDAAsD;IACtD,YAAY,GAAa,EAAE,CAAC;IAE5B,UAAU,CAAC,GAAG,GAAG,IAAI;QACnB,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;IAED,gBAAgB,CAAC,OAAgB;QAC/B,MAAM,WAAW,GAAG,OAAO;YACzB,CAAC,CAAC,WAAW,CAAC,UAAU;YACxB,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC;QAC3B,IAAI,CAAC,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AO,CAAC,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAY;QAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HttpsService } from './https.service.js';
|
|
2
|
+
export declare class UpdateService {
|
|
3
|
+
private readonly httpsService;
|
|
4
|
+
constructor(httpsService: HttpsService);
|
|
5
|
+
/**
|
|
6
|
+
* Check if localVersion is greater or equal to remote version
|
|
7
|
+
* ignoring the pre-release tag. ex: 1.3.12 = 1.3.12-21
|
|
8
|
+
*/
|
|
9
|
+
isUpdated(localVersion: string): Promise<boolean>;
|
|
10
|
+
private compareVersions;
|
|
11
|
+
private getRemoteVersion;
|
|
12
|
+
private isSameVersion;
|
|
13
|
+
/** Valid to compare versions up to 99999.99999.99999 */
|
|
14
|
+
private isLocalVersionGreater;
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { VERSION_CHECK_DIRECTION, VERSION_KEY, } from '../../constants/update.constants.js';
|
|
2
|
+
export class UpdateService {
|
|
3
|
+
httpsService;
|
|
4
|
+
constructor(httpsService) {
|
|
5
|
+
this.httpsService = httpsService;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if localVersion is greater or equal to remote version
|
|
9
|
+
* ignoring the pre-release tag. ex: 1.3.12 = 1.3.12-21
|
|
10
|
+
*/
|
|
11
|
+
async isUpdated(localVersion) {
|
|
12
|
+
const removePreReaseTag = (value) => value.split('-')[0];
|
|
13
|
+
const localVersionPrepared = removePreReaseTag(localVersion);
|
|
14
|
+
const remoteVersion = await this.getRemoteVersion();
|
|
15
|
+
const remoteVersionPrepared = removePreReaseTag(remoteVersion);
|
|
16
|
+
return this.compareVersions(localVersionPrepared, remoteVersionPrepared);
|
|
17
|
+
}
|
|
18
|
+
compareVersions(local, remote) {
|
|
19
|
+
return (this.isSameVersion(local, remote) ||
|
|
20
|
+
this.isLocalVersionGreater(local, remote));
|
|
21
|
+
}
|
|
22
|
+
async getRemoteVersion() {
|
|
23
|
+
const response = await this.httpsService.getJson(VERSION_CHECK_DIRECTION);
|
|
24
|
+
return response[VERSION_KEY];
|
|
25
|
+
}
|
|
26
|
+
isSameVersion(version1, version2) {
|
|
27
|
+
return version1 === version2;
|
|
28
|
+
}
|
|
29
|
+
/** Valid to compare versions up to 99999.99999.99999 */
|
|
30
|
+
isLocalVersionGreater(local, remote) {
|
|
31
|
+
const leadingZeros = (value) => `00000${value}`.substring(-5);
|
|
32
|
+
const localLeaded = +local.split('.').map(leadingZeros).join('');
|
|
33
|
+
const remoteLeaded = +remote.split('.').map(leadingZeros).join('');
|
|
34
|
+
return localLeaded >= remoteLeaded;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=update.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.service.js","sourceRoot":"","sources":["../../../src/cli/services/update.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,WAAW,GACZ,MAAM,qCAAqC,CAAC;AAI7C,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAE3D;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,YAAoB;QAClC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzE,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,YAAY,CA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
export interface Position {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface InteractiveUi {
|
|
7
|
+
onKeyInput: (key: IKeyPress) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class BaseUi {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
freezed: boolean;
|
|
12
|
+
protected _position: Position;
|
|
13
|
+
protected _visible: boolean;
|
|
14
|
+
private readonly stdout;
|
|
15
|
+
protected printAt(message: string, position: Position): void;
|
|
16
|
+
protected setCursorAt({ x, y }: Position): void;
|
|
17
|
+
protected print(text: string): void;
|
|
18
|
+
protected clearLine(row: number): void;
|
|
19
|
+
setPosition(position: Position, renderOnSet?: boolean): void;
|
|
20
|
+
setVisible(visible: boolean, renderOnSet?: boolean): void;
|
|
21
|
+
get position(): Position;
|
|
22
|
+
get visible(): boolean;
|
|
23
|
+
get terminal(): {
|
|
24
|
+
columns: number;
|
|
25
|
+
rows: number;
|
|
26
|
+
};
|
|
27
|
+
abstract render(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ansiEscapes from 'ansi-escapes';
|
|
2
|
+
export class BaseUi {
|
|
3
|
+
id = Math.random().toString(36).substring(2, 10);
|
|
4
|
+
freezed = false;
|
|
5
|
+
_position;
|
|
6
|
+
_visible = true;
|
|
7
|
+
stdout = process.stdout;
|
|
8
|
+
printAt(message, position) {
|
|
9
|
+
this.setCursorAt(position);
|
|
10
|
+
this.print(message);
|
|
11
|
+
}
|
|
12
|
+
setCursorAt({ x, y }) {
|
|
13
|
+
this.print(ansiEscapes.cursorTo(x, y));
|
|
14
|
+
}
|
|
15
|
+
print(text) {
|
|
16
|
+
if (this.freezed) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
process.stdout.write.bind(process.stdout)(text);
|
|
20
|
+
}
|
|
21
|
+
clearLine(row) {
|
|
22
|
+
this.printAt(ansiEscapes.eraseLine, { x: 0, y: row });
|
|
23
|
+
}
|
|
24
|
+
setPosition(position, renderOnSet = true) {
|
|
25
|
+
this._position = position;
|
|
26
|
+
if (renderOnSet) {
|
|
27
|
+
this.render();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
setVisible(visible, renderOnSet = true) {
|
|
31
|
+
this._visible = visible;
|
|
32
|
+
if (renderOnSet) {
|
|
33
|
+
this.render();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get position() {
|
|
37
|
+
return this._position;
|
|
38
|
+
}
|
|
39
|
+
get visible() {
|
|
40
|
+
return this._visible;
|
|
41
|
+
}
|
|
42
|
+
get terminal() {
|
|
43
|
+
return {
|
|
44
|
+
columns: this.stdout.columns,
|
|
45
|
+
rows: this.stdout.rows,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=base.ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.ui.js","sourceRoot":"","sources":["../../../src/cli/ui/base.ui.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAYvC,MAAM,OAAgB,MAAM;IACV,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1D,OAAO,GAAG,KAAK,CAAC;IACb,SAAS,CAAW;IACpB,QAAQ,GAAG,IAAI,CAAC;IACT,MAAM,GAAuB,OAAO,CAAC,MAAM,CAAC;IAEnD,OAAO,CAAC,OAAe,EAAE,QAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;IAES,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAY;QACtC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAES,KAAK,CAAC,IAAY;QAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAES,SAAS,CAAC,GAAW;QAC7B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,WAAW,CAAC,QAAkB,EAAE,WAAW,GAAG,IAAI;QAChD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,UAAU,CAAC,OAAgB,EAAE,WAAW,GAAG,IAAI;QAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SACvB,CAAC;IACJ,CAAC;CAGF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This class in only a intermediate for the refactor.
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { BaseUi } from '../base.ui.js';
|
|
4
|
+
export class GeneralUi extends BaseUi {
|
|
5
|
+
render() { }
|
|
6
|
+
printExitMessage(stats) {
|
|
7
|
+
const { spaceReleased } = stats;
|
|
8
|
+
let exitMessage = `Space saved: ${spaceReleased}\n`;
|
|
9
|
+
exitMessage += pc.dim('Thanks for using devkill!\n');
|
|
10
|
+
this.print(exitMessage);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=general.ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.ui.js","sourceRoot":"","sources":["../../../../src/cli/ui/components/general.ui.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,MAAM,KAAU,CAAC;IAEjB,gBAAgB,CAAC,KAAgC;QAC/C,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;QAChC,IAAI,WAAW,GAAG,gBAAgB,aAAa,IAAI,CAAC;QACpD,WAAW,IAAI,EAAE,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-ui.constants.js","sourceRoot":"","sources":["../../../../../src/cli/ui/components/header/header-ui.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import type { IConfig } from '../../../../cli/interfaces/config.interface.js';
|
|
3
|
+
import { BaseUi } from '../../base.ui.js';
|
|
4
|
+
import { MENU_BAR_OPTIONS } from './header-ui.constants.js';
|
|
5
|
+
export declare class HeaderUi extends BaseUi {
|
|
6
|
+
private readonly config;
|
|
7
|
+
programVersion: string;
|
|
8
|
+
private activeMenuIndex;
|
|
9
|
+
private searchMode;
|
|
10
|
+
private searchText;
|
|
11
|
+
private isSearchInputActive;
|
|
12
|
+
readonly menuIndex$: BehaviorSubject<MENU_BAR_OPTIONS>;
|
|
13
|
+
constructor(config: IConfig);
|
|
14
|
+
setSearch(text: string | null, isInputActive?: boolean): void;
|
|
15
|
+
render(): void;
|
|
16
|
+
private renderHeader;
|
|
17
|
+
private renderMenuBar;
|
|
18
|
+
}
|