@se-studio/site-check 2.8.4 → 2.8.5
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/CHANGELOG.md +7 -0
- package/README.md +16 -0
- package/develop-sites-timing.mjs +609 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -184,6 +184,22 @@ Cannot be set in `vercel.json` — Vercel restores cache before install/build co
|
|
|
184
184
|
|
|
185
185
|
Per-app script: `"smoke-test:deploy-check": "smoke-test-deploy-check"` (or `node ../../scripts/smoke-test-deploy-check.mjs` in the monorepo).
|
|
186
186
|
|
|
187
|
+
**Cross-site develop timing** (`develop-sites-timing`): probes all client marketing sites (smoke paths from each repo’s `smoke.cases.json`) against develop and production. Runs **N sequential full passes** (default 5) over every path — one request at a time. Reads `VERCEL_PROTECTION_BYPASS_TOKEN` from each site’s `.env.local`; never hardcodes secrets.
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pnpm develop-sites-timing
|
|
191
|
+
pnpm develop-sites-timing --site pointme --passes 3 --output /tmp/timing.json
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
| Option | Purpose |
|
|
195
|
+
|--------|---------|
|
|
196
|
+
| `--site <key>` | One site: `se2026`, `om1`, `brightline`, `brightlifekids`, `pedestal`, `headwater`, `pointme` |
|
|
197
|
+
| `--passes <n>` | Full passes over all paths (default `5`) |
|
|
198
|
+
| `--output <path>` | JSON report (default `./develop-sites-timing.json`) |
|
|
199
|
+
| `--delay-ms <n>` | Pause between requests |
|
|
200
|
+
| `--develop-only` / `--production-only` | Probe one environment |
|
|
201
|
+
| `--source-root <path>` | Client repos root (default `~/source`, or `SE_SOURCE_ROOT`) |
|
|
202
|
+
|
|
187
203
|
**Live deployment smoke** (`smoke-test-live` / `runLiveSmokeTest`): HTTP checks against a deployed URL — use with Vercel `repository_dispatch` (`vercel.deployment.ready`) and [Deployment Checks](https://vercel.com/docs/deployment-checks) to hold production domain aliasing until smoke passes.
|
|
188
204
|
|
|
189
205
|
| Variable | Purpose |
|
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cross-site develop vs production cache/timing probe for all client marketing sites.
|
|
5
|
+
*
|
|
6
|
+
* Reads smoke.cases.json from each site repo, then runs N sequential passes over every
|
|
7
|
+
* path (default 5). Each request is one-at-a-time — no concurrent fetches.
|
|
8
|
+
*
|
|
9
|
+
* Usage (from repo root or packages/site-check):
|
|
10
|
+
* node packages/site-check/develop-sites-timing.mjs
|
|
11
|
+
* develop-sites-timing --site pointme --passes 3 --output ./timing.json
|
|
12
|
+
*
|
|
13
|
+
* Options:
|
|
14
|
+
* --site <key> Run one site (se2026, om1, brightline, brightlifekids, pedestal, headwater, pointme)
|
|
15
|
+
* --passes <n> Number of full passes (default 5)
|
|
16
|
+
* --output <path> JSON output path (default: develop-sites-timing.json in cwd)
|
|
17
|
+
* --delay-ms <n> Pause between requests in ms (default 0)
|
|
18
|
+
* --develop-only Skip production probes
|
|
19
|
+
* --production-only Skip develop probes (no bypass token required)
|
|
20
|
+
*
|
|
21
|
+
* Env:
|
|
22
|
+
* SE_SOURCE_ROOT Client repo root (default: ~/source)
|
|
23
|
+
*
|
|
24
|
+
* Develop URLs use VERCEL_PROTECTION_BYPASS_TOKEN from each site's .env.local.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { spawnSync } from 'node:child_process';
|
|
28
|
+
import fs from 'node:fs';
|
|
29
|
+
import { homedir } from 'node:os';
|
|
30
|
+
import path from 'node:path';
|
|
31
|
+
import { fileURLToPath } from 'node:url';
|
|
32
|
+
|
|
33
|
+
const BYPASS_ENV_KEYS = [
|
|
34
|
+
'VERCEL_PROTECTION_BYPASS_TOKEN',
|
|
35
|
+
'VERCEL_AUTOMATION_BYPASS_SECRET',
|
|
36
|
+
'VERCEL_BYPASS_TOKEN',
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const DEFAULT_PASSES = 5;
|
|
40
|
+
const CURL_MAX_TIME_SECONDS = 45;
|
|
41
|
+
|
|
42
|
+
/** @type {readonly SiteDefinition[]} */
|
|
43
|
+
export const SITE_DEFINITIONS = [
|
|
44
|
+
{
|
|
45
|
+
key: 'se2026',
|
|
46
|
+
label: 'SE Studio',
|
|
47
|
+
develop: 'https://se-website-2026-git-develop-se-studio.vercel.app',
|
|
48
|
+
production: 'https://www.se.studio',
|
|
49
|
+
repoDir: 'se/se-website-2026',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'om1',
|
|
53
|
+
label: 'OM1',
|
|
54
|
+
develop: 'https://om1-website-git-develop-se-studio.vercel.app',
|
|
55
|
+
production: 'https://www.om1.com',
|
|
56
|
+
repoDir: 'customers/om1/om1-website',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: 'brightline',
|
|
60
|
+
label: 'Brightline',
|
|
61
|
+
develop: 'https://hellobrightline-com-git-develop-brightline.vercel.app',
|
|
62
|
+
production: 'https://www.brightline.com',
|
|
63
|
+
repoDir: 'customers/brightline/brightline-sites/apps/brightline-website',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: 'brightlifekids',
|
|
67
|
+
label: 'Brightlife Kids',
|
|
68
|
+
develop: 'https://brightlife-kids-website-git-develop-brightline.vercel.app',
|
|
69
|
+
production: 'https://www.brightlife.kids',
|
|
70
|
+
repoDir: 'customers/brightline/brightline-sites/apps/brightlife-kids-website',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: 'pedestal',
|
|
74
|
+
label: 'Pedestal',
|
|
75
|
+
develop: 'https://pedestal-health-git-develop-se-studio.vercel.app',
|
|
76
|
+
production: 'https://www.pedestalhealth.com',
|
|
77
|
+
repoDir: 'customers/pedestal/pedestal-sites/apps/pedestal-website',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
key: 'headwater',
|
|
81
|
+
label: 'Headwater',
|
|
82
|
+
develop: 'https://headwater-website-git-develop-se-studio.vercel.app',
|
|
83
|
+
production: 'https://www.headwaterscience.com',
|
|
84
|
+
repoDir: 'customers/pedestal/pedestal-sites/apps/headwater-website',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: 'pointme',
|
|
88
|
+
label: 'PointMe',
|
|
89
|
+
develop: 'https://develop-marketing-site.vercel.app',
|
|
90
|
+
production: 'https://www.point.me',
|
|
91
|
+
repoDir: 'customers/pointme/develop-marketing-site',
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @typedef {object} SiteDefinition
|
|
97
|
+
* @property {string} key
|
|
98
|
+
* @property {string} label
|
|
99
|
+
* @property {string} develop
|
|
100
|
+
* @property {string} production
|
|
101
|
+
* @property {string} repoDir — relative to SE_SOURCE_ROOT
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {object} ProbeResult
|
|
106
|
+
* @property {string} status
|
|
107
|
+
* @property {number | null} ttfb
|
|
108
|
+
* @property {number} size
|
|
109
|
+
* @property {string} vercel_cache
|
|
110
|
+
* @property {string} prerender
|
|
111
|
+
* @property {string} stale
|
|
112
|
+
* @property {string} age
|
|
113
|
+
* @property {string} pattern
|
|
114
|
+
* @property {string} cache_control
|
|
115
|
+
* @property {string} [error]
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {object} CliOptions
|
|
120
|
+
* @property {string | undefined} siteKey
|
|
121
|
+
* @property {number} passes
|
|
122
|
+
* @property {string} outputPath
|
|
123
|
+
* @property {number} delayMs
|
|
124
|
+
* @property {boolean} developOnly
|
|
125
|
+
* @property {boolean} productionOnly
|
|
126
|
+
* @property {string} sourceRoot
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
export function expandHome(filePath) {
|
|
130
|
+
return filePath.startsWith('~/') ? path.join(homedir(), filePath.slice(2)) : filePath;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function parseEnvFile(filePath) {
|
|
134
|
+
/** @type {Record<string, string>} */
|
|
135
|
+
const env = {};
|
|
136
|
+
if (!fs.existsSync(filePath)) {
|
|
137
|
+
return env;
|
|
138
|
+
}
|
|
139
|
+
for (const line of fs.readFileSync(filePath, 'utf8').split('\n')) {
|
|
140
|
+
const trimmed = line.trim();
|
|
141
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
142
|
+
const eq = trimmed.indexOf('=');
|
|
143
|
+
if (eq === -1) continue;
|
|
144
|
+
const key = trimmed.slice(0, eq).trim();
|
|
145
|
+
let value = trimmed.slice(eq + 1).trim();
|
|
146
|
+
if (
|
|
147
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
148
|
+
(value.startsWith("'") && value.endsWith("'"))
|
|
149
|
+
) {
|
|
150
|
+
value = value.slice(1, -1);
|
|
151
|
+
}
|
|
152
|
+
env[key] = value;
|
|
153
|
+
}
|
|
154
|
+
return env;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function resolveProtectionBypass(env) {
|
|
158
|
+
for (const key of BYPASS_ENV_KEYS) {
|
|
159
|
+
const value = (env[key] ?? '').trim();
|
|
160
|
+
if (value) return value;
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function parseHeaders(raw) {
|
|
166
|
+
/** @type {Record<string, string>} */
|
|
167
|
+
const out = { status: '' };
|
|
168
|
+
for (const line of raw.split('\n')) {
|
|
169
|
+
if (line.toUpperCase().startsWith('HTTP/')) {
|
|
170
|
+
const parts = line.split(/\s+/);
|
|
171
|
+
out.status = parts[1] ?? '';
|
|
172
|
+
} else if (line.includes(':')) {
|
|
173
|
+
const colon = line.indexOf(':');
|
|
174
|
+
const key = line.slice(0, colon).trim().toLowerCase();
|
|
175
|
+
const value = line.slice(colon + 1).trim();
|
|
176
|
+
out[key] = value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function classifyCachePattern(cacheControl) {
|
|
183
|
+
const cc = cacheControl.toLowerCase();
|
|
184
|
+
if (cc.includes('no-store') || cc.includes('private, no-cache')) {
|
|
185
|
+
return 'dynamic';
|
|
186
|
+
}
|
|
187
|
+
if (cc.includes('s-maxage') || cc.includes('stale-while-revalidate')) {
|
|
188
|
+
return 'isr';
|
|
189
|
+
}
|
|
190
|
+
return 'other';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function buildProbeFromCurl(headersRaw, metricsRaw) {
|
|
194
|
+
const metrics = metricsRaw.trim().split('|');
|
|
195
|
+
if (metrics.length < 3) {
|
|
196
|
+
return {
|
|
197
|
+
status: 'ERR',
|
|
198
|
+
ttfb: null,
|
|
199
|
+
size: 0,
|
|
200
|
+
vercel_cache: '-',
|
|
201
|
+
prerender: '-',
|
|
202
|
+
stale: '-',
|
|
203
|
+
age: '0',
|
|
204
|
+
pattern: 'other',
|
|
205
|
+
cache_control: '',
|
|
206
|
+
error: metricsRaw.slice(0, 200) || 'invalid curl metrics',
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const [ttfbRaw, statusCode, sizeRaw] = metrics;
|
|
211
|
+
const headers = parseHeaders(headersRaw);
|
|
212
|
+
const cacheControl = headers['cache-control'] ?? '';
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
status: headers.status || statusCode,
|
|
216
|
+
ttfb: Number.parseFloat(ttfbRaw),
|
|
217
|
+
size: Number.parseInt(sizeRaw, 10) || 0,
|
|
218
|
+
vercel_cache: headers['x-vercel-cache'] ?? '-',
|
|
219
|
+
prerender: headers['x-nextjs-prerender'] ?? '-',
|
|
220
|
+
stale: headers['x-nextjs-stale-time'] ?? '-',
|
|
221
|
+
age: headers.age ?? '0',
|
|
222
|
+
pattern: classifyCachePattern(cacheControl),
|
|
223
|
+
cache_control: cacheControl.slice(0, 80),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @param {string} url
|
|
229
|
+
* @param {string | undefined} bypass
|
|
230
|
+
* @param {(args: string[]) => { status: number | null; stdout: string; stderr: string }} [runCurl]
|
|
231
|
+
* @returns {ProbeResult}
|
|
232
|
+
*/
|
|
233
|
+
export function probeUrl(url, bypass, runCurl = defaultRunCurl) {
|
|
234
|
+
const args = [
|
|
235
|
+
'-sI',
|
|
236
|
+
'-w',
|
|
237
|
+
'\n__METRICS__%{time_starttransfer}|%{http_code}|%{size_download}',
|
|
238
|
+
'--max-time',
|
|
239
|
+
String(CURL_MAX_TIME_SECONDS),
|
|
240
|
+
];
|
|
241
|
+
if (bypass) {
|
|
242
|
+
args.push('-H', `x-vercel-protection-bypass: ${bypass}`);
|
|
243
|
+
}
|
|
244
|
+
args.push(url);
|
|
245
|
+
|
|
246
|
+
const result = runCurl(args);
|
|
247
|
+
const combined = `${result.stdout}${result.stderr}`;
|
|
248
|
+
if (result.status !== 0) {
|
|
249
|
+
return {
|
|
250
|
+
status: 'ERR',
|
|
251
|
+
ttfb: null,
|
|
252
|
+
size: 0,
|
|
253
|
+
vercel_cache: '-',
|
|
254
|
+
prerender: '-',
|
|
255
|
+
stale: '-',
|
|
256
|
+
age: '0',
|
|
257
|
+
pattern: 'other',
|
|
258
|
+
cache_control: '',
|
|
259
|
+
error: combined.slice(0, 300),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const marker = '__METRICS__';
|
|
264
|
+
const markerIndex = combined.lastIndexOf(marker);
|
|
265
|
+
if (markerIndex === -1) {
|
|
266
|
+
return {
|
|
267
|
+
status: 'ERR',
|
|
268
|
+
ttfb: null,
|
|
269
|
+
size: 0,
|
|
270
|
+
vercel_cache: '-',
|
|
271
|
+
prerender: '-',
|
|
272
|
+
stale: '-',
|
|
273
|
+
age: '0',
|
|
274
|
+
pattern: 'other',
|
|
275
|
+
cache_control: '',
|
|
276
|
+
error: combined.slice(0, 300) || 'missing curl metrics',
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const headersRaw = combined.slice(0, markerIndex);
|
|
281
|
+
const metricsRaw = combined.slice(markerIndex + marker.length);
|
|
282
|
+
return buildProbeFromCurl(headersRaw, metricsRaw);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function defaultRunCurl(args) {
|
|
286
|
+
const result = spawnSync('curl', args, { encoding: 'utf8' });
|
|
287
|
+
return {
|
|
288
|
+
status: result.status,
|
|
289
|
+
stdout: result.stdout ?? '',
|
|
290
|
+
stderr: result.stderr ?? '',
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function joinBaseUrl(baseUrl, routePath) {
|
|
295
|
+
const normalizedBase = baseUrl.replace(/\/$/, '');
|
|
296
|
+
const normalizedPath = routePath.startsWith('/') ? routePath : `/${routePath}`;
|
|
297
|
+
return `${normalizedBase}${normalizedPath}`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function loadSmokeCases(smokePath) {
|
|
301
|
+
const raw = JSON.parse(fs.readFileSync(smokePath, 'utf8'));
|
|
302
|
+
return raw.cases
|
|
303
|
+
.filter((entry) => entry.expectHtmlStatus !== 404)
|
|
304
|
+
.map((entry) => ({
|
|
305
|
+
category: entry.category ?? 'unknown',
|
|
306
|
+
label: entry.label ?? entry.path,
|
|
307
|
+
path: entry.path,
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function resolveSites(options) {
|
|
312
|
+
const sourceRoot = expandHome(options.sourceRoot);
|
|
313
|
+
let sites = SITE_DEFINITIONS;
|
|
314
|
+
|
|
315
|
+
if (options.siteKey) {
|
|
316
|
+
sites = sites.filter((site) => site.key === options.siteKey);
|
|
317
|
+
if (sites.length === 0) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
`Unknown site key "${options.siteKey}". Valid keys: ${SITE_DEFINITIONS.map((s) => s.key).join(', ')}`,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return sites.map((site) => {
|
|
325
|
+
const repoPath = path.join(sourceRoot, site.repoDir);
|
|
326
|
+
const smokePath = path.join(repoPath, 'smoke.cases.json');
|
|
327
|
+
if (!fs.existsSync(smokePath)) {
|
|
328
|
+
throw new Error(`Missing smoke.cases.json for ${site.label}: ${smokePath}`);
|
|
329
|
+
}
|
|
330
|
+
const envLocal = parseEnvFile(path.join(repoPath, '.env.local'));
|
|
331
|
+
const bypass = resolveProtectionBypass(envLocal);
|
|
332
|
+
return {
|
|
333
|
+
...site,
|
|
334
|
+
repoPath,
|
|
335
|
+
smokePath,
|
|
336
|
+
bypass,
|
|
337
|
+
cases: loadSmokeCases(smokePath),
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function sleep(ms) {
|
|
343
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* @param {ProbeResult[]} passes
|
|
348
|
+
*/
|
|
349
|
+
export function summarizePasses(passes) {
|
|
350
|
+
const valid = passes.filter((p) => p.ttfb !== null && !Number.isNaN(p.ttfb));
|
|
351
|
+
const ttfbs = valid.map((p) => p.ttfb);
|
|
352
|
+
const hitCount = passes.filter((p) => p.vercel_cache === 'HIT').length;
|
|
353
|
+
const staleCount = passes.filter((p) => p.vercel_cache === 'STALE').length;
|
|
354
|
+
const missCount = passes.filter((p) => p.vercel_cache === 'MISS').length;
|
|
355
|
+
const prerenderCount = passes.filter((p) => p.prerender === '1').length;
|
|
356
|
+
|
|
357
|
+
const avgTtfb =
|
|
358
|
+
ttfbs.length > 0 ? ttfbs.reduce((sum, value) => sum + value, 0) / ttfbs.length : null;
|
|
359
|
+
const minTtfb = ttfbs.length > 0 ? Math.min(...ttfbs) : null;
|
|
360
|
+
const maxTtfb = ttfbs.length > 0 ? Math.max(...ttfbs) : null;
|
|
361
|
+
const firstTtfb = passes[0]?.ttfb ?? null;
|
|
362
|
+
const lastTtfb = passes.at(-1)?.ttfb ?? null;
|
|
363
|
+
|
|
364
|
+
return {
|
|
365
|
+
count: passes.length,
|
|
366
|
+
avgTtfb,
|
|
367
|
+
minTtfb,
|
|
368
|
+
maxTtfb,
|
|
369
|
+
firstTtfb,
|
|
370
|
+
lastTtfb,
|
|
371
|
+
hitCount,
|
|
372
|
+
staleCount,
|
|
373
|
+
missCount,
|
|
374
|
+
prerenderCount,
|
|
375
|
+
lastVercelCache: passes.at(-1)?.vercel_cache ?? '-',
|
|
376
|
+
lastPrerender: passes.at(-1)?.prerender ?? '-',
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function parseCliArgs(argv) {
|
|
381
|
+
/** @type {CliOptions} */
|
|
382
|
+
const options = {
|
|
383
|
+
siteKey: undefined,
|
|
384
|
+
passes: DEFAULT_PASSES,
|
|
385
|
+
outputPath: path.join(process.cwd(), 'develop-sites-timing.json'),
|
|
386
|
+
delayMs: 0,
|
|
387
|
+
developOnly: false,
|
|
388
|
+
productionOnly: false,
|
|
389
|
+
sourceRoot: process.env.SE_SOURCE_ROOT ?? path.join(homedir(), 'source'),
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const args = argv.slice(2).filter((arg) => arg !== '--');
|
|
393
|
+
for (let i = 0; i < args.length; i++) {
|
|
394
|
+
const arg = args[i];
|
|
395
|
+
if (arg === '--site') {
|
|
396
|
+
options.siteKey = args[++i];
|
|
397
|
+
} else if (arg === '--passes') {
|
|
398
|
+
options.passes = Number.parseInt(args[++i] ?? '', 10);
|
|
399
|
+
} else if (arg === '--output') {
|
|
400
|
+
options.outputPath = args[++i] ?? options.outputPath;
|
|
401
|
+
} else if (arg === '--delay-ms') {
|
|
402
|
+
options.delayMs = Number.parseInt(args[++i] ?? '', 10);
|
|
403
|
+
} else if (arg === '--develop-only') {
|
|
404
|
+
options.developOnly = true;
|
|
405
|
+
} else if (arg === '--production-only') {
|
|
406
|
+
options.productionOnly = true;
|
|
407
|
+
} else if (arg === '--source-root') {
|
|
408
|
+
options.sourceRoot = args[++i] ?? options.sourceRoot;
|
|
409
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
410
|
+
printHelp();
|
|
411
|
+
process.exit(0);
|
|
412
|
+
} else {
|
|
413
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (options.developOnly && options.productionOnly) {
|
|
418
|
+
throw new Error('Use only one of --develop-only or --production-only');
|
|
419
|
+
}
|
|
420
|
+
if (!Number.isFinite(options.passes) || options.passes < 1) {
|
|
421
|
+
throw new Error('--passes must be a positive integer');
|
|
422
|
+
}
|
|
423
|
+
if (!Number.isFinite(options.delayMs) || options.delayMs < 0) {
|
|
424
|
+
throw new Error('--delay-ms must be a non-negative integer');
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return options;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function printHelp() {
|
|
431
|
+
console.log(`Usage: develop-sites-timing [options]
|
|
432
|
+
|
|
433
|
+
Options:
|
|
434
|
+
--site <key> se2026 | om1 | brightline | brightlifekids | pedestal | headwater | pointme
|
|
435
|
+
--passes <n> Full passes over all paths (default ${DEFAULT_PASSES})
|
|
436
|
+
--output <path> JSON report path (default: ./develop-sites-timing.json)
|
|
437
|
+
--delay-ms <n> Pause between requests (default 0)
|
|
438
|
+
--develop-only Probe develop deployments only
|
|
439
|
+
--production-only Probe production only
|
|
440
|
+
--source-root <path> Client repos root (default: ~/source or SE_SOURCE_ROOT)
|
|
441
|
+
-h, --help Show this help
|
|
442
|
+
`);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @param {CliOptions} options
|
|
447
|
+
*/
|
|
448
|
+
export async function runDevelopSitesTiming(options) {
|
|
449
|
+
const sites = resolveSites(options);
|
|
450
|
+
const startedAt = new Date().toISOString();
|
|
451
|
+
|
|
452
|
+
for (const site of sites) {
|
|
453
|
+
if (!options.productionOnly && !site.bypass) {
|
|
454
|
+
throw new Error(
|
|
455
|
+
`${site.label}: set VERCEL_PROTECTION_BYPASS_TOKEN in ${path.join(site.repoPath, '.env.local')}`,
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** @type {Map<string, Record<string, unknown>>} */
|
|
461
|
+
const resultByKey = new Map();
|
|
462
|
+
|
|
463
|
+
for (const site of sites) {
|
|
464
|
+
for (const testCase of site.cases) {
|
|
465
|
+
const resultKey = `${site.key}::${testCase.path}`;
|
|
466
|
+
resultByKey.set(resultKey, {
|
|
467
|
+
site: site.label,
|
|
468
|
+
key: site.key,
|
|
469
|
+
category: testCase.category,
|
|
470
|
+
label: testCase.label,
|
|
471
|
+
path: testCase.path,
|
|
472
|
+
develop: options.productionOnly
|
|
473
|
+
? undefined
|
|
474
|
+
: {
|
|
475
|
+
url: joinBaseUrl(site.develop, testCase.path),
|
|
476
|
+
passes: [],
|
|
477
|
+
},
|
|
478
|
+
production: options.developOnly
|
|
479
|
+
? undefined
|
|
480
|
+
: {
|
|
481
|
+
url: joinBaseUrl(site.production, testCase.path),
|
|
482
|
+
passes: [],
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
for (let pass = 1; pass <= options.passes; pass++) {
|
|
489
|
+
console.log(`Pass ${pass}/${options.passes}...`);
|
|
490
|
+
for (const site of sites) {
|
|
491
|
+
for (const testCase of site.cases) {
|
|
492
|
+
const resultKey = `${site.key}::${testCase.path}`;
|
|
493
|
+
const row = resultByKey.get(resultKey);
|
|
494
|
+
const developUrl = joinBaseUrl(site.develop, testCase.path);
|
|
495
|
+
const productionUrl = joinBaseUrl(site.production, testCase.path);
|
|
496
|
+
|
|
497
|
+
if (!options.productionOnly) {
|
|
498
|
+
row.develop.passes.push({
|
|
499
|
+
pass,
|
|
500
|
+
...probeUrl(developUrl, site.bypass),
|
|
501
|
+
});
|
|
502
|
+
if (options.delayMs > 0) await sleep(options.delayMs);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (!options.developOnly) {
|
|
506
|
+
row.production.passes.push({
|
|
507
|
+
pass,
|
|
508
|
+
...probeUrl(productionUrl, undefined),
|
|
509
|
+
});
|
|
510
|
+
if (options.delayMs > 0) await sleep(options.delayMs);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** @type {Array<Record<string, unknown>>} */
|
|
517
|
+
const results = [...resultByKey.values()].map((row) => {
|
|
518
|
+
if (row.develop) {
|
|
519
|
+
row.develop.summary = summarizePasses(row.develop.passes);
|
|
520
|
+
}
|
|
521
|
+
if (row.production) {
|
|
522
|
+
row.production.summary = summarizePasses(row.production.passes);
|
|
523
|
+
}
|
|
524
|
+
return row;
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
const report = {
|
|
528
|
+
meta: {
|
|
529
|
+
generatedAt: startedAt,
|
|
530
|
+
passes: options.passes,
|
|
531
|
+
delayMs: options.delayMs,
|
|
532
|
+
developOnly: options.developOnly,
|
|
533
|
+
productionOnly: options.productionOnly,
|
|
534
|
+
sites: sites.map((site) => ({
|
|
535
|
+
key: site.key,
|
|
536
|
+
label: site.label,
|
|
537
|
+
develop: site.develop,
|
|
538
|
+
production: site.production,
|
|
539
|
+
caseCount: site.cases.length,
|
|
540
|
+
})),
|
|
541
|
+
},
|
|
542
|
+
results,
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
fs.writeFileSync(options.outputPath, `${JSON.stringify(report, null, 2)}\n`);
|
|
546
|
+
printSummary(report, options);
|
|
547
|
+
return report;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function printSummary(report, options) {
|
|
551
|
+
console.log('DEVELOP SITES TIMING — smoke paths');
|
|
552
|
+
console.log('='.repeat(120));
|
|
553
|
+
console.log(`Passes: ${options.passes} | Output: ${options.outputPath}`);
|
|
554
|
+
console.log('');
|
|
555
|
+
|
|
556
|
+
for (const site of report.meta.sites) {
|
|
557
|
+
const rows = report.results.filter((row) => row.key === site.key);
|
|
558
|
+
console.log(`## ${site.label}`);
|
|
559
|
+
console.log(`Develop: ${site.develop}`);
|
|
560
|
+
console.log(`Prod: ${site.production}`);
|
|
561
|
+
console.log(
|
|
562
|
+
`${'Category'.padEnd(22)} ${'Path'.padEnd(42)} ${'D_avg'.padStart(7)} ${'D_last'.padStart(7)} ${'D_VC'.padStart(6)} ${'P_avg'.padStart(7)} ${'P_last'.padStart(7)} ${'P_VC'.padStart(6)}`,
|
|
563
|
+
);
|
|
564
|
+
console.log('-'.repeat(110));
|
|
565
|
+
|
|
566
|
+
for (const row of rows) {
|
|
567
|
+
const d = row.develop?.summary;
|
|
568
|
+
const p = row.production?.summary;
|
|
569
|
+
const dAvg = d?.avgTtfb != null ? `${d.avgTtfb.toFixed(2)}s` : ' n/a';
|
|
570
|
+
const dLast = d?.lastTtfb != null ? `${d.lastTtfb.toFixed(2)}s` : ' n/a';
|
|
571
|
+
const pAvg = p?.avgTtfb != null ? `${p.avgTtfb.toFixed(2)}s` : ' n/a';
|
|
572
|
+
const pLast = p?.lastTtfb != null ? `${p.lastTtfb.toFixed(2)}s` : ' n/a';
|
|
573
|
+
console.log(
|
|
574
|
+
`${row.category.padEnd(22)} ${row.path.padEnd(42)} ${dAvg.padStart(7)} ${dLast.padStart(7)} ${(d?.lastVercelCache ?? '-').padStart(6)} ${pAvg.padStart(7)} ${pLast.padStart(7)} ${(p?.lastVercelCache ?? '-').padStart(6)}`,
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
console.log('');
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (options.passes > 1) {
|
|
581
|
+
console.log('## Pass warmup (develop: first → last TTFB)');
|
|
582
|
+
for (const row of report.results) {
|
|
583
|
+
const d = row.develop?.summary;
|
|
584
|
+
if (!d || d.firstTtfb == null || d.lastTtfb == null) continue;
|
|
585
|
+
const delta = d.lastTtfb - d.firstTtfb;
|
|
586
|
+
if (Math.abs(delta) < 0.05) continue;
|
|
587
|
+
const sign = delta < 0 ? '' : '+';
|
|
588
|
+
console.log(
|
|
589
|
+
` ${row.site} ${row.path}: ${d.firstTtfb.toFixed(2)}s → ${d.lastTtfb.toFixed(2)}s (${sign}${delta.toFixed(2)}s)`,
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
console.log('');
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
async function main() {
|
|
597
|
+
try {
|
|
598
|
+
const options = parseCliArgs(process.argv);
|
|
599
|
+
await runDevelopSitesTiming(options);
|
|
600
|
+
} catch (error) {
|
|
601
|
+
console.error(error instanceof Error ? error.message : error);
|
|
602
|
+
process.exit(1);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
607
|
+
if (isMain) {
|
|
608
|
+
main();
|
|
609
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/site-check",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
4
4
|
"description": "Validate SE marketing sites (sitemap, llms.txt) and download markdown files preserving structure",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"smoke-test-deploy-check": "./smoke-test-deploy-check.mjs",
|
|
48
48
|
"smoke-test-live": "./smoke-test-live.mjs",
|
|
49
49
|
"validate-build-routes": "./validate-build-routes.mjs",
|
|
50
|
-
"revalidation-matrix-test": "./revalidation-matrix-test.mjs"
|
|
50
|
+
"revalidation-matrix-test": "./revalidation-matrix-test.mjs",
|
|
51
|
+
"develop-sites-timing": "./develop-sites-timing.mjs"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
53
54
|
"dist",
|
|
@@ -59,7 +60,8 @@
|
|
|
59
60
|
"smoke-test-deploy-check.mjs",
|
|
60
61
|
"smoke-test-live.mjs",
|
|
61
62
|
"validate-build-routes.mjs",
|
|
62
|
-
"revalidation-matrix-test.mjs"
|
|
63
|
+
"revalidation-matrix-test.mjs",
|
|
64
|
+
"develop-sites-timing.mjs"
|
|
63
65
|
],
|
|
64
66
|
"keywords": [
|
|
65
67
|
"sitemap",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"url": "https://github.com/Something-Else-Studio/se-core-product/issues"
|
|
78
80
|
},
|
|
79
81
|
"dependencies": {
|
|
80
|
-
"@se-studio/contentful-rest-api": "1.14.
|
|
82
|
+
"@se-studio/contentful-rest-api": "1.14.3",
|
|
81
83
|
"@se-studio/core-data-types": "1.6.0"
|
|
82
84
|
},
|
|
83
85
|
"devDependencies": {
|
|
@@ -91,6 +93,6 @@
|
|
|
91
93
|
"type-check": "tsc --noEmit",
|
|
92
94
|
"lint": "biome lint .",
|
|
93
95
|
"clean": "rm -rf dist .turbo *.tsbuildinfo",
|
|
94
|
-
"test": "pnpm build && node --test scripts/screaming-frog-audit.test.mjs scripts/production-audit.test.mjs scripts/smoke-test.test.mjs scripts/revalidation-matrix.test.mjs"
|
|
96
|
+
"test": "pnpm build && node --test scripts/screaming-frog-audit.test.mjs scripts/production-audit.test.mjs scripts/smoke-test.test.mjs scripts/revalidation-matrix.test.mjs scripts/develop-sites-timing.test.mjs"
|
|
95
97
|
}
|
|
96
98
|
}
|