@dongnanyang/deploy-cli 0.10.0 → 0.11.0
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/bin.js +1 -1
- package/dist/{cli-CR04-WjM.js → cli-D0f7LcnK.js} +2 -216
- package/dist/health-CZL7Ghs8.js +217 -0
- package/dist/main.js +15 -15
- package/dist/tui/main.js +1039 -69
- package/package.json +1 -1
package/dist/tui/main.js
CHANGED
|
@@ -1,9 +1,383 @@
|
|
|
1
|
+
import { s as listProjects } from "../project-BzJoAv1l.js";
|
|
2
|
+
import { n as loadConfig } from "../config-xUl8Oa3T.js";
|
|
1
3
|
import { t as export_helper_default } from "../export-helper-CIEcxb5I.js";
|
|
4
|
+
import { i as createDocker, t as checkProjectHealth } from "../health-CZL7Ghs8.js";
|
|
2
5
|
import { Box, Text, createApp, useApp, useInput } from "@vue-tui/runtime";
|
|
3
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, withCtx } from "vue";
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, shallowRef, toDisplayString, watch, withCtx } from "vue";
|
|
7
|
+
import { ScrollBox } from "@vue-tui/components";
|
|
8
|
+
//#region src/tui/composables/useKeymap.ts
|
|
9
|
+
/** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
|
|
10
|
+
const PANEL_IDS = [
|
|
11
|
+
"projects",
|
|
12
|
+
"containers",
|
|
13
|
+
"deploy",
|
|
14
|
+
"status",
|
|
15
|
+
"tunnels",
|
|
16
|
+
"output"
|
|
17
|
+
];
|
|
18
|
+
/** 面板标题(骨架/状态栏共用;中文文案) */
|
|
19
|
+
const PANEL_TITLES = {
|
|
20
|
+
projects: "Projects 项目",
|
|
21
|
+
containers: "Containers 容器",
|
|
22
|
+
deploy: "Deploy 部署",
|
|
23
|
+
status: "Status 状态",
|
|
24
|
+
tunnels: "Tunnels 隧道",
|
|
25
|
+
output: "Output 输出"
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 键名归一(R16 事件模型,面板/弹窗共用):text 事件取 text、key 事件取 character ?? name。
|
|
29
|
+
* 多字符文本(粘贴/连打)与 paste 不归一,防误触;命名键(enter/escape/up…)原样返回 name。
|
|
30
|
+
*/
|
|
31
|
+
function keyName(event) {
|
|
32
|
+
if (event.type === "text") return event.text.length === 1 ? event.text : void 0;
|
|
33
|
+
if (event.type === "key") return event.key.character ?? event.key.name;
|
|
34
|
+
}
|
|
35
|
+
/** 单字符键位(dispatchKey 用):keyName 结果中只留单字符,命名键不入内 */
|
|
36
|
+
function keyChar(event) {
|
|
37
|
+
const raw = keyName(event);
|
|
38
|
+
return raw !== void 0 && raw.length === 1 ? raw : void 0;
|
|
39
|
+
}
|
|
40
|
+
/** 键位分发(纯函数,单测锚点):1-6 切面板、q 退出、? 帮助;其余不分发 */
|
|
41
|
+
function dispatchKey(event) {
|
|
42
|
+
const ch = keyChar(event);
|
|
43
|
+
if (ch === void 0) return null;
|
|
44
|
+
if (ch >= "1" && ch <= "6") return {
|
|
45
|
+
kind: "panel",
|
|
46
|
+
panel: PANEL_IDS[Number(ch) - 1]
|
|
47
|
+
};
|
|
48
|
+
if (ch === "q") return { kind: "quit" };
|
|
49
|
+
if (ch === "?") return { kind: "help" };
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
/** 键位路由接线:useInput 订阅 → dispatchKey → 回调;组件不碰输入流本体 */
|
|
53
|
+
function useKeymap(handlers) {
|
|
54
|
+
useInput((event) => {
|
|
55
|
+
const action = dispatchKey(event);
|
|
56
|
+
if (action === null) return;
|
|
57
|
+
if (action.kind === "panel") handlers.onPanel(action.panel);
|
|
58
|
+
else if (action.kind === "quit") handlers.onQuit();
|
|
59
|
+
else handlers.onHelp();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/tui/components/ConfirmModal.vue
|
|
64
|
+
/**
|
|
65
|
+
* 破坏性动作二次确认弹窗(spec §6.3:down/rm/restart 等 TUI 需确认)。
|
|
66
|
+
* 只吃 ViewModel(visible/message),动作由父组件在 confirm 事件后执行。
|
|
67
|
+
* 键位:y/enter 确认、n/escape 取消;不可见时不响应。
|
|
68
|
+
*/
|
|
69
|
+
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
70
|
+
__name: "ConfirmModal",
|
|
71
|
+
props: {
|
|
72
|
+
visible: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
required: true
|
|
75
|
+
},
|
|
76
|
+
message: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
emits: ["confirm", "cancel"],
|
|
82
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
83
|
+
__expose();
|
|
84
|
+
const props = __props;
|
|
85
|
+
const emit = __emit;
|
|
86
|
+
useInput((event) => {
|
|
87
|
+
if (!props.visible) return;
|
|
88
|
+
const name = keyName(event);
|
|
89
|
+
if (name === "y" || name === "enter") emit("confirm");
|
|
90
|
+
else if (name === "n" || name === "escape") emit("cancel");
|
|
91
|
+
}, { isActive: () => props.visible });
|
|
92
|
+
const __returned__ = {
|
|
93
|
+
props,
|
|
94
|
+
emit,
|
|
95
|
+
get Box() {
|
|
96
|
+
return Box;
|
|
97
|
+
},
|
|
98
|
+
get Text() {
|
|
99
|
+
return Text;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
103
|
+
enumerable: false,
|
|
104
|
+
value: true
|
|
105
|
+
});
|
|
106
|
+
return __returned__;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
110
|
+
return $setup.props.visible ? (openBlock(), createBlock($setup["Box"], {
|
|
111
|
+
key: 0,
|
|
112
|
+
flexDirection: "column",
|
|
113
|
+
borderStyle: "round",
|
|
114
|
+
borderColor: "yellow",
|
|
115
|
+
padding: 1,
|
|
116
|
+
marginX: 1
|
|
117
|
+
}, {
|
|
118
|
+
default: withCtx(() => [
|
|
119
|
+
createVNode($setup["Text"], {
|
|
120
|
+
bold: "",
|
|
121
|
+
color: "yellow"
|
|
122
|
+
}, {
|
|
123
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("⚠ 确认操作", -1)])]),
|
|
124
|
+
_: 1
|
|
125
|
+
}),
|
|
126
|
+
createVNode($setup["Text"], null, {
|
|
127
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.props.message), 1)]),
|
|
128
|
+
_: 1
|
|
129
|
+
}),
|
|
130
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
131
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("[y] 确认 / [n] 取消", -1)])]),
|
|
132
|
+
_: 1
|
|
133
|
+
})
|
|
134
|
+
]),
|
|
135
|
+
_: 1
|
|
136
|
+
})) : createCommentVNode("v-if", true);
|
|
137
|
+
}
|
|
138
|
+
var ConfirmModal_default = /*#__PURE__*/ export_helper_default(_sfc_main$6, [["render", _sfc_render$6], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ConfirmModal.vue"]]);
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/tui/components/ContainersPanel.vue
|
|
141
|
+
const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
142
|
+
__name: "ContainersPanel",
|
|
143
|
+
props: {
|
|
144
|
+
rows: {
|
|
145
|
+
type: Array,
|
|
146
|
+
required: true
|
|
147
|
+
},
|
|
148
|
+
error: {
|
|
149
|
+
type: String,
|
|
150
|
+
required: false
|
|
151
|
+
},
|
|
152
|
+
following: {
|
|
153
|
+
type: String,
|
|
154
|
+
required: false
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
emits: [
|
|
158
|
+
"logs",
|
|
159
|
+
"restart",
|
|
160
|
+
"stop",
|
|
161
|
+
"remove",
|
|
162
|
+
"refresh"
|
|
163
|
+
],
|
|
164
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
165
|
+
__expose();
|
|
166
|
+
const props = __props;
|
|
167
|
+
const emit = __emit;
|
|
168
|
+
const ACTION_LABEL = {
|
|
169
|
+
restart: "重启",
|
|
170
|
+
stop: "停止",
|
|
171
|
+
remove: "删除"
|
|
172
|
+
};
|
|
173
|
+
const sel = ref(0);
|
|
174
|
+
const pending = ref(null);
|
|
175
|
+
const confirmMessage = computed(() => pending.value === null ? "" : `确认${ACTION_LABEL[pending.value.action]}容器 ${pending.value.name}?`);
|
|
176
|
+
watch(() => props.rows.length, () => {
|
|
177
|
+
sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
|
|
178
|
+
});
|
|
179
|
+
useInput((event) => {
|
|
180
|
+
if (pending.value !== null) return;
|
|
181
|
+
const name = keyName(event);
|
|
182
|
+
if (props.rows.length === 0) return;
|
|
183
|
+
if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
|
|
184
|
+
else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
|
|
185
|
+
else if (name === "l") emit("logs", props.rows[sel.value].name);
|
|
186
|
+
else if (name === "r") pending.value = {
|
|
187
|
+
action: "restart",
|
|
188
|
+
name: props.rows[sel.value].name
|
|
189
|
+
};
|
|
190
|
+
else if (name === "s") pending.value = {
|
|
191
|
+
action: "stop",
|
|
192
|
+
name: props.rows[sel.value].name
|
|
193
|
+
};
|
|
194
|
+
else if (name === "x") pending.value = {
|
|
195
|
+
action: "remove",
|
|
196
|
+
name: props.rows[sel.value].name
|
|
197
|
+
};
|
|
198
|
+
else if (name === "f") emit("refresh");
|
|
199
|
+
}, { isActive: () => pending.value === null });
|
|
200
|
+
function onConfirm() {
|
|
201
|
+
const p = pending.value;
|
|
202
|
+
pending.value = null;
|
|
203
|
+
if (p === null) return;
|
|
204
|
+
if (p.action === "restart") emit("restart", p.name);
|
|
205
|
+
else if (p.action === "stop") emit("stop", p.name);
|
|
206
|
+
else emit("remove", p.name);
|
|
207
|
+
}
|
|
208
|
+
const __returned__ = {
|
|
209
|
+
props,
|
|
210
|
+
emit,
|
|
211
|
+
ACTION_LABEL,
|
|
212
|
+
sel,
|
|
213
|
+
pending,
|
|
214
|
+
confirmMessage,
|
|
215
|
+
onConfirm,
|
|
216
|
+
get Box() {
|
|
217
|
+
return Box;
|
|
218
|
+
},
|
|
219
|
+
get Text() {
|
|
220
|
+
return Text;
|
|
221
|
+
},
|
|
222
|
+
ConfirmModal: ConfirmModal_default
|
|
223
|
+
};
|
|
224
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
225
|
+
enumerable: false,
|
|
226
|
+
value: true
|
|
227
|
+
});
|
|
228
|
+
return __returned__;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
232
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
233
|
+
flexDirection: "column",
|
|
234
|
+
flexGrow: 1,
|
|
235
|
+
borderStyle: "round",
|
|
236
|
+
borderColor: "cyan",
|
|
237
|
+
padding: 1
|
|
238
|
+
}, {
|
|
239
|
+
default: withCtx(() => [
|
|
240
|
+
createVNode($setup["Text"], {
|
|
241
|
+
bold: "",
|
|
242
|
+
color: "cyan"
|
|
243
|
+
}, {
|
|
244
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("2. Containers 容器", -1)])]),
|
|
245
|
+
_: 1
|
|
246
|
+
}),
|
|
247
|
+
createVNode($setup["Box"], { flexDirection: "row" }, {
|
|
248
|
+
default: withCtx(() => [
|
|
249
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
250
|
+
default: withCtx(() => [createVNode($setup["Text"])]),
|
|
251
|
+
_: 1
|
|
252
|
+
}),
|
|
253
|
+
createVNode($setup["Box"], { width: 20 }, {
|
|
254
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
255
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("NAME", -1)])]),
|
|
256
|
+
_: 1
|
|
257
|
+
})]),
|
|
258
|
+
_: 1
|
|
259
|
+
}),
|
|
260
|
+
createVNode($setup["Box"], { width: 24 }, {
|
|
261
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
262
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("IMAGE", -1)])]),
|
|
263
|
+
_: 1
|
|
264
|
+
})]),
|
|
265
|
+
_: 1
|
|
266
|
+
}),
|
|
267
|
+
createVNode($setup["Box"], { width: 10 }, {
|
|
268
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
269
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("STATE", -1)])]),
|
|
270
|
+
_: 1
|
|
271
|
+
})]),
|
|
272
|
+
_: 1
|
|
273
|
+
}),
|
|
274
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
275
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
276
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("PORTS", -1)])]),
|
|
277
|
+
_: 1
|
|
278
|
+
})]),
|
|
279
|
+
_: 1
|
|
280
|
+
})
|
|
281
|
+
]),
|
|
282
|
+
_: 1
|
|
283
|
+
}),
|
|
284
|
+
$setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
285
|
+
key: 0,
|
|
286
|
+
color: "red"
|
|
287
|
+
}, {
|
|
288
|
+
default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
|
|
289
|
+
_: 1
|
|
290
|
+
})) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
291
|
+
key: 1,
|
|
292
|
+
dimColor: ""
|
|
293
|
+
}, {
|
|
294
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("(暂无容器)", -1)])]),
|
|
295
|
+
_: 1
|
|
296
|
+
})) : createCommentVNode("v-if", true),
|
|
297
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row, i) => {
|
|
298
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
299
|
+
key: row.id,
|
|
300
|
+
flexDirection: "row"
|
|
301
|
+
}, {
|
|
302
|
+
default: withCtx(() => [
|
|
303
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
304
|
+
default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.sel ? "cyan" : void 0 }, {
|
|
305
|
+
default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.sel ? ">" : " "), 1)]),
|
|
306
|
+
_: 2
|
|
307
|
+
}, 1032, ["color"])]),
|
|
308
|
+
_: 2
|
|
309
|
+
}, 1024),
|
|
310
|
+
createVNode($setup["Box"], { width: 20 }, {
|
|
311
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
312
|
+
wrap: "truncate",
|
|
313
|
+
bold: i === $setup.sel
|
|
314
|
+
}, {
|
|
315
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
|
|
316
|
+
_: 2
|
|
317
|
+
}, 1032, ["bold"])]),
|
|
318
|
+
_: 2
|
|
319
|
+
}, 1024),
|
|
320
|
+
createVNode($setup["Box"], { width: 24 }, {
|
|
321
|
+
default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
|
|
322
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.image), 1)]),
|
|
323
|
+
_: 2
|
|
324
|
+
}, 1024)]),
|
|
325
|
+
_: 2
|
|
326
|
+
}, 1024),
|
|
327
|
+
createVNode($setup["Box"], { width: 10 }, {
|
|
328
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
329
|
+
wrap: "truncate",
|
|
330
|
+
color: row.state === "running" ? "green" : "yellow"
|
|
331
|
+
}, {
|
|
332
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.state), 1)]),
|
|
333
|
+
_: 2
|
|
334
|
+
}, 1032, ["color"])]),
|
|
335
|
+
_: 2
|
|
336
|
+
}, 1024),
|
|
337
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
338
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
339
|
+
wrap: "truncate",
|
|
340
|
+
dimColor: ""
|
|
341
|
+
}, {
|
|
342
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.ports), 1)]),
|
|
343
|
+
_: 2
|
|
344
|
+
}, 1024)]),
|
|
345
|
+
_: 2
|
|
346
|
+
}, 1024)
|
|
347
|
+
]),
|
|
348
|
+
_: 2
|
|
349
|
+
}, 1024);
|
|
350
|
+
}), 128)),
|
|
351
|
+
$setup.props.following !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
352
|
+
key: 2,
|
|
353
|
+
color: "green"
|
|
354
|
+
}, {
|
|
355
|
+
default: withCtx(() => [createTextVNode("日志跟随中: " + toDisplayString($setup.props.following), 1)]),
|
|
356
|
+
_: 1
|
|
357
|
+
})) : createCommentVNode("v-if", true),
|
|
358
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
359
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("j/k 选择 · l 日志 · r 重启 · s 停止 · x 删除 · f 刷新", -1)])]),
|
|
360
|
+
_: 1
|
|
361
|
+
}),
|
|
362
|
+
createVNode($setup["ConfirmModal"], {
|
|
363
|
+
visible: $setup.pending !== null,
|
|
364
|
+
message: $setup.confirmMessage,
|
|
365
|
+
onConfirm: $setup.onConfirm,
|
|
366
|
+
onCancel: _cache[0] || (_cache[0] = ($event) => $setup.pending = null)
|
|
367
|
+
}, null, 8, ["visible", "message"])
|
|
368
|
+
]),
|
|
369
|
+
_: 1
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [["render", _sfc_render$5], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ContainersPanel.vue"]]);
|
|
373
|
+
//#endregion
|
|
4
374
|
//#region src/tui/components/OutputPanel.vue
|
|
5
|
-
/**
|
|
6
|
-
|
|
375
|
+
/**
|
|
376
|
+
* 全局日志面板(spec 6.4 Output):只吃 ViewModel(logs 列表),不碰 core。
|
|
377
|
+
* 滚动/截断(T4#4 递延项):ScrollBox 有界视口(内容超高即截断)+ 旧 TUI g/G 键位语义(g 到顶、G 回底跟随)、↑/↓ 逐行;
|
|
378
|
+
* 列表上限在 useLogs(LOGS_LIMIT 环形截断),此处只管视口。
|
|
379
|
+
*/
|
|
380
|
+
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
7
381
|
__name: "OutputPanel",
|
|
8
382
|
props: { logs: {
|
|
9
383
|
type: Array,
|
|
@@ -11,8 +385,18 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
11
385
|
} },
|
|
12
386
|
setup(__props, { expose: __expose }) {
|
|
13
387
|
__expose();
|
|
388
|
+
const props = __props;
|
|
389
|
+
const scrollRef = shallowRef(null);
|
|
390
|
+
useInput((event) => {
|
|
391
|
+
const name = keyName(event);
|
|
392
|
+
if (name === "up") scrollRef.value?.scrollByLines(-1);
|
|
393
|
+
else if (name === "down") scrollRef.value?.scrollByLines(1);
|
|
394
|
+
else if (name === "g") scrollRef.value?.scrollToTop();
|
|
395
|
+
else if (name === "G") scrollRef.value?.scrollToBottom();
|
|
396
|
+
});
|
|
14
397
|
const __returned__ = {
|
|
15
|
-
props
|
|
398
|
+
props,
|
|
399
|
+
scrollRef,
|
|
16
400
|
LEVEL_COLOR: {
|
|
17
401
|
info: void 0,
|
|
18
402
|
success: "green",
|
|
@@ -24,6 +408,9 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
24
408
|
},
|
|
25
409
|
get Text() {
|
|
26
410
|
return Text;
|
|
411
|
+
},
|
|
412
|
+
get ScrollBox() {
|
|
413
|
+
return ScrollBox;
|
|
27
414
|
}
|
|
28
415
|
};
|
|
29
416
|
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
@@ -33,7 +420,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
33
420
|
return __returned__;
|
|
34
421
|
}
|
|
35
422
|
});
|
|
36
|
-
function _sfc_render$
|
|
423
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
37
424
|
return openBlock(), createBlock($setup["Box"], {
|
|
38
425
|
flexDirection: "column",
|
|
39
426
|
flexGrow: 1,
|
|
@@ -55,73 +442,382 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
55
442
|
}, {
|
|
56
443
|
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("(暂无日志)", -1)])]),
|
|
57
444
|
_: 1
|
|
445
|
+
})) : (openBlock(), createBlock($setup["ScrollBox"], {
|
|
446
|
+
key: 1,
|
|
447
|
+
ref: "scrollRef",
|
|
448
|
+
flexGrow: 1
|
|
449
|
+
}, {
|
|
450
|
+
default: withCtx(() => [createVNode($setup["Box"], { flexDirection: "column" }, {
|
|
451
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.logs, (entry, i) => {
|
|
452
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
453
|
+
key: i,
|
|
454
|
+
color: $setup.LEVEL_COLOR[entry.level],
|
|
455
|
+
wrap: "truncate"
|
|
456
|
+
}, {
|
|
457
|
+
default: withCtx(() => [createTextVNode(toDisplayString(entry.time) + " [" + toDisplayString(entry.level) + "] " + toDisplayString(entry.message), 1)]),
|
|
458
|
+
_: 2
|
|
459
|
+
}, 1032, ["color"]);
|
|
460
|
+
}), 128))]),
|
|
461
|
+
_: 1
|
|
462
|
+
})]),
|
|
463
|
+
_: 1
|
|
464
|
+
}, 512)),
|
|
465
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
466
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("g/G 到顶/底 · ↑/↓ 逐行滚动", -1)])]),
|
|
467
|
+
_: 1
|
|
468
|
+
})
|
|
469
|
+
]),
|
|
470
|
+
_: 1
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$4, [["render", _sfc_render$4], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/OutputPanel.vue"]]);
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/tui/components/ProjectsPanel.vue
|
|
476
|
+
/**
|
|
477
|
+
* Projects 面板(spec 6.4):项目列表 NAME/PATH/TYPE/ERROR + 动作事件出口。
|
|
478
|
+
* 只吃 ViewModel(rows);动作经 emit 交 App 接线(部署等 T6 接线)。
|
|
479
|
+
*/
|
|
480
|
+
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
481
|
+
__name: "ProjectsPanel",
|
|
482
|
+
props: {
|
|
483
|
+
rows: {
|
|
484
|
+
type: Array,
|
|
485
|
+
required: true
|
|
486
|
+
},
|
|
487
|
+
error: {
|
|
488
|
+
type: String,
|
|
489
|
+
required: false
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
emits: ["deploy", "refresh"],
|
|
493
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
494
|
+
__expose();
|
|
495
|
+
const props = __props;
|
|
496
|
+
const emit = __emit;
|
|
497
|
+
const sel = ref(0);
|
|
498
|
+
watch(() => props.rows.length, () => {
|
|
499
|
+
sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
|
|
500
|
+
});
|
|
501
|
+
useInput((event) => {
|
|
502
|
+
const name = keyName(event);
|
|
503
|
+
if (props.rows.length === 0) return;
|
|
504
|
+
if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
|
|
505
|
+
else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
|
|
506
|
+
else if (name === "d") emit("deploy", props.rows[sel.value].name);
|
|
507
|
+
else if (name === "f") emit("refresh");
|
|
508
|
+
});
|
|
509
|
+
const __returned__ = {
|
|
510
|
+
props,
|
|
511
|
+
emit,
|
|
512
|
+
sel,
|
|
513
|
+
get Box() {
|
|
514
|
+
return Box;
|
|
515
|
+
},
|
|
516
|
+
get Text() {
|
|
517
|
+
return Text;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
521
|
+
enumerable: false,
|
|
522
|
+
value: true
|
|
523
|
+
});
|
|
524
|
+
return __returned__;
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
528
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
529
|
+
flexDirection: "column",
|
|
530
|
+
flexGrow: 1,
|
|
531
|
+
borderStyle: "round",
|
|
532
|
+
borderColor: "cyan",
|
|
533
|
+
padding: 1
|
|
534
|
+
}, {
|
|
535
|
+
default: withCtx(() => [
|
|
536
|
+
createVNode($setup["Text"], {
|
|
537
|
+
bold: "",
|
|
538
|
+
color: "cyan"
|
|
539
|
+
}, {
|
|
540
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("1. Projects 项目", -1)])]),
|
|
541
|
+
_: 1
|
|
542
|
+
}),
|
|
543
|
+
createVNode($setup["Box"], { flexDirection: "row" }, {
|
|
544
|
+
default: withCtx(() => [
|
|
545
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
546
|
+
default: withCtx(() => [createVNode($setup["Text"])]),
|
|
547
|
+
_: 1
|
|
548
|
+
}),
|
|
549
|
+
createVNode($setup["Box"], { width: 18 }, {
|
|
550
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
551
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("NAME", -1)])]),
|
|
552
|
+
_: 1
|
|
553
|
+
})]),
|
|
554
|
+
_: 1
|
|
555
|
+
}),
|
|
556
|
+
createVNode($setup["Box"], { width: 30 }, {
|
|
557
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
558
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("PATH", -1)])]),
|
|
559
|
+
_: 1
|
|
560
|
+
})]),
|
|
561
|
+
_: 1
|
|
562
|
+
}),
|
|
563
|
+
createVNode($setup["Box"], { width: 8 }, {
|
|
564
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
565
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("TYPE", -1)])]),
|
|
566
|
+
_: 1
|
|
567
|
+
})]),
|
|
568
|
+
_: 1
|
|
569
|
+
}),
|
|
570
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
571
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
572
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("ERROR", -1)])]),
|
|
573
|
+
_: 1
|
|
574
|
+
})]),
|
|
575
|
+
_: 1
|
|
576
|
+
})
|
|
577
|
+
]),
|
|
578
|
+
_: 1
|
|
579
|
+
}),
|
|
580
|
+
$setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
581
|
+
key: 0,
|
|
582
|
+
color: "red"
|
|
583
|
+
}, {
|
|
584
|
+
default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
|
|
585
|
+
_: 1
|
|
586
|
+
})) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
587
|
+
key: 1,
|
|
588
|
+
dimColor: ""
|
|
589
|
+
}, {
|
|
590
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(暂无项目)", -1)])]),
|
|
591
|
+
_: 1
|
|
58
592
|
})) : createCommentVNode("v-if", true),
|
|
59
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.
|
|
60
|
-
return openBlock(), createBlock($setup["
|
|
61
|
-
key:
|
|
62
|
-
|
|
593
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row, i) => {
|
|
594
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
595
|
+
key: row.name,
|
|
596
|
+
flexDirection: "row"
|
|
63
597
|
}, {
|
|
64
|
-
default: withCtx(() => [
|
|
598
|
+
default: withCtx(() => [
|
|
599
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
600
|
+
default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.sel ? "cyan" : void 0 }, {
|
|
601
|
+
default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.sel ? ">" : " "), 1)]),
|
|
602
|
+
_: 2
|
|
603
|
+
}, 1032, ["color"])]),
|
|
604
|
+
_: 2
|
|
605
|
+
}, 1024),
|
|
606
|
+
createVNode($setup["Box"], { width: 18 }, {
|
|
607
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
608
|
+
wrap: "truncate",
|
|
609
|
+
bold: i === $setup.sel
|
|
610
|
+
}, {
|
|
611
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
|
|
612
|
+
_: 2
|
|
613
|
+
}, 1032, ["bold"])]),
|
|
614
|
+
_: 2
|
|
615
|
+
}, 1024),
|
|
616
|
+
createVNode($setup["Box"], { width: 30 }, {
|
|
617
|
+
default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
|
|
618
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.path), 1)]),
|
|
619
|
+
_: 2
|
|
620
|
+
}, 1024)]),
|
|
621
|
+
_: 2
|
|
622
|
+
}, 1024),
|
|
623
|
+
createVNode($setup["Box"], { width: 8 }, {
|
|
624
|
+
default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
|
|
625
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.type), 1)]),
|
|
626
|
+
_: 2
|
|
627
|
+
}, 1024)]),
|
|
628
|
+
_: 2
|
|
629
|
+
}, 1024),
|
|
630
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
631
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
632
|
+
wrap: "truncate",
|
|
633
|
+
color: "red"
|
|
634
|
+
}, {
|
|
635
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.error ?? ""), 1)]),
|
|
636
|
+
_: 2
|
|
637
|
+
}, 1024)]),
|
|
638
|
+
_: 2
|
|
639
|
+
}, 1024)
|
|
640
|
+
]),
|
|
65
641
|
_: 2
|
|
66
|
-
},
|
|
67
|
-
}), 128))
|
|
642
|
+
}, 1024);
|
|
643
|
+
}), 128)),
|
|
644
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
645
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("j/k 选择 · d 部署 · f 刷新", -1)])]),
|
|
646
|
+
_: 1
|
|
647
|
+
})
|
|
68
648
|
]),
|
|
69
649
|
_: 1
|
|
70
650
|
});
|
|
71
651
|
}
|
|
72
|
-
var
|
|
652
|
+
var ProjectsPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$3, [["render", _sfc_render$3], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ProjectsPanel.vue"]]);
|
|
73
653
|
//#endregion
|
|
74
|
-
//#region src/tui/
|
|
75
|
-
/** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
|
|
76
|
-
const PANEL_IDS = [
|
|
77
|
-
"projects",
|
|
78
|
-
"containers",
|
|
79
|
-
"deploy",
|
|
80
|
-
"status",
|
|
81
|
-
"tunnels",
|
|
82
|
-
"output"
|
|
83
|
-
];
|
|
84
|
-
/** 面板标题(骨架/状态栏共用;中文文案) */
|
|
85
|
-
const PANEL_TITLES = {
|
|
86
|
-
projects: "Projects 项目",
|
|
87
|
-
containers: "Containers 容器",
|
|
88
|
-
deploy: "Deploy 部署",
|
|
89
|
-
status: "Status 状态",
|
|
90
|
-
tunnels: "Tunnels 隧道",
|
|
91
|
-
output: "Output 输出"
|
|
92
|
-
};
|
|
654
|
+
//#region src/tui/components/StatusPanel.vue
|
|
93
655
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
656
|
+
* Status 面板(spec 6.4):项目健康聚合 CONTAINERS/HTTP/NGINX(口径同 CLI status 表格)。
|
|
657
|
+
* 只吃 ViewModel(rows);单行错误降级展示(检查失败/配置不可用行 + 继续,M2-T2 #10 的 UI 面)。
|
|
96
658
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
659
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
660
|
+
__name: "StatusPanel",
|
|
661
|
+
props: {
|
|
662
|
+
rows: {
|
|
663
|
+
type: Array,
|
|
664
|
+
required: true
|
|
665
|
+
},
|
|
666
|
+
error: {
|
|
667
|
+
type: String,
|
|
668
|
+
required: false
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
emits: ["refresh"],
|
|
672
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
673
|
+
__expose();
|
|
674
|
+
const props = __props;
|
|
675
|
+
const emit = __emit;
|
|
676
|
+
useInput((event) => {
|
|
677
|
+
if (keyName(event) === "f") emit("refresh");
|
|
678
|
+
});
|
|
679
|
+
const __returned__ = {
|
|
680
|
+
props,
|
|
681
|
+
emit,
|
|
682
|
+
get Box() {
|
|
683
|
+
return Box;
|
|
684
|
+
},
|
|
685
|
+
get Text() {
|
|
686
|
+
return Text;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
690
|
+
enumerable: false,
|
|
691
|
+
value: true
|
|
692
|
+
});
|
|
693
|
+
return __returned__;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
697
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
698
|
+
flexDirection: "column",
|
|
699
|
+
flexGrow: 1,
|
|
700
|
+
borderStyle: "round",
|
|
701
|
+
borderColor: "cyan",
|
|
702
|
+
padding: 1
|
|
703
|
+
}, {
|
|
704
|
+
default: withCtx(() => [
|
|
705
|
+
createVNode($setup["Text"], {
|
|
706
|
+
bold: "",
|
|
707
|
+
color: "cyan"
|
|
708
|
+
}, {
|
|
709
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("4. Status 状态", -1)])]),
|
|
710
|
+
_: 1
|
|
711
|
+
}),
|
|
712
|
+
createVNode($setup["Box"], { flexDirection: "row" }, {
|
|
713
|
+
default: withCtx(() => [
|
|
714
|
+
createVNode($setup["Box"], { width: 20 }, {
|
|
715
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
716
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("NAME", -1)])]),
|
|
717
|
+
_: 1
|
|
718
|
+
})]),
|
|
719
|
+
_: 1
|
|
720
|
+
}),
|
|
721
|
+
createVNode($setup["Box"], { width: 16 }, {
|
|
722
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
723
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("CONTAINERS", -1)])]),
|
|
724
|
+
_: 1
|
|
725
|
+
})]),
|
|
726
|
+
_: 1
|
|
727
|
+
}),
|
|
728
|
+
createVNode($setup["Box"], { width: 8 }, {
|
|
729
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
730
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("HTTP", -1)])]),
|
|
731
|
+
_: 1
|
|
732
|
+
})]),
|
|
733
|
+
_: 1
|
|
734
|
+
}),
|
|
735
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
736
|
+
default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
|
|
737
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("NGINX", -1)])]),
|
|
738
|
+
_: 1
|
|
739
|
+
})]),
|
|
740
|
+
_: 1
|
|
741
|
+
})
|
|
742
|
+
]),
|
|
743
|
+
_: 1
|
|
744
|
+
}),
|
|
745
|
+
$setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
746
|
+
key: 0,
|
|
747
|
+
color: "red"
|
|
748
|
+
}, {
|
|
749
|
+
default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
|
|
750
|
+
_: 1
|
|
751
|
+
})) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
752
|
+
key: 1,
|
|
753
|
+
dimColor: ""
|
|
754
|
+
}, {
|
|
755
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(暂无项目)", -1)])]),
|
|
756
|
+
_: 1
|
|
757
|
+
})) : createCommentVNode("v-if", true),
|
|
758
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row) => {
|
|
759
|
+
return openBlock(), createElementBlock(Fragment, { key: row.name }, [
|
|
760
|
+
createVNode($setup["Box"], { flexDirection: "row" }, {
|
|
761
|
+
default: withCtx(() => [
|
|
762
|
+
createVNode($setup["Box"], { width: 20 }, {
|
|
763
|
+
default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
|
|
764
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
|
|
765
|
+
_: 2
|
|
766
|
+
}, 1024)]),
|
|
767
|
+
_: 2
|
|
768
|
+
}, 1024),
|
|
769
|
+
createVNode($setup["Box"], { width: 16 }, {
|
|
770
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
771
|
+
wrap: "truncate",
|
|
772
|
+
color: row.error !== void 0 ? "red" : void 0
|
|
773
|
+
}, {
|
|
774
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.containers), 1)]),
|
|
775
|
+
_: 2
|
|
776
|
+
}, 1032, ["color"])]),
|
|
777
|
+
_: 2
|
|
778
|
+
}, 1024),
|
|
779
|
+
createVNode($setup["Box"], { width: 8 }, {
|
|
780
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
781
|
+
wrap: "truncate",
|
|
782
|
+
color: row.http === "FAIL" ? "red" : row.http === "-" ? void 0 : "green"
|
|
783
|
+
}, {
|
|
784
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.http), 1)]),
|
|
785
|
+
_: 2
|
|
786
|
+
}, 1032, ["color"])]),
|
|
787
|
+
_: 2
|
|
788
|
+
}, 1024),
|
|
789
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
790
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
791
|
+
wrap: "truncate",
|
|
792
|
+
color: row.nginx === "✓" ? "green" : row.nginx === "✗" ? "red" : void 0
|
|
793
|
+
}, {
|
|
794
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.nginx), 1)]),
|
|
795
|
+
_: 2
|
|
796
|
+
}, 1032, ["color"])]),
|
|
797
|
+
_: 2
|
|
798
|
+
}, 1024)
|
|
799
|
+
]),
|
|
800
|
+
_: 2
|
|
801
|
+
}, 1024),
|
|
802
|
+
createCommentVNode(" 单行降级详情(CLI status 的 error 行口径),不中断后续行 "),
|
|
803
|
+
row.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
804
|
+
key: 0,
|
|
805
|
+
color: "red"
|
|
806
|
+
}, {
|
|
807
|
+
default: withCtx(() => [createTextVNode(toDisplayString(row.error), 1)]),
|
|
808
|
+
_: 2
|
|
809
|
+
}, 1024)) : createCommentVNode("v-if", true)
|
|
810
|
+
], 64);
|
|
811
|
+
}), 128)),
|
|
812
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
813
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("f 刷新", -1)])]),
|
|
814
|
+
_: 1
|
|
815
|
+
})
|
|
816
|
+
]),
|
|
817
|
+
_: 1
|
|
123
818
|
});
|
|
124
819
|
}
|
|
820
|
+
var StatusPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusPanel.vue"]]);
|
|
125
821
|
//#endregion
|
|
126
822
|
//#region src/tui/components/StatusBar.vue
|
|
127
823
|
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
@@ -180,6 +876,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
180
876
|
var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusBar.vue"]]);
|
|
181
877
|
//#endregion
|
|
182
878
|
//#region src/tui/composables/useLogs.ts
|
|
879
|
+
/** 日志列表上限(T4#4 递延项):超出环形截断最旧行,防长会话无界增长 */
|
|
880
|
+
const LOGS_LIMIT = 2e3;
|
|
183
881
|
/** 全局日志条目(响应式列表,单例) */
|
|
184
882
|
const entries = ref([]);
|
|
185
883
|
function now() {
|
|
@@ -196,6 +894,7 @@ function useLogs() {
|
|
|
196
894
|
level,
|
|
197
895
|
message
|
|
198
896
|
});
|
|
897
|
+
if (entries.value.length > 2e3) entries.value.splice(0, entries.value.length - LOGS_LIMIT);
|
|
199
898
|
};
|
|
200
899
|
return {
|
|
201
900
|
logs: entries,
|
|
@@ -211,13 +910,200 @@ function useLogs() {
|
|
|
211
910
|
};
|
|
212
911
|
}
|
|
213
912
|
//#endregion
|
|
913
|
+
//#region src/tui/composables/useContainers.ts
|
|
914
|
+
/** docker ps 一行 → 行 VM(字段透传,展示裁剪在组件) */
|
|
915
|
+
function toRow$2(c) {
|
|
916
|
+
return {
|
|
917
|
+
id: c.id,
|
|
918
|
+
name: c.name,
|
|
919
|
+
image: c.image,
|
|
920
|
+
state: c.state,
|
|
921
|
+
status: c.status,
|
|
922
|
+
ports: c.ports
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Containers 面板数据面(M2-T5):DockerApi → 响应式 ViewModel + 破坏性动作执行面。
|
|
927
|
+
* 破坏性动作(restart/stop/remove)的二次确认在 ContainersPanel(ConfirmModal);此处只执行。
|
|
928
|
+
*/
|
|
929
|
+
function useContainers(opts = {}) {
|
|
930
|
+
const docker = () => opts.docker ?? createDocker();
|
|
931
|
+
const rows = ref([]);
|
|
932
|
+
const error = ref(void 0);
|
|
933
|
+
const following = ref(void 0);
|
|
934
|
+
const { info, warn, error: logError, pushLine } = useLogs();
|
|
935
|
+
/** 过期刷新丢弃(快速切面板/连按 f 不得交错回写) */
|
|
936
|
+
let seq = 0;
|
|
937
|
+
async function refresh() {
|
|
938
|
+
const my = ++seq;
|
|
939
|
+
try {
|
|
940
|
+
const list = (await docker().listContainers({ all: true })).map(toRow$2);
|
|
941
|
+
if (my !== seq) return;
|
|
942
|
+
rows.value = list;
|
|
943
|
+
error.value = void 0;
|
|
944
|
+
} catch (err) {
|
|
945
|
+
if (my !== seq) return;
|
|
946
|
+
rows.value = [];
|
|
947
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
async function followLogs(idOrName) {
|
|
951
|
+
if (following.value !== void 0) {
|
|
952
|
+
warn(`已在跟随容器 ${following.value} 的日志,忽略新请求: ${idOrName}`);
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
following.value = idOrName;
|
|
956
|
+
info(`跟随容器日志: ${idOrName}(tail 200 + follow,Output 面板查看)`);
|
|
957
|
+
try {
|
|
958
|
+
const result = await docker().logs(idOrName, {
|
|
959
|
+
tail: 200,
|
|
960
|
+
follow: true,
|
|
961
|
+
onLine: pushLine
|
|
962
|
+
});
|
|
963
|
+
if (result.code !== 0) logError(`容器日志跟随中断: ${idOrName}(exit ${result.code})`);
|
|
964
|
+
} catch (err) {
|
|
965
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
966
|
+
logError(`容器日志跟随失败: ${idOrName}: ${reason}`);
|
|
967
|
+
} finally {
|
|
968
|
+
following.value = void 0;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return {
|
|
972
|
+
rows,
|
|
973
|
+
error,
|
|
974
|
+
following,
|
|
975
|
+
refresh,
|
|
976
|
+
restart: (idOrName) => docker().restart(idOrName),
|
|
977
|
+
stop: (idOrName) => docker().stop(idOrName),
|
|
978
|
+
remove: (idOrName, o) => docker().remove(idOrName, o),
|
|
979
|
+
followLogs
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/tui/composables/useHealth.ts
|
|
984
|
+
/** ProjectHealth → 三列单元格(复刻 CLI status formatRow 口径) */
|
|
985
|
+
function toRow$1(health) {
|
|
986
|
+
const total = health.containers.length;
|
|
987
|
+
const running = health.containers.filter((c) => c.state === "running").length;
|
|
988
|
+
return {
|
|
989
|
+
name: health.name,
|
|
990
|
+
containers: total === 0 ? "无容器" : `${running}/${total} running`,
|
|
991
|
+
http: health.http === void 0 ? "-" : health.http.ok ? String(health.http.status) : "FAIL",
|
|
992
|
+
nginx: health.nginxPresent === void 0 ? "-" : health.nginxPresent ? "✓" : "✗"
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
/** 坏配置行降级(口径同 CLI status:`项目配置不可用: <name>: <reason>`) */
|
|
996
|
+
function configErrorRow(project) {
|
|
997
|
+
const reason = project.error ?? "";
|
|
998
|
+
return {
|
|
999
|
+
name: project.name,
|
|
1000
|
+
containers: "配置不可用",
|
|
1001
|
+
http: "-",
|
|
1002
|
+
nginx: "-",
|
|
1003
|
+
error: `项目配置不可用: ${project.name}: ${reason}`
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
/** 单项目检查失败降级(M2-T2 #10 的 UI 面:`检查失败` 行 + 继续,口径同 CLI status) */
|
|
1007
|
+
function checkErrorRow(name, reason) {
|
|
1008
|
+
return {
|
|
1009
|
+
name,
|
|
1010
|
+
containers: "检查失败",
|
|
1011
|
+
http: "-",
|
|
1012
|
+
nginx: "-",
|
|
1013
|
+
error: `项目健康检查失败: ${name}: ${reason}`
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Status 面板数据面(M2-T5):逐项目 checkProjectHealth 聚合 → 响应式行列表。
|
|
1018
|
+
* 单项目异常按行降级(配置不可用/检查失败行 + 继续),不得一坏全断(M2-T2 #10)。
|
|
1019
|
+
*/
|
|
1020
|
+
function useHealth(opts = {}) {
|
|
1021
|
+
const rows = ref([]);
|
|
1022
|
+
const error = ref(void 0);
|
|
1023
|
+
/** 过期刷新丢弃(HTTP 探测可达数秒,快速连刷不得交错回写) */
|
|
1024
|
+
let seq = 0;
|
|
1025
|
+
async function rowFor(project) {
|
|
1026
|
+
if (!project.config) return configErrorRow(project);
|
|
1027
|
+
try {
|
|
1028
|
+
return toRow$1(await checkProjectHealth(project.config, {
|
|
1029
|
+
docker: opts.docker,
|
|
1030
|
+
runner: opts.runner,
|
|
1031
|
+
nginx: opts.nginx
|
|
1032
|
+
}));
|
|
1033
|
+
} catch (err) {
|
|
1034
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1035
|
+
return checkErrorRow(project.name, reason);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
async function refresh() {
|
|
1039
|
+
const my = ++seq;
|
|
1040
|
+
let projects;
|
|
1041
|
+
try {
|
|
1042
|
+
projects = listProjects(opts.load ? opts.load() : loadConfig());
|
|
1043
|
+
error.value = void 0;
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
rows.value = [];
|
|
1046
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const out = [];
|
|
1050
|
+
for (const project of projects) {
|
|
1051
|
+
if (my !== seq) return;
|
|
1052
|
+
out.push(await rowFor(project));
|
|
1053
|
+
if (my === seq) rows.value = [...out];
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return {
|
|
1057
|
+
rows,
|
|
1058
|
+
error,
|
|
1059
|
+
refresh
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/tui/composables/useProjects.ts
|
|
1064
|
+
/** RegisteredProject → 行 VM:坏配置降级 type '-' + ERROR 列(listProjects 已做单行降级) */
|
|
1065
|
+
function toRow(project) {
|
|
1066
|
+
return {
|
|
1067
|
+
name: project.name,
|
|
1068
|
+
path: project.path,
|
|
1069
|
+
type: project.config?.type ?? "-",
|
|
1070
|
+
error: project.error
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Projects 面板数据面(M2-T5):core(loadConfig+listProjects)→ 响应式 ViewModel。
|
|
1075
|
+
* 组件只吃 VM;注册表读取失败降级为单行错误提示,不抛。
|
|
1076
|
+
*/
|
|
1077
|
+
function useProjects(opts = {}) {
|
|
1078
|
+
const rows = ref([]);
|
|
1079
|
+
const error = ref(void 0);
|
|
1080
|
+
function refresh() {
|
|
1081
|
+
try {
|
|
1082
|
+
const cfg = opts.load ? opts.load() : loadConfig();
|
|
1083
|
+
rows.value = listProjects(cfg).map(toRow);
|
|
1084
|
+
error.value = void 0;
|
|
1085
|
+
} catch (err) {
|
|
1086
|
+
rows.value = [];
|
|
1087
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return {
|
|
1091
|
+
rows,
|
|
1092
|
+
error,
|
|
1093
|
+
refresh
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
//#endregion
|
|
214
1097
|
//#region src/tui/App.vue
|
|
215
1098
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
216
1099
|
__name: "App",
|
|
217
1100
|
setup(__props, { expose: __expose }) {
|
|
218
1101
|
__expose();
|
|
219
1102
|
const { exit } = useApp();
|
|
220
|
-
const { logs } = useLogs();
|
|
1103
|
+
const { logs, info, success, error: logError } = useLogs();
|
|
1104
|
+
const { rows: projectRows, error: projectError, refresh: refreshProjects } = useProjects();
|
|
1105
|
+
const { rows: containerRows, error: containerError, following, refresh: refreshContainers, restart, stop, remove, followLogs } = useContainers();
|
|
1106
|
+
const { rows: healthRows, error: healthError, refresh: refreshHealth } = useHealth();
|
|
221
1107
|
const activePanel = ref("projects");
|
|
222
1108
|
const helpVisible = ref(false);
|
|
223
1109
|
useKeymap({
|
|
@@ -230,11 +1116,59 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
230
1116
|
helpVisible.value = !helpVisible.value;
|
|
231
1117
|
}
|
|
232
1118
|
});
|
|
1119
|
+
watch(activePanel, (panel) => {
|
|
1120
|
+
if (panel === "projects") refreshProjects();
|
|
1121
|
+
else if (panel === "containers") refreshContainers();
|
|
1122
|
+
else if (panel === "status") refreshHealth();
|
|
1123
|
+
}, { immediate: true });
|
|
1124
|
+
const ACTION_LABEL = {
|
|
1125
|
+
restart: "重启",
|
|
1126
|
+
stop: "停止",
|
|
1127
|
+
remove: "删除"
|
|
1128
|
+
};
|
|
1129
|
+
/** Containers 破坏性动作(面板 ConfirmModal 确认后才到达此处):执行 → 日志 → 刷新列表 */
|
|
1130
|
+
async function onContainerAction(action, name) {
|
|
1131
|
+
info(`${ACTION_LABEL[action]}容器: ${name}`);
|
|
1132
|
+
try {
|
|
1133
|
+
const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name);
|
|
1134
|
+
if (result.code === 0) {
|
|
1135
|
+
success(`${ACTION_LABEL[action]}容器成功: ${name}`);
|
|
1136
|
+
await refreshContainers();
|
|
1137
|
+
} else logError(`${ACTION_LABEL[action]}容器失败: ${name}(exit ${result.code})`);
|
|
1138
|
+
} catch (err) {
|
|
1139
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1140
|
+
logError(`${ACTION_LABEL[action]}容器失败: ${name}: ${reason}`);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
/** 日志跟随:useContainers.followLogs → core onLine → useLogs → Output 面板 */
|
|
1144
|
+
function onLogs(name) {
|
|
1145
|
+
followLogs(name);
|
|
1146
|
+
}
|
|
233
1147
|
const __returned__ = {
|
|
234
1148
|
exit,
|
|
235
1149
|
logs,
|
|
1150
|
+
info,
|
|
1151
|
+
success,
|
|
1152
|
+
logError,
|
|
1153
|
+
projectRows,
|
|
1154
|
+
projectError,
|
|
1155
|
+
refreshProjects,
|
|
1156
|
+
containerRows,
|
|
1157
|
+
containerError,
|
|
1158
|
+
following,
|
|
1159
|
+
refreshContainers,
|
|
1160
|
+
restart,
|
|
1161
|
+
stop,
|
|
1162
|
+
remove,
|
|
1163
|
+
followLogs,
|
|
1164
|
+
healthRows,
|
|
1165
|
+
healthError,
|
|
1166
|
+
refreshHealth,
|
|
236
1167
|
activePanel,
|
|
237
1168
|
helpVisible,
|
|
1169
|
+
ACTION_LABEL,
|
|
1170
|
+
onContainerAction,
|
|
1171
|
+
onLogs,
|
|
238
1172
|
panelTitle: computed(() => `${PANEL_IDS.indexOf(activePanel.value) + 1}. ${PANEL_TITLES[activePanel.value]}`),
|
|
239
1173
|
get Box() {
|
|
240
1174
|
return Box;
|
|
@@ -242,7 +1176,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
242
1176
|
get Text() {
|
|
243
1177
|
return Text;
|
|
244
1178
|
},
|
|
1179
|
+
ContainersPanel: ContainersPanel_default,
|
|
245
1180
|
OutputPanel: OutputPanel_default,
|
|
1181
|
+
ProjectsPanel: ProjectsPanel_default,
|
|
1182
|
+
StatusPanel: StatusPanel_default,
|
|
246
1183
|
StatusBar: StatusBar_default,
|
|
247
1184
|
get PANEL_IDS() {
|
|
248
1185
|
return PANEL_IDS;
|
|
@@ -275,25 +1212,58 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
275
1212
|
bold: "",
|
|
276
1213
|
color: "cyan"
|
|
277
1214
|
}, {
|
|
278
|
-
default: withCtx(() => [..._cache[
|
|
1215
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("Deploy CLI", -1)])]),
|
|
279
1216
|
_: 1
|
|
280
1217
|
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
281
|
-
default: withCtx(() => [..._cache[
|
|
1218
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
|
|
282
1219
|
_: 1
|
|
283
1220
|
})]),
|
|
284
1221
|
_: 1
|
|
285
1222
|
}),
|
|
286
|
-
createCommentVNode(" 主面板区:1
|
|
1223
|
+
createCommentVNode(" 主面板区:1/2/4/6 实装,3 Deploy(T6)/5 Tunnels(T7)骨架占位 "),
|
|
287
1224
|
createVNode($setup["Box"], {
|
|
288
1225
|
flexDirection: "column",
|
|
289
1226
|
flexGrow: 1,
|
|
290
1227
|
paddingX: 1
|
|
291
1228
|
}, {
|
|
292
|
-
default: withCtx(() => [$setup.activePanel === "
|
|
1229
|
+
default: withCtx(() => [createCommentVNode(" 项目动作出口(deploy)先挂 emit,T6 接线 "), $setup.activePanel === "projects" ? (openBlock(), createBlock($setup["ProjectsPanel"], {
|
|
293
1230
|
key: 0,
|
|
1231
|
+
rows: $setup.projectRows,
|
|
1232
|
+
error: $setup.projectError,
|
|
1233
|
+
onRefresh: $setup.refreshProjects
|
|
1234
|
+
}, null, 8, [
|
|
1235
|
+
"rows",
|
|
1236
|
+
"error",
|
|
1237
|
+
"onRefresh"
|
|
1238
|
+
])) : $setup.activePanel === "containers" ? (openBlock(), createBlock($setup["ContainersPanel"], {
|
|
1239
|
+
key: 1,
|
|
1240
|
+
rows: $setup.containerRows,
|
|
1241
|
+
error: $setup.containerError,
|
|
1242
|
+
following: $setup.following,
|
|
1243
|
+
onLogs: $setup.onLogs,
|
|
1244
|
+
onRestart: _cache[0] || (_cache[0] = (name) => $setup.onContainerAction("restart", name)),
|
|
1245
|
+
onStop: _cache[1] || (_cache[1] = (name) => $setup.onContainerAction("stop", name)),
|
|
1246
|
+
onRemove: _cache[2] || (_cache[2] = (name) => $setup.onContainerAction("remove", name)),
|
|
1247
|
+
onRefresh: $setup.refreshContainers
|
|
1248
|
+
}, null, 8, [
|
|
1249
|
+
"rows",
|
|
1250
|
+
"error",
|
|
1251
|
+
"following",
|
|
1252
|
+
"onRefresh"
|
|
1253
|
+
])) : $setup.activePanel === "status" ? (openBlock(), createBlock($setup["StatusPanel"], {
|
|
1254
|
+
key: 2,
|
|
1255
|
+
rows: $setup.healthRows,
|
|
1256
|
+
error: $setup.healthError,
|
|
1257
|
+
onRefresh: $setup.refreshHealth
|
|
1258
|
+
}, null, 8, [
|
|
1259
|
+
"rows",
|
|
1260
|
+
"error",
|
|
1261
|
+
"onRefresh"
|
|
1262
|
+
])) : $setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
|
|
1263
|
+
key: 3,
|
|
294
1264
|
logs: $setup.logs
|
|
295
1265
|
}, null, 8, ["logs"])) : (openBlock(), createBlock($setup["Box"], {
|
|
296
|
-
key:
|
|
1266
|
+
key: 4,
|
|
297
1267
|
flexDirection: "column",
|
|
298
1268
|
flexGrow: 1,
|
|
299
1269
|
borderStyle: "round",
|
|
@@ -306,7 +1276,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
306
1276
|
default: withCtx(() => [createTextVNode(toDisplayString($setup.panelTitle), 1)]),
|
|
307
1277
|
_: 1
|
|
308
1278
|
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
309
|
-
default: withCtx(() => [..._cache[
|
|
1279
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
|
|
310
1280
|
_: 1
|
|
311
1281
|
})]),
|
|
312
1282
|
_: 1
|
|
@@ -327,7 +1297,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
327
1297
|
bold: "",
|
|
328
1298
|
color: "yellow"
|
|
329
1299
|
}, {
|
|
330
|
-
default: withCtx(() => [..._cache[
|
|
1300
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("快捷键帮助", -1)])]),
|
|
331
1301
|
_: 1
|
|
332
1302
|
}),
|
|
333
1303
|
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.PANEL_IDS, (id, i) => {
|
|
@@ -337,7 +1307,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
337
1307
|
}, 1024);
|
|
338
1308
|
}), 128)),
|
|
339
1309
|
createVNode($setup["Text"], null, {
|
|
340
|
-
default: withCtx(() => [..._cache[
|
|
1310
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
|
|
341
1311
|
_: 1
|
|
342
1312
|
})
|
|
343
1313
|
]),
|