@reliverse/dler 2.0.0 → 2.0.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.
Files changed (135) hide show
  1. package/dist/cli.d.ts +2 -0
  2. package/dist/cli.js +3 -0
  3. package/dist/cmds/build/cmd.d.ts +2 -0
  4. package/dist/cmds/build/cmd.js +564 -0
  5. package/dist/cmds/clean/cmd.d.ts +2 -0
  6. package/dist/cmds/clean/cmd.js +146 -0
  7. package/dist/cmds/clean/impl.d.ts +2 -0
  8. package/dist/cmds/clean/impl.js +627 -0
  9. package/dist/cmds/clean/presets.d.ts +10 -0
  10. package/dist/cmds/clean/presets.js +112 -0
  11. package/dist/cmds/clean/types.d.ts +62 -0
  12. package/dist/cmds/clean/types.js +0 -0
  13. package/dist/cmds/init/cmd.d.ts +3 -0
  14. package/dist/cmds/init/cmd.js +56 -0
  15. package/dist/cmds/init/impl/config.d.ts +45 -0
  16. package/dist/cmds/init/impl/config.js +99 -0
  17. package/dist/cmds/init/impl/generators.d.ts +6 -0
  18. package/dist/cmds/init/impl/generators.js +178 -0
  19. package/dist/cmds/init/impl/prompts.d.ts +2 -0
  20. package/dist/cmds/init/impl/prompts.js +98 -0
  21. package/dist/cmds/init/impl/types.d.ts +22 -0
  22. package/dist/cmds/init/impl/types.js +0 -0
  23. package/dist/cmds/init/impl/utils.d.ts +4 -0
  24. package/dist/cmds/init/impl/utils.js +11 -0
  25. package/dist/cmds/init/impl/validators.d.ts +4 -0
  26. package/dist/cmds/init/impl/validators.js +42 -0
  27. package/dist/cmds/integrate/cmd.d.ts +3 -0
  28. package/dist/cmds/integrate/cmd.js +70 -0
  29. package/dist/cmds/integrate/impl.d.ts +7 -0
  30. package/dist/cmds/integrate/impl.js +127 -0
  31. package/dist/cmds/integrate/integrations/base.d.ts +13 -0
  32. package/dist/cmds/integrate/integrations/base.js +41 -0
  33. package/dist/cmds/integrate/integrations/nextjs.d.ts +16 -0
  34. package/dist/cmds/integrate/integrations/nextjs.js +167 -0
  35. package/dist/cmds/integrate/integrations/registry.d.ts +7 -0
  36. package/dist/cmds/integrate/integrations/registry.js +31 -0
  37. package/dist/cmds/integrate/integrations/ultracite.d.ts +11 -0
  38. package/dist/cmds/integrate/integrations/ultracite.js +40 -0
  39. package/dist/cmds/integrate/types.d.ts +39 -0
  40. package/dist/cmds/integrate/types.js +0 -0
  41. package/dist/cmds/integrate/utils/biome.d.ts +4 -0
  42. package/dist/cmds/integrate/utils/biome.js +140 -0
  43. package/dist/cmds/integrate/utils/context.d.ts +3 -0
  44. package/dist/cmds/integrate/utils/context.js +111 -0
  45. package/dist/cmds/integrate/utils/temp.d.ts +3 -0
  46. package/dist/cmds/integrate/utils/temp.js +36 -0
  47. package/dist/cmds/perf/analysis/bundle.d.ts +20 -0
  48. package/dist/cmds/perf/analysis/bundle.js +225 -0
  49. package/dist/cmds/perf/analysis/filesystem.d.ts +27 -0
  50. package/dist/cmds/perf/analysis/filesystem.js +246 -0
  51. package/dist/cmds/perf/analysis/monorepo.d.ts +29 -0
  52. package/dist/cmds/perf/analysis/monorepo.js +307 -0
  53. package/dist/cmds/perf/benchmarks/command.d.ts +21 -0
  54. package/dist/cmds/perf/benchmarks/command.js +162 -0
  55. package/dist/cmds/perf/benchmarks/memory.d.ts +41 -0
  56. package/dist/cmds/perf/benchmarks/memory.js +169 -0
  57. package/dist/cmds/perf/benchmarks/runner.d.ts +22 -0
  58. package/dist/cmds/perf/benchmarks/runner.js +157 -0
  59. package/dist/cmds/perf/cmd.d.ts +2 -0
  60. package/dist/cmds/perf/cmd.js +238 -0
  61. package/dist/cmds/perf/impl.d.ts +24 -0
  62. package/dist/cmds/perf/impl.js +304 -0
  63. package/dist/cmds/perf/reporters/console.d.ts +12 -0
  64. package/dist/cmds/perf/reporters/console.js +257 -0
  65. package/dist/cmds/perf/reporters/html.d.ts +27 -0
  66. package/dist/cmds/perf/reporters/html.js +881 -0
  67. package/dist/cmds/perf/reporters/json.d.ts +9 -0
  68. package/dist/cmds/perf/reporters/json.js +32 -0
  69. package/dist/cmds/perf/types.d.ts +184 -0
  70. package/dist/cmds/perf/types.js +0 -0
  71. package/dist/cmds/perf/utils/cache.d.ts +23 -0
  72. package/dist/cmds/perf/utils/cache.js +171 -0
  73. package/dist/cmds/perf/utils/formatter.d.ts +17 -0
  74. package/dist/cmds/perf/utils/formatter.js +134 -0
  75. package/dist/cmds/perf/utils/stats.d.ts +15 -0
  76. package/dist/cmds/perf/utils/stats.js +101 -0
  77. package/dist/cmds/publish/cmd.d.ts +3 -0
  78. package/dist/cmds/publish/cmd.js +189 -0
  79. package/dist/cmds/shell/cmd.d.ts +3 -0
  80. package/dist/cmds/shell/cmd.js +50 -0
  81. package/dist/cmds/tsc/cache.d.ts +27 -0
  82. package/dist/cmds/tsc/cache.js +160 -0
  83. package/dist/cmds/tsc/cmd.d.ts +2 -0
  84. package/dist/cmds/tsc/cmd.js +111 -0
  85. package/dist/cmds/tsc/impl.d.ts +41 -0
  86. package/dist/cmds/tsc/impl.js +572 -0
  87. package/dist/cmds/tsc/types.d.ts +57 -0
  88. package/dist/cmds/tsc/types.js +0 -0
  89. package/package.json +4 -11
  90. package/src/cli.ts +8 -0
  91. package/src/cmds/build/cmd.ts +582 -0
  92. package/src/cmds/clean/cmd.ts +166 -0
  93. package/src/cmds/clean/impl.ts +900 -0
  94. package/src/cmds/clean/presets.ts +158 -0
  95. package/src/cmds/clean/types.ts +71 -0
  96. package/src/cmds/init/cmd.ts +68 -0
  97. package/src/cmds/init/impl/config.ts +105 -0
  98. package/src/cmds/init/impl/generators.ts +220 -0
  99. package/src/cmds/init/impl/prompts.ts +137 -0
  100. package/src/cmds/init/impl/types.ts +25 -0
  101. package/src/cmds/init/impl/utils.ts +17 -0
  102. package/src/cmds/init/impl/validators.ts +55 -0
  103. package/src/cmds/integrate/cmd.ts +82 -0
  104. package/src/cmds/integrate/impl.ts +204 -0
  105. package/src/cmds/integrate/integrations/base.ts +69 -0
  106. package/src/cmds/integrate/integrations/nextjs.ts +227 -0
  107. package/src/cmds/integrate/integrations/registry.ts +45 -0
  108. package/src/cmds/integrate/integrations/ultracite.ts +53 -0
  109. package/src/cmds/integrate/types.ts +48 -0
  110. package/src/cmds/integrate/utils/biome.ts +173 -0
  111. package/src/cmds/integrate/utils/context.ts +148 -0
  112. package/src/cmds/integrate/utils/temp.ts +47 -0
  113. package/src/cmds/perf/analysis/bundle.ts +311 -0
  114. package/src/cmds/perf/analysis/filesystem.ts +324 -0
  115. package/src/cmds/perf/analysis/monorepo.ts +439 -0
  116. package/src/cmds/perf/benchmarks/command.ts +230 -0
  117. package/src/cmds/perf/benchmarks/memory.ts +249 -0
  118. package/src/cmds/perf/benchmarks/runner.ts +220 -0
  119. package/src/cmds/perf/cmd.ts +285 -0
  120. package/src/cmds/perf/impl.ts +411 -0
  121. package/src/cmds/perf/reporters/console.ts +331 -0
  122. package/src/cmds/perf/reporters/html.ts +984 -0
  123. package/src/cmds/perf/reporters/json.ts +42 -0
  124. package/src/cmds/perf/types.ts +220 -0
  125. package/src/cmds/perf/utils/cache.ts +234 -0
  126. package/src/cmds/perf/utils/formatter.ts +190 -0
  127. package/src/cmds/perf/utils/stats.ts +153 -0
  128. package/src/cmds/publish/cmd.ts +215 -0
  129. package/src/cmds/shell/cmd.ts +61 -0
  130. package/src/cmds/tsc/cache.ts +237 -0
  131. package/src/cmds/tsc/cmd.ts +139 -0
  132. package/src/cmds/tsc/impl.ts +855 -0
  133. package/src/cmds/tsc/types.ts +66 -0
  134. package/tsconfig.json +9 -0
  135. package/cli.js +0 -1316
