@stati/core 1.16.3 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/build.d.ts +41 -12
- package/dist/core/build.d.ts.map +1 -1
- package/dist/core/build.js +95 -13
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/markdown.d.ts +19 -2
- package/dist/core/markdown.d.ts.map +1 -1
- package/dist/core/markdown.js +81 -2
- package/dist/core/templates.d.ts +11 -2
- package/dist/core/templates.d.ts.map +1 -1
- package/dist/core/templates.js +28 -11
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/index.d.ts.map +1 -1
- package/dist/core/utils/index.js +2 -0
- package/dist/core/utils/slugify.utils.d.ts +22 -0
- package/dist/core/utils/slugify.utils.d.ts.map +1 -0
- package/dist/core/utils/slugify.utils.js +108 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/metrics/index.d.ts +38 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +42 -0
- package/dist/metrics/noop.d.ts +12 -0
- package/dist/metrics/noop.d.ts.map +1 -0
- package/dist/metrics/noop.js +88 -0
- package/dist/metrics/recorder.d.ts +31 -0
- package/dist/metrics/recorder.d.ts.map +1 -0
- package/dist/metrics/recorder.js +176 -0
- package/dist/metrics/types.d.ts +236 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +7 -0
- package/dist/metrics/utils/index.d.ts +9 -0
- package/dist/metrics/utils/index.d.ts.map +1 -0
- package/dist/metrics/utils/index.js +9 -0
- package/dist/metrics/utils/system.utils.d.ts +44 -0
- package/dist/metrics/utils/system.utils.d.ts.map +1 -0
- package/dist/metrics/utils/system.utils.js +95 -0
- package/dist/metrics/utils/writer.utils.d.ts +64 -0
- package/dist/metrics/utils/writer.utils.d.ts.map +1 -0
- package/dist/metrics/utils/writer.utils.js +145 -0
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/content.d.ts +23 -4
- package/dist/types/content.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build metrics type definitions for Stati performance measurement system.
|
|
3
|
+
*
|
|
4
|
+
* Schema version: 1
|
|
5
|
+
* This schema is versioned for backward compatibility.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Complete build metrics output format.
|
|
9
|
+
* Written to JSON files and used for CI regression detection.
|
|
10
|
+
*/
|
|
11
|
+
export interface BuildMetrics {
|
|
12
|
+
/** Schema version for backward compatibility */
|
|
13
|
+
readonly schemaVersion: '1';
|
|
14
|
+
/** Run metadata */
|
|
15
|
+
readonly meta: MetricsMeta;
|
|
16
|
+
/** Total timings and memory */
|
|
17
|
+
readonly totals: MetricsTotals;
|
|
18
|
+
/** Phase breakdown (all times in milliseconds) */
|
|
19
|
+
readonly phases: MetricsPhases;
|
|
20
|
+
/** Counts */
|
|
21
|
+
readonly counts: MetricsCounts;
|
|
22
|
+
/** ISG cache metrics */
|
|
23
|
+
readonly isg: MetricsISG;
|
|
24
|
+
/** Per-page timing (optional, only when detailed tracing enabled) */
|
|
25
|
+
readonly pageTimings?: readonly PageTiming[];
|
|
26
|
+
/** Incremental rebuild metrics (dev mode only) */
|
|
27
|
+
readonly incremental?: IncrementalMetrics;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run metadata for a build metrics report.
|
|
31
|
+
*/
|
|
32
|
+
export interface MetricsMeta {
|
|
33
|
+
/** ISO timestamp of build start */
|
|
34
|
+
readonly timestamp: string;
|
|
35
|
+
/** Git commit SHA (if available) */
|
|
36
|
+
readonly gitCommit?: string;
|
|
37
|
+
/** Git branch (if available) */
|
|
38
|
+
readonly gitBranch?: string;
|
|
39
|
+
/** Whether running in CI environment */
|
|
40
|
+
readonly ci: boolean;
|
|
41
|
+
/** Node.js version */
|
|
42
|
+
readonly nodeVersion: string;
|
|
43
|
+
/** Platform (darwin, linux, win32) */
|
|
44
|
+
readonly platform: 'aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32';
|
|
45
|
+
/** CPU architecture */
|
|
46
|
+
readonly arch: string;
|
|
47
|
+
/** Number of CPU cores */
|
|
48
|
+
readonly cpuCount: number;
|
|
49
|
+
/** Stati version */
|
|
50
|
+
readonly statiVersion: string;
|
|
51
|
+
/** Command executed */
|
|
52
|
+
readonly command: 'build' | 'dev';
|
|
53
|
+
/** CLI flags used */
|
|
54
|
+
readonly flags: MetricsFlags;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* CLI flags captured in metrics.
|
|
58
|
+
*/
|
|
59
|
+
export interface MetricsFlags {
|
|
60
|
+
readonly force?: boolean | undefined;
|
|
61
|
+
readonly clean?: boolean | undefined;
|
|
62
|
+
readonly includeDrafts?: boolean | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Total timings and memory measurements.
|
|
66
|
+
*/
|
|
67
|
+
export interface MetricsTotals {
|
|
68
|
+
/** Total build duration in milliseconds */
|
|
69
|
+
readonly durationMs: number;
|
|
70
|
+
/** Peak RSS in bytes */
|
|
71
|
+
readonly peakRssBytes: number;
|
|
72
|
+
/** Heap used at end of build in bytes */
|
|
73
|
+
readonly heapUsedBytes: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Phase breakdown timings in milliseconds.
|
|
77
|
+
* All fields are optional as not all phases run in every build.
|
|
78
|
+
*/
|
|
79
|
+
export interface MetricsPhases {
|
|
80
|
+
readonly configLoadMs?: number;
|
|
81
|
+
readonly contentDiscoveryMs?: number;
|
|
82
|
+
readonly navigationBuildMs?: number;
|
|
83
|
+
readonly cacheManifestLoadMs?: number;
|
|
84
|
+
readonly typescriptCompileMs?: number;
|
|
85
|
+
readonly pageRenderingMs?: number;
|
|
86
|
+
readonly assetCopyMs?: number;
|
|
87
|
+
readonly cacheManifestSaveMs?: number;
|
|
88
|
+
readonly sitemapGenerationMs?: number;
|
|
89
|
+
readonly rssGenerationMs?: number;
|
|
90
|
+
/** Build hooks - only recorded when hooks are configured */
|
|
91
|
+
readonly hookBeforeAllMs?: number;
|
|
92
|
+
readonly hookAfterAllMs?: number;
|
|
93
|
+
/** Aggregate time spent in beforeRender hooks across all pages */
|
|
94
|
+
readonly hookBeforeRenderTotalMs?: number;
|
|
95
|
+
/** Aggregate time spent in afterRender hooks across all pages */
|
|
96
|
+
readonly hookAfterRenderTotalMs?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Phase names as a union type for type safety.
|
|
100
|
+
*/
|
|
101
|
+
export type PhaseName = keyof MetricsPhases;
|
|
102
|
+
/**
|
|
103
|
+
* Counts of various build artifacts.
|
|
104
|
+
*/
|
|
105
|
+
export interface MetricsCounts {
|
|
106
|
+
readonly totalPages: number;
|
|
107
|
+
readonly renderedPages: number;
|
|
108
|
+
readonly cachedPages: number;
|
|
109
|
+
readonly assetsCopied: number;
|
|
110
|
+
readonly templatesLoaded: number;
|
|
111
|
+
readonly markdownFilesProcessed: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Counter names as a union type for type safety.
|
|
115
|
+
*/
|
|
116
|
+
export type CounterName = keyof MetricsCounts;
|
|
117
|
+
/**
|
|
118
|
+
* Known gauge names as a union type for type safety.
|
|
119
|
+
* Gauges are point-in-time values that can go up or down (unlike counters).
|
|
120
|
+
*/
|
|
121
|
+
export type GaugeName = 'peakRss';
|
|
122
|
+
/**
|
|
123
|
+
* ISG cache metrics.
|
|
124
|
+
*/
|
|
125
|
+
export interface MetricsISG {
|
|
126
|
+
/** Whether ISG caching is enabled */
|
|
127
|
+
readonly enabled: boolean;
|
|
128
|
+
/** Cache hit rate (0..1) */
|
|
129
|
+
readonly cacheHitRate: number;
|
|
130
|
+
/** Number of entries in manifest */
|
|
131
|
+
readonly manifestEntries: number;
|
|
132
|
+
/** Number of entries invalidated this build */
|
|
133
|
+
readonly invalidatedEntries: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Per-page timing information.
|
|
137
|
+
* Only collected when detailed metrics are enabled.
|
|
138
|
+
*/
|
|
139
|
+
export interface PageTiming {
|
|
140
|
+
/** Page URL */
|
|
141
|
+
readonly url: string;
|
|
142
|
+
/** Render duration in milliseconds */
|
|
143
|
+
readonly durationMs: number;
|
|
144
|
+
/** Whether page was served from cache */
|
|
145
|
+
readonly cached: boolean;
|
|
146
|
+
/** Number of templates loaded for this page (undefined for cached pages) */
|
|
147
|
+
readonly templatesLoaded?: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Incremental rebuild metrics for dev server.
|
|
151
|
+
*/
|
|
152
|
+
export interface IncrementalMetrics {
|
|
153
|
+
/** File that triggered the rebuild */
|
|
154
|
+
readonly triggerFile: string;
|
|
155
|
+
/** Type of file that changed */
|
|
156
|
+
readonly triggerType: 'markdown' | 'template' | 'static' | 'config';
|
|
157
|
+
/** Number of pages rendered */
|
|
158
|
+
readonly renderedPages: number;
|
|
159
|
+
/** Number of pages served from cache */
|
|
160
|
+
readonly cachedPages: number;
|
|
161
|
+
/** Total rebuild duration in milliseconds */
|
|
162
|
+
readonly durationMs: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Options for creating a MetricRecorder.
|
|
166
|
+
*/
|
|
167
|
+
export interface MetricRecorderOptions {
|
|
168
|
+
/** Whether metrics collection is enabled */
|
|
169
|
+
enabled?: boolean | undefined;
|
|
170
|
+
/** Whether to collect per-page timings */
|
|
171
|
+
detailed?: boolean | undefined;
|
|
172
|
+
/** Command being executed */
|
|
173
|
+
command?: 'build' | 'dev' | undefined;
|
|
174
|
+
/** CLI flags used */
|
|
175
|
+
flags?: MetricsFlags | undefined;
|
|
176
|
+
/** Stati version string */
|
|
177
|
+
statiVersion?: string | undefined;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Interface for metrics collection.
|
|
181
|
+
* The noop implementation has zero overhead when disabled.
|
|
182
|
+
*/
|
|
183
|
+
export interface MetricRecorder {
|
|
184
|
+
/**
|
|
185
|
+
* Start a named span, returns a function to end it.
|
|
186
|
+
* The returned function records the duration when called.
|
|
187
|
+
*/
|
|
188
|
+
startSpan(name: PhaseName): () => void;
|
|
189
|
+
/**
|
|
190
|
+
* Record a phase duration directly (replaces existing value).
|
|
191
|
+
*/
|
|
192
|
+
recordPhase(name: PhaseName, durationMs: number): void;
|
|
193
|
+
/**
|
|
194
|
+
* Add to an existing phase duration (for accumulating per-page hook times).
|
|
195
|
+
*/
|
|
196
|
+
addToPhase(name: PhaseName, durationMs: number): void;
|
|
197
|
+
/**
|
|
198
|
+
* Increment a counter.
|
|
199
|
+
*/
|
|
200
|
+
increment(name: CounterName, amount?: number): void;
|
|
201
|
+
/**
|
|
202
|
+
* Set a gauge value (for point-in-time metrics like peak memory).
|
|
203
|
+
* Gauges track the maximum value observed for a given name.
|
|
204
|
+
*/
|
|
205
|
+
setGauge(name: GaugeName, value: number): void;
|
|
206
|
+
/**
|
|
207
|
+
* Record page timing (only when detailed mode enabled).
|
|
208
|
+
* @param templatesLoaded - Number of templates loaded (optional, typically undefined for cached pages)
|
|
209
|
+
*/
|
|
210
|
+
recordPageTiming(url: string, durationMs: number, cached: boolean, templatesLoaded?: number): void;
|
|
211
|
+
/**
|
|
212
|
+
* Take memory snapshot to track peak RSS.
|
|
213
|
+
*/
|
|
214
|
+
snapshotMemory(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Set ISG metrics.
|
|
217
|
+
*/
|
|
218
|
+
setISGMetrics(metrics: Partial<MetricsISG>): void;
|
|
219
|
+
/**
|
|
220
|
+
* Set incremental rebuild metrics (dev mode).
|
|
221
|
+
*/
|
|
222
|
+
setIncrementalMetrics(metrics: IncrementalMetrics): void;
|
|
223
|
+
/**
|
|
224
|
+
* Finalize and return metrics object.
|
|
225
|
+
*/
|
|
226
|
+
finalize(): BuildMetrics;
|
|
227
|
+
/**
|
|
228
|
+
* Whether metrics collection is enabled.
|
|
229
|
+
*/
|
|
230
|
+
readonly enabled: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Whether detailed (per-page) metrics are enabled.
|
|
233
|
+
*/
|
|
234
|
+
readonly detailed: boolean;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metrics/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC;IAE5B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,aAAa;IACb,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,wBAAwB;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAEzB,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAE7C,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,wCAAwC;IACxC,QAAQ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IAEvC;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/C;;;OAGG;IACH,gBAAgB,CACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC;IAER;;OAEG;IACH,cAAc,IAAI,IAAI,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAElD;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,QAAQ,IAAI,YAAY,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics utility functions barrel export.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { isCI, getGitCommit, getGitBranch, getCpuCount, getPlatform, getArch, getMemoryUsage, getNodeVersion, } from './system.utils.js';
|
|
7
|
+
export { DEFAULT_METRICS_DIR, generateMetricsFilename, writeMetrics, formatMetricsSummary, } from './writer.utils.js';
|
|
8
|
+
export type { WriteMetricsOptions, WriteMetricsResult } from './writer.utils.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics utility functions barrel export.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
// System utilities
|
|
7
|
+
export { isCI, getGitCommit, getGitBranch, getCpuCount, getPlatform, getArch, getMemoryUsage, getNodeVersion, } from './system.utils.js';
|
|
8
|
+
// Writer utilities
|
|
9
|
+
export { DEFAULT_METRICS_DIR, generateMetricsFilename, writeMetrics, formatMetricsSummary, } from './writer.utils.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System information utilities for metrics collection.
|
|
3
|
+
* Uses only Node.js built-ins to avoid external dependencies.
|
|
4
|
+
*/
|
|
5
|
+
import { platform } from 'node:os';
|
|
6
|
+
/**
|
|
7
|
+
* Detect if running in a CI environment.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCI(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current Git commit SHA.
|
|
12
|
+
* Returns undefined if not in a git repository or git is not available.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getGitCommit(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get the current Git branch name.
|
|
17
|
+
* Returns undefined if not in a git repository or git is not available.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getGitBranch(): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Get the number of CPU cores.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCpuCount(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get the current platform.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPlatform(): ReturnType<typeof platform>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the CPU architecture.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getArch(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get Node.js version string (without the 'v' prefix).
|
|
34
|
+
*/
|
|
35
|
+
export declare function getNodeVersion(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Get current memory usage snapshot.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getMemoryUsage(): {
|
|
40
|
+
rss: number;
|
|
41
|
+
heapUsed: number;
|
|
42
|
+
heapTotal: number;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=system.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.utils.d.ts","sourceRoot":"","sources":["../../../src/metrics/utils/system.utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAQ,QAAQ,EAAQ,MAAM,SAAS,CAAC;AAiB/C;;GAEG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAE9B;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAWjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAWjD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAEzD;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAOA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System information utilities for metrics collection.
|
|
3
|
+
* Uses only Node.js built-ins to avoid external dependencies.
|
|
4
|
+
*/
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
import { cpus, platform, arch } from 'node:os';
|
|
7
|
+
/**
|
|
8
|
+
* CI environment detection environment variables.
|
|
9
|
+
*/
|
|
10
|
+
const CI_ENV_VARS = [
|
|
11
|
+
'CI',
|
|
12
|
+
'GITHUB_ACTIONS',
|
|
13
|
+
'GITLAB_CI',
|
|
14
|
+
'CIRCLECI',
|
|
15
|
+
'TRAVIS',
|
|
16
|
+
'JENKINS_URL',
|
|
17
|
+
'BUILDKITE',
|
|
18
|
+
'AZURE_PIPELINES',
|
|
19
|
+
'TF_BUILD',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Detect if running in a CI environment.
|
|
23
|
+
*/
|
|
24
|
+
export function isCI() {
|
|
25
|
+
return CI_ENV_VARS.some((envVar) => process.env[envVar] !== undefined);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the current Git commit SHA.
|
|
29
|
+
* Returns undefined if not in a git repository or git is not available.
|
|
30
|
+
*/
|
|
31
|
+
export function getGitCommit() {
|
|
32
|
+
try {
|
|
33
|
+
const result = execSync('git rev-parse HEAD', {
|
|
34
|
+
encoding: 'utf-8',
|
|
35
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
36
|
+
timeout: 5000,
|
|
37
|
+
});
|
|
38
|
+
return result.trim() || undefined;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the current Git branch name.
|
|
46
|
+
* Returns undefined if not in a git repository or git is not available.
|
|
47
|
+
*/
|
|
48
|
+
export function getGitBranch() {
|
|
49
|
+
try {
|
|
50
|
+
const result = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
51
|
+
encoding: 'utf-8',
|
|
52
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
53
|
+
timeout: 5000,
|
|
54
|
+
});
|
|
55
|
+
return result.trim() || undefined;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the number of CPU cores.
|
|
63
|
+
*/
|
|
64
|
+
export function getCpuCount() {
|
|
65
|
+
return cpus().length;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the current platform.
|
|
69
|
+
*/
|
|
70
|
+
export function getPlatform() {
|
|
71
|
+
return platform();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the CPU architecture.
|
|
75
|
+
*/
|
|
76
|
+
export function getArch() {
|
|
77
|
+
return arch();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get Node.js version string (without the 'v' prefix).
|
|
81
|
+
*/
|
|
82
|
+
export function getNodeVersion() {
|
|
83
|
+
return process.version.replace(/^v/, '');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get current memory usage snapshot.
|
|
87
|
+
*/
|
|
88
|
+
export function getMemoryUsage() {
|
|
89
|
+
const usage = process.memoryUsage();
|
|
90
|
+
return {
|
|
91
|
+
rss: usage.rss,
|
|
92
|
+
heapUsed: usage.heapUsed,
|
|
93
|
+
heapTotal: usage.heapTotal,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics file writing utilities.
|
|
3
|
+
* Handles graceful degradation - never blocks builds on write failures.
|
|
4
|
+
*/
|
|
5
|
+
import type { BuildMetrics } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Default metrics output directory (relative to cache dir).
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_METRICS_DIR = "metrics";
|
|
10
|
+
/**
|
|
11
|
+
* Generate a timestamped filename for metrics output.
|
|
12
|
+
*
|
|
13
|
+
* @param command - The command that was run (build, dev)
|
|
14
|
+
* @param timestamp - ISO timestamp
|
|
15
|
+
* @returns Filename like "build-2024-01-15T10-30-00.json"
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateMetricsFilename(command: string, timestamp: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Options for writing metrics.
|
|
20
|
+
*/
|
|
21
|
+
export interface WriteMetricsOptions {
|
|
22
|
+
/** Base cache directory (e.g., .stati) */
|
|
23
|
+
cacheDir: string;
|
|
24
|
+
/** Custom output path (overrides default) */
|
|
25
|
+
outputPath?: string | undefined;
|
|
26
|
+
/** Format: json (default) or ndjson */
|
|
27
|
+
format?: 'json' | 'ndjson' | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Result of metrics write operation.
|
|
31
|
+
*/
|
|
32
|
+
export interface WriteMetricsResult {
|
|
33
|
+
success: boolean;
|
|
34
|
+
path?: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Write build metrics to a JSON file.
|
|
39
|
+
* Degrades gracefully on failure - logs warning but doesn't throw.
|
|
40
|
+
*
|
|
41
|
+
* @param metrics - The metrics to write
|
|
42
|
+
* @param options - Write options
|
|
43
|
+
* @returns Result indicating success/failure and path
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const result = await writeMetrics(metrics, {
|
|
48
|
+
* cacheDir: '.stati',
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* if (result.success) {
|
|
52
|
+
* console.log(`Metrics written to ${result.path}`);
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function writeMetrics(metrics: BuildMetrics, options: WriteMetricsOptions): Promise<WriteMetricsResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Format metrics for CLI summary output.
|
|
59
|
+
*
|
|
60
|
+
* @param metrics - Build metrics to format
|
|
61
|
+
* @returns Array of formatted lines for CLI output
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatMetricsSummary(metrics: BuildMetrics): string[];
|
|
64
|
+
//# sourceMappingURL=writer.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.utils.d.ts","sourceRoot":"","sources":["../../../src/metrics/utils/writer.utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAuB7C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAIlF;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA2C7B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,CA6CpE"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics file writing utilities.
|
|
3
|
+
* Handles graceful degradation - never blocks builds on write failures.
|
|
4
|
+
*/
|
|
5
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
6
|
+
import { join, dirname } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Default metrics output directory (relative to cache dir).
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_METRICS_DIR = 'metrics';
|
|
11
|
+
/**
|
|
12
|
+
* Display names for build phases.
|
|
13
|
+
* Maps raw phase keys (e.g., 'configLoadMs') to human-readable labels.
|
|
14
|
+
*/
|
|
15
|
+
const PHASE_DISPLAY_NAMES = {
|
|
16
|
+
configLoadMs: 'Config Load',
|
|
17
|
+
contentDiscoveryMs: 'Content Discovery',
|
|
18
|
+
navigationBuildMs: 'Navigation Build',
|
|
19
|
+
cacheManifestLoadMs: 'Cache Manifest Load',
|
|
20
|
+
typescriptCompileMs: 'TypeScript Compile',
|
|
21
|
+
pageRenderingMs: 'Page Rendering',
|
|
22
|
+
assetCopyMs: 'Asset Copy',
|
|
23
|
+
cacheManifestSaveMs: 'Cache Manifest Save',
|
|
24
|
+
sitemapGenerationMs: 'Sitemap Generation',
|
|
25
|
+
rssGenerationMs: 'RSS Generation',
|
|
26
|
+
hookBeforeAllMs: 'Hook: Before All',
|
|
27
|
+
hookAfterAllMs: 'Hook: After All',
|
|
28
|
+
hookBeforeRenderTotalMs: 'Hook: Before Render (Total)',
|
|
29
|
+
hookAfterRenderTotalMs: 'Hook: After Render (Total)',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Generate a timestamped filename for metrics output.
|
|
33
|
+
*
|
|
34
|
+
* @param command - The command that was run (build, dev)
|
|
35
|
+
* @param timestamp - ISO timestamp
|
|
36
|
+
* @returns Filename like "build-2024-01-15T10-30-00.json"
|
|
37
|
+
*/
|
|
38
|
+
export function generateMetricsFilename(command, timestamp) {
|
|
39
|
+
// Replace colons with dashes for Windows compatibility
|
|
40
|
+
const safeTimestamp = timestamp.replace(/:/g, '-').replace(/\.\d+Z$/, 'Z');
|
|
41
|
+
return `${command}-${safeTimestamp}.json`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Write build metrics to a JSON file.
|
|
45
|
+
* Degrades gracefully on failure - logs warning but doesn't throw.
|
|
46
|
+
*
|
|
47
|
+
* @param metrics - The metrics to write
|
|
48
|
+
* @param options - Write options
|
|
49
|
+
* @returns Result indicating success/failure and path
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const result = await writeMetrics(metrics, {
|
|
54
|
+
* cacheDir: '.stati',
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* if (result.success) {
|
|
58
|
+
* console.log(`Metrics written to ${result.path}`);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export async function writeMetrics(metrics, options) {
|
|
63
|
+
try {
|
|
64
|
+
// Determine output path
|
|
65
|
+
let outputPath;
|
|
66
|
+
if (options.outputPath) {
|
|
67
|
+
outputPath = options.outputPath;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const metricsDir = join(options.cacheDir, DEFAULT_METRICS_DIR);
|
|
71
|
+
const filename = generateMetricsFilename(metrics.meta.command, metrics.meta.timestamp);
|
|
72
|
+
outputPath = join(metricsDir, filename);
|
|
73
|
+
}
|
|
74
|
+
// Ensure directory exists
|
|
75
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
76
|
+
// Format content
|
|
77
|
+
const format = options.format ?? 'json';
|
|
78
|
+
let content;
|
|
79
|
+
if (format === 'ndjson') {
|
|
80
|
+
// NDJSON: one JSON object per line, no pretty printing
|
|
81
|
+
content = JSON.stringify(metrics) + '\n';
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// JSON: pretty printed for readability
|
|
85
|
+
content = JSON.stringify(metrics, null, 2) + '\n';
|
|
86
|
+
}
|
|
87
|
+
// Write file
|
|
88
|
+
await writeFile(outputPath, content, 'utf-8');
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
path: outputPath,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// Graceful degradation - don't throw, just report failure
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
97
|
+
return {
|
|
98
|
+
success: false,
|
|
99
|
+
error: `Failed to write metrics: ${errorMessage}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Format metrics for CLI summary output.
|
|
105
|
+
*
|
|
106
|
+
* @param metrics - Build metrics to format
|
|
107
|
+
* @returns Array of formatted lines for CLI output
|
|
108
|
+
*/
|
|
109
|
+
export function formatMetricsSummary(metrics) {
|
|
110
|
+
const lines = [];
|
|
111
|
+
// Header
|
|
112
|
+
lines.push('');
|
|
113
|
+
lines.push('Build Metrics Summary');
|
|
114
|
+
lines.push('─'.repeat(40));
|
|
115
|
+
// Total duration
|
|
116
|
+
const totalSeconds = (metrics.totals.durationMs / 1000).toFixed(2);
|
|
117
|
+
lines.push(`Total build time: ${totalSeconds}s`);
|
|
118
|
+
// Page stats
|
|
119
|
+
const { totalPages, renderedPages, cachedPages } = metrics.counts;
|
|
120
|
+
lines.push(`Pages: ${totalPages} total, ${renderedPages} rendered, ${cachedPages} cached`);
|
|
121
|
+
// Cache hit rate
|
|
122
|
+
const hitRate = (metrics.isg.cacheHitRate * 100).toFixed(1);
|
|
123
|
+
lines.push(`Cache hit rate: ${hitRate}%`);
|
|
124
|
+
// Memory
|
|
125
|
+
const peakMB = (metrics.totals.peakRssBytes / 1024 / 1024).toFixed(1);
|
|
126
|
+
lines.push(`Peak memory: ${peakMB} MB`);
|
|
127
|
+
// Top phases (sorted by duration, top 3)
|
|
128
|
+
const phases = Object.entries(metrics.phases)
|
|
129
|
+
.filter(([, duration]) => duration !== undefined && duration > 0)
|
|
130
|
+
.map(([name, duration]) => ({ name, duration: duration }))
|
|
131
|
+
.sort((a, b) => b.duration - a.duration)
|
|
132
|
+
.slice(0, 3);
|
|
133
|
+
if (phases.length > 0) {
|
|
134
|
+
lines.push('');
|
|
135
|
+
lines.push('Top phases:');
|
|
136
|
+
for (const phase of phases) {
|
|
137
|
+
// Use mapped display name if available, otherwise fall back to raw name
|
|
138
|
+
const phaseName = PHASE_DISPLAY_NAMES[phase.name] || phase.name;
|
|
139
|
+
const phaseMs = phase.duration.toFixed(0);
|
|
140
|
+
lines.push(` ${phaseName}: ${phaseMs}ms`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
lines.push('─'.repeat(40));
|
|
144
|
+
return lines;
|
|
145
|
+
}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface StatiConfig {
|
|
|
60
60
|
plugins?: (string | [string, unknown])[];
|
|
61
61
|
/** Function to configure the MarkdownIt instance */
|
|
62
62
|
configure?: (md: MarkdownIt) => void;
|
|
63
|
+
/** Enable TOC extraction and heading anchor generation (default: true) */
|
|
64
|
+
toc?: boolean;
|
|
63
65
|
};
|
|
64
66
|
/** Eta template engine configuration */
|
|
65
67
|
eta?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,C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