| 12345678910111213141516171819202122232425262728293031323334353637 |
- // R150 189 admin-desktop E2E 派发(PowerShell 5.1;不 reset 工作区,仅取证 HEAD + spec blob)
- const BASE = process.env.OPENCODE_189_BASE || 'http://192.168.16.189:4090';
- const AUTH = 'Basic ' + Buffer.from('opencode:' + (process.env.OPENCODE_SERVER_PASSWORD || 'IwinTrue@123')).toString('base64');
- const capMs = parseInt(process.env.DISPATCH_CAP_MS || '540000', 10);
- const CMD = process.env.E2E_CMD ||
- 'cd C:\\code\\cfc; git rev-parse --short HEAD; git hash-object tests\\e2e-live\\admin-live.spec.js; cd tests; npx playwright test -c playwright.config.live.js --project=admin-desktop --reporter=list --workers=1; echo "EXIT=$LASTEXITCODE"';
- async function j(url, opt) {
- try {
- const r = await fetch(url, Object.assign({ headers: { 'Authorization': AUTH, 'Content-Type': 'application/json' } }, opt || {}));
- const t = await r.text();
- try { return { status: r.status, json: JSON.parse(t) }; } catch { return { status: r.status, text: t }; }
- } catch (e) { return { status: 0, err: e.message }; }
- }
- (async () => {
- const cr = await j(BASE + '/api/shell', { method: 'POST', body: JSON.stringify({ command: CMD }) });
- const id = (cr.json && cr.json.data && cr.json.data.id) || (cr.json && cr.json.id);
- if (!id) { console.log('CREATE_FAIL ' + cr.status + ' ' + JSON.stringify(cr).slice(0, 300)); return; }
- console.log('SHELL_ID ' + id);
- const t0 = Date.now();
- let last = '';
- while (Date.now() - t0 < capMs) {
- await new Promise(r => setTimeout(r, 6000));
- const st = await j(BASE + '/api/shell/' + id);
- const s = (st.json && ((st.json.data && st.json.data.status) || st.json.status)) || '?';
- if (s !== last) { console.log('STATUS ' + s + ' @' + Math.round((Date.now() - t0) / 1000) + 's'); last = s; }
- if (s && s !== 'running' && s !== 'pending' && s !== 'queued') {
- const o = await j(BASE + '/api/shell/' + id + '/output');
- const out = (o.json && o.json.data && o.json.data.output) || '';
- console.log('===OUTPUT===');
- console.log(out.slice(-7000));
- return;
- }
- }
- console.log('TIMEOUT ' + capMs + 'ms');
- })();
|