@dongnanyang/deploy-cli 0.11.0 → 0.12.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/tui/main.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { s as listProjects } from "../project-
|
|
2
|
-
import { n as loadConfig } from "../config-xUl8Oa3T.js";
|
|
1
|
+
import { a as generateCompose, b as isValidSlug, i as createManagedProject, l as managedComposeExists, s as listProjects, u as managedDir } from "../project-BL00JHAo.js";
|
|
2
|
+
import { n as loadConfig, t as expandPath } from "../config-xUl8Oa3T.js";
|
|
3
3
|
import { t as export_helper_default } from "../export-helper-CIEcxb5I.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as createDocker, n as runDeploy, r as checkProjectHealth } from "../deploy-DNT8Hzl1.js";
|
|
5
|
+
import { stringify } from "yaml";
|
|
5
6
|
import { Box, Text, createApp, useApp, useInput } from "@vue-tui/runtime";
|
|
6
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, shallowRef, toDisplayString, watch, withCtx } from "vue";
|
|
7
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, onScopeDispose, openBlock, reactive, ref, renderList, shallowRef, toDisplayString, toValue, watch, withCtx } from "vue";
|
|
7
8
|
import { ScrollBox } from "@vue-tui/components";
|
|
8
9
|
//#region src/tui/composables/useKeymap.ts
|
|
9
10
|
/** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
|
|
@@ -49,9 +50,27 @@ function dispatchKey(event) {
|
|
|
49
50
|
if (ch === "?") return { kind: "help" };
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
53
|
+
/** 模态挂载集(R17):任一确认弹窗可见 = 全局键 1-6/q/? 停用(弹窗独占 y/n/enter/escape),防按 3 静默丢弃待确认动作 / 按 q 中途退出 */
|
|
54
|
+
const modalTokens = /* @__PURE__ */ new Set();
|
|
55
|
+
const modalOpen = ref(false);
|
|
56
|
+
/**
|
|
57
|
+
* 模态登记(ConfirmModal 在 visible 时挂闸):期间 useKeymap 全局分发暂停。
|
|
58
|
+
* 按组件实例计数(token 随作用域释放),多弹窗/卸载不残留。
|
|
59
|
+
*/
|
|
60
|
+
function useModalGate(visible) {
|
|
61
|
+
const token = {};
|
|
62
|
+
const sync = (open) => {
|
|
63
|
+
if (open) modalTokens.add(token);
|
|
64
|
+
else modalTokens.delete(token);
|
|
65
|
+
modalOpen.value = modalTokens.size > 0;
|
|
66
|
+
};
|
|
67
|
+
watch(() => toValue(visible), sync, { immediate: true });
|
|
68
|
+
onScopeDispose(() => sync(false));
|
|
69
|
+
}
|
|
52
70
|
/** 键位路由接线:useInput 订阅 → dispatchKey → 回调;组件不碰输入流本体 */
|
|
53
71
|
function useKeymap(handlers) {
|
|
54
72
|
useInput((event) => {
|
|
73
|
+
if (modalOpen.value) return;
|
|
55
74
|
const action = dispatchKey(event);
|
|
56
75
|
if (action === null) return;
|
|
57
76
|
if (action.kind === "panel") handlers.onPanel(action.panel);
|
|
@@ -65,8 +84,9 @@ function useKeymap(handlers) {
|
|
|
65
84
|
* 破坏性动作二次确认弹窗(spec §6.3:down/rm/restart 等 TUI 需确认)。
|
|
66
85
|
* 只吃 ViewModel(visible/message),动作由父组件在 confirm 事件后执行。
|
|
67
86
|
* 键位:y/enter 确认、n/escape 取消;不可见时不响应。
|
|
87
|
+
* R17:visible 期间挂模态闸——全局键 1-6/q/? 一并停用(弹窗独占输入)。
|
|
68
88
|
*/
|
|
69
|
-
const _sfc_main$
|
|
89
|
+
const _sfc_main$8 = /*@__PURE__*/ defineComponent({
|
|
70
90
|
__name: "ConfirmModal",
|
|
71
91
|
props: {
|
|
72
92
|
visible: {
|
|
@@ -83,6 +103,7 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
|
83
103
|
__expose();
|
|
84
104
|
const props = __props;
|
|
85
105
|
const emit = __emit;
|
|
106
|
+
useModalGate(() => props.visible);
|
|
86
107
|
useInput((event) => {
|
|
87
108
|
if (!props.visible) return;
|
|
88
109
|
const name = keyName(event);
|
|
@@ -106,7 +127,7 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
|
106
127
|
return __returned__;
|
|
107
128
|
}
|
|
108
129
|
});
|
|
109
|
-
function _sfc_render$
|
|
130
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
110
131
|
return $setup.props.visible ? (openBlock(), createBlock($setup["Box"], {
|
|
111
132
|
key: 0,
|
|
112
133
|
flexDirection: "column",
|
|
@@ -135,10 +156,10 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
135
156
|
_: 1
|
|
136
157
|
})) : createCommentVNode("v-if", true);
|
|
137
158
|
}
|
|
138
|
-
var ConfirmModal_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
159
|
+
var ConfirmModal_default = /*#__PURE__*/ export_helper_default(_sfc_main$8, [["render", _sfc_render$8], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ConfirmModal.vue"]]);
|
|
139
160
|
//#endregion
|
|
140
161
|
//#region src/tui/components/ContainersPanel.vue
|
|
141
|
-
const _sfc_main$
|
|
162
|
+
const _sfc_main$7 = /*@__PURE__*/ defineComponent({
|
|
142
163
|
__name: "ContainersPanel",
|
|
143
164
|
props: {
|
|
144
165
|
rows: {
|
|
@@ -165,14 +186,15 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
|
165
186
|
__expose();
|
|
166
187
|
const props = __props;
|
|
167
188
|
const emit = __emit;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
189
|
+
/** 确认文案(R18:删除=停止并强制删除,文案与语义一致) */
|
|
190
|
+
const CONFIRM_MESSAGE = {
|
|
191
|
+
restart: (name) => `确认重启容器 ${name}?`,
|
|
192
|
+
stop: (name) => `确认停止容器 ${name}?`,
|
|
193
|
+
remove: (name) => `将停止并强制删除容器 ${name}?`
|
|
172
194
|
};
|
|
173
195
|
const sel = ref(0);
|
|
174
196
|
const pending = ref(null);
|
|
175
|
-
const confirmMessage = computed(() => pending.value === null ? "" :
|
|
197
|
+
const confirmMessage = computed(() => pending.value === null ? "" : CONFIRM_MESSAGE[pending.value.action](pending.value.name));
|
|
176
198
|
watch(() => props.rows.length, () => {
|
|
177
199
|
sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
|
|
178
200
|
});
|
|
@@ -208,7 +230,7 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
|
208
230
|
const __returned__ = {
|
|
209
231
|
props,
|
|
210
232
|
emit,
|
|
211
|
-
|
|
233
|
+
CONFIRM_MESSAGE,
|
|
212
234
|
sel,
|
|
213
235
|
pending,
|
|
214
236
|
confirmMessage,
|
|
@@ -228,7 +250,7 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
|
228
250
|
return __returned__;
|
|
229
251
|
}
|
|
230
252
|
});
|
|
231
|
-
function _sfc_render$
|
|
253
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
232
254
|
return openBlock(), createBlock($setup["Box"], {
|
|
233
255
|
flexDirection: "column",
|
|
234
256
|
flexGrow: 1,
|
|
@@ -369,7 +391,206 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
369
391
|
_: 1
|
|
370
392
|
});
|
|
371
393
|
}
|
|
372
|
-
var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
394
|
+
var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$7, [["render", _sfc_render$7], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ContainersPanel.vue"]]);
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/tui/components/DeployPanel.vue
|
|
397
|
+
/**
|
|
398
|
+
* Deploy 面板(spec 6.4):流水线步骤条 update→pre→build→up→nginx→health→post(R10)+ 实时日志流。
|
|
399
|
+
* 只吃 ViewModel(useDeployRun);发起部署入口在 Projects 面板 d(App 接线)。
|
|
400
|
+
* 失败即停视觉呈现:fail 步标「失败」,其后步骤标「跳过」。
|
|
401
|
+
*/
|
|
402
|
+
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
403
|
+
__name: "DeployPanel",
|
|
404
|
+
props: {
|
|
405
|
+
projectName: {
|
|
406
|
+
type: String,
|
|
407
|
+
required: false
|
|
408
|
+
},
|
|
409
|
+
steps: {
|
|
410
|
+
type: Array,
|
|
411
|
+
required: true
|
|
412
|
+
},
|
|
413
|
+
lines: {
|
|
414
|
+
type: Array,
|
|
415
|
+
required: true
|
|
416
|
+
},
|
|
417
|
+
running: {
|
|
418
|
+
type: Boolean,
|
|
419
|
+
required: true
|
|
420
|
+
},
|
|
421
|
+
done: {
|
|
422
|
+
type: String,
|
|
423
|
+
required: false
|
|
424
|
+
},
|
|
425
|
+
failedStep: {
|
|
426
|
+
type: String,
|
|
427
|
+
required: false
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
setup(__props, { expose: __expose }) {
|
|
431
|
+
__expose();
|
|
432
|
+
const __returned__ = {
|
|
433
|
+
props: __props,
|
|
434
|
+
STATUS_TEXT: {
|
|
435
|
+
pending: "待执行",
|
|
436
|
+
running: "进行中",
|
|
437
|
+
ok: "成功",
|
|
438
|
+
fail: "失败",
|
|
439
|
+
skipped: "跳过"
|
|
440
|
+
},
|
|
441
|
+
STATUS_MARK: {
|
|
442
|
+
pending: "○",
|
|
443
|
+
running: "▸",
|
|
444
|
+
ok: "✓",
|
|
445
|
+
fail: "✗",
|
|
446
|
+
skipped: "-"
|
|
447
|
+
},
|
|
448
|
+
STATUS_COLOR: {
|
|
449
|
+
pending: void 0,
|
|
450
|
+
running: "cyan",
|
|
451
|
+
ok: "green",
|
|
452
|
+
fail: "red",
|
|
453
|
+
skipped: "yellow"
|
|
454
|
+
},
|
|
455
|
+
get Box() {
|
|
456
|
+
return Box;
|
|
457
|
+
},
|
|
458
|
+
get Text() {
|
|
459
|
+
return Text;
|
|
460
|
+
},
|
|
461
|
+
get ScrollBox() {
|
|
462
|
+
return ScrollBox;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
466
|
+
enumerable: false,
|
|
467
|
+
value: true
|
|
468
|
+
});
|
|
469
|
+
return __returned__;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
473
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
474
|
+
flexDirection: "column",
|
|
475
|
+
flexGrow: 1,
|
|
476
|
+
borderStyle: "round",
|
|
477
|
+
borderColor: "cyan",
|
|
478
|
+
padding: 1
|
|
479
|
+
}, {
|
|
480
|
+
default: withCtx(() => [
|
|
481
|
+
createVNode($setup["Text"], {
|
|
482
|
+
bold: "",
|
|
483
|
+
color: "cyan"
|
|
484
|
+
}, {
|
|
485
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("3. Deploy 部署", -1)])]),
|
|
486
|
+
_: 1
|
|
487
|
+
}),
|
|
488
|
+
$setup.props.projectName === void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
489
|
+
key: 0,
|
|
490
|
+
dimColor: ""
|
|
491
|
+
}, {
|
|
492
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("(暂无部署任务——Projects 面板 n 新建、选中项目按 d 部署)", -1)])]),
|
|
493
|
+
_: 1
|
|
494
|
+
})) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
495
|
+
$setup.props.running ? (openBlock(), createBlock($setup["Text"], {
|
|
496
|
+
key: 0,
|
|
497
|
+
color: "cyan"
|
|
498
|
+
}, {
|
|
499
|
+
default: withCtx(() => [createTextVNode("部署中: " + toDisplayString($setup.props.projectName), 1)]),
|
|
500
|
+
_: 1
|
|
501
|
+
})) : $setup.props.done === "ok" ? (openBlock(), createBlock($setup["Text"], {
|
|
502
|
+
key: 1,
|
|
503
|
+
color: "green"
|
|
504
|
+
}, {
|
|
505
|
+
default: withCtx(() => [createTextVNode("部署成功: " + toDisplayString($setup.props.projectName), 1)]),
|
|
506
|
+
_: 1
|
|
507
|
+
})) : $setup.props.done === "fail" ? (openBlock(), createBlock($setup["Text"], {
|
|
508
|
+
key: 2,
|
|
509
|
+
color: "red"
|
|
510
|
+
}, {
|
|
511
|
+
default: withCtx(() => [createTextVNode("部署失败: " + toDisplayString($setup.props.projectName) + "(步骤: " + toDisplayString($setup.props.failedStep ?? "未知") + ")", 1)]),
|
|
512
|
+
_: 1
|
|
513
|
+
})) : (openBlock(), createBlock($setup["Text"], { key: 3 }, {
|
|
514
|
+
default: withCtx(() => [createTextVNode("待部署: " + toDisplayString($setup.props.projectName), 1)]),
|
|
515
|
+
_: 1
|
|
516
|
+
})),
|
|
517
|
+
createCommentVNode(" 步骤条(R10 顺序,失败即停=后续「跳过」) "),
|
|
518
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.steps, (s) => {
|
|
519
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
520
|
+
key: s.key,
|
|
521
|
+
flexDirection: "row"
|
|
522
|
+
}, {
|
|
523
|
+
default: withCtx(() => [
|
|
524
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
525
|
+
default: withCtx(() => [createVNode($setup["Text"], { color: $setup.STATUS_COLOR[s.status] }, {
|
|
526
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.STATUS_MARK[s.status]), 1)]),
|
|
527
|
+
_: 2
|
|
528
|
+
}, 1032, ["color"])]),
|
|
529
|
+
_: 2
|
|
530
|
+
}, 1024),
|
|
531
|
+
createVNode($setup["Box"], { width: 22 }, {
|
|
532
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
533
|
+
wrap: "truncate",
|
|
534
|
+
bold: s.status === "running"
|
|
535
|
+
}, {
|
|
536
|
+
default: withCtx(() => [createTextVNode(toDisplayString(s.label), 1)]),
|
|
537
|
+
_: 2
|
|
538
|
+
}, 1032, ["bold"])]),
|
|
539
|
+
_: 2
|
|
540
|
+
}, 1024),
|
|
541
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
542
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
543
|
+
color: $setup.STATUS_COLOR[s.status],
|
|
544
|
+
wrap: "truncate"
|
|
545
|
+
}, {
|
|
546
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.STATUS_TEXT[s.status]), 1)]),
|
|
547
|
+
_: 2
|
|
548
|
+
}, 1032, ["color"])]),
|
|
549
|
+
_: 2
|
|
550
|
+
}, 1024)
|
|
551
|
+
]),
|
|
552
|
+
_: 2
|
|
553
|
+
}, 1024);
|
|
554
|
+
}), 128)),
|
|
555
|
+
createCommentVNode(" 实时日志流 "),
|
|
556
|
+
createVNode($setup["Text"], { bold: "" }, {
|
|
557
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("日志流:", -1)])]),
|
|
558
|
+
_: 1
|
|
559
|
+
}),
|
|
560
|
+
$setup.props.lines.length === 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
561
|
+
key: 4,
|
|
562
|
+
dimColor: ""
|
|
563
|
+
}, {
|
|
564
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("(暂无日志)", -1)])]),
|
|
565
|
+
_: 1
|
|
566
|
+
})) : (openBlock(), createBlock($setup["ScrollBox"], {
|
|
567
|
+
key: 5,
|
|
568
|
+
flexGrow: 1
|
|
569
|
+
}, {
|
|
570
|
+
default: withCtx(() => [createVNode($setup["Box"], { flexDirection: "column" }, {
|
|
571
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.lines, (line, i) => {
|
|
572
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
573
|
+
key: i,
|
|
574
|
+
wrap: "truncate"
|
|
575
|
+
}, {
|
|
576
|
+
default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
|
|
577
|
+
_: 2
|
|
578
|
+
}, 1024);
|
|
579
|
+
}), 128))]),
|
|
580
|
+
_: 1
|
|
581
|
+
})]),
|
|
582
|
+
_: 1
|
|
583
|
+
}))
|
|
584
|
+
], 64)),
|
|
585
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
586
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("步骤条实时状态 · 全量日志见 Output 面板", -1)])]),
|
|
587
|
+
_: 1
|
|
588
|
+
})
|
|
589
|
+
]),
|
|
590
|
+
_: 1
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
var DeployPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$6, [["render", _sfc_render$6], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/DeployPanel.vue"]]);
|
|
373
594
|
//#endregion
|
|
374
595
|
//#region src/tui/components/OutputPanel.vue
|
|
375
596
|
/**
|
|
@@ -377,7 +598,7 @@ var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [
|
|
|
377
598
|
* 滚动/截断(T4#4 递延项):ScrollBox 有界视口(内容超高即截断)+ 旧 TUI g/G 键位语义(g 到顶、G 回底跟随)、↑/↓ 逐行;
|
|
378
599
|
* 列表上限在 useLogs(LOGS_LIMIT 环形截断),此处只管视口。
|
|
379
600
|
*/
|
|
380
|
-
const _sfc_main$
|
|
601
|
+
const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
381
602
|
__name: "OutputPanel",
|
|
382
603
|
props: { logs: {
|
|
383
604
|
type: Array,
|
|
@@ -420,7 +641,7 @@ const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
|
420
641
|
return __returned__;
|
|
421
642
|
}
|
|
422
643
|
});
|
|
423
|
-
function _sfc_render$
|
|
644
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
424
645
|
return openBlock(), createBlock($setup["Box"], {
|
|
425
646
|
flexDirection: "column",
|
|
426
647
|
flexGrow: 1,
|
|
@@ -470,14 +691,14 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
470
691
|
_: 1
|
|
471
692
|
});
|
|
472
693
|
}
|
|
473
|
-
var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
694
|
+
var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [["render", _sfc_render$5], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/OutputPanel.vue"]]);
|
|
474
695
|
//#endregion
|
|
475
696
|
//#region src/tui/components/ProjectsPanel.vue
|
|
476
697
|
/**
|
|
477
698
|
* Projects 面板(spec 6.4):项目列表 NAME/PATH/TYPE/ERROR + 动作事件出口。
|
|
478
699
|
* 只吃 ViewModel(rows);动作经 emit 交 App 接线(部署等 T6 接线)。
|
|
479
700
|
*/
|
|
480
|
-
const _sfc_main$
|
|
701
|
+
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
481
702
|
__name: "ProjectsPanel",
|
|
482
703
|
props: {
|
|
483
704
|
rows: {
|
|
@@ -489,7 +710,11 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
489
710
|
required: false
|
|
490
711
|
}
|
|
491
712
|
},
|
|
492
|
-
emits: [
|
|
713
|
+
emits: [
|
|
714
|
+
"deploy",
|
|
715
|
+
"create",
|
|
716
|
+
"refresh"
|
|
717
|
+
],
|
|
493
718
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
494
719
|
__expose();
|
|
495
720
|
const props = __props;
|
|
@@ -500,6 +725,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
500
725
|
});
|
|
501
726
|
useInput((event) => {
|
|
502
727
|
const name = keyName(event);
|
|
728
|
+
if (name === "n") emit("create");
|
|
503
729
|
if (props.rows.length === 0) return;
|
|
504
730
|
if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
|
|
505
731
|
else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
|
|
@@ -524,7 +750,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
524
750
|
return __returned__;
|
|
525
751
|
}
|
|
526
752
|
});
|
|
527
|
-
function _sfc_render$
|
|
753
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
528
754
|
return openBlock(), createBlock($setup["Box"], {
|
|
529
755
|
flexDirection: "column",
|
|
530
756
|
flexGrow: 1,
|
|
@@ -642,21 +868,21 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
642
868
|
}, 1024);
|
|
643
869
|
}), 128)),
|
|
644
870
|
createVNode($setup["Text"], { dimColor: "" }, {
|
|
645
|
-
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("j/k 选择 · d 部署 · f 刷新", -1)])]),
|
|
871
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("j/k 选择 · n 新建(创建向导) · d 部署 · f 刷新", -1)])]),
|
|
646
872
|
_: 1
|
|
647
873
|
})
|
|
648
874
|
]),
|
|
649
875
|
_: 1
|
|
650
876
|
});
|
|
651
877
|
}
|
|
652
|
-
var ProjectsPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
878
|
+
var ProjectsPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$4, [["render", _sfc_render$4], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ProjectsPanel.vue"]]);
|
|
653
879
|
//#endregion
|
|
654
880
|
//#region src/tui/components/StatusPanel.vue
|
|
655
881
|
/**
|
|
656
882
|
* Status 面板(spec 6.4):项目健康聚合 CONTAINERS/HTTP/NGINX(口径同 CLI status 表格)。
|
|
657
883
|
* 只吃 ViewModel(rows);单行错误降级展示(检查失败/配置不可用行 + 继续,M2-T2 #10 的 UI 面)。
|
|
658
884
|
*/
|
|
659
|
-
const _sfc_main$
|
|
885
|
+
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
660
886
|
__name: "StatusPanel",
|
|
661
887
|
props: {
|
|
662
888
|
rows: {
|
|
@@ -693,7 +919,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
693
919
|
return __returned__;
|
|
694
920
|
}
|
|
695
921
|
});
|
|
696
|
-
function _sfc_render$
|
|
922
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
697
923
|
return openBlock(), createBlock($setup["Box"], {
|
|
698
924
|
flexDirection: "column",
|
|
699
925
|
flexGrow: 1,
|
|
@@ -817,10 +1043,10 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
817
1043
|
_: 1
|
|
818
1044
|
});
|
|
819
1045
|
}
|
|
820
|
-
var StatusPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
1046
|
+
var StatusPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$3, [["render", _sfc_render$3], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusPanel.vue"]]);
|
|
821
1047
|
//#endregion
|
|
822
1048
|
//#region src/tui/components/StatusBar.vue
|
|
823
|
-
const _sfc_main$
|
|
1049
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
824
1050
|
__name: "StatusBar",
|
|
825
1051
|
props: {
|
|
826
1052
|
activePanel: {
|
|
@@ -853,7 +1079,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
853
1079
|
return __returned__;
|
|
854
1080
|
}
|
|
855
1081
|
});
|
|
856
|
-
function _sfc_render$
|
|
1082
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
857
1083
|
return openBlock(), createBlock($setup["Box"], {
|
|
858
1084
|
paddingX: 1,
|
|
859
1085
|
flexDirection: "row",
|
|
@@ -873,7 +1099,641 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
873
1099
|
_: 1
|
|
874
1100
|
});
|
|
875
1101
|
}
|
|
876
|
-
var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$
|
|
1102
|
+
var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusBar.vue"]]);
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/tui/composables/useWizard.ts
|
|
1105
|
+
/** 类型步选项(顺序=spec 6.1 compose|image|static) */
|
|
1106
|
+
const TYPE_OPTIONS = [
|
|
1107
|
+
{
|
|
1108
|
+
value: "compose",
|
|
1109
|
+
label: "compose",
|
|
1110
|
+
desc: "源码项目(自行准备 compose 文件放入托管目录)"
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
value: "image",
|
|
1114
|
+
label: "image",
|
|
1115
|
+
desc: "现成镜像(向导生成 docker-compose.yml)"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
value: "static",
|
|
1119
|
+
label: "static",
|
|
1120
|
+
desc: "静态站点(nginx root 直出)"
|
|
1121
|
+
}
|
|
1122
|
+
];
|
|
1123
|
+
/** 三类输入流(表单字段随类型增减) */
|
|
1124
|
+
const FIELDS = {
|
|
1125
|
+
image: [
|
|
1126
|
+
{
|
|
1127
|
+
key: "name",
|
|
1128
|
+
label: "项目名",
|
|
1129
|
+
placeholder: "my-app(小写字母/数字/连字符)"
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
key: "image",
|
|
1133
|
+
label: "镜像",
|
|
1134
|
+
placeholder: "nginx:alpine"
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
key: "ports",
|
|
1138
|
+
label: "端口映射",
|
|
1139
|
+
placeholder: "127.0.0.1:18080:80,多个逗号分隔(可空)"
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
key: "volumes",
|
|
1143
|
+
label: "卷映射",
|
|
1144
|
+
placeholder: "./data:/data,多个逗号分隔(可空)"
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
key: "env",
|
|
1148
|
+
label: "环境变量",
|
|
1149
|
+
placeholder: "FOO=bar, BAZ=qux(可空)"
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
key: "domain",
|
|
1153
|
+
label: "域名",
|
|
1154
|
+
placeholder: "app.example.com(留空=不配置 nginx)"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
key: "upstream",
|
|
1158
|
+
label: "代理目标",
|
|
1159
|
+
placeholder: "127.0.0.1:3000(配 nginx 时必填)"
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
key: "ssl",
|
|
1163
|
+
label: "SSL",
|
|
1164
|
+
placeholder: "none 或 acme(默认 none)"
|
|
1165
|
+
}
|
|
1166
|
+
],
|
|
1167
|
+
compose: [
|
|
1168
|
+
{
|
|
1169
|
+
key: "name",
|
|
1170
|
+
label: "项目名",
|
|
1171
|
+
placeholder: "my-app(小写字母/数字/连字符)"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
key: "services",
|
|
1175
|
+
label: "参与服务",
|
|
1176
|
+
placeholder: "web, worker(可空=全部)"
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
key: "domain",
|
|
1180
|
+
label: "域名",
|
|
1181
|
+
placeholder: "app.example.com(留空=不配置 nginx)"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
key: "upstream",
|
|
1185
|
+
label: "代理目标",
|
|
1186
|
+
placeholder: "127.0.0.1:3000(配 nginx 时必填)"
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
key: "ssl",
|
|
1190
|
+
label: "SSL",
|
|
1191
|
+
placeholder: "none 或 acme(默认 none)"
|
|
1192
|
+
}
|
|
1193
|
+
],
|
|
1194
|
+
static: [
|
|
1195
|
+
{
|
|
1196
|
+
key: "name",
|
|
1197
|
+
label: "项目名",
|
|
1198
|
+
placeholder: "my-app(小写字母/数字/连字符)"
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
key: "root",
|
|
1202
|
+
label: "站点根目录",
|
|
1203
|
+
placeholder: "/var/www/site"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
key: "domain",
|
|
1207
|
+
label: "域名",
|
|
1208
|
+
placeholder: "app.example.com(留空=不配置 nginx)"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
key: "ssl",
|
|
1212
|
+
label: "SSL",
|
|
1213
|
+
placeholder: "none 或 acme(默认 none)"
|
|
1214
|
+
}
|
|
1215
|
+
]
|
|
1216
|
+
};
|
|
1217
|
+
/** 逗号列表字段校验:空=无项;逐项过 check */
|
|
1218
|
+
function listError(value, check) {
|
|
1219
|
+
if (value.trim() === "") return void 0;
|
|
1220
|
+
for (const part of value.split(",")) {
|
|
1221
|
+
const seg = part.trim();
|
|
1222
|
+
if (seg === "") return "存在空项,请去掉多余逗号";
|
|
1223
|
+
const err = check(seg);
|
|
1224
|
+
if (err !== void 0) return err;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
/** 字段级校验(非法即时提示;镜像 core validate 口径:name slug/必填/值域) */
|
|
1228
|
+
function fieldError(type, key, values) {
|
|
1229
|
+
const value = values[key] ?? "";
|
|
1230
|
+
switch (key) {
|
|
1231
|
+
case "name":
|
|
1232
|
+
if (value.trim() === "") return "项目名不能为空";
|
|
1233
|
+
if (!isValidSlug(value)) return "项目名非法:仅允许小写字母、数字与连字符且以字母数字开头";
|
|
1234
|
+
return;
|
|
1235
|
+
case "image": return value.trim() === "" ? "镜像不能为空(如 nginx:alpine)" : void 0;
|
|
1236
|
+
case "root": return value.trim() === "" ? "静态站点根目录不能为空" : void 0;
|
|
1237
|
+
case "ports": return listError(value, (seg) => seg.includes(":") ? void 0 : `端口映射非法: ${seg}(如 127.0.0.1:18080:80)`);
|
|
1238
|
+
case "volumes": return listError(value, (seg) => seg.includes(":") ? void 0 : `卷映射非法: ${seg}(如 ./data:/data)`);
|
|
1239
|
+
case "env": return listError(value, (seg) => /^[A-Za-z_][A-Za-z0-9_]*=/.test(seg) ? void 0 : `环境变量非法: ${seg}(应为 KEY=VALUE)`);
|
|
1240
|
+
case "services": return listError(value, (seg) => /^\S+$/.test(seg) ? void 0 : `服务名非法: ${seg}(不得含空白)`);
|
|
1241
|
+
case "domain": return;
|
|
1242
|
+
case "upstream": return (values["domain"] ?? "").trim() !== "" && type !== "static" && value.trim() === "" ? "代理目标不能为空(如 127.0.0.1:3000)" : void 0;
|
|
1243
|
+
case "ssl":
|
|
1244
|
+
if (value.trim() === "") return void 0;
|
|
1245
|
+
return value.trim() === "none" || value.trim() === "acme" ? void 0 : "SSL 只支持 none 或 acme";
|
|
1246
|
+
default: return;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function splitList(value) {
|
|
1250
|
+
const items = value.split(",").map((s) => s.trim()).filter((s) => s !== "");
|
|
1251
|
+
return items.length > 0 ? items : void 0;
|
|
1252
|
+
}
|
|
1253
|
+
function parseEnv(value) {
|
|
1254
|
+
const env = {};
|
|
1255
|
+
let seen = false;
|
|
1256
|
+
for (const part of value.split(",")) {
|
|
1257
|
+
const seg = part.trim();
|
|
1258
|
+
if (seg === "") continue;
|
|
1259
|
+
const eq = seg.indexOf("=");
|
|
1260
|
+
if (eq <= 0) continue;
|
|
1261
|
+
env[seg.slice(0, eq)] = seg.slice(eq + 1);
|
|
1262
|
+
seen = true;
|
|
1263
|
+
}
|
|
1264
|
+
return seen ? env : void 0;
|
|
1265
|
+
}
|
|
1266
|
+
/** 表单值 → createManagedProject input(Task 3 冻结签名逐字:name/type/image/ports/volumes/env/root/nginx/services) */
|
|
1267
|
+
function toCreateInput(type, values) {
|
|
1268
|
+
const input = {
|
|
1269
|
+
name: (values["name"] ?? "").trim(),
|
|
1270
|
+
type
|
|
1271
|
+
};
|
|
1272
|
+
const services = splitList(values["services"] ?? "");
|
|
1273
|
+
if (services !== void 0) input.services = services;
|
|
1274
|
+
if (type === "image") {
|
|
1275
|
+
input.image = (values["image"] ?? "").trim();
|
|
1276
|
+
const ports = splitList(values["ports"] ?? "");
|
|
1277
|
+
if (ports !== void 0) input.ports = ports;
|
|
1278
|
+
const volumes = splitList(values["volumes"] ?? "");
|
|
1279
|
+
if (volumes !== void 0) input.volumes = volumes;
|
|
1280
|
+
const env = parseEnv(values["env"] ?? "");
|
|
1281
|
+
if (env !== void 0) input.env = env;
|
|
1282
|
+
}
|
|
1283
|
+
if (type === "static") input.root = (values["root"] ?? "").trim();
|
|
1284
|
+
const domain = (values["domain"] ?? "").trim();
|
|
1285
|
+
if (domain !== "") {
|
|
1286
|
+
const upstream = (values["upstream"] ?? "").trim();
|
|
1287
|
+
const ssl = (values["ssl"] ?? "").trim();
|
|
1288
|
+
input.nginx = {
|
|
1289
|
+
domain,
|
|
1290
|
+
...type !== "static" && upstream !== "" ? { upstream } : {},
|
|
1291
|
+
ssl: ssl === "acme" ? "acme" : "none"
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
return input;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* input → 预览 DeployYaml(键序=createManagedProject 落盘口径:validate 归一 +
|
|
1298
|
+
* saveProject 过滤 undefined;compose 型 composeFile 缺省追加在末尾)。
|
|
1299
|
+
* 预览文本与落盘 deploy.yaml 逐字一致由测试锚定。
|
|
1300
|
+
*/
|
|
1301
|
+
function toDeployYaml(input) {
|
|
1302
|
+
const d = {
|
|
1303
|
+
name: input.name,
|
|
1304
|
+
type: input.type
|
|
1305
|
+
};
|
|
1306
|
+
if (input.services !== void 0) d.services = input.services;
|
|
1307
|
+
if (input.type === "image") {
|
|
1308
|
+
d.image = input.image;
|
|
1309
|
+
d.ports = input.ports;
|
|
1310
|
+
d.volumes = input.volumes;
|
|
1311
|
+
d.env = input.env;
|
|
1312
|
+
}
|
|
1313
|
+
if (input.type === "static") d.root = input.root;
|
|
1314
|
+
if (input.nginx !== void 0) d.nginx = input.nginx;
|
|
1315
|
+
if (input.type === "compose") d.composeFile = "docker-compose.yml";
|
|
1316
|
+
return d;
|
|
1317
|
+
}
|
|
1318
|
+
function toPreviewYaml(input) {
|
|
1319
|
+
const out = {};
|
|
1320
|
+
for (const [key, value] of Object.entries(toDeployYaml(input))) if (value !== void 0) out[key] = value;
|
|
1321
|
+
return stringify(out);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* 创建向导数据面(M2-T6):三步状态机 + 逐字消费 createManagedProject(Task 3 冻结签名)。
|
|
1325
|
+
* 落盘前必经预览步(生成物内容可见再确认,ConfirmModal);输出路径恒托管目录。
|
|
1326
|
+
* concern④:compose 型缺 compose 文件不允许完成(二选一引导:放文件进托管目录 / 改走 image 型)。
|
|
1327
|
+
*/
|
|
1328
|
+
function useWizard(opts = {}) {
|
|
1329
|
+
const create = opts.create ?? createManagedProject;
|
|
1330
|
+
const composeExists = opts.composeExists ?? managedComposeExists;
|
|
1331
|
+
const step = ref("type");
|
|
1332
|
+
const typeSel = ref(0);
|
|
1333
|
+
const projectType = ref(TYPE_OPTIONS[0].value);
|
|
1334
|
+
const values = reactive({});
|
|
1335
|
+
const fieldSel = ref(0);
|
|
1336
|
+
const message = ref(void 0);
|
|
1337
|
+
const composeReady = ref(false);
|
|
1338
|
+
const confirmOpen = ref(false);
|
|
1339
|
+
const created = ref(void 0);
|
|
1340
|
+
const fields = computed(() => FIELDS[projectType.value].map((spec, i) => ({
|
|
1341
|
+
key: spec.key,
|
|
1342
|
+
label: spec.label,
|
|
1343
|
+
placeholder: spec.placeholder,
|
|
1344
|
+
value: values[spec.key] ?? "",
|
|
1345
|
+
focused: i === fieldSel.value,
|
|
1346
|
+
error: fieldError(projectType.value, spec.key, values)
|
|
1347
|
+
})));
|
|
1348
|
+
const targetDir = computed(() => {
|
|
1349
|
+
try {
|
|
1350
|
+
return managedDir((values["name"] ?? "").trim());
|
|
1351
|
+
} catch {
|
|
1352
|
+
return "";
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
const previewYaml = computed(() => toPreviewYaml(toCreateInput(projectType.value, values)));
|
|
1356
|
+
const previewCompose = computed(() => {
|
|
1357
|
+
const input = toCreateInput(projectType.value, values);
|
|
1358
|
+
if (input.type !== "image") return void 0;
|
|
1359
|
+
try {
|
|
1360
|
+
return generateCompose(toDeployYaml(input));
|
|
1361
|
+
} catch {
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
/** concern④ 二选一引导(compose 型预览步恒显) */
|
|
1366
|
+
const guidance = computed(() => {
|
|
1367
|
+
if (projectType.value !== "compose") return [];
|
|
1368
|
+
const dir = targetDir.value || "~/.deploy-cli/projects/<name>";
|
|
1369
|
+
return [
|
|
1370
|
+
"compose 型需自行准备 compose 文件(二选一):",
|
|
1371
|
+
`① mkdir -p ${dir} 并放入 ${dir}/docker-compose.yml,再按 c 重新检查(当前: ${composeReady.value ? "已就位" : "未就位"})`,
|
|
1372
|
+
"② esc 返回上一步改选 image 型(向导自动生成 compose 文件)",
|
|
1373
|
+
...composeReady.value ? [] : ["未就位不允许创建:防止造出不可部署项目"]
|
|
1374
|
+
];
|
|
1375
|
+
});
|
|
1376
|
+
function currentFieldKey() {
|
|
1377
|
+
return FIELDS[projectType.value][fieldSel.value]?.key;
|
|
1378
|
+
}
|
|
1379
|
+
function handleTypeKey(name) {
|
|
1380
|
+
if (name === "down" || name === "j") typeSel.value = Math.min(typeSel.value + 1, TYPE_OPTIONS.length - 1);
|
|
1381
|
+
else if (name === "up" || name === "k") typeSel.value = Math.max(typeSel.value - 1, 0);
|
|
1382
|
+
else if (name === "enter") {
|
|
1383
|
+
projectType.value = TYPE_OPTIONS[typeSel.value].value;
|
|
1384
|
+
fieldSel.value = 0;
|
|
1385
|
+
message.value = void 0;
|
|
1386
|
+
step.value = "form";
|
|
1387
|
+
} else if (name === "escape") opts.onClose?.();
|
|
1388
|
+
}
|
|
1389
|
+
function handleFormKey(name) {
|
|
1390
|
+
const specs = FIELDS[projectType.value];
|
|
1391
|
+
const key = currentFieldKey();
|
|
1392
|
+
if (name === "tab" || name === "down") fieldSel.value = (fieldSel.value + 1) % specs.length;
|
|
1393
|
+
else if (name === "up") fieldSel.value = (fieldSel.value - 1 + specs.length) % specs.length;
|
|
1394
|
+
else if (name === "backspace") {
|
|
1395
|
+
if (key !== void 0) values[key] = (values[key] ?? "").slice(0, -1);
|
|
1396
|
+
} else if (name.length === 1) {
|
|
1397
|
+
if (key !== void 0) values[key] = (values[key] ?? "") + name;
|
|
1398
|
+
} else if (name === "enter") {
|
|
1399
|
+
if (fields.value.filter((f) => f.error !== void 0).length > 0) {
|
|
1400
|
+
message.value = "存在非法输入,请修正标红字段后重试";
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
message.value = void 0;
|
|
1404
|
+
if (projectType.value === "compose") composeReady.value = composeExists(values["name"] ?? "");
|
|
1405
|
+
step.value = "preview";
|
|
1406
|
+
} else if (name === "escape") step.value = "type";
|
|
1407
|
+
}
|
|
1408
|
+
function handlePreviewKey(name) {
|
|
1409
|
+
if (name === "c" && projectType.value === "compose") {
|
|
1410
|
+
composeReady.value = composeExists(values["name"] ?? "");
|
|
1411
|
+
message.value = void 0;
|
|
1412
|
+
} else if (name === "enter") {
|
|
1413
|
+
if (projectType.value === "compose" && !composeReady.value) {
|
|
1414
|
+
message.value = "compose 文件未就位:请将 docker-compose.yml 放入托管目录(见上方二选一指引),或返回改选 image 型";
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
message.value = void 0;
|
|
1418
|
+
confirmOpen.value = true;
|
|
1419
|
+
} else if (name === "escape") step.value = "form";
|
|
1420
|
+
}
|
|
1421
|
+
function handleKey(name) {
|
|
1422
|
+
if (confirmOpen.value) return;
|
|
1423
|
+
if (created.value !== void 0) {
|
|
1424
|
+
if (name === "enter" || name === "escape") opts.onClose?.();
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
if (step.value === "type") handleTypeKey(name);
|
|
1428
|
+
else if (step.value === "form") handleFormKey(name);
|
|
1429
|
+
else handlePreviewKey(name);
|
|
1430
|
+
}
|
|
1431
|
+
/** 落盘(ConfirmModal y):走 createManagedProject;失败降级 message 留在预览步可重试 */
|
|
1432
|
+
function confirm() {
|
|
1433
|
+
confirmOpen.value = false;
|
|
1434
|
+
try {
|
|
1435
|
+
const result = create(toCreateInput(projectType.value, values));
|
|
1436
|
+
created.value = result;
|
|
1437
|
+
opts.onCreated?.(result);
|
|
1438
|
+
} catch (error) {
|
|
1439
|
+
message.value = error instanceof Error ? error.message : String(error);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
function cancelConfirm() {
|
|
1443
|
+
confirmOpen.value = false;
|
|
1444
|
+
}
|
|
1445
|
+
return {
|
|
1446
|
+
step,
|
|
1447
|
+
projectType,
|
|
1448
|
+
typeSel,
|
|
1449
|
+
fields,
|
|
1450
|
+
fieldSel,
|
|
1451
|
+
message,
|
|
1452
|
+
guidance,
|
|
1453
|
+
composeReady,
|
|
1454
|
+
targetDir,
|
|
1455
|
+
previewYaml,
|
|
1456
|
+
previewCompose,
|
|
1457
|
+
confirmOpen,
|
|
1458
|
+
created,
|
|
1459
|
+
handleKey,
|
|
1460
|
+
confirm,
|
|
1461
|
+
cancelConfirm
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
//#endregion
|
|
1465
|
+
//#region src/tui/components/WizardPanel.vue
|
|
1466
|
+
/**
|
|
1467
|
+
* 创建向导(spec 6.4 Projects 入口;M2-T6):三步=选类型→填输入(非法即时提示)→预览生成物→确认落盘。
|
|
1468
|
+
* 落盘走 createManagedProject(Task 3 冻结签名),输出路径恒托管目录;预览步生成物内容可见再经 ConfirmModal 确认。
|
|
1469
|
+
* concern④:compose 型缺 compose 文件不允许完成(二选一引导:放文件进托管目录 / 改走 image 型)。
|
|
1470
|
+
* 只吃 ViewModel(useWizard 状态机);动作经 emit 交 App。挂模态闸(R17 机制):向导打开期间全局键停用。
|
|
1471
|
+
*/
|
|
1472
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
1473
|
+
__name: "WizardPanel",
|
|
1474
|
+
props: {
|
|
1475
|
+
create: {
|
|
1476
|
+
type: null,
|
|
1477
|
+
required: false
|
|
1478
|
+
},
|
|
1479
|
+
composeExists: {
|
|
1480
|
+
type: Function,
|
|
1481
|
+
required: false
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
emits: ["created", "close"],
|
|
1485
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1486
|
+
__expose();
|
|
1487
|
+
const props = __props;
|
|
1488
|
+
const emit = __emit;
|
|
1489
|
+
useModalGate(() => true);
|
|
1490
|
+
const w = useWizard({
|
|
1491
|
+
create: props.create,
|
|
1492
|
+
composeExists: props.composeExists,
|
|
1493
|
+
onCreated: (result) => emit("created", result),
|
|
1494
|
+
onClose: () => emit("close")
|
|
1495
|
+
});
|
|
1496
|
+
useInput((event) => {
|
|
1497
|
+
const name = keyName(event);
|
|
1498
|
+
if (name !== void 0) w.handleKey(name);
|
|
1499
|
+
});
|
|
1500
|
+
const __returned__ = {
|
|
1501
|
+
props,
|
|
1502
|
+
emit,
|
|
1503
|
+
w,
|
|
1504
|
+
stepTitle: computed(() => {
|
|
1505
|
+
if (w.created.value !== void 0) return "创建成功";
|
|
1506
|
+
if (w.step.value === "type") return `创建向导 · 第 1 步:选择项目类型(输出恒落托管目录)`;
|
|
1507
|
+
if (w.step.value === "form") return `创建向导 · 第 2 步:填写输入(${w.projectType.value} 型)`;
|
|
1508
|
+
return "创建向导 · 第 3 步:预览生成物";
|
|
1509
|
+
}),
|
|
1510
|
+
previewLines: computed(() => w.previewYaml.value.split("\n")),
|
|
1511
|
+
composeLines: computed(() => (w.previewCompose.value ?? "").split("\n")),
|
|
1512
|
+
get Box() {
|
|
1513
|
+
return Box;
|
|
1514
|
+
},
|
|
1515
|
+
get Text() {
|
|
1516
|
+
return Text;
|
|
1517
|
+
},
|
|
1518
|
+
get TYPE_OPTIONS() {
|
|
1519
|
+
return TYPE_OPTIONS;
|
|
1520
|
+
},
|
|
1521
|
+
ConfirmModal: ConfirmModal_default
|
|
1522
|
+
};
|
|
1523
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
1524
|
+
enumerable: false,
|
|
1525
|
+
value: true
|
|
1526
|
+
});
|
|
1527
|
+
return __returned__;
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1531
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
1532
|
+
flexDirection: "column",
|
|
1533
|
+
flexGrow: 1,
|
|
1534
|
+
borderStyle: "round",
|
|
1535
|
+
borderColor: "cyan",
|
|
1536
|
+
padding: 1
|
|
1537
|
+
}, {
|
|
1538
|
+
default: withCtx(() => [
|
|
1539
|
+
createVNode($setup["Text"], {
|
|
1540
|
+
bold: "",
|
|
1541
|
+
color: "cyan"
|
|
1542
|
+
}, {
|
|
1543
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.stepTitle), 1)]),
|
|
1544
|
+
_: 1
|
|
1545
|
+
}),
|
|
1546
|
+
createCommentVNode(" 创建完成视图 "),
|
|
1547
|
+
$setup.w.created.value !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1548
|
+
createVNode($setup["Text"], { color: "green" }, {
|
|
1549
|
+
default: withCtx(() => [createTextVNode("✓ 创建成功: " + toDisplayString($setup.w.created.value.config.name), 1)]),
|
|
1550
|
+
_: 1
|
|
1551
|
+
}),
|
|
1552
|
+
createVNode($setup["Text"], null, {
|
|
1553
|
+
default: withCtx(() => [createTextVNode("目录: " + toDisplayString($setup.w.created.value.dir), 1)]),
|
|
1554
|
+
_: 1
|
|
1555
|
+
}),
|
|
1556
|
+
createVNode($setup["Text"], null, {
|
|
1557
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("已自动注册进 config.json(Projects 面板可见,可按 d 部署)", -1)])]),
|
|
1558
|
+
_: 1
|
|
1559
|
+
}),
|
|
1560
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
1561
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("enter/esc 关闭向导", -1)])]),
|
|
1562
|
+
_: 1
|
|
1563
|
+
})
|
|
1564
|
+
], 64)) : $setup.w.step.value === "type" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1565
|
+
createCommentVNode(" 第 1 步:选类型 "),
|
|
1566
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.TYPE_OPTIONS, (opt, i) => {
|
|
1567
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
1568
|
+
key: opt.value,
|
|
1569
|
+
flexDirection: "row"
|
|
1570
|
+
}, {
|
|
1571
|
+
default: withCtx(() => [
|
|
1572
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
1573
|
+
default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.w.typeSel.value ? "cyan" : void 0 }, {
|
|
1574
|
+
default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.w.typeSel.value ? ">" : " "), 1)]),
|
|
1575
|
+
_: 2
|
|
1576
|
+
}, 1032, ["color"])]),
|
|
1577
|
+
_: 2
|
|
1578
|
+
}, 1024),
|
|
1579
|
+
createVNode($setup["Box"], { width: 10 }, {
|
|
1580
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
1581
|
+
wrap: "truncate",
|
|
1582
|
+
bold: i === $setup.w.typeSel.value
|
|
1583
|
+
}, {
|
|
1584
|
+
default: withCtx(() => [createTextVNode(toDisplayString(opt.label), 1)]),
|
|
1585
|
+
_: 2
|
|
1586
|
+
}, 1032, ["bold"])]),
|
|
1587
|
+
_: 2
|
|
1588
|
+
}, 1024),
|
|
1589
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
1590
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
1591
|
+
wrap: "truncate",
|
|
1592
|
+
dimColor: ""
|
|
1593
|
+
}, {
|
|
1594
|
+
default: withCtx(() => [createTextVNode(toDisplayString(opt.desc), 1)]),
|
|
1595
|
+
_: 2
|
|
1596
|
+
}, 1024)]),
|
|
1597
|
+
_: 2
|
|
1598
|
+
}, 1024)
|
|
1599
|
+
]),
|
|
1600
|
+
_: 2
|
|
1601
|
+
}, 1024);
|
|
1602
|
+
}), 128)),
|
|
1603
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
1604
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("↑/↓/j/k 选择 · enter 下一步 · esc 退出向导", -1)])]),
|
|
1605
|
+
_: 1
|
|
1606
|
+
})
|
|
1607
|
+
], 64)) : $setup.w.step.value === "form" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
1608
|
+
createCommentVNode(" 第 2 步:填输入(非法即时提示) "),
|
|
1609
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.w.fields.value, (f, i) => {
|
|
1610
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
1611
|
+
key: f.key,
|
|
1612
|
+
flexDirection: "column"
|
|
1613
|
+
}, {
|
|
1614
|
+
default: withCtx(() => [createVNode($setup["Box"], { flexDirection: "row" }, {
|
|
1615
|
+
default: withCtx(() => [
|
|
1616
|
+
createVNode($setup["Box"], { width: 2 }, {
|
|
1617
|
+
default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.w.fieldSel.value ? "cyan" : void 0 }, {
|
|
1618
|
+
default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.w.fieldSel.value ? "▸" : " "), 1)]),
|
|
1619
|
+
_: 2
|
|
1620
|
+
}, 1032, ["color"])]),
|
|
1621
|
+
_: 2
|
|
1622
|
+
}, 1024),
|
|
1623
|
+
createVNode($setup["Box"], { width: 12 }, {
|
|
1624
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
1625
|
+
bold: i === $setup.w.fieldSel.value,
|
|
1626
|
+
wrap: "truncate"
|
|
1627
|
+
}, {
|
|
1628
|
+
default: withCtx(() => [createTextVNode(toDisplayString(f.label) + ":", 1)]),
|
|
1629
|
+
_: 2
|
|
1630
|
+
}, 1032, ["bold"])]),
|
|
1631
|
+
_: 2
|
|
1632
|
+
}, 1024),
|
|
1633
|
+
createVNode($setup["Box"], { flexGrow: 1 }, {
|
|
1634
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
1635
|
+
bold: i === $setup.w.fieldSel.value,
|
|
1636
|
+
wrap: "truncate"
|
|
1637
|
+
}, {
|
|
1638
|
+
default: withCtx(() => [createTextVNode(toDisplayString(f.value), 1), i === $setup.w.fieldSel.value ? (openBlock(), createBlock($setup["Text"], {
|
|
1639
|
+
key: 0,
|
|
1640
|
+
color: "cyan"
|
|
1641
|
+
}, {
|
|
1642
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("_", -1)])]),
|
|
1643
|
+
_: 1
|
|
1644
|
+
})) : createCommentVNode("v-if", true)]),
|
|
1645
|
+
_: 2
|
|
1646
|
+
}, 1032, ["bold"])]),
|
|
1647
|
+
_: 2
|
|
1648
|
+
}, 1024)
|
|
1649
|
+
]),
|
|
1650
|
+
_: 2
|
|
1651
|
+
}, 1024), f.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
1652
|
+
key: 0,
|
|
1653
|
+
color: "red"
|
|
1654
|
+
}, {
|
|
1655
|
+
default: withCtx(() => [createTextVNode(toDisplayString(f.error), 1)]),
|
|
1656
|
+
_: 2
|
|
1657
|
+
}, 1024)) : createCommentVNode("v-if", true)]),
|
|
1658
|
+
_: 2
|
|
1659
|
+
}, 1024);
|
|
1660
|
+
}), 128)),
|
|
1661
|
+
$setup.w.message.value !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
1662
|
+
key: 0,
|
|
1663
|
+
color: "red"
|
|
1664
|
+
}, {
|
|
1665
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.w.message.value), 1)]),
|
|
1666
|
+
_: 1
|
|
1667
|
+
})) : createCommentVNode("v-if", true),
|
|
1668
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
1669
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("↑/↓/tab 换字段 · 输入即编辑 · enter 预览生成物 · esc 返回", -1)])]),
|
|
1670
|
+
_: 1
|
|
1671
|
+
})
|
|
1672
|
+
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
1673
|
+
createCommentVNode(" 第 3 步:预览生成物(落盘前可见再确认) "),
|
|
1674
|
+
createVNode($setup["Text"], null, {
|
|
1675
|
+
default: withCtx(() => [createTextVNode("输出目录: " + toDisplayString($setup.w.targetDir.value), 1)]),
|
|
1676
|
+
_: 1
|
|
1677
|
+
}),
|
|
1678
|
+
createVNode($setup["Text"], { bold: "" }, {
|
|
1679
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("--- deploy.yaml ---", -1)])]),
|
|
1680
|
+
_: 1
|
|
1681
|
+
}),
|
|
1682
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.previewLines, (line, i) => {
|
|
1683
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
1684
|
+
key: `yaml-${i}`,
|
|
1685
|
+
wrap: "truncate"
|
|
1686
|
+
}, {
|
|
1687
|
+
default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
|
|
1688
|
+
_: 2
|
|
1689
|
+
}, 1024);
|
|
1690
|
+
}), 128)),
|
|
1691
|
+
$setup.w.previewCompose.value !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode($setup["Text"], { bold: "" }, {
|
|
1692
|
+
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("--- docker-compose.yml(image 型自动生成)---", -1)])]),
|
|
1693
|
+
_: 1
|
|
1694
|
+
}), (openBlock(true), createElementBlock(Fragment, null, renderList($setup.composeLines, (line, i) => {
|
|
1695
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
1696
|
+
key: `compose-${i}`,
|
|
1697
|
+
wrap: "truncate"
|
|
1698
|
+
}, {
|
|
1699
|
+
default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
|
|
1700
|
+
_: 2
|
|
1701
|
+
}, 1024);
|
|
1702
|
+
}), 128))], 64)) : createCommentVNode("v-if", true),
|
|
1703
|
+
createCommentVNode(" concern④:compose 型二选一引导 "),
|
|
1704
|
+
$setup.w.projectType.value === "compose" ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList($setup.w.guidance.value, (line, i) => {
|
|
1705
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
1706
|
+
key: `guide-${i}`,
|
|
1707
|
+
color: i === 0 ? "yellow" : void 0
|
|
1708
|
+
}, {
|
|
1709
|
+
default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
|
|
1710
|
+
_: 2
|
|
1711
|
+
}, 1032, ["color"]);
|
|
1712
|
+
}), 128)) : createCommentVNode("v-if", true),
|
|
1713
|
+
$setup.w.message.value !== void 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
1714
|
+
key: 2,
|
|
1715
|
+
color: "red"
|
|
1716
|
+
}, {
|
|
1717
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.w.message.value), 1)]),
|
|
1718
|
+
_: 1
|
|
1719
|
+
})) : createCommentVNode("v-if", true),
|
|
1720
|
+
createVNode($setup["Text"], { dimColor: "" }, {
|
|
1721
|
+
default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode("enter 确认创建 · c 重新检查 compose 文件 · esc 返回修改", -1)])]),
|
|
1722
|
+
_: 1
|
|
1723
|
+
})
|
|
1724
|
+
], 64)),
|
|
1725
|
+
createCommentVNode(" 落盘确认(破坏性/落盘动作走 ConfirmModal) "),
|
|
1726
|
+
createVNode($setup["ConfirmModal"], {
|
|
1727
|
+
visible: $setup.w.confirmOpen.value,
|
|
1728
|
+
message: `确认创建托管项目 ${$setup.w.fields.value.find((f) => f.key === "name")?.value ?? ""} 于 ${$setup.w.targetDir.value}?`,
|
|
1729
|
+
onConfirm: _cache[0] || (_cache[0] = ($event) => $setup.w.confirm()),
|
|
1730
|
+
onCancel: _cache[1] || (_cache[1] = ($event) => $setup.w.cancelConfirm())
|
|
1731
|
+
}, null, 8, ["visible", "message"])
|
|
1732
|
+
]),
|
|
1733
|
+
_: 1
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
var WizardPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/WizardPanel.vue"]]);
|
|
877
1737
|
//#endregion
|
|
878
1738
|
//#region src/tui/composables/useLogs.ts
|
|
879
1739
|
/** 日志列表上限(T4#4 递延项):超出环形截断最旧行,防长会话无界增长 */
|
|
@@ -980,6 +1840,134 @@ function useContainers(opts = {}) {
|
|
|
980
1840
|
};
|
|
981
1841
|
}
|
|
982
1842
|
//#endregion
|
|
1843
|
+
//#region src/tui/composables/useDeployRun.ts
|
|
1844
|
+
/** 流水线步骤条顺序(R10):update→pre→build→up→nginx→health→post,与 core StepName 一一对应 */
|
|
1845
|
+
const DEPLOY_STEPS = [
|
|
1846
|
+
"update",
|
|
1847
|
+
"pre",
|
|
1848
|
+
"build",
|
|
1849
|
+
"up",
|
|
1850
|
+
"nginx",
|
|
1851
|
+
"health",
|
|
1852
|
+
"post"
|
|
1853
|
+
];
|
|
1854
|
+
/** 步骤条中文文案 */
|
|
1855
|
+
const STEP_LABELS = {
|
|
1856
|
+
update: "update 更新(git pull)",
|
|
1857
|
+
pre: "pre 前置钩子",
|
|
1858
|
+
build: "build 构建",
|
|
1859
|
+
up: "up 启动容器",
|
|
1860
|
+
nginx: "nginx 站点配置",
|
|
1861
|
+
health: "health 健康检查",
|
|
1862
|
+
post: "post 后置钩子"
|
|
1863
|
+
};
|
|
1864
|
+
/** 流水线事件 → 日志行(CLI deploy formatEvent 同口径) */
|
|
1865
|
+
function formatEvent(e) {
|
|
1866
|
+
if (e.status === "ok") return `[${e.step}] ✓`;
|
|
1867
|
+
if (e.status === "fail") return `[${e.step}] ✗ ${e.line ?? ""}`;
|
|
1868
|
+
if (e.status === "warn") return `[${e.step}] ⚠ ${e.line ?? ""}`;
|
|
1869
|
+
return `[${e.step}] ${e.line ?? "开始"}`;
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Deploy 面板数据面(M2-T6):runDeploy 事件流 → 步骤条 ViewModel + 实时日志流。
|
|
1873
|
+
* 失败即停:fail 步之后的 pending 步骤标「跳过」;成功收尾时配置跳过(未执行)步骤同样标「跳过」。
|
|
1874
|
+
* 启动入口=Projects 面板 d(App 接线);运行中拒绝二次 start(防重复部署)。
|
|
1875
|
+
*/
|
|
1876
|
+
function useDeployRun(opts = {}) {
|
|
1877
|
+
const { info, success, warn, error: logError } = useLogs();
|
|
1878
|
+
const projectName = ref(void 0);
|
|
1879
|
+
const steps = ref(DEPLOY_STEPS.map((key) => ({
|
|
1880
|
+
key,
|
|
1881
|
+
label: STEP_LABELS[key],
|
|
1882
|
+
status: "pending"
|
|
1883
|
+
})));
|
|
1884
|
+
const running = ref(false);
|
|
1885
|
+
const done = ref(void 0);
|
|
1886
|
+
const failedStep = ref(void 0);
|
|
1887
|
+
const lines = ref([]);
|
|
1888
|
+
/** fail 之后(含 fail 步自身之后)的 pending 步骤标跳过(失败即停视觉呈现) */
|
|
1889
|
+
function skipAfter(step) {
|
|
1890
|
+
const idx = DEPLOY_STEPS.indexOf(step);
|
|
1891
|
+
for (let i = idx + 1; i < steps.value.length; i++) {
|
|
1892
|
+
const vm = steps.value[i];
|
|
1893
|
+
if (vm.status === "pending") vm.status = "skipped";
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
function onEvent(e) {
|
|
1897
|
+
const line = formatEvent(e);
|
|
1898
|
+
lines.value.push(line);
|
|
1899
|
+
const vm = steps.value.find((s) => s.key === e.step);
|
|
1900
|
+
if (e.status === "start") {
|
|
1901
|
+
if (vm) vm.status = "running";
|
|
1902
|
+
info(line);
|
|
1903
|
+
} else if (e.status === "ok") {
|
|
1904
|
+
if (vm) vm.status = "ok";
|
|
1905
|
+
info(line);
|
|
1906
|
+
} else if (e.status === "warn") warn(line);
|
|
1907
|
+
else {
|
|
1908
|
+
if (vm) vm.status = "fail";
|
|
1909
|
+
skipAfter(e.step);
|
|
1910
|
+
logError(line);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
async function start(name) {
|
|
1914
|
+
if (running.value) {
|
|
1915
|
+
warn(`已有部署在运行: ${projectName.value ?? ""},忽略新请求: ${name}`);
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1918
|
+
const row = listProjects(opts.load ? opts.load() : loadConfig()).find((r) => r.name === name);
|
|
1919
|
+
if (!row) {
|
|
1920
|
+
logError(`未找到项目: ${name}(先在 Projects 面板按 n 创建,或 deploy-cli project add 注册)`);
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
if (!row.config) {
|
|
1924
|
+
logError(`项目配置不可用: ${name}: ${row.error ?? ""}`);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
projectName.value = name;
|
|
1928
|
+
steps.value = DEPLOY_STEPS.map((key) => ({
|
|
1929
|
+
key,
|
|
1930
|
+
label: STEP_LABELS[key],
|
|
1931
|
+
status: "pending"
|
|
1932
|
+
}));
|
|
1933
|
+
done.value = void 0;
|
|
1934
|
+
failedStep.value = void 0;
|
|
1935
|
+
lines.value = [];
|
|
1936
|
+
running.value = true;
|
|
1937
|
+
info(`开始部署: ${name}(${row.path})`);
|
|
1938
|
+
try {
|
|
1939
|
+
const result = await (opts.run ?? runDeploy)(row.config, {
|
|
1940
|
+
cwd: expandPath(row.path),
|
|
1941
|
+
onEvent
|
|
1942
|
+
});
|
|
1943
|
+
if (result.ok) {
|
|
1944
|
+
done.value = "ok";
|
|
1945
|
+
success(`部署完成: ${name}`);
|
|
1946
|
+
} else {
|
|
1947
|
+
done.value = "fail";
|
|
1948
|
+
failedStep.value = result.failedStep;
|
|
1949
|
+
if (result.failedStep !== void 0) skipAfter(result.failedStep);
|
|
1950
|
+
logError(`部署失败: ${name}(步骤: ${result.failedStep ?? "未知"})`);
|
|
1951
|
+
}
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
done.value = "fail";
|
|
1954
|
+
logError(`部署异常: ${name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1955
|
+
} finally {
|
|
1956
|
+
for (const vm of steps.value) if (vm.status === "pending") vm.status = "skipped";
|
|
1957
|
+
running.value = false;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
return {
|
|
1961
|
+
projectName,
|
|
1962
|
+
steps,
|
|
1963
|
+
running,
|
|
1964
|
+
done,
|
|
1965
|
+
failedStep,
|
|
1966
|
+
lines,
|
|
1967
|
+
start
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
//#endregion
|
|
983
1971
|
//#region src/tui/composables/useHealth.ts
|
|
984
1972
|
/** ProjectHealth → 三列单元格(复刻 CLI status formatRow 口径) */
|
|
985
1973
|
function toRow$1(health) {
|
|
@@ -1104,8 +2092,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1104
2092
|
const { rows: projectRows, error: projectError, refresh: refreshProjects } = useProjects();
|
|
1105
2093
|
const { rows: containerRows, error: containerError, following, refresh: refreshContainers, restart, stop, remove, followLogs } = useContainers();
|
|
1106
2094
|
const { rows: healthRows, error: healthError, refresh: refreshHealth } = useHealth();
|
|
2095
|
+
const { projectName: deployProject, steps: deploySteps, lines: deployLines, running: deployRunning, done: deployDone, failedStep: deployFailedStep, start: startDeploy } = useDeployRun();
|
|
1107
2096
|
const activePanel = ref("projects");
|
|
1108
2097
|
const helpVisible = ref(false);
|
|
2098
|
+
const wizardOpen = ref(false);
|
|
1109
2099
|
useKeymap({
|
|
1110
2100
|
onPanel: (panel) => {
|
|
1111
2101
|
activePanel.value = panel;
|
|
@@ -1130,7 +2120,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1130
2120
|
async function onContainerAction(action, name) {
|
|
1131
2121
|
info(`${ACTION_LABEL[action]}容器: ${name}`);
|
|
1132
2122
|
try {
|
|
1133
|
-
const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name);
|
|
2123
|
+
const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name, { force: true });
|
|
1134
2124
|
if (result.code === 0) {
|
|
1135
2125
|
success(`${ACTION_LABEL[action]}容器成功: ${name}`);
|
|
1136
2126
|
await refreshContainers();
|
|
@@ -1144,6 +2134,19 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1144
2134
|
function onLogs(name) {
|
|
1145
2135
|
followLogs(name);
|
|
1146
2136
|
}
|
|
2137
|
+
/** Projects d → 部署执行面(useDeployRun)并切到 Deploy 面板看步骤流(T6 接线) */
|
|
2138
|
+
function onDeploy(name) {
|
|
2139
|
+
activePanel.value = "deploy";
|
|
2140
|
+
startDeploy(name);
|
|
2141
|
+
}
|
|
2142
|
+
/** 创建向导落盘成功(WizardPanel 经 ConfirmModal 确认后):日志 + 关闭时刷新列表 */
|
|
2143
|
+
function onWizardCreated(result) {
|
|
2144
|
+
success(`创建托管项目成功: ${result.config.name}(${result.dir})`);
|
|
2145
|
+
}
|
|
2146
|
+
function onWizardClose() {
|
|
2147
|
+
wizardOpen.value = false;
|
|
2148
|
+
refreshProjects();
|
|
2149
|
+
}
|
|
1147
2150
|
const __returned__ = {
|
|
1148
2151
|
exit,
|
|
1149
2152
|
logs,
|
|
@@ -1164,11 +2167,22 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1164
2167
|
healthRows,
|
|
1165
2168
|
healthError,
|
|
1166
2169
|
refreshHealth,
|
|
2170
|
+
deployProject,
|
|
2171
|
+
deploySteps,
|
|
2172
|
+
deployLines,
|
|
2173
|
+
deployRunning,
|
|
2174
|
+
deployDone,
|
|
2175
|
+
deployFailedStep,
|
|
2176
|
+
startDeploy,
|
|
1167
2177
|
activePanel,
|
|
1168
2178
|
helpVisible,
|
|
2179
|
+
wizardOpen,
|
|
1169
2180
|
ACTION_LABEL,
|
|
1170
2181
|
onContainerAction,
|
|
1171
2182
|
onLogs,
|
|
2183
|
+
onDeploy,
|
|
2184
|
+
onWizardCreated,
|
|
2185
|
+
onWizardClose,
|
|
1172
2186
|
panelTitle: computed(() => `${PANEL_IDS.indexOf(activePanel.value) + 1}. ${PANEL_TITLES[activePanel.value]}`),
|
|
1173
2187
|
get Box() {
|
|
1174
2188
|
return Box;
|
|
@@ -1177,10 +2191,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1177
2191
|
return Text;
|
|
1178
2192
|
},
|
|
1179
2193
|
ContainersPanel: ContainersPanel_default,
|
|
2194
|
+
DeployPanel: DeployPanel_default,
|
|
1180
2195
|
OutputPanel: OutputPanel_default,
|
|
1181
2196
|
ProjectsPanel: ProjectsPanel_default,
|
|
1182
2197
|
StatusPanel: StatusPanel_default,
|
|
1183
2198
|
StatusBar: StatusBar_default,
|
|
2199
|
+
WizardPanel: WizardPanel_default,
|
|
1184
2200
|
get PANEL_IDS() {
|
|
1185
2201
|
return PANEL_IDS;
|
|
1186
2202
|
},
|
|
@@ -1212,46 +2228,67 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1212
2228
|
bold: "",
|
|
1213
2229
|
color: "cyan"
|
|
1214
2230
|
}, {
|
|
1215
|
-
default: withCtx(() => [..._cache[
|
|
2231
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("Deploy CLI", -1)])]),
|
|
1216
2232
|
_: 1
|
|
1217
2233
|
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
1218
|
-
default: withCtx(() => [..._cache[
|
|
2234
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
|
|
1219
2235
|
_: 1
|
|
1220
2236
|
})]),
|
|
1221
2237
|
_: 1
|
|
1222
2238
|
}),
|
|
1223
|
-
createCommentVNode(" 主面板区:1/2/4/6 实装,
|
|
2239
|
+
createCommentVNode(" 主面板区:1/2/3/4/6 实装,5 Tunnels(T7)骨架占位;创建向导(n)打开时独占主区 "),
|
|
1224
2240
|
createVNode($setup["Box"], {
|
|
1225
2241
|
flexDirection: "column",
|
|
1226
2242
|
flexGrow: 1,
|
|
1227
2243
|
paddingX: 1
|
|
1228
2244
|
}, {
|
|
1229
|
-
default: withCtx(() => [
|
|
2245
|
+
default: withCtx(() => [$setup.wizardOpen ? (openBlock(), createBlock($setup["WizardPanel"], {
|
|
1230
2246
|
key: 0,
|
|
2247
|
+
onCreated: $setup.onWizardCreated,
|
|
2248
|
+
onClose: $setup.onWizardClose
|
|
2249
|
+
})) : $setup.activePanel === "projects" ? (openBlock(), createBlock($setup["ProjectsPanel"], {
|
|
2250
|
+
key: 1,
|
|
1231
2251
|
rows: $setup.projectRows,
|
|
1232
2252
|
error: $setup.projectError,
|
|
2253
|
+
onDeploy: $setup.onDeploy,
|
|
2254
|
+
onCreate: _cache[0] || (_cache[0] = ($event) => $setup.wizardOpen = true),
|
|
1233
2255
|
onRefresh: $setup.refreshProjects
|
|
1234
2256
|
}, null, 8, [
|
|
1235
2257
|
"rows",
|
|
1236
2258
|
"error",
|
|
1237
2259
|
"onRefresh"
|
|
1238
2260
|
])) : $setup.activePanel === "containers" ? (openBlock(), createBlock($setup["ContainersPanel"], {
|
|
1239
|
-
key:
|
|
2261
|
+
key: 2,
|
|
1240
2262
|
rows: $setup.containerRows,
|
|
1241
2263
|
error: $setup.containerError,
|
|
1242
2264
|
following: $setup.following,
|
|
1243
2265
|
onLogs: $setup.onLogs,
|
|
1244
|
-
onRestart: _cache[
|
|
1245
|
-
onStop: _cache[
|
|
1246
|
-
onRemove: _cache[
|
|
2266
|
+
onRestart: _cache[1] || (_cache[1] = (name) => $setup.onContainerAction("restart", name)),
|
|
2267
|
+
onStop: _cache[2] || (_cache[2] = (name) => $setup.onContainerAction("stop", name)),
|
|
2268
|
+
onRemove: _cache[3] || (_cache[3] = (name) => $setup.onContainerAction("remove", name)),
|
|
1247
2269
|
onRefresh: $setup.refreshContainers
|
|
1248
2270
|
}, null, 8, [
|
|
1249
2271
|
"rows",
|
|
1250
2272
|
"error",
|
|
1251
2273
|
"following",
|
|
1252
2274
|
"onRefresh"
|
|
2275
|
+
])) : $setup.activePanel === "deploy" ? (openBlock(), createBlock($setup["DeployPanel"], {
|
|
2276
|
+
key: 3,
|
|
2277
|
+
"project-name": $setup.deployProject,
|
|
2278
|
+
steps: $setup.deploySteps,
|
|
2279
|
+
lines: $setup.deployLines,
|
|
2280
|
+
running: $setup.deployRunning,
|
|
2281
|
+
done: $setup.deployDone,
|
|
2282
|
+
"failed-step": $setup.deployFailedStep
|
|
2283
|
+
}, null, 8, [
|
|
2284
|
+
"project-name",
|
|
2285
|
+
"steps",
|
|
2286
|
+
"lines",
|
|
2287
|
+
"running",
|
|
2288
|
+
"done",
|
|
2289
|
+
"failed-step"
|
|
1253
2290
|
])) : $setup.activePanel === "status" ? (openBlock(), createBlock($setup["StatusPanel"], {
|
|
1254
|
-
key:
|
|
2291
|
+
key: 4,
|
|
1255
2292
|
rows: $setup.healthRows,
|
|
1256
2293
|
error: $setup.healthError,
|
|
1257
2294
|
onRefresh: $setup.refreshHealth
|
|
@@ -1260,10 +2297,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1260
2297
|
"error",
|
|
1261
2298
|
"onRefresh"
|
|
1262
2299
|
])) : $setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
|
|
1263
|
-
key:
|
|
2300
|
+
key: 5,
|
|
1264
2301
|
logs: $setup.logs
|
|
1265
2302
|
}, null, 8, ["logs"])) : (openBlock(), createBlock($setup["Box"], {
|
|
1266
|
-
key:
|
|
2303
|
+
key: 6,
|
|
1267
2304
|
flexDirection: "column",
|
|
1268
2305
|
flexGrow: 1,
|
|
1269
2306
|
borderStyle: "round",
|
|
@@ -1276,7 +2313,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1276
2313
|
default: withCtx(() => [createTextVNode(toDisplayString($setup.panelTitle), 1)]),
|
|
1277
2314
|
_: 1
|
|
1278
2315
|
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
1279
|
-
default: withCtx(() => [..._cache[
|
|
2316
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
|
|
1280
2317
|
_: 1
|
|
1281
2318
|
})]),
|
|
1282
2319
|
_: 1
|
|
@@ -1297,7 +2334,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1297
2334
|
bold: "",
|
|
1298
2335
|
color: "yellow"
|
|
1299
2336
|
}, {
|
|
1300
|
-
default: withCtx(() => [..._cache[
|
|
2337
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("快捷键帮助", -1)])]),
|
|
1301
2338
|
_: 1
|
|
1302
2339
|
}),
|
|
1303
2340
|
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.PANEL_IDS, (id, i) => {
|
|
@@ -1307,7 +2344,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1307
2344
|
}, 1024);
|
|
1308
2345
|
}), 128)),
|
|
1309
2346
|
createVNode($setup["Text"], null, {
|
|
1310
|
-
default: withCtx(() => [..._cache[
|
|
2347
|
+
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
|
|
1311
2348
|
_: 1
|
|
1312
2349
|
})
|
|
1313
2350
|
]),
|