helixlife-v5-cli 1.2.0 → 1.2.2
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/lib/.cli.runtime.generated.json +7 -0
- package/lib/automation-overlay.init.js +208 -78
- package/lib/cli.js +76 -45
- package/lib/cli.runtime.config.json +1 -3
- package/lib/visual.js +248 -0
- package/package.json +1 -1
- package/scripts/workbench-jova-outline-regenerate-node.js +149 -0
- package/scripts/workbench-jova-proofread-section.js +262 -0
- package/scripts/workbench-jova-writing-tool.js +308 -0
- package/lib/automation-overlay.browser.js +0 -76
- package/lib/automation-overlay.js +0 -238
|
@@ -1,78 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* helixlife-v5-cli 页面内视觉反馈层。
|
|
4
|
+
* 挂载 window.__helix_visual__:节点高亮框 + 动作标签(pending/success/danger/info)+ 右上角 HUD。
|
|
5
|
+
* 可作为 Playwright initScript 注入,也可由 CLI eval 懒加载。
|
|
6
|
+
*/
|
|
7
|
+
(() => {
|
|
8
|
+
if (window.__helix_visual__) return;
|
|
9
|
+
|
|
10
|
+
const VERSION = '1.0.0';
|
|
11
|
+
const VISUAL_DEFAULTS = {
|
|
12
|
+
enabled: true,
|
|
13
|
+
durationMs: 420,
|
|
14
|
+
};
|
|
15
|
+
const VISUAL_STYLE_ID = '__helix_visual_style__';
|
|
16
|
+
const VISUAL_LAYER_ID = '__helix_visual_layer__';
|
|
17
|
+
const VISUAL_HUD_ID = '__helix_visual_hud__';
|
|
18
|
+
const VISUAL_TONE_MAP = {
|
|
19
|
+
pending: { border: '#faad14', fill: 'rgba(250, 173, 20, 0.16)', pill: '#ad6800', text: '#fffbe6' },
|
|
20
|
+
success: { border: '#52c41a', fill: 'rgba(82, 196, 26, 0.14)', pill: '#237804', text: '#f6ffed' },
|
|
21
|
+
danger: { border: '#ff4d4f', fill: 'rgba(255, 77, 79, 0.14)', pill: '#a8071a', text: '#fff1f0' },
|
|
22
|
+
info: { border: '#1677ff', fill: 'rgba(22, 119, 255, 0.14)', pill: '#0958d9', text: '#f0f5ff' },
|
|
23
|
+
};
|
|
24
|
+
const visualState = {
|
|
25
|
+
config: { ...VISUAL_DEFAULTS },
|
|
26
|
+
hudTimer: null,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function clamp(n, min, max) {
|
|
30
|
+
return Math.max(min, Math.min(max, n));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function normalizeDuration(ms, fallback = VISUAL_DEFAULTS.durationMs) {
|
|
34
|
+
const n = Number(ms);
|
|
35
|
+
if (!Number.isFinite(n) || n <= 0) return fallback;
|
|
36
|
+
return clamp(Math.round(n), 120, 4000);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function normalizeVisualOptions(options = {}) {
|
|
40
|
+
const base = { ...visualState.config };
|
|
41
|
+
if (!options || typeof options !== 'object') return base;
|
|
42
|
+
if (typeof options.enabled === 'boolean') base.enabled = options.enabled;
|
|
43
|
+
if (options.durationMs != null) base.durationMs = normalizeDuration(options.durationMs, base.durationMs);
|
|
44
|
+
return base;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function ensureVisualRoot() {
|
|
48
|
+
let style = document.getElementById(VISUAL_STYLE_ID);
|
|
49
|
+
if (!style) {
|
|
50
|
+
style = document.createElement('style');
|
|
51
|
+
style.id = VISUAL_STYLE_ID;
|
|
52
|
+
style.textContent = `
|
|
53
|
+
#${VISUAL_LAYER_ID}{
|
|
54
|
+
position:fixed;
|
|
55
|
+
inset:0;
|
|
56
|
+
pointer-events:none;
|
|
57
|
+
z-index:2147483646;
|
|
58
|
+
overflow:visible;
|
|
59
|
+
}
|
|
60
|
+
.__helix_visual_box{
|
|
61
|
+
position:fixed;
|
|
62
|
+
box-sizing:border-box;
|
|
63
|
+
border-radius:8px;
|
|
64
|
+
animation:__helix_visual_pulse .55s ease-out 1;
|
|
65
|
+
}
|
|
66
|
+
.__helix_visual_badge{
|
|
67
|
+
position:absolute;
|
|
68
|
+
left:0;
|
|
69
|
+
top:-28px;
|
|
70
|
+
max-width:280px;
|
|
71
|
+
padding:4px 10px;
|
|
72
|
+
border-radius:999px;
|
|
73
|
+
font:600 12px/1.2 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
|
|
74
|
+
letter-spacing:.01em;
|
|
75
|
+
white-space:nowrap;
|
|
76
|
+
text-overflow:ellipsis;
|
|
77
|
+
overflow:hidden;
|
|
78
|
+
box-shadow:0 8px 24px rgba(0,0,0,.18);
|
|
79
|
+
}
|
|
80
|
+
#${VISUAL_HUD_ID}{
|
|
81
|
+
position:fixed;
|
|
82
|
+
top:16px;
|
|
83
|
+
right:16px;
|
|
84
|
+
max-width:360px;
|
|
85
|
+
padding:10px 14px;
|
|
86
|
+
border-radius:12px;
|
|
87
|
+
box-shadow:0 12px 32px rgba(0,0,0,.22);
|
|
88
|
+
font:600 13px/1.35 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
|
|
89
|
+
white-space:pre-wrap;
|
|
90
|
+
}
|
|
91
|
+
@keyframes __helix_visual_pulse{
|
|
92
|
+
0%{transform:scale(.985);opacity:.2}
|
|
93
|
+
35%{transform:scale(1.003);opacity:1}
|
|
94
|
+
100%{transform:scale(1);opacity:1}
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
(document.head || document.documentElement).appendChild(style);
|
|
98
|
+
}
|
|
99
|
+
let layer = document.getElementById(VISUAL_LAYER_ID);
|
|
100
|
+
if (!layer) {
|
|
101
|
+
layer = document.createElement('div');
|
|
102
|
+
layer.id = VISUAL_LAYER_ID;
|
|
103
|
+
(document.body || document.documentElement).appendChild(layer);
|
|
104
|
+
}
|
|
105
|
+
return layer;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function toneSpec(tone) {
|
|
109
|
+
return VISUAL_TONE_MAP[tone] || VISUAL_TONE_MAP.info;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function removeLater(el, durationMs) {
|
|
113
|
+
if (!el) return;
|
|
114
|
+
const ms = normalizeDuration(durationMs);
|
|
115
|
+
window.setTimeout(() => {
|
|
116
|
+
if (el && el.parentNode) el.remove();
|
|
117
|
+
}, ms);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function flashElement(el, options = {}) {
|
|
121
|
+
const { tone = 'info', label = '', durationMs, inset = 0 } = options;
|
|
122
|
+
if (!el || !visualState.config.enabled) return false;
|
|
123
|
+
const rect = el.getBoundingClientRect();
|
|
124
|
+
if (!rect || rect.width <= 0 || rect.height <= 0) return false;
|
|
125
|
+
const layer = ensureVisualRoot();
|
|
126
|
+
const spec = toneSpec(tone);
|
|
127
|
+
const box = document.createElement('div');
|
|
128
|
+
box.className = '__helix_visual_box';
|
|
129
|
+
box.style.left = Math.max(4, rect.left - inset) + 'px';
|
|
130
|
+
box.style.top = Math.max(4, rect.top - inset) + 'px';
|
|
131
|
+
box.style.width = Math.max(18, rect.width + inset * 2) + 'px';
|
|
132
|
+
box.style.height = Math.max(18, rect.height + inset * 2) + 'px';
|
|
133
|
+
box.style.border = `2px solid ${spec.border}`;
|
|
134
|
+
box.style.background = spec.fill;
|
|
135
|
+
box.style.boxShadow = `0 0 0 1px ${spec.border}33, 0 12px 28px ${spec.border}22`;
|
|
136
|
+
if (label) {
|
|
137
|
+
const badge = document.createElement('div');
|
|
138
|
+
badge.className = '__helix_visual_badge';
|
|
139
|
+
badge.textContent = label;
|
|
140
|
+
badge.style.background = spec.pill;
|
|
141
|
+
badge.style.color = spec.text;
|
|
142
|
+
badge.style.top = (rect.top < 38 ? rect.height + 8 : -28) + 'px';
|
|
143
|
+
box.appendChild(badge);
|
|
144
|
+
}
|
|
145
|
+
layer.appendChild(box);
|
|
146
|
+
removeLater(box, durationMs);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function showHud(options = {}) {
|
|
151
|
+
const { action = '', target = '', status = 'pending', detail = '', durationMs } = options;
|
|
152
|
+
if (!visualState.config.enabled) return false;
|
|
153
|
+
const layer = ensureVisualRoot();
|
|
154
|
+
let hud = document.getElementById(VISUAL_HUD_ID);
|
|
155
|
+
if (!hud) {
|
|
156
|
+
hud = document.createElement('div');
|
|
157
|
+
hud.id = VISUAL_HUD_ID;
|
|
158
|
+
layer.appendChild(hud);
|
|
159
|
+
}
|
|
160
|
+
const spec = toneSpec(status);
|
|
161
|
+
const lines = [];
|
|
162
|
+
if (action) lines.push(action);
|
|
163
|
+
if (target) lines.push(target);
|
|
164
|
+
if (detail) lines.push(detail);
|
|
165
|
+
hud.textContent = lines.join('\n');
|
|
166
|
+
hud.style.border = `1px solid ${spec.border}`;
|
|
167
|
+
hud.style.background = spec.fill.replace(/0\.\d+\)$/, '0.92)');
|
|
168
|
+
hud.style.color = spec.pill;
|
|
169
|
+
if (visualState.hudTimer) clearTimeout(visualState.hudTimer);
|
|
170
|
+
visualState.hudTimer = window.setTimeout(() => {
|
|
171
|
+
if (hud && hud.parentNode) hud.remove();
|
|
172
|
+
visualState.hudTimer = null;
|
|
173
|
+
}, normalizeDuration(durationMs, Math.max(900, visualState.config.durationMs * 2)));
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function cleanupVisualArtifacts() {
|
|
178
|
+
const layer = document.getElementById(VISUAL_LAYER_ID);
|
|
179
|
+
if (!layer) return;
|
|
180
|
+
Array.from(layer.querySelectorAll('.__helix_visual_box')).forEach((el) => el.remove());
|
|
181
|
+
const hud = document.getElementById(VISUAL_HUD_ID);
|
|
182
|
+
if (hud) hud.remove();
|
|
183
|
+
if (visualState.hudTimer) {
|
|
184
|
+
clearTimeout(visualState.hudTimer);
|
|
185
|
+
visualState.hudTimer = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function setVisualOptions(options = {}) {
|
|
190
|
+
if (!options || typeof options !== 'object') {
|
|
191
|
+
visualState.config = { ...VISUAL_DEFAULTS };
|
|
192
|
+
cleanupVisualArtifacts();
|
|
193
|
+
return { ok: true, data: { ...visualState.config } };
|
|
194
|
+
}
|
|
195
|
+
visualState.config = normalizeVisualOptions(options);
|
|
196
|
+
if (!visualState.config.enabled) cleanupVisualArtifacts();
|
|
197
|
+
return { ok: true, data: { ...visualState.config } };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
window.__helix_visual__ = {
|
|
201
|
+
version: () => VERSION,
|
|
202
|
+
setVisualOptions,
|
|
203
|
+
flash: flashElement,
|
|
204
|
+
showHud,
|
|
205
|
+
cleanup: cleanupVisualArtifacts,
|
|
206
|
+
__meta: { version: VERSION, loadedAt: new Date().toISOString() },
|
|
207
|
+
};
|
|
208
|
+
})();
|
package/lib/cli.js
CHANGED
|
@@ -5,12 +5,12 @@ const { spawnSync } = require('node:child_process');
|
|
|
5
5
|
|
|
6
6
|
const PACKAGE_JSON = require(path.join(__dirname, '..', 'package.json'));
|
|
7
7
|
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = require('./
|
|
8
|
+
parseVisualFlags,
|
|
9
|
+
injectVisualConfig,
|
|
10
|
+
shouldWrapWithVisual,
|
|
11
|
+
runWithVisualFeedback,
|
|
12
|
+
DEFAULT_VISUAL_ENABLED,
|
|
13
|
+
} = require('./visual');
|
|
14
14
|
|
|
15
15
|
/** 默认快照/下载等工作区目录名(相对 cwd),替代引擎默认的 .playwright-cli */
|
|
16
16
|
const DEFAULT_OUTPUT_DIR_NAME = 'helixlife-v5-cli';
|
|
@@ -41,40 +41,36 @@ function buildChildEnv() {
|
|
|
41
41
|
/**
|
|
42
42
|
* 将参数原样交给底层浏览器自动化引擎,返回子进程退出码。
|
|
43
43
|
* 使用 node 直接执行入口脚本,避免依赖 npx、Shell 与 PATH,在 Windows / macOS 上一致。
|
|
44
|
+
* @param {string[]} args
|
|
45
|
+
* @param {{ capture?: boolean }} [options]
|
|
46
|
+
* @returns {number | { code: number, stdout: string, stderr: string }}
|
|
44
47
|
*/
|
|
45
48
|
function runPlaywrightCliPassthrough(args, options = {}) {
|
|
46
|
-
const
|
|
47
|
-
stdio: options.quiet ? ['ignore', 'ignore', 'ignore'] : 'inherit',
|
|
49
|
+
const spawnOpts = {
|
|
48
50
|
env: buildChildEnv(),
|
|
49
51
|
windowsHide: true,
|
|
50
|
-
}
|
|
52
|
+
};
|
|
53
|
+
if (options.capture) {
|
|
54
|
+
spawnOpts.encoding = 'utf8';
|
|
55
|
+
spawnOpts.stdio = ['ignore', 'pipe', 'pipe'];
|
|
56
|
+
} else {
|
|
57
|
+
spawnOpts.stdio = 'inherit';
|
|
58
|
+
}
|
|
59
|
+
const result = spawnSync(process.execPath, [playwrightCliEntry(), ...args], spawnOpts);
|
|
51
60
|
if (result.error) {
|
|
52
61
|
throw result.error;
|
|
53
62
|
}
|
|
54
63
|
if (result.signal) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function updateAutomationOverlay(tokens, phase) {
|
|
62
|
-
if (!isOverlayEnabled() || !shouldUpdateOverlay(tokens)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const payload = describeOverlayPayload(tokens, phase);
|
|
66
|
-
const code = buildOverlayRunCode(payload);
|
|
67
|
-
runPlaywrightCliPassthrough(['run-code', code], { quiet: true });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function runPlaywrightCliWithOverlay(tokens) {
|
|
71
|
-
const args = injectOpenConfig(tokens);
|
|
72
|
-
if (isOverlayEnabled() && shouldUpdateOverlay(args)) {
|
|
73
|
-
updateAutomationOverlay(args, 'before');
|
|
64
|
+
if (!options.capture) {
|
|
65
|
+
console.error(`[${PACKAGE_JSON.name}] 子进程被终止: ${result.signal}`);
|
|
66
|
+
}
|
|
67
|
+
return options.capture
|
|
68
|
+
? { code: 1, stdout: result.stdout || '', stderr: result.stderr || '' }
|
|
69
|
+
: 1;
|
|
74
70
|
}
|
|
75
|
-
const code =
|
|
76
|
-
if (
|
|
77
|
-
|
|
71
|
+
const code = result.status === null || result.status === undefined ? 1 : result.status;
|
|
72
|
+
if (options.capture) {
|
|
73
|
+
return { code, stdout: result.stdout || '', stderr: result.stderr || '' };
|
|
78
74
|
}
|
|
79
75
|
return code;
|
|
80
76
|
}
|
|
@@ -85,11 +81,21 @@ function parseHelixFlags(tokens, startIndex) {
|
|
|
85
81
|
cdpUrl: process.env.HELIX_CDP_URL || 'http://127.0.0.1:9222',
|
|
86
82
|
profile:
|
|
87
83
|
process.env.HELIX_PROFILE_DIR || path.join(process.cwd(), '.helixlife-profile'),
|
|
84
|
+
visual: { enabled: DEFAULT_VISUAL_ENABLED, durationMs: null },
|
|
88
85
|
};
|
|
89
86
|
for (let i = startIndex; i < tokens.length; i += 1) {
|
|
90
87
|
const t = tokens[i];
|
|
91
88
|
if (t === '--headless') {
|
|
92
89
|
options.headless = true;
|
|
90
|
+
} else if (t === '--visual') {
|
|
91
|
+
options.visual.enabled = true;
|
|
92
|
+
} else if (t === '--no-visual') {
|
|
93
|
+
options.visual.enabled = false;
|
|
94
|
+
} else if (t === '--visual-ms') {
|
|
95
|
+
options.visual.durationMs = tokens[i + 1];
|
|
96
|
+
i += 1;
|
|
97
|
+
} else if (t.startsWith('--visual-ms=')) {
|
|
98
|
+
options.visual.durationMs = t.slice('--visual-ms='.length);
|
|
93
99
|
} else if (t === '--profile') {
|
|
94
100
|
const next = tokens[i + 1];
|
|
95
101
|
if (next === undefined) {
|
|
@@ -113,6 +119,14 @@ function parseHelixFlags(tokens, startIndex) {
|
|
|
113
119
|
return null;
|
|
114
120
|
}
|
|
115
121
|
}
|
|
122
|
+
if (options.visual.durationMs != null) {
|
|
123
|
+
const n = Number(options.visual.durationMs);
|
|
124
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
125
|
+
console.error(`[${PACKAGE_JSON.name}] --visual-ms 需要正数,收到 ${JSON.stringify(options.visual.durationMs)}`);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
options.visual.durationMs = Math.round(n);
|
|
129
|
+
}
|
|
116
130
|
return options;
|
|
117
131
|
}
|
|
118
132
|
|
|
@@ -133,6 +147,11 @@ function printHelp() {
|
|
|
133
147
|
` ${n} helix doctor [--cdp-url <url>] [--profile <dir>] 先 list,再执行 helix home`
|
|
134
148
|
);
|
|
135
149
|
console.log('');
|
|
150
|
+
console.log('页面内视觉反馈(默认开启,作用于 click/fill/hover 等元素命令):');
|
|
151
|
+
console.log(` ${n} click e5 操作前黄框 + 标签,成功后绿框`);
|
|
152
|
+
console.log(` ${n} click e5 --no-visual 静默执行,无页面高亮`);
|
|
153
|
+
console.log(` ${n} fill e3 "文本" --visual-ms 700 自定义高亮时长(毫秒)`);
|
|
154
|
+
console.log('');
|
|
136
155
|
console.log('本地开发可使用:');
|
|
137
156
|
console.log(' node helix-cli.js <同上参数>');
|
|
138
157
|
console.log('');
|
|
@@ -140,12 +159,9 @@ function printHelp() {
|
|
|
140
159
|
'环境变量:HELIX_BASE_URL、HELIX_CDP_URL、HELIX_PROFILE_DIR(默认 profile 目录)、'
|
|
141
160
|
);
|
|
142
161
|
console.log(
|
|
143
|
-
` HELIX_OUTPUT_DIR / PLAYWRIGHT_MCP_OUTPUT_DIR(默认输出目录 <cwd>/${DEFAULT_OUTPUT_DIR_NAME}
|
|
144
|
-
);
|
|
145
|
-
console.log(
|
|
146
|
-
' HELIX_AUTOMATION_OVERLAY(设为 0/false/off 可关闭右上角机器操作浮层,默认开启)'
|
|
162
|
+
` HELIX_OUTPUT_DIR / PLAYWRIGHT_MCP_OUTPUT_DIR(默认输出目录 <cwd>/${DEFAULT_OUTPUT_DIR_NAME})、`
|
|
147
163
|
);
|
|
148
|
-
console.log('
|
|
164
|
+
console.log(' HELIX_VISUAL=0(全局关闭视觉反馈,可用 --visual 单次开启)');
|
|
149
165
|
}
|
|
150
166
|
|
|
151
167
|
function getBaseUrl() {
|
|
@@ -154,20 +170,19 @@ function getBaseUrl() {
|
|
|
154
170
|
|
|
155
171
|
function helixHome(options) {
|
|
156
172
|
const baseUrl = getBaseUrl();
|
|
157
|
-
|
|
158
|
-
const openArgs = ['open', baseUrl];
|
|
173
|
+
const openArgs = injectVisualConfig(['open', baseUrl], options.visual);
|
|
159
174
|
if (options.profile) {
|
|
160
175
|
openArgs.push(`--profile=${options.profile}`);
|
|
161
176
|
}
|
|
162
177
|
if (!options.headless) {
|
|
163
178
|
openArgs.push('--headed');
|
|
164
179
|
}
|
|
165
|
-
const code =
|
|
180
|
+
const code = runPlaywrightCliPassthrough(openArgs);
|
|
166
181
|
if (code !== 0) {
|
|
167
182
|
return code;
|
|
168
183
|
}
|
|
169
184
|
console.error(`[${PACKAGE_JSON.name}] opened: ${baseUrl}`);
|
|
170
|
-
return
|
|
185
|
+
return runPlaywrightCliPassthrough(['eval', 'document.title']);
|
|
171
186
|
}
|
|
172
187
|
|
|
173
188
|
function helixDoctor(options) {
|
|
@@ -184,6 +199,25 @@ function helixDoctor(options) {
|
|
|
184
199
|
return helixHome(options);
|
|
185
200
|
}
|
|
186
201
|
|
|
202
|
+
async function runPassthroughWithVisual(tokens) {
|
|
203
|
+
let visual;
|
|
204
|
+
let stripped;
|
|
205
|
+
try {
|
|
206
|
+
({ tokens: stripped, visual } = parseVisualFlags(tokens));
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.error(`[${PACKAGE_JSON.name}] ${e.message}`);
|
|
209
|
+
return 3;
|
|
210
|
+
}
|
|
211
|
+
const withConfig = injectVisualConfig(stripped, visual);
|
|
212
|
+
if (shouldWrapWithVisual(stripped, visual)) {
|
|
213
|
+
return runWithVisualFeedback(stripped, visual, (args, opts) => {
|
|
214
|
+
const result = runPlaywrightCliPassthrough(args, opts);
|
|
215
|
+
return opts && opts.capture ? result.code : result;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return runPlaywrightCliPassthrough(withConfig);
|
|
219
|
+
}
|
|
220
|
+
|
|
187
221
|
/**
|
|
188
222
|
* @param {string[]} argv process.argv
|
|
189
223
|
* @returns {Promise<number>} exit code
|
|
@@ -196,7 +230,6 @@ async function main(argv = process.argv) {
|
|
|
196
230
|
return 0;
|
|
197
231
|
}
|
|
198
232
|
|
|
199
|
-
// 勿透传到底层引擎:否则 --version 会变成 @playwright/cli 的版本(如 0.1.x),易与本体版本混淆。
|
|
200
233
|
if (tokens[0] === '--version' || tokens[0] === '-v') {
|
|
201
234
|
console.log(PACKAGE_JSON.version);
|
|
202
235
|
return 0;
|
|
@@ -230,19 +263,17 @@ async function main(argv = process.argv) {
|
|
|
230
263
|
return 2;
|
|
231
264
|
}
|
|
232
265
|
|
|
233
|
-
return
|
|
266
|
+
return runPassthroughWithVisual(tokens);
|
|
234
267
|
}
|
|
235
268
|
|
|
236
269
|
main.printHelp = printHelp;
|
|
237
270
|
main.runPlaywrightCliPassthrough = runPlaywrightCliPassthrough;
|
|
238
271
|
main.playwrightCliEntry = playwrightCliEntry;
|
|
239
272
|
|
|
240
|
-
// 注意:`require.main === module` 入口守卫统一放在 helix-cli.js;
|
|
241
|
-
// 本文件仅导出,不在此处重复启动。
|
|
242
|
-
|
|
243
273
|
module.exports = {
|
|
244
274
|
main,
|
|
245
275
|
resolveOutputDir,
|
|
246
276
|
buildChildEnv,
|
|
247
277
|
DEFAULT_OUTPUT_DIR_NAME,
|
|
278
|
+
runPassthroughWithVisual,
|
|
248
279
|
};
|