@reliverse/dler 2.2.5 → 2.2.10
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/README.md +14 -14
- package/dist/cli.js +1 -1
- package/dist/cmds/biome/cmd.js +58 -0
- package/dist/cmds/biome/impl.d.ts +26 -0
- package/dist/cmds/biome/impl.js +272 -0
- package/dist/cmds/build/cmd.js +18 -10
- package/dist/cmds/clean/cmd.js +6 -6
- package/dist/cmds/clean/impl.js +16 -12
- package/dist/cmds/clean/presets.js +2 -2
- package/dist/cmds/publish/cmd.js +7 -7
- package/dist/cmds/senv/cmd.js +13 -15
- package/dist/cmds/tsc/cache.js +1 -1
- package/dist/cmds/tsc/cmd.js +11 -8
- package/dist/cmds/tsc/impl.js +132 -17
- package/dist/cmds/update/cmd.js +11 -10
- package/dist/cmds/update/impl.d.ts +4 -4
- package/dist/cmds/update/impl.js +10 -11
- package/dist/cmds/update/utils.d.ts +23 -4
- package/dist/cmds/update/utils.js +22 -16
- package/package.json +16 -13
- package/dist/cmds/perf/analysis/bundle.d.ts +0 -20
- package/dist/cmds/perf/analysis/bundle.js +0 -225
- package/dist/cmds/perf/analysis/filesystem.d.ts +0 -27
- package/dist/cmds/perf/analysis/filesystem.js +0 -245
- package/dist/cmds/perf/analysis/monorepo.d.ts +0 -30
- package/dist/cmds/perf/analysis/monorepo.js +0 -345
- package/dist/cmds/perf/benchmarks/command.d.ts +0 -21
- package/dist/cmds/perf/benchmarks/command.js +0 -162
- package/dist/cmds/perf/benchmarks/memory.d.ts +0 -41
- package/dist/cmds/perf/benchmarks/memory.js +0 -169
- package/dist/cmds/perf/benchmarks/runner.d.ts +0 -22
- package/dist/cmds/perf/benchmarks/runner.js +0 -157
- package/dist/cmds/perf/cmd.js +0 -240
- package/dist/cmds/perf/impl.d.ts +0 -24
- package/dist/cmds/perf/impl.js +0 -297
- package/dist/cmds/perf/reporters/console.d.ts +0 -12
- package/dist/cmds/perf/reporters/console.js +0 -257
- package/dist/cmds/perf/reporters/html.d.ts +0 -27
- package/dist/cmds/perf/reporters/html.js +0 -881
- package/dist/cmds/perf/reporters/json.d.ts +0 -9
- package/dist/cmds/perf/reporters/json.js +0 -32
- package/dist/cmds/perf/types.d.ts +0 -184
- package/dist/cmds/perf/types.js +0 -0
- package/dist/cmds/perf/utils/cache.d.ts +0 -23
- package/dist/cmds/perf/utils/cache.js +0 -172
- package/dist/cmds/perf/utils/formatter.d.ts +0 -17
- package/dist/cmds/perf/utils/formatter.js +0 -134
- package/dist/cmds/perf/utils/stats.d.ts +0 -15
- package/dist/cmds/perf/utils/stats.js +0 -101
- package/dist/cmds/port/cmd.d.ts +0 -2
- package/dist/cmds/port/cmd.js +0 -58
- package/dist/cmds/port/impl.d.ts +0 -5
- package/dist/cmds/port/impl.js +0 -280
- package/dist/cmds/shell/cmd.d.ts +0 -2
- package/dist/cmds/shell/cmd.js +0 -46
- /package/dist/cmds/{perf → biome}/cmd.d.ts +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PerfReport } from "../types.js";
|
|
2
|
-
export declare class JsonReporter {
|
|
3
|
-
private outputPath?;
|
|
4
|
-
constructor(outputPath?: string);
|
|
5
|
-
report(report: PerfReport): void;
|
|
6
|
-
static save(report: PerfReport, outputPath: string): void;
|
|
7
|
-
static print(report: PerfReport): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const createJsonReporter: (outputPath?: string) => JsonReporter;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
2
|
-
import { logger } from "@reliverse/dler-logger";
|
|
3
|
-
export class JsonReporter {
|
|
4
|
-
outputPath;
|
|
5
|
-
constructor(outputPath) {
|
|
6
|
-
this.outputPath = outputPath;
|
|
7
|
-
}
|
|
8
|
-
report(report) {
|
|
9
|
-
const json = JSON.stringify(report, null, 2);
|
|
10
|
-
if (this.outputPath) {
|
|
11
|
-
try {
|
|
12
|
-
writeFileSync(this.outputPath, json, "utf-8");
|
|
13
|
-
logger.success(`\u{1F4C4} JSON report saved to: ${this.outputPath}`);
|
|
14
|
-
} catch (error) {
|
|
15
|
-
logger.error(`Failed to save JSON report: ${error}`);
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
console.log(json);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
static save(report, outputPath) {
|
|
22
|
-
const reporter = new JsonReporter(outputPath);
|
|
23
|
-
reporter.report(report);
|
|
24
|
-
}
|
|
25
|
-
static print(report) {
|
|
26
|
-
const reporter = new JsonReporter();
|
|
27
|
-
reporter.report(report);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export const createJsonReporter = (outputPath) => {
|
|
31
|
-
return new JsonReporter(outputPath);
|
|
32
|
-
};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
export interface PerfOptions {
|
|
2
|
-
target?: string;
|
|
3
|
-
type?: string;
|
|
4
|
-
runs?: number;
|
|
5
|
-
warmup?: number;
|
|
6
|
-
concurrency?: number;
|
|
7
|
-
compare?: boolean;
|
|
8
|
-
output?: string;
|
|
9
|
-
save?: boolean;
|
|
10
|
-
verbose?: boolean;
|
|
11
|
-
cwd?: string;
|
|
12
|
-
ignore?: string | string[];
|
|
13
|
-
}
|
|
14
|
-
export type PerfAnalysisType = "command" | "bundle" | "file" | "monorepo" | "auto";
|
|
15
|
-
export type PerfOutputFormat = "console" | "json" | "html" | "all";
|
|
16
|
-
export interface BenchmarkResult {
|
|
17
|
-
command: string;
|
|
18
|
-
runs: number;
|
|
19
|
-
warmup: number;
|
|
20
|
-
concurrency: number;
|
|
21
|
-
measurements: Measurement[];
|
|
22
|
-
statistics: Statistics;
|
|
23
|
-
memory: MemoryStats;
|
|
24
|
-
executionTime: number;
|
|
25
|
-
success: boolean;
|
|
26
|
-
error?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface Measurement {
|
|
29
|
-
run: number;
|
|
30
|
-
duration: number;
|
|
31
|
-
memory: MemoryUsage;
|
|
32
|
-
success: boolean;
|
|
33
|
-
error?: string;
|
|
34
|
-
stdout?: string;
|
|
35
|
-
stderr?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface Statistics {
|
|
38
|
-
min: number;
|
|
39
|
-
max: number;
|
|
40
|
-
mean: number;
|
|
41
|
-
median: number;
|
|
42
|
-
p95: number;
|
|
43
|
-
p99: number;
|
|
44
|
-
variance: number;
|
|
45
|
-
standardDeviation: number;
|
|
46
|
-
coefficientOfVariation: number;
|
|
47
|
-
}
|
|
48
|
-
export interface MemoryUsage {
|
|
49
|
-
rss: number;
|
|
50
|
-
heapTotal: number;
|
|
51
|
-
heapUsed: number;
|
|
52
|
-
external: number;
|
|
53
|
-
arrayBuffers: number;
|
|
54
|
-
}
|
|
55
|
-
export interface MemoryStats {
|
|
56
|
-
peak: MemoryUsage;
|
|
57
|
-
average: MemoryUsage;
|
|
58
|
-
growth: number;
|
|
59
|
-
}
|
|
60
|
-
export interface BundleAnalysisResult {
|
|
61
|
-
target: string;
|
|
62
|
-
totalSize: number;
|
|
63
|
-
fileCount: number;
|
|
64
|
-
largestFiles: FileSize[];
|
|
65
|
-
modules: ModuleInfo[];
|
|
66
|
-
duplicates: DuplicateInfo[];
|
|
67
|
-
compressionPotential: number;
|
|
68
|
-
analysisTime: number;
|
|
69
|
-
}
|
|
70
|
-
export interface FileSize {
|
|
71
|
-
path: string;
|
|
72
|
-
size: number;
|
|
73
|
-
percentage: number;
|
|
74
|
-
type: string;
|
|
75
|
-
}
|
|
76
|
-
export interface ModuleInfo {
|
|
77
|
-
name: string;
|
|
78
|
-
size: number;
|
|
79
|
-
percentage: number;
|
|
80
|
-
dependencies: string[];
|
|
81
|
-
isExternal: boolean;
|
|
82
|
-
}
|
|
83
|
-
export interface DuplicateInfo {
|
|
84
|
-
name: string;
|
|
85
|
-
count: number;
|
|
86
|
-
totalSize: number;
|
|
87
|
-
locations: string[];
|
|
88
|
-
}
|
|
89
|
-
export interface FileSystemAnalysisResult {
|
|
90
|
-
target: string;
|
|
91
|
-
totalFiles: number;
|
|
92
|
-
totalSize: number;
|
|
93
|
-
directoryCount: number;
|
|
94
|
-
maxDepth: number;
|
|
95
|
-
largestFiles: FileSize[];
|
|
96
|
-
largestDirectories: DirectorySize[];
|
|
97
|
-
fileTypes: FileTypeDistribution[];
|
|
98
|
-
compressionPotential: number;
|
|
99
|
-
analysisTime: number;
|
|
100
|
-
}
|
|
101
|
-
export interface DirectorySize {
|
|
102
|
-
path: string;
|
|
103
|
-
size: number;
|
|
104
|
-
fileCount: number;
|
|
105
|
-
depth: number;
|
|
106
|
-
}
|
|
107
|
-
export interface FileTypeDistribution {
|
|
108
|
-
extension: string;
|
|
109
|
-
count: number;
|
|
110
|
-
totalSize: number;
|
|
111
|
-
percentage: number;
|
|
112
|
-
}
|
|
113
|
-
export interface MonorepoAnalysisResult {
|
|
114
|
-
packages: PackageInfo[];
|
|
115
|
-
dependencies: DependencyGraph;
|
|
116
|
-
circularDependencies: CircularDependency[];
|
|
117
|
-
criticalPath: string[];
|
|
118
|
-
buildOrder: string[];
|
|
119
|
-
bottlenecks: Bottleneck[];
|
|
120
|
-
suggestedConcurrency: number;
|
|
121
|
-
analysisTime: number;
|
|
122
|
-
}
|
|
123
|
-
export interface PackageInfo {
|
|
124
|
-
name: string;
|
|
125
|
-
path: string;
|
|
126
|
-
dependencies: string[];
|
|
127
|
-
dependents: string[];
|
|
128
|
-
buildTime?: number;
|
|
129
|
-
size?: number;
|
|
130
|
-
}
|
|
131
|
-
export interface DependencyGraph {
|
|
132
|
-
nodes: string[];
|
|
133
|
-
edges: DependencyEdge[];
|
|
134
|
-
levels: string[][];
|
|
135
|
-
}
|
|
136
|
-
export interface DependencyEdge {
|
|
137
|
-
from: string;
|
|
138
|
-
to: string;
|
|
139
|
-
type: "dependency" | "devDependency" | "peerDependency";
|
|
140
|
-
}
|
|
141
|
-
export interface CircularDependency {
|
|
142
|
-
packages: string[];
|
|
143
|
-
cycle: string[];
|
|
144
|
-
severity: "low" | "medium" | "high";
|
|
145
|
-
}
|
|
146
|
-
export interface Bottleneck {
|
|
147
|
-
package: string;
|
|
148
|
-
type: "slow-build" | "many-dependencies" | "circular-dependency";
|
|
149
|
-
impact: number;
|
|
150
|
-
suggestion: string;
|
|
151
|
-
}
|
|
152
|
-
export interface PerfReport {
|
|
153
|
-
timestamp: number;
|
|
154
|
-
options: PerfOptions;
|
|
155
|
-
benchmark?: BenchmarkResult;
|
|
156
|
-
bundleAnalysis?: BundleAnalysisResult;
|
|
157
|
-
fileSystemAnalysis?: FileSystemAnalysisResult;
|
|
158
|
-
monorepoAnalysis?: MonorepoAnalysisResult;
|
|
159
|
-
baseline?: BaselineComparison;
|
|
160
|
-
}
|
|
161
|
-
export interface BaselineComparison {
|
|
162
|
-
exists: boolean;
|
|
163
|
-
improvement?: number;
|
|
164
|
-
regression?: number;
|
|
165
|
-
changes?: ChangeSummary;
|
|
166
|
-
}
|
|
167
|
-
export interface ChangeSummary {
|
|
168
|
-
duration?: number;
|
|
169
|
-
memory?: number;
|
|
170
|
-
size?: number;
|
|
171
|
-
files?: number;
|
|
172
|
-
}
|
|
173
|
-
export interface CacheEntry {
|
|
174
|
-
timestamp: number;
|
|
175
|
-
report: PerfReport;
|
|
176
|
-
hash: string;
|
|
177
|
-
}
|
|
178
|
-
export interface CacheOptions {
|
|
179
|
-
enabled: boolean;
|
|
180
|
-
cacheDir: string;
|
|
181
|
-
maxAge: number;
|
|
182
|
-
}
|
|
183
|
-
export type AnalysisResult = BundleAnalysisResult | FileSystemAnalysisResult | MonorepoAnalysisResult;
|
|
184
|
-
export type OutputFormat = PerfOutputFormat;
|
package/dist/cmds/perf/types.js
DELETED
|
File without changes
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CacheOptions, PerfReport } from "../types.js";
|
|
2
|
-
export declare class PerfCache {
|
|
3
|
-
private options;
|
|
4
|
-
private cacheDir;
|
|
5
|
-
constructor(options: CacheOptions);
|
|
6
|
-
ensureCacheDir(): void;
|
|
7
|
-
private generateHash;
|
|
8
|
-
private getCachePath;
|
|
9
|
-
private isExpired;
|
|
10
|
-
save(report: PerfReport): Promise<void>;
|
|
11
|
-
load(target: string, type?: string): Promise<PerfReport | null>;
|
|
12
|
-
findBaseline(target: string, type?: string): Promise<PerfReport | null>;
|
|
13
|
-
listBaselines(): Promise<Array<{
|
|
14
|
-
target: string;
|
|
15
|
-
type?: string;
|
|
16
|
-
timestamp: number;
|
|
17
|
-
hash: string;
|
|
18
|
-
}>>;
|
|
19
|
-
clear(): Promise<void>;
|
|
20
|
-
cleanup(): Promise<void>;
|
|
21
|
-
getCacheSize(): number;
|
|
22
|
-
}
|
|
23
|
-
export declare const createPerfCache: (options?: Partial<CacheOptions>) => PerfCache;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
export class PerfCache {
|
|
5
|
-
options;
|
|
6
|
-
cacheDir;
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.cacheDir = resolve(options.cacheDir);
|
|
10
|
-
this.ensureCacheDir();
|
|
11
|
-
}
|
|
12
|
-
ensureCacheDir() {
|
|
13
|
-
if (existsSync(this.cacheDir)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
mkdirSync(this.cacheDir, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
generateHash(report) {
|
|
19
|
-
const content = JSON.stringify({
|
|
20
|
-
target: report.options.target,
|
|
21
|
-
type: report.options.type,
|
|
22
|
-
// Exclude timestamp and other volatile fields
|
|
23
|
-
benchmark: report.benchmark ? {
|
|
24
|
-
command: report.benchmark.command,
|
|
25
|
-
runs: report.benchmark.runs,
|
|
26
|
-
concurrency: report.benchmark.concurrency
|
|
27
|
-
} : void 0
|
|
28
|
-
});
|
|
29
|
-
return createHash("sha256").update(content).digest("hex").substring(0, 16);
|
|
30
|
-
}
|
|
31
|
-
getCachePath(hash) {
|
|
32
|
-
return join(this.cacheDir, `${hash}.json`);
|
|
33
|
-
}
|
|
34
|
-
isExpired(entry) {
|
|
35
|
-
if (!this.options.enabled) return true;
|
|
36
|
-
const age = Date.now() - entry.timestamp;
|
|
37
|
-
return age > this.options.maxAge;
|
|
38
|
-
}
|
|
39
|
-
async save(report) {
|
|
40
|
-
if (!this.options.enabled) return;
|
|
41
|
-
try {
|
|
42
|
-
const hash = this.generateHash(report);
|
|
43
|
-
const entry = {
|
|
44
|
-
timestamp: Date.now(),
|
|
45
|
-
report,
|
|
46
|
-
hash
|
|
47
|
-
};
|
|
48
|
-
const cachePath = this.getCachePath(hash);
|
|
49
|
-
writeFileSync(cachePath, JSON.stringify(entry, null, 2));
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.warn("Failed to save performance cache:", error);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async load(target, type) {
|
|
55
|
-
if (!this.options.enabled) return null;
|
|
56
|
-
try {
|
|
57
|
-
const cacheFiles = Array.from(
|
|
58
|
-
new Bun.Glob("*.json").scanSync({ cwd: this.cacheDir })
|
|
59
|
-
);
|
|
60
|
-
for (const file of cacheFiles) {
|
|
61
|
-
const cachePath = join(this.cacheDir, file);
|
|
62
|
-
try {
|
|
63
|
-
const content = readFileSync(cachePath, "utf-8");
|
|
64
|
-
const entry = JSON.parse(content);
|
|
65
|
-
if (this.isExpired(entry)) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (entry.report.options.target === target && (!type || entry.report.options.type === type)) {
|
|
69
|
-
return entry.report;
|
|
70
|
-
}
|
|
71
|
-
} catch {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.warn("Failed to load performance cache:", error);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async findBaseline(target, type) {
|
|
82
|
-
return this.load(target, type);
|
|
83
|
-
}
|
|
84
|
-
async listBaselines() {
|
|
85
|
-
if (!this.options.enabled) return [];
|
|
86
|
-
try {
|
|
87
|
-
const cacheFiles = Array.from(
|
|
88
|
-
new Bun.Glob("*.json").scanSync({ cwd: this.cacheDir })
|
|
89
|
-
);
|
|
90
|
-
const baselines = [];
|
|
91
|
-
for (const file of cacheFiles) {
|
|
92
|
-
const cachePath = join(this.cacheDir, file);
|
|
93
|
-
try {
|
|
94
|
-
const content = readFileSync(cachePath, "utf-8");
|
|
95
|
-
const entry = JSON.parse(content);
|
|
96
|
-
if (!this.isExpired(entry)) {
|
|
97
|
-
baselines.push({
|
|
98
|
-
target: entry.report.options.target ?? "unknown",
|
|
99
|
-
type: entry.report.options.type,
|
|
100
|
-
timestamp: entry.timestamp,
|
|
101
|
-
hash: entry.hash
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
} catch {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return baselines.sort((a, b) => b.timestamp - a.timestamp);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.warn("Failed to list performance baselines:", error);
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async clear() {
|
|
115
|
-
if (!this.options.enabled) return;
|
|
116
|
-
try {
|
|
117
|
-
const cacheFiles = Array.from(
|
|
118
|
-
new Bun.Glob("*.json").scanSync({ cwd: this.cacheDir })
|
|
119
|
-
);
|
|
120
|
-
for (const file of cacheFiles) {
|
|
121
|
-
const cachePath = join(this.cacheDir, file);
|
|
122
|
-
try {
|
|
123
|
-
Bun.write(cachePath, "");
|
|
124
|
-
} catch {
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.warn("Failed to clear performance cache:", error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async cleanup() {
|
|
132
|
-
if (!this.options.enabled) return;
|
|
133
|
-
try {
|
|
134
|
-
const cacheFiles = Array.from(
|
|
135
|
-
new Bun.Glob("*.json").scanSync({ cwd: this.cacheDir })
|
|
136
|
-
);
|
|
137
|
-
for (const file of cacheFiles) {
|
|
138
|
-
const cachePath = join(this.cacheDir, file);
|
|
139
|
-
try {
|
|
140
|
-
const content = readFileSync(cachePath, "utf-8");
|
|
141
|
-
const entry = JSON.parse(content);
|
|
142
|
-
if (this.isExpired(entry)) {
|
|
143
|
-
Bun.write(cachePath, "");
|
|
144
|
-
}
|
|
145
|
-
} catch {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} catch (error) {
|
|
150
|
-
console.warn("Failed to cleanup performance cache:", error);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
getCacheSize() {
|
|
154
|
-
try {
|
|
155
|
-
const cacheFiles = Array.from(
|
|
156
|
-
new Bun.Glob("*.json").scanSync({ cwd: this.cacheDir })
|
|
157
|
-
);
|
|
158
|
-
return cacheFiles.length;
|
|
159
|
-
} catch {
|
|
160
|
-
return 0;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
export const createPerfCache = (options = {}) => {
|
|
165
|
-
const defaultOptions = {
|
|
166
|
-
enabled: true,
|
|
167
|
-
cacheDir: ".dler-cache/perf",
|
|
168
|
-
maxAge: 7 * 24 * 60 * 60 * 1e3
|
|
169
|
-
// 7 days
|
|
170
|
-
};
|
|
171
|
-
return new PerfCache({ ...defaultOptions, ...options });
|
|
172
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const formatDuration: (ms: number) => string;
|
|
2
|
-
export declare const formatBytes: (bytes: number) => string;
|
|
3
|
-
export declare const formatPercentage: (value: number, total: number) => string;
|
|
4
|
-
export declare const formatNumber: (num: number) => string;
|
|
5
|
-
export declare const formatMemory: (bytes: number) => string;
|
|
6
|
-
export declare const formatImprovement: (improvement: number) => string;
|
|
7
|
-
export declare const formatRegression: (regression: number) => string;
|
|
8
|
-
export declare const formatConfidenceInterval: (lower: number, upper: number, formatter?: (ms: number) => string) => string;
|
|
9
|
-
export declare const formatProgress: (current: number, total: number) => string;
|
|
10
|
-
export declare const formatTable: (headers: string[], rows: string[][]) => string;
|
|
11
|
-
export declare const formatDurationBar: (value: number, max: number, width?: number) => string;
|
|
12
|
-
export declare const formatSizeBar: (value: number, max: number, width?: number) => string;
|
|
13
|
-
export declare const formatRelativeChange: (baseline: number, current: number) => string;
|
|
14
|
-
export declare const truncatePath: (path: string, maxLength?: number) => string;
|
|
15
|
-
export declare const formatFileType: (extension: string) => string;
|
|
16
|
-
export declare const formatSeverity: (severity: "low" | "medium" | "high") => string;
|
|
17
|
-
export declare const formatBottleneckType: (type: "slow-build" | "many-dependencies" | "circular-dependency") => string;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
export const formatDuration = (ms) => {
|
|
2
|
-
if (ms < 1e3) {
|
|
3
|
-
return `${ms.toFixed(2)}ms`;
|
|
4
|
-
}
|
|
5
|
-
if (ms < 6e4) {
|
|
6
|
-
return `${(ms / 1e3).toFixed(2)}s`;
|
|
7
|
-
}
|
|
8
|
-
const minutes = Math.floor(ms / 6e4);
|
|
9
|
-
const seconds = (ms % 6e4 / 1e3).toFixed(2);
|
|
10
|
-
return `${minutes}m ${seconds}s`;
|
|
11
|
-
};
|
|
12
|
-
export const formatBytes = (bytes) => {
|
|
13
|
-
if (bytes === 0) return "0 B";
|
|
14
|
-
const k = 1024;
|
|
15
|
-
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
16
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
17
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
18
|
-
};
|
|
19
|
-
export const formatPercentage = (value, total) => {
|
|
20
|
-
if (total === 0) return "0.00%";
|
|
21
|
-
return `${(value / total * 100).toFixed(2)}%`;
|
|
22
|
-
};
|
|
23
|
-
export const formatNumber = (num) => {
|
|
24
|
-
if (num < 1e3) return num.toString();
|
|
25
|
-
if (num < 1e6) return `${(num / 1e3).toFixed(1)}K`;
|
|
26
|
-
if (num < 1e9) return `${(num / 1e6).toFixed(1)}M`;
|
|
27
|
-
return `${(num / 1e9).toFixed(1)}B`;
|
|
28
|
-
};
|
|
29
|
-
export const formatMemory = (bytes) => {
|
|
30
|
-
return formatBytes(bytes);
|
|
31
|
-
};
|
|
32
|
-
export const formatImprovement = (improvement) => {
|
|
33
|
-
const sign = improvement > 0 ? "+" : "";
|
|
34
|
-
return `${sign}${improvement.toFixed(2)}%`;
|
|
35
|
-
};
|
|
36
|
-
export const formatRegression = (regression) => {
|
|
37
|
-
return `+${regression.toFixed(2)}%`;
|
|
38
|
-
};
|
|
39
|
-
export const formatConfidenceInterval = (lower, upper, formatter = formatDuration) => {
|
|
40
|
-
return `${formatter(lower)} - ${formatter(upper)}`;
|
|
41
|
-
};
|
|
42
|
-
export const formatProgress = (current, total) => {
|
|
43
|
-
const percentage = total === 0 ? 0 : current / total * 100;
|
|
44
|
-
const barLength = 20;
|
|
45
|
-
const filled = Math.floor(percentage / 100 * barLength);
|
|
46
|
-
const bar = "\u2588".repeat(filled) + "\u2591".repeat(barLength - filled);
|
|
47
|
-
return `[${bar}] ${percentage.toFixed(1)}% (${current}/${total})`;
|
|
48
|
-
};
|
|
49
|
-
export const formatTable = (headers, rows) => {
|
|
50
|
-
if (rows.length === 0) return "";
|
|
51
|
-
const widths = headers.map((header, i) => {
|
|
52
|
-
const maxRowWidth = Math.max(...rows.map((row) => row[i]?.length ?? 0));
|
|
53
|
-
return Math.max(header.length, maxRowWidth);
|
|
54
|
-
});
|
|
55
|
-
const separator = "\u2500".repeat(widths.reduce((sum, w) => sum + w + 3, 0) - 1);
|
|
56
|
-
const headerRow = headers.map((header, i) => header.padEnd(widths[i])).join(" \u2502 ");
|
|
57
|
-
const dataRows = rows.map(
|
|
58
|
-
(row) => row.map((cell, i) => (cell ?? "").padEnd(widths[i])).join(" \u2502 ")
|
|
59
|
-
);
|
|
60
|
-
return [headerRow, separator, ...dataRows].join("\n");
|
|
61
|
-
};
|
|
62
|
-
export const formatDurationBar = (value, max, width = 20) => {
|
|
63
|
-
const percentage = max === 0 ? 0 : value / max * 100;
|
|
64
|
-
const filled = Math.floor(percentage / 100 * width);
|
|
65
|
-
const bar = "\u2588".repeat(filled) + "\u2591".repeat(width - filled);
|
|
66
|
-
return `${bar} ${formatDuration(value)}`;
|
|
67
|
-
};
|
|
68
|
-
export const formatSizeBar = (value, max, width = 20) => {
|
|
69
|
-
const percentage = max === 0 ? 0 : value / max * 100;
|
|
70
|
-
const filled = Math.floor(percentage / 100 * width);
|
|
71
|
-
const bar = "\u2588".repeat(filled) + "\u2591".repeat(width - filled);
|
|
72
|
-
return `${bar} ${formatBytes(value)}`;
|
|
73
|
-
};
|
|
74
|
-
export const formatRelativeChange = (baseline, current) => {
|
|
75
|
-
if (baseline === 0) return "N/A";
|
|
76
|
-
const change = (current - baseline) / baseline * 100;
|
|
77
|
-
const sign = change > 0 ? "+" : "";
|
|
78
|
-
const color = change > 0 ? "\u{1F534}" : change < 0 ? "\u{1F7E2}" : "\u26AA";
|
|
79
|
-
return `${color} ${sign}${change.toFixed(2)}%`;
|
|
80
|
-
};
|
|
81
|
-
export const truncatePath = (path, maxLength = 50) => {
|
|
82
|
-
if (path.length <= maxLength) return path;
|
|
83
|
-
const start = path.substring(0, Math.floor(maxLength / 2) - 2);
|
|
84
|
-
const end = path.substring(path.length - Math.floor(maxLength / 2) + 2);
|
|
85
|
-
return `${start}...${end}`;
|
|
86
|
-
};
|
|
87
|
-
export const formatFileType = (extension) => {
|
|
88
|
-
const typeMap = {
|
|
89
|
-
".js": "JavaScript",
|
|
90
|
-
".ts": "TypeScript",
|
|
91
|
-
".jsx": "React JSX",
|
|
92
|
-
".tsx": "React TSX",
|
|
93
|
-
".json": "JSON",
|
|
94
|
-
".css": "CSS",
|
|
95
|
-
".scss": "SCSS",
|
|
96
|
-
".sass": "Sass",
|
|
97
|
-
".less": "Less",
|
|
98
|
-
".html": "HTML",
|
|
99
|
-
".svg": "SVG",
|
|
100
|
-
".png": "PNG",
|
|
101
|
-
".jpg": "JPEG",
|
|
102
|
-
".jpeg": "JPEG",
|
|
103
|
-
".gif": "GIF",
|
|
104
|
-
".webp": "WebP",
|
|
105
|
-
".woff": "WOFF",
|
|
106
|
-
".woff2": "WOFF2",
|
|
107
|
-
".ttf": "TrueType",
|
|
108
|
-
".eot": "EOT",
|
|
109
|
-
".map": "Source Map",
|
|
110
|
-
".d.ts": "TypeScript Declarations"
|
|
111
|
-
};
|
|
112
|
-
return typeMap[extension] ?? extension.toUpperCase();
|
|
113
|
-
};
|
|
114
|
-
export const formatSeverity = (severity) => {
|
|
115
|
-
const icons = {
|
|
116
|
-
low: "\u{1F7E1}",
|
|
117
|
-
medium: "\u{1F7E0}",
|
|
118
|
-
high: "\u{1F534}"
|
|
119
|
-
};
|
|
120
|
-
return `${icons[severity]} ${severity.toUpperCase()}`;
|
|
121
|
-
};
|
|
122
|
-
export const formatBottleneckType = (type) => {
|
|
123
|
-
const icons = {
|
|
124
|
-
"slow-build": "\u23F1\uFE0F",
|
|
125
|
-
"many-dependencies": "\u{1F517}",
|
|
126
|
-
"circular-dependency": "\u{1F504}"
|
|
127
|
-
};
|
|
128
|
-
const labels = {
|
|
129
|
-
"slow-build": "Slow Build",
|
|
130
|
-
"many-dependencies": "Many Dependencies",
|
|
131
|
-
"circular-dependency": "Circular Dependency"
|
|
132
|
-
};
|
|
133
|
-
return `${icons[type]} ${labels[type]}`;
|
|
134
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Statistics } from "../types.js";
|
|
2
|
-
export declare const calculateStatistics: (values: number[]) => Statistics;
|
|
3
|
-
export declare const percentile: (sorted: number[], p: number) => number;
|
|
4
|
-
export declare const calculateMemoryGrowth: (initial: number, final: number) => number;
|
|
5
|
-
export declare const calculateMemoryAverage: (measurements: number[]) => number;
|
|
6
|
-
export declare const findPeakMemory: (measurements: number[]) => number;
|
|
7
|
-
export declare const calculateImprovement: (baseline: number, current: number) => number;
|
|
8
|
-
export declare const calculateRegression: (baseline: number, current: number) => number;
|
|
9
|
-
export declare const isSignificantChange: (baseline: number, current: number, threshold?: number) => boolean;
|
|
10
|
-
export declare const calculateConfidenceInterval: (values: number[], confidence?: number) => {
|
|
11
|
-
lower: number;
|
|
12
|
-
upper: number;
|
|
13
|
-
};
|
|
14
|
-
export declare const detectOutliers: (values: number[], threshold?: number) => number[];
|
|
15
|
-
export declare const removeOutliers: (values: number[], threshold?: number) => number[];
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export const calculateStatistics = (values) => {
|
|
2
|
-
if (values.length === 0) {
|
|
3
|
-
return {
|
|
4
|
-
min: 0,
|
|
5
|
-
max: 0,
|
|
6
|
-
mean: 0,
|
|
7
|
-
median: 0,
|
|
8
|
-
p95: 0,
|
|
9
|
-
p99: 0,
|
|
10
|
-
variance: 0,
|
|
11
|
-
standardDeviation: 0,
|
|
12
|
-
coefficientOfVariation: 0
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
16
|
-
const n = values.length;
|
|
17
|
-
const min = sorted[0];
|
|
18
|
-
const max = sorted[n - 1];
|
|
19
|
-
const mean = values.reduce((sum, val) => sum + val, 0) / n;
|
|
20
|
-
const median = n % 2 === 0 ? (sorted[n / 2 - 1] + sorted[n / 2]) / 2 : sorted[Math.floor(n / 2)];
|
|
21
|
-
const p95 = percentile(sorted, 0.95);
|
|
22
|
-
const p99 = percentile(sorted, 0.99);
|
|
23
|
-
const variance = values.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / n;
|
|
24
|
-
const standardDeviation = Math.sqrt(variance);
|
|
25
|
-
const coefficientOfVariation = mean === 0 ? 0 : standardDeviation / mean;
|
|
26
|
-
return {
|
|
27
|
-
min,
|
|
28
|
-
max,
|
|
29
|
-
mean,
|
|
30
|
-
median,
|
|
31
|
-
p95,
|
|
32
|
-
p99,
|
|
33
|
-
variance,
|
|
34
|
-
standardDeviation,
|
|
35
|
-
coefficientOfVariation
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export const percentile = (sorted, p) => {
|
|
39
|
-
if (sorted.length === 0) return 0;
|
|
40
|
-
if (sorted.length === 1) return sorted[0];
|
|
41
|
-
const index = p * (sorted.length - 1);
|
|
42
|
-
const lower = Math.floor(index);
|
|
43
|
-
const upper = Math.ceil(index);
|
|
44
|
-
if (lower === upper) {
|
|
45
|
-
return sorted[lower];
|
|
46
|
-
}
|
|
47
|
-
const weight = index - lower;
|
|
48
|
-
return sorted[lower] * (1 - weight) + sorted[upper] * weight;
|
|
49
|
-
};
|
|
50
|
-
export const calculateMemoryGrowth = (initial, final) => {
|
|
51
|
-
return final - initial;
|
|
52
|
-
};
|
|
53
|
-
export const calculateMemoryAverage = (measurements) => {
|
|
54
|
-
if (measurements.length === 0) return 0;
|
|
55
|
-
return measurements.reduce((sum, val) => sum + val, 0) / measurements.length;
|
|
56
|
-
};
|
|
57
|
-
export const findPeakMemory = (measurements) => {
|
|
58
|
-
return measurements.length === 0 ? 0 : Math.max(...measurements);
|
|
59
|
-
};
|
|
60
|
-
export const calculateImprovement = (baseline, current) => {
|
|
61
|
-
if (baseline === 0) return 0;
|
|
62
|
-
return (baseline - current) / baseline * 100;
|
|
63
|
-
};
|
|
64
|
-
export const calculateRegression = (baseline, current) => {
|
|
65
|
-
if (baseline === 0) return 0;
|
|
66
|
-
return (current - baseline) / baseline * 100;
|
|
67
|
-
};
|
|
68
|
-
export const isSignificantChange = (baseline, current, threshold = 5) => {
|
|
69
|
-
const change = Math.abs(calculateImprovement(baseline, current));
|
|
70
|
-
return change >= threshold;
|
|
71
|
-
};
|
|
72
|
-
export const calculateConfidenceInterval = (values, confidence = 0.95) => {
|
|
73
|
-
if (values.length < 2) {
|
|
74
|
-
return { lower: values[0] ?? 0, upper: values[0] ?? 0 };
|
|
75
|
-
}
|
|
76
|
-
const mean = values.reduce((sum, val) => sum + val, 0) / values.length;
|
|
77
|
-
const variance = values.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / (values.length - 1);
|
|
78
|
-
const standardError = Math.sqrt(variance / values.length);
|
|
79
|
-
const tValue = confidence === 0.95 ? 1.96 : 2.576;
|
|
80
|
-
const margin = tValue * standardError;
|
|
81
|
-
return {
|
|
82
|
-
lower: mean - margin,
|
|
83
|
-
upper: mean + margin
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export const detectOutliers = (values, threshold = 2) => {
|
|
87
|
-
if (values.length < 3) return [];
|
|
88
|
-
const stats = calculateStatistics(values);
|
|
89
|
-
const outliers = [];
|
|
90
|
-
for (const value of values) {
|
|
91
|
-
const zScore = Math.abs((value - stats.mean) / stats.standardDeviation);
|
|
92
|
-
if (zScore > threshold) {
|
|
93
|
-
outliers.push(value);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return outliers;
|
|
97
|
-
};
|
|
98
|
-
export const removeOutliers = (values, threshold = 2) => {
|
|
99
|
-
const outliers = detectOutliers(values, threshold);
|
|
100
|
-
return values.filter((val) => !outliers.includes(val));
|
|
101
|
-
};
|
package/dist/cmds/port/cmd.d.ts
DELETED