@sovovs/bycli 2.1.8 → 2.1.10
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.
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { AuthRequiredError, BrowserConnectError
|
|
1
|
+
import { AuthRequiredError, BrowserConnectError } from '@sovovs/bycli/errors';
|
|
2
2
|
|
|
3
3
|
const DOMAIN = 'mp.weixin.qq.com';
|
|
4
4
|
const LOGIN_URL = `https://${DOMAIN}/`;
|
|
5
|
-
const DEFAULT_TIMEOUT_MS = 180_000;
|
|
6
|
-
const POLL_INTERVAL_MS = 500;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @typedef {{token: string, cookie: string, fingerprint?: string}} WechatCredentials
|
|
10
8
|
* @typedef {{url: string | null, hasLoginUi: boolean}} PreflightState
|
|
11
|
-
* @typedef {{
|
|
9
|
+
* @typedef {{now?: () => number}} ResolveBrowserCredentialsOptions
|
|
12
10
|
* @typedef {Pick<import('@sovovs/bycli/types').IPage, 'evaluate' | 'getCookies' | 'goto' | 'wait' | 'focusWindow'>} AuthPage
|
|
13
11
|
*/
|
|
14
12
|
|
|
@@ -94,29 +92,27 @@ export async function resolveBrowserCredentials(page, options = {}) {
|
|
|
94
92
|
throw new BrowserConnectError('No browser page is connected for WeChat authentication');
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
98
95
|
const now = options.now ?? Date.now;
|
|
99
|
-
const startedAt = now();
|
|
100
96
|
let state = await readPreflight(page);
|
|
101
97
|
|
|
102
98
|
if (!isLoggedInPreflight(state)) {
|
|
103
|
-
if (!page.focusWindow) {
|
|
104
|
-
throw new BrowserConnectError(
|
|
105
|
-
'The connected browser cannot be focused for WeChat login',
|
|
106
|
-
'Upgrade to byCLI 2.1 or newer to support interactive browser login',
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
await page.goto(LOGIN_URL);
|
|
111
|
-
await page
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
state = await readPreflight(page);
|
|
101
|
+
|
|
102
|
+
if (!isLoggedInPreflight(state)) {
|
|
103
|
+
if (!page.focusWindow) {
|
|
104
|
+
throw new BrowserConnectError(
|
|
105
|
+
'The connected browser cannot be focused for WeChat login',
|
|
106
|
+
'Upgrade to byCLI 2.1 or newer to support interactive browser login',
|
|
107
|
+
);
|
|
117
108
|
}
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
|
|
110
|
+
await page.focusWindow();
|
|
111
|
+
|
|
112
|
+
throw new AuthRequiredError(
|
|
113
|
+
DOMAIN,
|
|
114
|
+
'WeChat login is required. The login tab is open; complete QR-code login and run the command again.',
|
|
115
|
+
);
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as defaultFs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { ArgumentError, CommandExecutionError } from '@sovovs/bycli/errors';
|
|
3
|
+
import { ArgumentError, AuthRequiredError, CommandExecutionError } from '@sovovs/bycli/errors';
|
|
4
4
|
import { cleanMarkdownFilename, wechatArticleToMarkdown } from './markdown.js';
|
|
5
5
|
|
|
6
6
|
export const MAX_FILENAME_ATTEMPTS = 100;
|
|
@@ -121,7 +121,8 @@ export async function saveArticles({ articles, accountName, outputDir, fetchArti
|
|
|
121
121
|
let articleHtml;
|
|
122
122
|
try {
|
|
123
123
|
articleHtml = await fetchArticleHtml(article);
|
|
124
|
-
} catch {
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (error instanceof AuthRequiredError) throw error;
|
|
125
126
|
rows.push({ title: article.title || '', url: article.url || '', status: 'failed', stage: 'download', saved: '', error: 'article download failed' });
|
|
126
127
|
continue;
|
|
127
128
|
}
|
package/clis/weixin/download.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { cli, Strategy } from '@sovovs/bycli/registry';
|
|
10
10
|
import { downloadArticle } from '@sovovs/bycli/download/article-download';
|
|
11
|
+
import { AuthRequiredError } from '@sovovs/bycli/errors';
|
|
11
12
|
import { buildExtractWechatArticleContentJs } from './_wechat/article-content.js';
|
|
12
13
|
export { extractWechatArticleContent } from './_wechat/article-content.js';
|
|
13
14
|
// ============================================================
|
|
@@ -249,14 +250,10 @@ cli({
|
|
|
249
250
|
})()
|
|
250
251
|
`);
|
|
251
252
|
if (data?.errorHint === 'environment verification required') {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
status: 'failed — verification required in WeChat browser page',
|
|
257
|
-
size: '-',
|
|
258
|
-
saved: '-',
|
|
259
|
-
}];
|
|
253
|
+
throw new AuthRequiredError(
|
|
254
|
+
'mp.weixin.qq.com',
|
|
255
|
+
'WeChat article page requires environment verification. Complete it in the open browser tab and run the command again.',
|
|
256
|
+
);
|
|
260
257
|
}
|
|
261
258
|
return downloadArticle({
|
|
262
259
|
title: data?.title || '',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArgumentError, CommandExecutionError } from '@sovovs/bycli/errors';
|
|
1
|
+
import { ArgumentError, AuthRequiredError, CommandExecutionError } from '@sovovs/bycli/errors';
|
|
2
2
|
import { MAX_WECHAT_HTML_BYTES } from '@sovovs/bycli/download/wechat-article';
|
|
3
3
|
import { cli, Strategy } from '@sovovs/bycli/registry';
|
|
4
4
|
import { readEnvironmentCredentials, resolveBrowserCredentials } from './_wechat/auth-session.js';
|
|
@@ -107,7 +107,12 @@ export async function fetchArticleHtmlInBrowser(article, page) {
|
|
|
107
107
|
html: byteLength > maxBytes ? '' : html,
|
|
108
108
|
};
|
|
109
109
|
}, { maxBytes: MAX_WECHAT_HTML_BYTES });
|
|
110
|
-
if (result?.accessIssue)
|
|
110
|
+
if (result?.accessIssue) {
|
|
111
|
+
throw new AuthRequiredError(
|
|
112
|
+
DOMAIN,
|
|
113
|
+
'WeChat article page requires environment verification. Complete it in the open browser tab and run the command again.',
|
|
114
|
+
);
|
|
115
|
+
}
|
|
111
116
|
if (!isTrustedWechatArticleUrl(result?.finalUrl)) {
|
|
112
117
|
throw new CommandExecutionError('Article browser navigation left the trusted article path');
|
|
113
118
|
}
|
|
@@ -123,7 +128,7 @@ export async function fetchArticleHtmlInBrowser(article, page) {
|
|
|
123
128
|
}
|
|
124
129
|
return result.html;
|
|
125
130
|
} catch (error) {
|
|
126
|
-
if (error instanceof CommandExecutionError) throw error;
|
|
131
|
+
if (error instanceof CommandExecutionError || error instanceof AuthRequiredError) throw error;
|
|
127
132
|
throw new CommandExecutionError('Article browser request failed');
|
|
128
133
|
}
|
|
129
134
|
}
|
package/package.json
CHANGED
package/scripts/recorder.sh
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# 录制三端管理脚本
|
|
3
|
-
# daemon : 浏览器底座(19825),由 bycli 管理;扩展连这口
|
|
4
|
-
# be : Recorder Local Service(19826),同源托管真实工作台 UI(dashboard/dist)
|
|
5
|
-
# web : Umi dev server(8000),mock 模式,仅前端开发用(无真实录制)
|
|
6
|
-
#
|
|
7
|
-
# 用法:
|
|
8
|
-
# scripts/recorder.sh start [daemon|be|all] # 默认=真实录制环境(daemon+be,自动停 mock)
|
|
9
|
-
# scripts/recorder.sh start --mock # 仅此参数才起 mock 前端(web :8000,假数据)
|
|
10
|
-
# scripts/recorder.sh stop [daemon|be|web|all]
|
|
11
|
-
# scripts/recorder.sh restart [daemon|be|vnc|all] # restart all=daemon+be(不含 mock);改了 .env/dist 后用;vnc=删旧容器换新镜像
|
|
12
|
-
# scripts/recorder.sh status # 看三端
|
|
13
|
-
# scripts/recorder.sh build [core|be|ui|ext|all] # 重建 dist(改源码后;all 含扩展,需手动重载)
|
|
14
|
-
#
|
|
15
|
-
# 真实录制(带 LLM)启动:scripts/recorder.sh start → 打开 http://127.0.0.1:19826/workbench
|
|
16
|
-
#
|
|
17
|
-
# embedded_iframe 录制模式(P2,公开站页内嵌入;**本机默认开**):起 be 默认带 flag——
|
|
18
|
-
# EMBEDDED=0 scripts/recorder.sh start # 显式关闭页内嵌入模式
|
|
19
|
-
# IFRAME_FRAME_SRC=https://juejin.cn scripts/recorder.sh restart be # 只放该 origin(hardened)
|
|
20
|
-
# inline env 经 `env VAR=…` 注入,优先级高于 --env-file(.env 不覆盖已存在的 process env)。
|
|
21
|
-
#
|
|
22
|
-
# vnc 录制模式(容器内 Chromium+扩展+daemon,noVNC 投画面;**本机默认开**,需 podman + 镜像):
|
|
23
|
-
# scripts/recorder.sh build vnc # 构建容器镜像 bycli-verify:latest(需先 build ext + npm run build)
|
|
24
|
-
# scripts/recorder.sh restart vnc # 重启镜像:删旧容器(bycli-vnc),be 下次 bind 用新镜像重建(改镜像后用)
|
|
25
|
-
# VNC=0 scripts/recorder.sh restart be # 显式关闭 vnc 模式
|
|
26
|
-
# 选 VNC 模式后 be 自动 podman run 起容器、前端 iframe 投 noVNC 画面;录的数据走容器网关→be→合成链。
|
|
27
|
-
set -uo pipefail
|
|
28
|
-
|
|
29
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
30
|
-
RUN="$ROOT/.recorder-run"; mkdir -p "$RUN"
|
|
31
|
-
DAEMON_PORT=19825; BE_PORT=19826; WEB_PORT=8000
|
|
32
|
-
|
|
33
|
-
port_pid() { lsof -ti "tcp:$1" -sTCP:LISTEN 2>/dev/null | head -1; }
|
|
34
|
-
alive() { [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null; }
|
|
35
|
-
|
|
36
|
-
# ───────────────────────── daemon(交给 bycli 管) ─────────────────────────
|
|
37
|
-
need_bycli() { command -v bycli >/dev/null || { echo "✗ bycli 不在 PATH(在仓库根 npm link)"; return 1; }; }
|
|
38
|
-
daemon_start() { need_bycli || return 1; bycli daemon start 2>&1 | tail -1; }
|
|
39
|
-
daemon_stop() { need_bycli && { bycli daemon stop 2>&1 | tail -1; } || true; }
|
|
40
|
-
daemon_restart() { need_bycli || return 1; bycli daemon restart 2>&1 | tail -1; }
|
|
41
|
-
daemon_status() { local p; p="$(port_pid $DAEMON_PORT)"; [ -n "$p" ] && echo "● daemon RUNNING :$DAEMON_PORT pid=$p" || echo "○ daemon stopped :$DAEMON_PORT"; }
|
|
42
|
-
|
|
43
|
-
# ───────────────────────── vnc(podman 容器,be 自动编排) ────────────────
|
|
44
|
-
# 容器名与 vncOrchestrator.ts 保持一致(BYCLI_VNC_CONTAINER 覆盖,默认 bycli-vnc)。
|
|
45
|
-
VNC_CONTAINER="${BYCLI_VNC_CONTAINER:-bycli-vnc}"
|
|
46
|
-
VNC_IMAGE="${BYCLI_VNC_IMAGE:-bycli-verify:latest}"
|
|
47
|
-
need_podman() { command -v podman >/dev/null || { echo "✗ podman 不在 PATH(VNC 模式需 podman)"; return 1; }; }
|
|
48
|
-
# 重启镜像:删旧容器,be 下次 bind 时用当前镜像重建(build vnc 换镜像后调用)。
|
|
49
|
-
vnc_restart() {
|
|
50
|
-
need_podman || return 1
|
|
51
|
-
[ -n "$(podman images -q "$VNC_IMAGE" 2>/dev/null)" ] || { echo "✗ 镜像 $VNC_IMAGE 不存在 → scripts/recorder.sh build vnc"; return 1; }
|
|
52
|
-
if [ -n "$(podman ps -aq -f "name=^${VNC_CONTAINER}$" 2>/dev/null)" ]; then
|
|
53
|
-
podman rm -f "$VNC_CONTAINER" >/dev/null 2>&1 && echo "✓ 已删旧容器 $VNC_CONTAINER(be 下次 bind 用新镜像 $VNC_IMAGE 重建)"
|
|
54
|
-
else
|
|
55
|
-
echo "○ 容器 $VNC_CONTAINER 未运行(be 下次 bind 会用新镜像 $VNC_IMAGE 新建)"
|
|
56
|
-
fi
|
|
57
|
-
}
|
|
58
|
-
vnc_stop() {
|
|
59
|
-
need_podman || return 1
|
|
60
|
-
if [ -n "$(podman ps -aq -f "name=^${VNC_CONTAINER}$" 2>/dev/null)" ]; then
|
|
61
|
-
podman rm -f "$VNC_CONTAINER" >/dev/null 2>&1 && echo "✓ vnc 容器 $VNC_CONTAINER 已删"
|
|
62
|
-
else echo "○ vnc 容器未运行"; fi
|
|
63
|
-
}
|
|
64
|
-
vnc_status() {
|
|
65
|
-
command -v podman >/dev/null || { echo "○ vnc (podman 未装)"; return; }
|
|
66
|
-
local st; st="$(podman inspect "$VNC_CONTAINER" --format '{{.State.Status}}' 2>/dev/null)"
|
|
67
|
-
[ -n "$st" ] && echo "● vnc $st container=$VNC_CONTAINER image=$VNC_IMAGE" || echo "○ vnc no container ($VNC_CONTAINER)"
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
# ───────────────────────── be(node 进程,PID 文件) ──────────────────────
|
|
71
|
-
be_start() {
|
|
72
|
-
[ -f "$ROOT/dashboard-be/dist/server.js" ] || { echo "✗ be 未构建 → scripts/recorder.sh build be"; return 1; }
|
|
73
|
-
[ -f "$ROOT/dashboard-be/.env" ] || { echo "✗ 缺 dashboard-be/.env → cp dashboard-be/.env.example dashboard-be/.env 并填值"; return 1; }
|
|
74
|
-
[ -d "$ROOT/dashboard/dist" ] || echo "⚠ dashboard/dist 不存在,be 将 API-only(无 UI)→ scripts/recorder.sh build ui"
|
|
75
|
-
if [ -n "$(port_pid $BE_PORT)" ]; then echo "● be 已在 :$BE_PORT(先 stop/restart)"; return 0; fi
|
|
76
|
-
# embedded_iframe 模式(P2):EMBEDDED=1 → 注入 flag 开 frame-src + 前端模式选项。
|
|
77
|
-
# 经 `env VAR=…` 内联注入,优先级高于 --env-file(.env 不覆盖已存在的 process env)。
|
|
78
|
-
# 三种录制模式默认全开(本机录制工作台);显式 EMBEDDED=0 / VNC=0 可单独关。
|
|
79
|
-
# 注:只在本机 be 启动注入,不动 recorder-core 的 fail-closed 发布默认(全局 CSP 安全底线不变)。
|
|
80
|
-
local envv=()
|
|
81
|
-
if [ "${EMBEDDED:-1}" = 1 ]; then
|
|
82
|
-
envv+=(FEATURE_EMBEDDED_IFRAME_RECORDING=1)
|
|
83
|
-
[ -n "${IFRAME_FRAME_SRC:-}" ] && envv+=("RECORDER_IFRAME_FRAME_SRC=$IFRAME_FRAME_SRC")
|
|
84
|
-
echo " ⚙ embedded_iframe 模式 ON${IFRAME_FRAME_SRC:+(frame-src=$IFRAME_FRAME_SRC)}"
|
|
85
|
-
fi
|
|
86
|
-
if [ "${VNC:-1}" = 1 ]; then
|
|
87
|
-
envv+=(FEATURE_VNC_RECORDING=1)
|
|
88
|
-
echo " ⚙ vnc 容器模式 ON(be 自动 podman run bycli-verify:latest;需先 build vnc)"
|
|
89
|
-
fi
|
|
90
|
-
( cd "$ROOT" && nohup env ${envv[@]+"${envv[@]}"} node --env-file=dashboard-be/.env dashboard-be/dist/server.js >"$RUN/be.log" 2>&1 & echo $! >"$RUN/be.pid" )
|
|
91
|
-
sleep 1; be_status; echo " 日志: $RUN/be.log"
|
|
92
|
-
}
|
|
93
|
-
be_stop() {
|
|
94
|
-
# 端口权威:pid 文件 + 实际占 19826 的进程都杀(防重复实例残留)
|
|
95
|
-
local stopped=0 pf; pf="$(cat "$RUN/be.pid" 2>/dev/null)"
|
|
96
|
-
for pid in "$pf" "$(port_pid $BE_PORT)"; do
|
|
97
|
-
if alive "$pid"; then kill "$pid" 2>/dev/null; echo "✓ be 已停(pid=$pid)"; stopped=1; fi
|
|
98
|
-
done
|
|
99
|
-
[ "$stopped" = 0 ] && echo "○ be 未运行"
|
|
100
|
-
rm -f "$RUN/be.pid"
|
|
101
|
-
}
|
|
102
|
-
be_restart() { be_stop; sleep 1; be_start; }
|
|
103
|
-
be_status() { local p; p="$(port_pid $BE_PORT)"; [ -n "$p" ] && echo "● be RUNNING http://127.0.0.1:$BE_PORT/workbench pid=$p" || echo "○ be stopped :$BE_PORT"; }
|
|
104
|
-
|
|
105
|
-
# ───────────────────────── web(Umi dev,mock) ───────────────────────────
|
|
106
|
-
web_start() {
|
|
107
|
-
if [ -n "$(port_pid $WEB_PORT)" ]; then echo "● web 已在 :$WEB_PORT"; return 0; fi
|
|
108
|
-
( cd "$ROOT/dashboard" && nohup npm run dev >"$RUN/web.log" 2>&1 & echo $! >"$RUN/web.pid" )
|
|
109
|
-
echo "✓ web 启动中(mock,http://127.0.0.1:$WEB_PORT) 日志: $RUN/web.log"
|
|
110
|
-
}
|
|
111
|
-
web_stop() {
|
|
112
|
-
local pid; pid="$(cat "$RUN/web.pid" 2>/dev/null)"; [ -z "$pid" ] && pid="$(port_pid $WEB_PORT)"
|
|
113
|
-
if alive "$pid"; then pkill -P "$pid" 2>/dev/null; kill "$pid" 2>/dev/null; echo "✓ web 已停"; else echo "○ web 未运行"; fi
|
|
114
|
-
rm -f "$RUN/web.pid"
|
|
115
|
-
}
|
|
116
|
-
web_restart() { web_stop; sleep 1; web_start; }
|
|
117
|
-
web_status() { local p; p="$(port_pid $WEB_PORT)"; [ -n "$p" ] && echo "● web RUNNING http://127.0.0.1:$WEB_PORT (mock) pid=$p" || echo "○ web stopped :$WEB_PORT (mock dev)"; }
|
|
118
|
-
|
|
119
|
-
# ───────────────────────── build ────────────────────────────────────────
|
|
120
|
-
do_build() {
|
|
121
|
-
case "${1:-all}" in
|
|
122
|
-
core) npm --prefix "$ROOT/packages/recorder-core" run build ;;
|
|
123
|
-
be) npm --prefix "$ROOT/dashboard-be" run build ;;
|
|
124
|
-
ui) ( cd "$ROOT/dashboard" && npm run build ) ;;
|
|
125
|
-
ext) ( cd "$ROOT/extension" && npm run build ) ;;
|
|
126
|
-
vnc) # VNC 录制模式容器镜像(Chromium+扩展+daemon+x11vnc+websockify+网关);be 起容器时复用 bycli-verify:latest。
|
|
127
|
-
command -v podman >/dev/null || { echo "✗ podman 不在 PATH(VNC 模式需 podman)"; return 1; }
|
|
128
|
-
[ -f "$ROOT/extension/dist/background.js" ] || { echo "✗ 扩展未构建 → scripts/recorder.sh build ext"; return 1; }
|
|
129
|
-
[ -f "$ROOT/dist/src/daemon.js" ] || { echo "✗ dist 未构建 → npm run build"; return 1; }
|
|
130
|
-
echo "▶ 构建 VNC 容器镜像 bycli-verify:latest(首次装 chromium 较慢)…"
|
|
131
|
-
( cd "$ROOT" && podman build -f podman-verify/Dockerfile -t bycli-verify:latest . ) ;;
|
|
132
|
-
all) npm --prefix "$ROOT/packages/recorder-core" run build \
|
|
133
|
-
&& npm --prefix "$ROOT/dashboard-be" run build \
|
|
134
|
-
&& ( cd "$ROOT/dashboard" && npm run build ) \
|
|
135
|
-
&& ( cd "$ROOT/extension" && npm run build ) \
|
|
136
|
-
&& echo "↻ 扩展已重建 → chrome://extensions 重载 byCLI(确认版本号刷新)" ;;
|
|
137
|
-
*) echo "build: core|be|ui|ext|vnc|all"; return 1 ;;
|
|
138
|
-
esac
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
# ───────────────────────── dispatch ─────────────────────────────────────
|
|
142
|
-
action="${1:-}"; shift || true
|
|
143
|
-
case "$action" in
|
|
144
|
-
start)
|
|
145
|
-
# mock 仅在显式 --mock 时启动;其余参数视作服务名
|
|
146
|
-
mock=0; svcs=()
|
|
147
|
-
for a in "$@"; do if [ "$a" = "--mock" ]; then mock=1; else svcs+=("$a"); fi; done
|
|
148
|
-
if [ "$mock" = 1 ]; then
|
|
149
|
-
echo "▶ 启动【mock 前端】(web :$WEB_PORT,假数据,无真实录制)"
|
|
150
|
-
web_start
|
|
151
|
-
elif [ ${#svcs[@]} -eq 0 ]; then
|
|
152
|
-
# 默认 = 真实录制环境:停掉 mock web(防 :8000 误测)→ 起 daemon + be
|
|
153
|
-
echo "▶ 启动【真实录制环境】(daemon + be);mock web 若在跑将被停掉以免混淆"
|
|
154
|
-
[ -n "$(port_pid $WEB_PORT)" ] && web_stop
|
|
155
|
-
daemon_start; be_start
|
|
156
|
-
echo; echo "✅ 真实录制 → http://127.0.0.1:$BE_PORT/workbench(mock 需 start --mock)"
|
|
157
|
-
else
|
|
158
|
-
[ "${svcs[0]}" = "all" ] && svcs=(daemon be)
|
|
159
|
-
for t in "${svcs[@]}"; do
|
|
160
|
-
case "$t" in
|
|
161
|
-
daemon|be) "${t}_start" ;;
|
|
162
|
-
web) echo "✗ web 是 mock,请用:scripts/recorder.sh start --mock" ;;
|
|
163
|
-
*) echo "未知服务: $t(daemon|be|all,mock 用 --mock)" ;;
|
|
164
|
-
esac
|
|
165
|
-
done
|
|
166
|
-
fi ;;
|
|
167
|
-
stop|restart)
|
|
168
|
-
# all 语义:restart 只起真实环境(daemon+be,不复活 mock,与 start 默认一致);
|
|
169
|
-
# stop 则全停(含 mock web,teardown)。mock 启停一律显式 web/--mock。
|
|
170
|
-
if [ $# -eq 0 ]; then targets=(daemon be)
|
|
171
|
-
elif [ "${1:-}" = all ]; then
|
|
172
|
-
[ "$action" = stop ] && targets=(daemon be web) || targets=(daemon be)
|
|
173
|
-
else targets=("$@"); fi
|
|
174
|
-
[ "$action" = stop ] && targets=($(printf '%s\n' "${targets[@]}" | tail -r 2>/dev/null || printf '%s\n' "${targets[@]}"))
|
|
175
|
-
for t in "${targets[@]}"; do
|
|
176
|
-
case "$t" in daemon|be|web|vnc) "${t}_${action}" ;; *) echo "未知服务: $t(daemon|be|web|vnc|all)";; esac
|
|
177
|
-
done ;;
|
|
178
|
-
status)
|
|
179
|
-
daemon_status; be_status; web_status; vnc_status ;;
|
|
180
|
-
build)
|
|
181
|
-
do_build "${1:-all}" ;;
|
|
182
|
-
""|-h|--help|help)
|
|
183
|
-
awk 'NR>1 && /^#/{sub(/^# ?/,"");print;next} NR>1{exit}' "${BASH_SOURCE[0]}" ;;
|
|
184
|
-
*)
|
|
185
|
-
echo "未知命令: $action(start|stop|restart|status|build)"; exit 1 ;;
|
|
186
|
-
esac
|