viberadar 0.3.210 → 0.3.211
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/server/index.d.ts.map +1 -1
- package/dist/server/index.js +33 -12
- package/dist/server/index.js.map +1 -1
- package/dist/ui/dashboard.html +59 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,UAAU,EAA4H,MAAM,YAAY,CAAC;AAOlK,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB;AA0vED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,UAAU,EAA4H,MAAM,YAAY,CAAC;AAOlK,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB;AA0vED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAs1G1G"}
|
package/dist/server/index.js
CHANGED
|
@@ -2216,6 +2216,13 @@ function startServer({ data: initialData, port, projectRoot }) {
|
|
|
2216
2216
|
}
|
|
2217
2217
|
return out;
|
|
2218
2218
|
}
|
|
2219
|
+
function sanitizeLoadEnvName(value, fallback) {
|
|
2220
|
+
const raw = typeof value === 'string' && value.trim() ? value.trim() : fallback;
|
|
2221
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(raw) ? raw : fallback;
|
|
2222
|
+
}
|
|
2223
|
+
function detectK6Scenarios(script) {
|
|
2224
|
+
return /\bscenarios\s*:/.test(script) || /export\s+const\s+options[\s\S]*\bscenarios\b/.test(script);
|
|
2225
|
+
}
|
|
2219
2226
|
function redactLoadEnvVars(envVars) {
|
|
2220
2227
|
const out = {};
|
|
2221
2228
|
for (const key of Object.keys(envVars)) {
|
|
@@ -2268,12 +2275,18 @@ function startServer({ data: initialData, port, projectRoot }) {
|
|
|
2268
2275
|
const baseUrl = typeof cfg.baseUrl === 'string' && cfg.baseUrl.trim() ? cfg.baseUrl.trim() : 'http://localhost:5000';
|
|
2269
2276
|
const dataDir = resolveLoadLocalPath(cfg.dataDir);
|
|
2270
2277
|
const resultDir = resolveLoadLocalPath(cfg.resultDir);
|
|
2278
|
+
const executionMode = cfg.executionMode === 'script' ? 'script' : 'cli';
|
|
2279
|
+
const vusEnvName = sanitizeLoadEnvName(cfg.vusEnvName, 'SMOKE_VUS');
|
|
2280
|
+
const durationEnvName = sanitizeLoadEnvName(cfg.durationEnvName, 'SMOKE_DURATION');
|
|
2271
2281
|
envVars.BASE_URL = baseUrl;
|
|
2272
2282
|
const config = {
|
|
2273
2283
|
vus: normalizeLoadVus(cfg.vus),
|
|
2274
2284
|
duration: normalizeLoadDuration(cfg.duration),
|
|
2275
2285
|
baseUrl,
|
|
2276
2286
|
scriptName: sanitizeLoadScriptName(cfg.scriptName),
|
|
2287
|
+
executionMode,
|
|
2288
|
+
vusEnvName,
|
|
2289
|
+
durationEnvName,
|
|
2277
2290
|
dataDir,
|
|
2278
2291
|
resultDir,
|
|
2279
2292
|
runDir: paths?.runDir,
|
|
@@ -2282,6 +2295,11 @@ function startServer({ data: initialData, port, projectRoot }) {
|
|
|
2282
2295
|
dataFilesCopied: paths?.dataFilesCopied,
|
|
2283
2296
|
envVars: redactLoadEnvVars(envVars),
|
|
2284
2297
|
};
|
|
2298
|
+
if (executionMode === 'script') {
|
|
2299
|
+
envVars[vusEnvName] = String(config.vus);
|
|
2300
|
+
envVars[durationEnvName] = config.duration;
|
|
2301
|
+
config.envVars = redactLoadEnvVars(envVars);
|
|
2302
|
+
}
|
|
2285
2303
|
return { config, envVars, dataDir, resultDir };
|
|
2286
2304
|
}
|
|
2287
2305
|
function flattenK6Checks(group) {
|
|
@@ -5097,7 +5115,7 @@ a{color:var(--blue)}
|
|
|
5097
5115
|
req.on('data', (d) => { body += d; });
|
|
5098
5116
|
req.on('end', () => {
|
|
5099
5117
|
try {
|
|
5100
|
-
const { name, script, vus, duration, baseUrl, dataDir, resultDir } = JSON.parse(body);
|
|
5118
|
+
const { name, script, vus, duration, baseUrl, dataDir, resultDir, executionMode, vusEnvName, durationEnvName } = JSON.parse(body);
|
|
5101
5119
|
if (!name || !script) {
|
|
5102
5120
|
res.writeHead(400, jsonH);
|
|
5103
5121
|
res.end(JSON.stringify({ error: 'name and script required' }));
|
|
@@ -5115,6 +5133,9 @@ a{color:var(--blue)}
|
|
|
5115
5133
|
vus: normalizeLoadVus(vus),
|
|
5116
5134
|
duration: normalizeLoadDuration(duration),
|
|
5117
5135
|
baseUrl: typeof baseUrl === 'string' && baseUrl.trim() ? baseUrl.trim() : 'http://localhost:5000',
|
|
5136
|
+
executionMode: executionMode === 'script' ? 'script' : 'cli',
|
|
5137
|
+
vusEnvName: sanitizeLoadEnvName(vusEnvName, 'SMOKE_VUS'),
|
|
5138
|
+
durationEnvName: sanitizeLoadEnvName(durationEnvName, 'SMOKE_DURATION'),
|
|
5118
5139
|
dataDir: resolveLoadLocalPath(dataDir),
|
|
5119
5140
|
resultDir: resolveLoadLocalPath(resultDir),
|
|
5120
5141
|
};
|
|
@@ -5278,7 +5299,11 @@ a{color:var(--blue)}
|
|
|
5278
5299
|
const runDir = path.join(loadRunsDir, runId);
|
|
5279
5300
|
const workDir = path.join(runDir, 'work');
|
|
5280
5301
|
const defaultResultDir = path.join(runDir, 'results');
|
|
5281
|
-
const
|
|
5302
|
+
const effectiveCfg = { ...cfg };
|
|
5303
|
+
if (!effectiveCfg.executionMode) {
|
|
5304
|
+
effectiveCfg.executionMode = detectK6Scenarios(script) ? 'script' : 'cli';
|
|
5305
|
+
}
|
|
5306
|
+
const initial = buildLoadConfig(effectiveCfg);
|
|
5282
5307
|
const resultPath = initial.resultDir ? path.join(initial.resultDir, runId) : defaultResultDir;
|
|
5283
5308
|
const scriptPath = path.join(workDir, 'script.js');
|
|
5284
5309
|
const jsonOutPath = path.join(resultPath, 'metrics.ndjson');
|
|
@@ -5295,7 +5320,7 @@ a{color:var(--blue)}
|
|
|
5295
5320
|
res.end(JSON.stringify({ error: e.message }));
|
|
5296
5321
|
return;
|
|
5297
5322
|
}
|
|
5298
|
-
const { config: loadConfig, envVars } = buildLoadConfig(
|
|
5323
|
+
const { config: loadConfig, envVars } = buildLoadConfig(effectiveCfg, {
|
|
5299
5324
|
runDir,
|
|
5300
5325
|
workDir,
|
|
5301
5326
|
resultPath,
|
|
@@ -5314,15 +5339,11 @@ a{color:var(--blue)}
|
|
|
5314
5339
|
if (k && v !== undefined && v !== '')
|
|
5315
5340
|
envFlags.push('--env', `${k}=${v}`);
|
|
5316
5341
|
}
|
|
5317
|
-
const args = [
|
|
5318
|
-
|
|
5319
|
-
'--vus', String(loadConfig.vus),
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
'--summary-export', summaryPath,
|
|
5323
|
-
'--out', `json=${jsonOutPath}`,
|
|
5324
|
-
scriptPath,
|
|
5325
|
-
];
|
|
5342
|
+
const args = ['run'];
|
|
5343
|
+
if (loadConfig.executionMode !== 'script') {
|
|
5344
|
+
args.push('--vus', String(loadConfig.vus), '--duration', loadConfig.duration);
|
|
5345
|
+
}
|
|
5346
|
+
args.push(...envFlags, '--summary-export', summaryPath, '--out', `json=${jsonOutPath}`, scriptPath);
|
|
5326
5347
|
loadProc = (0, child_process_1.spawn)('k6', args, {
|
|
5327
5348
|
cwd: workDir, env: { ...process.env }, shell: WIN, stdio: 'pipe',
|
|
5328
5349
|
});
|