mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +03:00
65ea06ab6e
Внутренности move в cli/:
- util.mjs — out/die/json/readBody/readStdin/elapsed/elapsed2/slugify/formatDuration/xmlEscape/interpolate/printSteps/usage
- session.mjs — SESSION_FILE, loadSession, cleanup
- exec-context.mjs — buildContext, buildScopedContext, executeScript
- server.mjs — handleRequest (HTTP сервер в процессе start)
- commands/{start,run,exec,shot,stop,status,test}.mjs — по одной команде на файл
- test-runner/assertions.mjs — createAssertions (ctx.assert API)
- test-runner/severity.mjs — SEVERITY_RANK/LEVELS, buildSeverityIndex, resolveSeverity
- test-runner/reporters.mjs — writeAllure, allureStep, syncAllureExtras, buildJUnit
- test-runner/discover.mjs — discoverTests, resetState
run.mjs остался публичным entry-point с CLI-парсингом и dispatcher'ом.
Регресс tests/web-test/ зелёный (19/19, 9m 28s).
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
// web-test cli/server v1.0 — HTTP server для exec/shot/stop/status в процессе start
|
|
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
|
import * as browser from '../browser.mjs';
|
|
import { json, readBody } from './util.mjs';
|
|
import { cleanup } from './session.mjs';
|
|
import { executeScript } from './exec-context.mjs';
|
|
|
|
export async function handleRequest(req, res) {
|
|
try {
|
|
if (req.method === 'POST' && req.url === '/exec') {
|
|
const code = await readBody(req);
|
|
const noRecord = req.headers['x-no-record'] === '1';
|
|
const result = await executeScript(code, { noRecord });
|
|
json(res, result);
|
|
|
|
} else if (req.method === 'GET' && req.url === '/shot') {
|
|
const png = await browser.screenshot();
|
|
res.writeHead(200, { 'Content-Type': 'image/png' });
|
|
res.end(png);
|
|
|
|
} else if (req.method === 'POST' && req.url === '/stop') {
|
|
json(res, { ok: true, message: 'Stopping' });
|
|
await browser.disconnect();
|
|
cleanup();
|
|
process.exit(0);
|
|
|
|
} else if (req.method === 'GET' && req.url === '/status') {
|
|
json(res, { ok: true, connected: browser.isConnected() });
|
|
|
|
} else {
|
|
res.writeHead(404);
|
|
res.end('Not found');
|
|
}
|
|
} catch (e) {
|
|
json(res, { ok: false, error: e.message }, 500);
|
|
}
|
|
}
|