@@ -0,0 +1,331 @@
1
+ // apps/dler/src/cmds/perf/reporters/console.ts
2
+
3
+ import { logger } from "@reliverse/dler-logger";
4
+ import type {
5
+ BenchmarkResult,
6
+ BundleAnalysisResult,
7
+ FileSystemAnalysisResult,
8
+ MonorepoAnalysisResult,
9
+ PerfReport,
10
+ } from "../types";
11
+ import {
12
+ formatBottleneckType,
13
+ formatBytes,
14
+ formatDuration,
15
+ formatNumber,
16
+ formatPercentage,
17
+ formatRelativeChange,
18
+ formatSeverity,
19
+ formatTable,
20
+ truncatePath,
21
+ } from "../utils/formatter";
22
+
23
+ export class ConsoleReporter {
24
+ private verbose: boolean;
25
+
26
+ constructor(verbose = false) {
27
+ this.verbose = verbose;
28
+ }
29
+
30
+ report(report: PerfReport): void {
31
+ logger.log("━".repeat(80));
32
+ logger.log("šŸ“Š Performance Analysis Report");
33
+ logger.log("━".repeat(80));
34
+
35
+ if (report.benchmark) {
36
+ this.reportBenchmark(report.benchmark);
37
+ }
38
+
39
+ if (report.bundleAnalysis) {
40
+ this.reportBundleAnalysis(report.bundleAnalysis);
41
+ }
42
+
43
+ if (report.fileSystemAnalysis) {
44
+ this.reportFileSystemAnalysis(report.fileSystemAnalysis);
45
+ }
46
+
47
+ if (report.monorepoAnalysis) {
48
+ this.reportMonorepoAnalysis(report.monorepoAnalysis);
49
+ }
50
+
51
+ if (report.baseline) {
52
+ this.reportBaselineComparison(report.baseline);
53
+ }
54
+
55
+ logger.log("━".repeat(80));
56
+ }
57
+
58
+ private reportBenchmark(result: BenchmarkResult): void {
59
+ logger.log("\nšŸš€ Command Benchmark Results");
60
+ logger.log("─".repeat(40));
61
+
62
+ // Summary
63
+ logger.log(`Command: ${result.command}`);
64
+ logger.log(`Runs: ${result.runs} (${result.warmup} warmup)`);
65
+ logger.log(`Concurrency: ${result.concurrency}`);
66
+ logger.log(`Success: ${result.success ? "āœ…" : "āŒ"}`);
67
+
68
+ if (!result.success && result.error) {
69
+ logger.error(`Error: ${result.error}`);
70
+ }
71
+
72
+ // Timing statistics
73
+ logger.log("\nā±ļø Timing Statistics:");
74
+ logger.log(` Mean: ${formatDuration(result.statistics.mean)}`);
75
+ logger.log(` Median: ${formatDuration(result.statistics.median)}`);
76
+ logger.log(` Min: ${formatDuration(result.statistics.min)}`);
77
+ logger.log(` Max: ${formatDuration(result.statistics.max)}`);
78
+ logger.log(` P95: ${formatDuration(result.statistics.p95)}`);
79
+ logger.log(` P99: ${formatDuration(result.statistics.p99)}`);
80
+ logger.log(
81
+ ` Std Dev: ${formatDuration(result.statistics.standardDeviation)}`,
82
+ );
83
+ logger.log(
84
+ ` CV: ${(result.statistics.coefficientOfVariation * 100).toFixed(2)}%`,
85
+ );
86
+
87
+ // Memory statistics
88
+ logger.log("\nšŸ’¾ Memory Statistics:");
89
+ logger.log(` Peak RSS: ${formatBytes(result.memory.peak.rss)}`);
90
+ logger.log(` Avg RSS: ${formatBytes(result.memory.average.rss)}`);
91
+ logger.log(` Peak Heap: ${formatBytes(result.memory.peak.heapUsed)}`);
92
+ logger.log(` Avg Heap: ${formatBytes(result.memory.average.heapUsed)}`);
93
+ logger.log(` Growth: ${formatBytes(result.memory.growth)}`);
94
+
95
+ // Individual runs (if verbose)
96
+ if (this.verbose && result.measurements.length > 0) {
97
+ logger.log("\nšŸ“‹ Individual Runs:");
98
+ const headers = ["Run", "Duration", "RSS", "Heap", "Status"];
99
+ const rows = result.measurements.map((m, i) => [
100
+ (i + 1).toString(),
101
+ formatDuration(m.duration),
102
+ formatBytes(m.memory.rss),
103
+ formatBytes(m.memory.heapUsed),
104
+ m.success ? "āœ…" : "āŒ",
105
+ ]);
106
+
107
+ logger.log(formatTable(headers, rows));
108
+ }
109
+ }
110
+
111
+ private reportBundleAnalysis(result: BundleAnalysisResult): void {
112
+ logger.log("\nšŸ“¦ Bundle Analysis Results");
113
+ logger.log("─".repeat(40));
114
+
115
+ // Summary
116
+ logger.log(`Target: ${result.target}`);
117
+ logger.log(`Total Size: ${formatBytes(result.totalSize)}`);
118
+ logger.log(`File Count: ${formatNumber(result.fileCount)}`);
119
+ logger.log(
120
+ `Compression Potential: ${result.compressionPotential.toFixed(1)}%`,
121
+ );
122
+
123
+ // Largest files
124
+ if (result.largestFiles.length > 0) {
125
+ logger.log("\nšŸ“ Largest Files:");
126
+ const headers = ["File", "Size", "Percentage", "Type"];
127
+ const rows = result.largestFiles.map((file) => [
128
+ truncatePath(file.path, 50),
129
+ formatBytes(file.size),
130
+ formatPercentage(file.percentage, 100),
131
+ file.type,
132
+ ]);
133
+
134
+ logger.log(formatTable(headers, rows));
135
+ }
136
+
137
+ // Modules (if available)
138
+ if (result.modules.length > 0) {
139
+ logger.log("\nšŸ”— Top Modules:");
140
+ const headers = ["Module", "Size", "Percentage", "Type"];
141
+ const rows = result.modules.map((module) => [
142
+ truncatePath(module.name, 50),
143
+ formatBytes(module.size),
144
+ formatPercentage(module.percentage, 100),
145
+ module.isExternal ? "External" : "Internal",
146
+ ]);
147
+
148
+ logger.log(formatTable(headers, rows));
149
+ }
150
+
151
+ // Duplicates (if available)
152
+ if (result.duplicates.length > 0) {
153
+ logger.log("\nšŸ”„ Duplicate Dependencies:");
154
+ const headers = ["Module", "Count", "Total Size", "Locations"];
155
+ const rows = result.duplicates.map((dup) => [
156
+ truncatePath(dup.name, 30),
157
+ dup.count.toString(),
158
+ formatBytes(dup.totalSize),
159
+ dup.locations.length.toString(),
160
+ ]);
161
+
162
+ logger.log(formatTable(headers, rows));
163
+ }
164
+ }
165
+
166
+ private reportFileSystemAnalysis(result: FileSystemAnalysisResult): void {
167
+ logger.log("\nšŸ“ File System Analysis Results");
168
+ logger.log("─".repeat(40));
169
+
170
+ // Summary
171
+ logger.log(`Target: ${result.target}`);
172
+ logger.log(`Total Files: ${formatNumber(result.totalFiles)}`);
173
+ logger.log(`Total Size: ${formatBytes(result.totalSize)}`);
174
+ logger.log(`Directories: ${formatNumber(result.directoryCount)}`);
175
+ logger.log(`Max Depth: ${result.maxDepth}`);
176
+ logger.log(
177
+ `Compression Potential: ${result.compressionPotential.toFixed(1)}%`,
178
+ );
179
+
180
+ // Largest files
181
+ if (result.largestFiles.length > 0) {
182
+ logger.log("\nšŸ“„ Largest Files:");
183
+ const headers = ["File", "Size", "Percentage", "Type"];
184
+ const rows = result.largestFiles.map((file) => [
185
+ truncatePath(file.path, 50),
186
+ formatBytes(file.size),
187
+ formatPercentage(file.percentage, 100),
188
+ file.type,
189
+ ]);
190
+
191
+ logger.log(formatTable(headers, rows));
192
+ }
193
+
194
+ // Largest directories
195
+ if (result.largestDirectories.length > 0) {
196
+ logger.log("\nšŸ“‚ Largest Directories:");
197
+ const headers = ["Directory", "Size", "Files", "Depth"];
198
+ const rows = result.largestDirectories.map((dir) => [
199
+ truncatePath(dir.path, 50),
200
+ formatBytes(dir.size),
201
+ formatNumber(dir.fileCount),
202
+ dir.depth.toString(),
203
+ ]);
204
+
205
+ logger.log(formatTable(headers, rows));
206
+ }
207
+
208
+ // File types
209
+ if (result.fileTypes.length > 0) {
210
+ logger.log("\nšŸ“Š File Type Distribution:");
211
+ const headers = ["Type", "Count", "Size", "Percentage"];
212
+ const rows = result.fileTypes.map((type) => [
213
+ type.extension || "no-extension",
214
+ formatNumber(type.count),
215
+ formatBytes(type.totalSize),
216
+ formatPercentage(type.percentage, 100),
217
+ ]);
218
+
219
+ logger.log(formatTable(headers, rows));
220
+ }
221
+ }
222
+
223
+ private reportMonorepoAnalysis(result: MonorepoAnalysisResult): void {
224
+ logger.log("\nšŸ—ļø Monorepo Analysis Results");
225
+ logger.log("─".repeat(40));
226
+
227
+ // Summary
228
+ logger.log(`Packages: ${formatNumber(result.packages.length)}`);
229
+ logger.log(
230
+ `Dependencies: ${formatNumber(result.dependencies.edges.length)}`,
231
+ );
232
+ logger.log(`Circular Dependencies: ${result.circularDependencies.length}`);
233
+ logger.log(`Suggested Concurrency: ${result.suggestedConcurrency}`);
234
+
235
+ // Build order
236
+ if (result.buildOrder.length > 0) {
237
+ logger.log("\nšŸ”„ Build Order:");
238
+ const levels = result.dependencies.levels;
239
+ for (let i = 0; i < levels.length; i++) {
240
+ const level = levels[i]!;
241
+ logger.log(` Level ${i + 1}: ${level.join(", ")}`);
242
+ }
243
+ }
244
+
245
+ // Critical path
246
+ if (result.criticalPath.length > 0) {
247
+ logger.log("\nšŸŽÆ Critical Path:");
248
+ logger.log(` ${result.criticalPath.slice(0, 10).join(" → ")}`);
249
+ if (result.criticalPath.length > 10) {
250
+ logger.log(` ... and ${result.criticalPath.length - 10} more`);
251
+ }
252
+ }
253
+
254
+ // Circular dependencies
255
+ if (result.circularDependencies.length > 0) {
256
+ logger.log("\nšŸ”„ Circular Dependencies:");
257
+ for (const circular of result.circularDependencies) {
258
+ logger.log(
259
+ ` ${formatSeverity(circular.severity)} ${circular.cycle.join(" → ")}`,
260
+ );
261
+ }
262
+ }
263
+
264
+ // Bottlenecks
265
+ if (result.bottlenecks.length > 0) {
266
+ logger.log("\nāš ļø Bottlenecks:");
267
+ const headers = ["Package", "Type", "Impact", "Suggestion"];
268
+ const rows = result.bottlenecks.map((bottleneck) => [
269
+ bottleneck.package,
270
+ formatBottleneckType(bottleneck.type),
271
+ bottleneck.impact.toString(),
272
+ bottleneck.suggestion,
273
+ ]);
274
+
275
+ logger.log(formatTable(headers, rows));
276
+ }
277
+
278
+ // Package details (if verbose)
279
+ if (this.verbose) {
280
+ logger.log("\nšŸ“¦ Package Details:");
281
+ const headers = ["Package", "Dependencies", "Dependents", "Type"];
282
+ const rows = result.packages.map((pkg) => [
283
+ pkg.name,
284
+ pkg.dependencies.length.toString(),
285
+ pkg.dependents.length.toString(),
286
+ pkg.dependencies.length > 10 ? "Heavy" : "Light",
287
+ ]);
288
+
289
+ logger.log(formatTable(headers, rows));
290
+ }
291
+ }
292
+
293
+ private reportBaselineComparison(baseline: PerfReport["baseline"]): void {
294
+ if (!baseline?.exists) return;
295
+
296
+ logger.log("\nšŸ“ˆ Baseline Comparison");
297
+ logger.log("─".repeat(40));
298
+
299
+ if (baseline.improvement !== undefined) {
300
+ logger.log(
301
+ `Performance: ${formatRelativeChange(0, baseline.improvement)}`,
302
+ );
303
+ }
304
+
305
+ if (baseline.regression !== undefined) {
306
+ logger.log(
307
+ `Performance: ${formatRelativeChange(0, -baseline.regression)}`,
308
+ );
309
+ }
310
+
311
+ if (baseline.changes) {
312
+ const changes = baseline.changes;
313
+ if (changes.duration !== undefined) {
314
+ logger.log(`Duration: ${formatRelativeChange(0, changes.duration)}`);
315
+ }
316
+ if (changes.memory !== undefined) {
317
+ logger.log(`Memory: ${formatRelativeChange(0, changes.memory)}`);
318
+ }
319
+ if (changes.size !== undefined) {
320
+ logger.log(`Size: ${formatRelativeChange(0, changes.size)}`);
321
+ }
322
+ if (changes.files !== undefined) {
323
+ logger.log(`Files: ${formatRelativeChange(0, changes.files)}`);
324
+ }
325
+ }
326
+ }
327
+ }
328
+
329
+ export const createConsoleReporter = (verbose = false): ConsoleReporter => {
330
+ return new ConsoleReporter(verbose);
331
+ };