@dongnanyang/deploy-cli 0.11.1 → 0.12.1

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-BzJoAv1l.js";
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 { i as createDocker, t as checkProjectHealth } from "../health-CZL7Ghs8.js";
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, onScopeDispose, openBlock, ref, renderList, shallowRef, toDisplayString, toValue, 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 与数组序一一对应 */
@@ -85,7 +86,7 @@ function useKeymap(handlers) {
85
86
  * 键位:y/enter 确认、n/escape 取消;不可见时不响应。
86
87
  * R17:visible 期间挂模态闸——全局键 1-6/q/? 一并停用(弹窗独占输入)。
87
88
  */
88
- const _sfc_main$6 = /*@__PURE__*/ defineComponent({
89
+ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
89
90
  __name: "ConfirmModal",
90
91
  props: {
91
92
  visible: {
@@ -126,7 +127,7 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
126
127
  return __returned__;
127
128
  }
128
129
  });
129
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
130
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
130
131
  return $setup.props.visible ? (openBlock(), createBlock($setup["Box"], {
131
132
  key: 0,
132
133
  flexDirection: "column",
@@ -155,10 +156,10 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
155
156
  _: 1
156
157
  })) : createCommentVNode("v-if", true);
157
158
  }
158
- 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"]]);
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"]]);
159
160
  //#endregion
160
161
  //#region src/tui/components/ContainersPanel.vue
161
- const _sfc_main$5 = /*@__PURE__*/ defineComponent({
162
+ const _sfc_main$7 = /*@__PURE__*/ defineComponent({
162
163
  __name: "ContainersPanel",
163
164
  props: {
164
165
  rows: {
@@ -185,14 +186,15 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
185
186
  __expose();
186
187
  const props = __props;
187
188
  const emit = __emit;
188
- const ACTION_LABEL = {
189
- restart: "重启",
190
- stop: "停止",
191
- remove: "删除"
189
+ /** 确认文案(R18:删除=停止并强制删除,文案与语义一致) */
190
+ const CONFIRM_MESSAGE = {
191
+ restart: (name) => `确认重启容器 ${name}?`,
192
+ stop: (name) => `确认停止容器 ${name}?`,
193
+ remove: (name) => `将停止并强制删除容器 ${name}?`
192
194
  };
193
195
  const sel = ref(0);
194
196
  const pending = ref(null);
195
- const confirmMessage = computed(() => pending.value === null ? "" : `确认${ACTION_LABEL[pending.value.action]}容器 ${pending.value.name}?`);
197
+ const confirmMessage = computed(() => pending.value === null ? "" : CONFIRM_MESSAGE[pending.value.action](pending.value.name));
196
198
  watch(() => props.rows.length, () => {
197
199
  sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
198
200
  });
@@ -228,7 +230,7 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
228
230
  const __returned__ = {
229
231
  props,
230
232
  emit,
231
- ACTION_LABEL,
233
+ CONFIRM_MESSAGE,
232
234
  sel,
233
235
  pending,
234
236
  confirmMessage,
@@ -248,7 +250,7 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
248
250
  return __returned__;
249
251
  }
250
252
  });
251
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
253
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
252
254
  return openBlock(), createBlock($setup["Box"], {
253
255
  flexDirection: "column",
254
256
  flexGrow: 1,
@@ -389,7 +391,206 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
389
391
  _: 1
390
392
  });
391
393
  }
392
- 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"]]);
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"]]);
393
594
  //#endregion
394
595
  //#region src/tui/components/OutputPanel.vue
395
596
  /**
@@ -397,7 +598,7 @@ var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [
397
598
  * 滚动/截断(T4#4 递延项):ScrollBox 有界视口(内容超高即截断)+ 旧 TUI g/G 键位语义(g 到顶、G 回底跟随)、↑/↓ 逐行;
398
599
  * 列表上限在 useLogs(LOGS_LIMIT 环形截断),此处只管视口。
399
600
  */
400
- const _sfc_main$4 = /*@__PURE__*/ defineComponent({
601
+ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
401
602
  __name: "OutputPanel",
402
603
  props: { logs: {
403
604
  type: Array,
@@ -440,7 +641,7 @@ const _sfc_main$4 = /*@__PURE__*/ defineComponent({
440
641
  return __returned__;
441
642
  }
442
643
  });
443
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
644
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
444
645
  return openBlock(), createBlock($setup["Box"], {
445
646
  flexDirection: "column",
446
647
  flexGrow: 1,
@@ -490,14 +691,14 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
490
691
  _: 1
491
692
  });
492
693
  }
493
- 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"]]);
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"]]);
494
695
  //#endregion
495
696
  //#region src/tui/components/ProjectsPanel.vue
496
697
  /**
497
698
  * Projects 面板(spec 6.4):项目列表 NAME/PATH/TYPE/ERROR + 动作事件出口。
498
699
  * 只吃 ViewModel(rows);动作经 emit 交 App 接线(部署等 T6 接线)。
499
700
  */
500
- const _sfc_main$3 = /*@__PURE__*/ defineComponent({
701
+ const _sfc_main$4 = /*@__PURE__*/ defineComponent({
501
702
  __name: "ProjectsPanel",
502
703
  props: {
503
704
  rows: {
@@ -509,7 +710,11 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
509
710
  required: false
510
711
  }
511
712
  },
512
- emits: ["deploy", "refresh"],
713
+ emits: [
714
+ "deploy",
715
+ "create",
716
+ "refresh"
717
+ ],
513
718
  setup(__props, { expose: __expose, emit: __emit }) {
514
719
  __expose();
515
720
  const props = __props;
@@ -520,6 +725,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
520
725
  });
521
726
  useInput((event) => {
522
727
  const name = keyName(event);
728
+ if (name === "n") emit("create");
523
729
  if (props.rows.length === 0) return;
524
730
  if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
525
731
  else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
@@ -544,7 +750,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
544
750
  return __returned__;
545
751
  }
546
752
  });
547
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
753
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
548
754
  return openBlock(), createBlock($setup["Box"], {
549
755
  flexDirection: "column",
550
756
  flexGrow: 1,
@@ -662,21 +868,21 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
662
868
  }, 1024);
663
869
  }), 128)),
664
870
  createVNode($setup["Text"], { dimColor: "" }, {
665
- 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)])]),
666
872
  _: 1
667
873
  })
668
874
  ]),
669
875
  _: 1
670
876
  });
671
877
  }
672
- 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"]]);
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"]]);
673
879
  //#endregion
674
880
  //#region src/tui/components/StatusPanel.vue
675
881
  /**
676
882
  * Status 面板(spec 6.4):项目健康聚合 CONTAINERS/HTTP/NGINX(口径同 CLI status 表格)。
677
883
  * 只吃 ViewModel(rows);单行错误降级展示(检查失败/配置不可用行 + 继续,M2-T2 #10 的 UI 面)。
678
884
  */
679
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
885
+ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
680
886
  __name: "StatusPanel",
681
887
  props: {
682
888
  rows: {
@@ -713,7 +919,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
713
919
  return __returned__;
714
920
  }
715
921
  });
716
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
922
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
717
923
  return openBlock(), createBlock($setup["Box"], {
718
924
  flexDirection: "column",
719
925
  flexGrow: 1,
@@ -837,10 +1043,10 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
837
1043
  _: 1
838
1044
  });
839
1045
  }
840
- 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"]]);
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"]]);
841
1047
  //#endregion
842
1048
  //#region src/tui/components/StatusBar.vue
843
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
1049
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
844
1050
  __name: "StatusBar",
845
1051
  props: {
846
1052
  activePanel: {
@@ -873,7 +1079,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
873
1079
  return __returned__;
874
1080
  }
875
1081
  });
876
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
1082
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
877
1083
  return openBlock(), createBlock($setup["Box"], {
878
1084
  paddingX: 1,
879
1085
  flexDirection: "row",
@@ -893,7 +1099,648 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
893
1099
  _: 1
894
1100
  });
895
1101
  }
896
- 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"]]);
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
+ if (type === "compose") {
1273
+ const services = splitList(values["services"] ?? "");
1274
+ if (services !== void 0) input.services = services;
1275
+ }
1276
+ if (type === "image") {
1277
+ input.image = (values["image"] ?? "").trim();
1278
+ const ports = splitList(values["ports"] ?? "");
1279
+ if (ports !== void 0) input.ports = ports;
1280
+ const volumes = splitList(values["volumes"] ?? "");
1281
+ if (volumes !== void 0) input.volumes = volumes;
1282
+ const env = parseEnv(values["env"] ?? "");
1283
+ if (env !== void 0) input.env = env;
1284
+ }
1285
+ if (type === "static") input.root = (values["root"] ?? "").trim();
1286
+ const domain = (values["domain"] ?? "").trim();
1287
+ if (domain !== "") {
1288
+ const upstream = (values["upstream"] ?? "").trim();
1289
+ const ssl = (values["ssl"] ?? "").trim();
1290
+ input.nginx = {
1291
+ domain,
1292
+ ...type !== "static" && upstream !== "" ? { upstream } : {},
1293
+ ssl: ssl === "acme" ? "acme" : "none"
1294
+ };
1295
+ }
1296
+ return input;
1297
+ }
1298
+ /**
1299
+ * input → 预览 DeployYaml(键序=createManagedProject 落盘口径:validate 归一 +
1300
+ * saveProject 过滤 undefined;compose 型 composeFile 缺省追加在末尾)。
1301
+ * 预览文本与落盘 deploy.yaml 逐字一致由测试锚定。
1302
+ */
1303
+ function toDeployYaml(input) {
1304
+ const d = {
1305
+ name: input.name,
1306
+ type: input.type
1307
+ };
1308
+ if (input.services !== void 0) d.services = input.services;
1309
+ if (input.type === "image") {
1310
+ d.image = input.image;
1311
+ d.ports = input.ports;
1312
+ d.volumes = input.volumes;
1313
+ d.env = input.env;
1314
+ }
1315
+ if (input.type === "static") d.root = input.root;
1316
+ if (input.nginx !== void 0) d.nginx = input.nginx;
1317
+ if (input.type === "compose") d.composeFile = "docker-compose.yml";
1318
+ return d;
1319
+ }
1320
+ function toPreviewYaml(input) {
1321
+ const out = {};
1322
+ for (const [key, value] of Object.entries(toDeployYaml(input))) if (value !== void 0) out[key] = value;
1323
+ return stringify(out);
1324
+ }
1325
+ /**
1326
+ * 创建向导数据面(M2-T6):三步状态机 + 逐字消费 createManagedProject(Task 3 冻结签名)。
1327
+ * 落盘前必经预览步(生成物内容可见再确认,ConfirmModal);输出路径恒托管目录。
1328
+ * concern④:compose 型缺 compose 文件不允许完成(二选一引导:放文件进托管目录 / 改走 image 型)。
1329
+ */
1330
+ function useWizard(opts = {}) {
1331
+ const create = opts.create ?? createManagedProject;
1332
+ const composeExists = opts.composeExists ?? managedComposeExists;
1333
+ const step = ref("type");
1334
+ const typeSel = ref(0);
1335
+ const projectType = ref(TYPE_OPTIONS[0].value);
1336
+ const values = reactive({});
1337
+ const fieldSel = ref(0);
1338
+ const message = ref(void 0);
1339
+ const composeReady = ref(false);
1340
+ const confirmOpen = ref(false);
1341
+ const created = ref(void 0);
1342
+ const fields = computed(() => FIELDS[projectType.value].map((spec, i) => ({
1343
+ key: spec.key,
1344
+ label: spec.label,
1345
+ placeholder: spec.placeholder,
1346
+ value: values[spec.key] ?? "",
1347
+ focused: i === fieldSel.value,
1348
+ error: fieldError(projectType.value, spec.key, values)
1349
+ })));
1350
+ const targetDir = computed(() => {
1351
+ try {
1352
+ return managedDir((values["name"] ?? "").trim());
1353
+ } catch {
1354
+ return "";
1355
+ }
1356
+ });
1357
+ const previewYaml = computed(() => toPreviewYaml(toCreateInput(projectType.value, values)));
1358
+ const previewCompose = computed(() => {
1359
+ const input = toCreateInput(projectType.value, values);
1360
+ if (input.type !== "image") return void 0;
1361
+ try {
1362
+ return generateCompose(toDeployYaml(input));
1363
+ } catch {
1364
+ return;
1365
+ }
1366
+ });
1367
+ /** concern④ 二选一引导(compose 型预览步恒显) */
1368
+ const guidance = computed(() => {
1369
+ if (projectType.value !== "compose") return [];
1370
+ const dir = targetDir.value || "~/.deploy-cli/projects/<name>";
1371
+ return [
1372
+ "compose 型需自行准备 compose 文件(二选一):",
1373
+ `① mkdir -p ${dir} 并放入 ${dir}/docker-compose.yml,再按 c 重新检查(当前: ${composeReady.value ? "已就位" : "未就位"})`,
1374
+ "② esc 返回上一步改选 image 型(向导自动生成 compose 文件)",
1375
+ ...composeReady.value ? [] : ["未就位不允许创建:防止造出不可部署项目"]
1376
+ ];
1377
+ });
1378
+ function currentFieldKey() {
1379
+ return FIELDS[projectType.value][fieldSel.value]?.key;
1380
+ }
1381
+ function handleTypeKey(name) {
1382
+ if (name === "down" || name === "j") typeSel.value = Math.min(typeSel.value + 1, TYPE_OPTIONS.length - 1);
1383
+ else if (name === "up" || name === "k") typeSel.value = Math.max(typeSel.value - 1, 0);
1384
+ else if (name === "enter") {
1385
+ projectType.value = TYPE_OPTIONS[typeSel.value].value;
1386
+ fieldSel.value = 0;
1387
+ message.value = void 0;
1388
+ step.value = "form";
1389
+ } else if (name === "escape") opts.onClose?.();
1390
+ }
1391
+ function handleFormKey(name) {
1392
+ const specs = FIELDS[projectType.value];
1393
+ const key = currentFieldKey();
1394
+ if (name === "tab" || name === "down") fieldSel.value = (fieldSel.value + 1) % specs.length;
1395
+ else if (name === "up") fieldSel.value = (fieldSel.value - 1 + specs.length) % specs.length;
1396
+ else if (name === "backspace") {
1397
+ if (key !== void 0) values[key] = (values[key] ?? "").slice(0, -1);
1398
+ } else if (name.length === 1) {
1399
+ if (key !== void 0) values[key] = (values[key] ?? "") + name;
1400
+ } else if (name === "enter") {
1401
+ if (fields.value.filter((f) => f.error !== void 0).length > 0) {
1402
+ message.value = "存在非法输入,请修正标红字段后重试";
1403
+ return;
1404
+ }
1405
+ message.value = void 0;
1406
+ if (projectType.value === "compose") composeReady.value = composeExists(values["name"] ?? "");
1407
+ step.value = "preview";
1408
+ } else if (name === "escape") step.value = "type";
1409
+ }
1410
+ function handlePreviewKey(name) {
1411
+ if (name === "c" && projectType.value === "compose") {
1412
+ composeReady.value = composeExists(values["name"] ?? "");
1413
+ message.value = void 0;
1414
+ } else if (name === "enter") {
1415
+ if (projectType.value === "compose" && !composeReady.value) {
1416
+ message.value = "compose 文件未就位:请将 docker-compose.yml 放入托管目录(见上方二选一指引),或返回改选 image 型";
1417
+ return;
1418
+ }
1419
+ message.value = void 0;
1420
+ confirmOpen.value = true;
1421
+ } else if (name === "escape") step.value = "form";
1422
+ }
1423
+ function handleKey(name) {
1424
+ if (confirmOpen.value) return;
1425
+ if (created.value !== void 0) {
1426
+ if (name === "enter" || name === "escape") opts.onClose?.();
1427
+ return;
1428
+ }
1429
+ if (step.value === "type") handleTypeKey(name);
1430
+ else if (step.value === "form") handleFormKey(name);
1431
+ else handlePreviewKey(name);
1432
+ }
1433
+ /** 落盘(ConfirmModal y):走 createManagedProject;失败降级 message 留在预览步可重试 */
1434
+ function confirm() {
1435
+ confirmOpen.value = false;
1436
+ if (projectType.value === "compose" && !composeExists(values["name"] ?? "")) {
1437
+ composeReady.value = false;
1438
+ message.value = "compose 文件未就位(状态已变化):请重新放入后按 c 重检,再确认创建";
1439
+ return;
1440
+ }
1441
+ try {
1442
+ const result = create(toCreateInput(projectType.value, values));
1443
+ created.value = result;
1444
+ opts.onCreated?.(result);
1445
+ } catch (error) {
1446
+ message.value = error instanceof Error ? error.message : String(error);
1447
+ }
1448
+ }
1449
+ function cancelConfirm() {
1450
+ confirmOpen.value = false;
1451
+ }
1452
+ return {
1453
+ step,
1454
+ projectType,
1455
+ typeSel,
1456
+ fields,
1457
+ fieldSel,
1458
+ message,
1459
+ guidance,
1460
+ composeReady,
1461
+ targetDir,
1462
+ previewYaml,
1463
+ previewCompose,
1464
+ confirmOpen,
1465
+ created,
1466
+ handleKey,
1467
+ confirm,
1468
+ cancelConfirm
1469
+ };
1470
+ }
1471
+ //#endregion
1472
+ //#region src/tui/components/WizardPanel.vue
1473
+ /**
1474
+ * 创建向导(spec 6.4 Projects 入口;M2-T6):三步=选类型→填输入(非法即时提示)→预览生成物→确认落盘。
1475
+ * 落盘走 createManagedProject(Task 3 冻结签名),输出路径恒托管目录;预览步生成物内容可见再经 ConfirmModal 确认。
1476
+ * concern④:compose 型缺 compose 文件不允许完成(二选一引导:放文件进托管目录 / 改走 image 型)。
1477
+ * 只吃 ViewModel(useWizard 状态机);动作经 emit 交 App。挂模态闸(R17 机制):向导打开期间全局键停用。
1478
+ */
1479
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
1480
+ __name: "WizardPanel",
1481
+ props: {
1482
+ create: {
1483
+ type: null,
1484
+ required: false
1485
+ },
1486
+ composeExists: {
1487
+ type: Function,
1488
+ required: false
1489
+ }
1490
+ },
1491
+ emits: ["created", "close"],
1492
+ setup(__props, { expose: __expose, emit: __emit }) {
1493
+ __expose();
1494
+ const props = __props;
1495
+ const emit = __emit;
1496
+ useModalGate(() => true);
1497
+ const w = useWizard({
1498
+ create: props.create,
1499
+ composeExists: props.composeExists,
1500
+ onCreated: (result) => emit("created", result),
1501
+ onClose: () => emit("close")
1502
+ });
1503
+ useInput((event) => {
1504
+ const name = keyName(event);
1505
+ if (name !== void 0) w.handleKey(name);
1506
+ });
1507
+ const __returned__ = {
1508
+ props,
1509
+ emit,
1510
+ w,
1511
+ stepTitle: computed(() => {
1512
+ if (w.created.value !== void 0) return "创建成功";
1513
+ if (w.step.value === "type") return `创建向导 · 第 1 步:选择项目类型(输出恒落托管目录)`;
1514
+ if (w.step.value === "form") return `创建向导 · 第 2 步:填写输入(${w.projectType.value} 型)`;
1515
+ return "创建向导 · 第 3 步:预览生成物";
1516
+ }),
1517
+ previewLines: computed(() => w.previewYaml.value.split("\n")),
1518
+ composeLines: computed(() => (w.previewCompose.value ?? "").split("\n")),
1519
+ get Box() {
1520
+ return Box;
1521
+ },
1522
+ get Text() {
1523
+ return Text;
1524
+ },
1525
+ get TYPE_OPTIONS() {
1526
+ return TYPE_OPTIONS;
1527
+ },
1528
+ ConfirmModal: ConfirmModal_default
1529
+ };
1530
+ Object.defineProperty(__returned__, "__isScriptSetup", {
1531
+ enumerable: false,
1532
+ value: true
1533
+ });
1534
+ return __returned__;
1535
+ }
1536
+ });
1537
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
1538
+ return openBlock(), createBlock($setup["Box"], {
1539
+ flexDirection: "column",
1540
+ flexGrow: 1,
1541
+ borderStyle: "round",
1542
+ borderColor: "cyan",
1543
+ padding: 1
1544
+ }, {
1545
+ default: withCtx(() => [
1546
+ createVNode($setup["Text"], {
1547
+ bold: "",
1548
+ color: "cyan"
1549
+ }, {
1550
+ default: withCtx(() => [createTextVNode(toDisplayString($setup.stepTitle), 1)]),
1551
+ _: 1
1552
+ }),
1553
+ createCommentVNode(" 创建完成视图 "),
1554
+ $setup.w.created.value !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1555
+ createVNode($setup["Text"], { color: "green" }, {
1556
+ default: withCtx(() => [createTextVNode("✓ 创建成功: " + toDisplayString($setup.w.created.value.config.name), 1)]),
1557
+ _: 1
1558
+ }),
1559
+ createVNode($setup["Text"], null, {
1560
+ default: withCtx(() => [createTextVNode("目录: " + toDisplayString($setup.w.created.value.dir), 1)]),
1561
+ _: 1
1562
+ }),
1563
+ createVNode($setup["Text"], null, {
1564
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("已自动注册进 config.json(Projects 面板可见,可按 d 部署)", -1)])]),
1565
+ _: 1
1566
+ }),
1567
+ createVNode($setup["Text"], { dimColor: "" }, {
1568
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("enter/esc 关闭向导", -1)])]),
1569
+ _: 1
1570
+ })
1571
+ ], 64)) : $setup.w.step.value === "type" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1572
+ createCommentVNode(" 第 1 步:选类型 "),
1573
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.TYPE_OPTIONS, (opt, i) => {
1574
+ return openBlock(), createBlock($setup["Box"], {
1575
+ key: opt.value,
1576
+ flexDirection: "row"
1577
+ }, {
1578
+ default: withCtx(() => [
1579
+ createVNode($setup["Box"], { width: 2 }, {
1580
+ default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.w.typeSel.value ? "cyan" : void 0 }, {
1581
+ default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.w.typeSel.value ? ">" : " "), 1)]),
1582
+ _: 2
1583
+ }, 1032, ["color"])]),
1584
+ _: 2
1585
+ }, 1024),
1586
+ createVNode($setup["Box"], { width: 10 }, {
1587
+ default: withCtx(() => [createVNode($setup["Text"], {
1588
+ wrap: "truncate",
1589
+ bold: i === $setup.w.typeSel.value
1590
+ }, {
1591
+ default: withCtx(() => [createTextVNode(toDisplayString(opt.label), 1)]),
1592
+ _: 2
1593
+ }, 1032, ["bold"])]),
1594
+ _: 2
1595
+ }, 1024),
1596
+ createVNode($setup["Box"], { flexGrow: 1 }, {
1597
+ default: withCtx(() => [createVNode($setup["Text"], {
1598
+ wrap: "truncate",
1599
+ dimColor: ""
1600
+ }, {
1601
+ default: withCtx(() => [createTextVNode(toDisplayString(opt.desc), 1)]),
1602
+ _: 2
1603
+ }, 1024)]),
1604
+ _: 2
1605
+ }, 1024)
1606
+ ]),
1607
+ _: 2
1608
+ }, 1024);
1609
+ }), 128)),
1610
+ createVNode($setup["Text"], { dimColor: "" }, {
1611
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("↑/↓/j/k 选择 · enter 下一步 · esc 退出向导", -1)])]),
1612
+ _: 1
1613
+ })
1614
+ ], 64)) : $setup.w.step.value === "form" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
1615
+ createCommentVNode(" 第 2 步:填输入(非法即时提示) "),
1616
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.w.fields.value, (f, i) => {
1617
+ return openBlock(), createBlock($setup["Box"], {
1618
+ key: f.key,
1619
+ flexDirection: "column"
1620
+ }, {
1621
+ default: withCtx(() => [createVNode($setup["Box"], { flexDirection: "row" }, {
1622
+ default: withCtx(() => [
1623
+ createVNode($setup["Box"], { width: 2 }, {
1624
+ default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.w.fieldSel.value ? "cyan" : void 0 }, {
1625
+ default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.w.fieldSel.value ? "▸" : " "), 1)]),
1626
+ _: 2
1627
+ }, 1032, ["color"])]),
1628
+ _: 2
1629
+ }, 1024),
1630
+ createVNode($setup["Box"], { width: 12 }, {
1631
+ default: withCtx(() => [createVNode($setup["Text"], {
1632
+ bold: i === $setup.w.fieldSel.value,
1633
+ wrap: "truncate"
1634
+ }, {
1635
+ default: withCtx(() => [createTextVNode(toDisplayString(f.label) + ":", 1)]),
1636
+ _: 2
1637
+ }, 1032, ["bold"])]),
1638
+ _: 2
1639
+ }, 1024),
1640
+ createVNode($setup["Box"], { flexGrow: 1 }, {
1641
+ default: withCtx(() => [createVNode($setup["Text"], {
1642
+ bold: i === $setup.w.fieldSel.value,
1643
+ wrap: "truncate"
1644
+ }, {
1645
+ default: withCtx(() => [createTextVNode(toDisplayString(f.value), 1), i === $setup.w.fieldSel.value ? (openBlock(), createBlock($setup["Text"], {
1646
+ key: 0,
1647
+ color: "cyan"
1648
+ }, {
1649
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("_", -1)])]),
1650
+ _: 1
1651
+ })) : createCommentVNode("v-if", true)]),
1652
+ _: 2
1653
+ }, 1032, ["bold"])]),
1654
+ _: 2
1655
+ }, 1024)
1656
+ ]),
1657
+ _: 2
1658
+ }, 1024), f.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
1659
+ key: 0,
1660
+ color: "red"
1661
+ }, {
1662
+ default: withCtx(() => [createTextVNode(toDisplayString(f.error), 1)]),
1663
+ _: 2
1664
+ }, 1024)) : createCommentVNode("v-if", true)]),
1665
+ _: 2
1666
+ }, 1024);
1667
+ }), 128)),
1668
+ $setup.w.message.value !== void 0 ? (openBlock(), createBlock($setup["Text"], {
1669
+ key: 0,
1670
+ color: "red"
1671
+ }, {
1672
+ default: withCtx(() => [createTextVNode(toDisplayString($setup.w.message.value), 1)]),
1673
+ _: 1
1674
+ })) : createCommentVNode("v-if", true),
1675
+ createVNode($setup["Text"], { dimColor: "" }, {
1676
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("↑/↓/tab 换字段 · 输入即编辑 · enter 预览生成物 · esc 返回", -1)])]),
1677
+ _: 1
1678
+ })
1679
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
1680
+ createCommentVNode(" 第 3 步:预览生成物(落盘前可见再确认) "),
1681
+ createVNode($setup["Text"], null, {
1682
+ default: withCtx(() => [createTextVNode("输出目录: " + toDisplayString($setup.w.targetDir.value), 1)]),
1683
+ _: 1
1684
+ }),
1685
+ createVNode($setup["Text"], { bold: "" }, {
1686
+ default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("--- deploy.yaml ---", -1)])]),
1687
+ _: 1
1688
+ }),
1689
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.previewLines, (line, i) => {
1690
+ return openBlock(), createBlock($setup["Text"], {
1691
+ key: `yaml-${i}`,
1692
+ wrap: "truncate"
1693
+ }, {
1694
+ default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
1695
+ _: 2
1696
+ }, 1024);
1697
+ }), 128)),
1698
+ $setup.w.previewCompose.value !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode($setup["Text"], { bold: "" }, {
1699
+ default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("--- docker-compose.yml(image 型自动生成)---", -1)])]),
1700
+ _: 1
1701
+ }), (openBlock(true), createElementBlock(Fragment, null, renderList($setup.composeLines, (line, i) => {
1702
+ return openBlock(), createBlock($setup["Text"], {
1703
+ key: `compose-${i}`,
1704
+ wrap: "truncate"
1705
+ }, {
1706
+ default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
1707
+ _: 2
1708
+ }, 1024);
1709
+ }), 128))], 64)) : createCommentVNode("v-if", true),
1710
+ createCommentVNode(" concern④:compose 型二选一引导 "),
1711
+ $setup.w.projectType.value === "compose" ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList($setup.w.guidance.value, (line, i) => {
1712
+ return openBlock(), createBlock($setup["Text"], {
1713
+ key: `guide-${i}`,
1714
+ color: i === 0 ? "yellow" : void 0
1715
+ }, {
1716
+ default: withCtx(() => [createTextVNode(toDisplayString(line), 1)]),
1717
+ _: 2
1718
+ }, 1032, ["color"]);
1719
+ }), 128)) : createCommentVNode("v-if", true),
1720
+ $setup.w.message.value !== void 0 ? (openBlock(), createBlock($setup["Text"], {
1721
+ key: 2,
1722
+ color: "red"
1723
+ }, {
1724
+ default: withCtx(() => [createTextVNode(toDisplayString($setup.w.message.value), 1)]),
1725
+ _: 1
1726
+ })) : createCommentVNode("v-if", true),
1727
+ createVNode($setup["Text"], { dimColor: "" }, {
1728
+ default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode("enter 确认创建 · c 重新检查 compose 文件 · esc 返回修改", -1)])]),
1729
+ _: 1
1730
+ })
1731
+ ], 64)),
1732
+ createCommentVNode(" 落盘确认(破坏性/落盘动作走 ConfirmModal) "),
1733
+ createVNode($setup["ConfirmModal"], {
1734
+ visible: $setup.w.confirmOpen.value,
1735
+ message: `确认创建托管项目 ${$setup.w.fields.value.find((f) => f.key === "name")?.value ?? ""} 于 ${$setup.w.targetDir.value}?`,
1736
+ onConfirm: _cache[0] || (_cache[0] = ($event) => $setup.w.confirm()),
1737
+ onCancel: _cache[1] || (_cache[1] = ($event) => $setup.w.cancelConfirm())
1738
+ }, null, 8, ["visible", "message"])
1739
+ ]),
1740
+ _: 1
1741
+ });
1742
+ }
1743
+ 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"]]);
897
1744
  //#endregion
898
1745
  //#region src/tui/composables/useLogs.ts
899
1746
  /** 日志列表上限(T4#4 递延项):超出环形截断最旧行,防长会话无界增长 */
@@ -1000,6 +1847,134 @@ function useContainers(opts = {}) {
1000
1847
  };
1001
1848
  }
1002
1849
  //#endregion
1850
+ //#region src/tui/composables/useDeployRun.ts
1851
+ /** 流水线步骤条顺序(R10):update→pre→build→up→nginx→health→post,与 core StepName 一一对应 */
1852
+ const DEPLOY_STEPS = [
1853
+ "update",
1854
+ "pre",
1855
+ "build",
1856
+ "up",
1857
+ "nginx",
1858
+ "health",
1859
+ "post"
1860
+ ];
1861
+ /** 步骤条中文文案 */
1862
+ const STEP_LABELS = {
1863
+ update: "update 更新(git pull)",
1864
+ pre: "pre 前置钩子",
1865
+ build: "build 构建",
1866
+ up: "up 启动容器",
1867
+ nginx: "nginx 站点配置",
1868
+ health: "health 健康检查",
1869
+ post: "post 后置钩子"
1870
+ };
1871
+ /** 流水线事件 → 日志行(CLI deploy formatEvent 同口径) */
1872
+ function formatEvent(e) {
1873
+ if (e.status === "ok") return `[${e.step}] ✓`;
1874
+ if (e.status === "fail") return `[${e.step}] ✗ ${e.line ?? ""}`;
1875
+ if (e.status === "warn") return `[${e.step}] ⚠ ${e.line ?? ""}`;
1876
+ return `[${e.step}] ${e.line ?? "开始"}`;
1877
+ }
1878
+ /**
1879
+ * Deploy 面板数据面(M2-T6):runDeploy 事件流 → 步骤条 ViewModel + 实时日志流。
1880
+ * 失败即停:fail 步之后的 pending 步骤标「跳过」;成功收尾时配置跳过(未执行)步骤同样标「跳过」。
1881
+ * 启动入口=Projects 面板 d(App 接线);运行中拒绝二次 start(防重复部署)。
1882
+ */
1883
+ function useDeployRun(opts = {}) {
1884
+ const { info, success, warn, error: logError } = useLogs();
1885
+ const projectName = ref(void 0);
1886
+ const steps = ref(DEPLOY_STEPS.map((key) => ({
1887
+ key,
1888
+ label: STEP_LABELS[key],
1889
+ status: "pending"
1890
+ })));
1891
+ const running = ref(false);
1892
+ const done = ref(void 0);
1893
+ const failedStep = ref(void 0);
1894
+ const lines = ref([]);
1895
+ /** fail 之后(含 fail 步自身之后)的 pending 步骤标跳过(失败即停视觉呈现) */
1896
+ function skipAfter(step) {
1897
+ const idx = DEPLOY_STEPS.indexOf(step);
1898
+ for (let i = idx + 1; i < steps.value.length; i++) {
1899
+ const vm = steps.value[i];
1900
+ if (vm.status === "pending") vm.status = "skipped";
1901
+ }
1902
+ }
1903
+ function onEvent(e) {
1904
+ const line = formatEvent(e);
1905
+ lines.value.push(line);
1906
+ const vm = steps.value.find((s) => s.key === e.step);
1907
+ if (e.status === "start") {
1908
+ if (vm) vm.status = "running";
1909
+ info(line);
1910
+ } else if (e.status === "ok") {
1911
+ if (vm) vm.status = "ok";
1912
+ info(line);
1913
+ } else if (e.status === "warn") warn(line);
1914
+ else {
1915
+ if (vm) vm.status = "fail";
1916
+ skipAfter(e.step);
1917
+ logError(line);
1918
+ }
1919
+ }
1920
+ async function start(name) {
1921
+ if (running.value) {
1922
+ warn(`已有部署在运行: ${projectName.value ?? ""},忽略新请求: ${name}`);
1923
+ return;
1924
+ }
1925
+ const row = listProjects(opts.load ? opts.load() : loadConfig()).find((r) => r.name === name);
1926
+ if (!row) {
1927
+ logError(`未找到项目: ${name}(先在 Projects 面板按 n 创建,或 deploy-cli project add 注册)`);
1928
+ return;
1929
+ }
1930
+ if (!row.config) {
1931
+ logError(`项目配置不可用: ${name}: ${row.error ?? ""}`);
1932
+ return;
1933
+ }
1934
+ projectName.value = name;
1935
+ steps.value = DEPLOY_STEPS.map((key) => ({
1936
+ key,
1937
+ label: STEP_LABELS[key],
1938
+ status: "pending"
1939
+ }));
1940
+ done.value = void 0;
1941
+ failedStep.value = void 0;
1942
+ lines.value = [];
1943
+ running.value = true;
1944
+ info(`开始部署: ${name}(${row.path})`);
1945
+ try {
1946
+ const result = await (opts.run ?? runDeploy)(row.config, {
1947
+ cwd: expandPath(row.path),
1948
+ onEvent
1949
+ });
1950
+ if (result.ok) {
1951
+ done.value = "ok";
1952
+ success(`部署完成: ${name}`);
1953
+ } else {
1954
+ done.value = "fail";
1955
+ failedStep.value = result.failedStep;
1956
+ if (result.failedStep !== void 0) skipAfter(result.failedStep);
1957
+ logError(`部署失败: ${name}(步骤: ${result.failedStep ?? "未知"})`);
1958
+ }
1959
+ } catch (err) {
1960
+ done.value = "fail";
1961
+ logError(`部署异常: ${name}: ${err instanceof Error ? err.message : String(err)}`);
1962
+ } finally {
1963
+ for (const vm of steps.value) if (vm.status === "pending") vm.status = "skipped";
1964
+ running.value = false;
1965
+ }
1966
+ }
1967
+ return {
1968
+ projectName,
1969
+ steps,
1970
+ running,
1971
+ done,
1972
+ failedStep,
1973
+ lines,
1974
+ start
1975
+ };
1976
+ }
1977
+ //#endregion
1003
1978
  //#region src/tui/composables/useHealth.ts
1004
1979
  /** ProjectHealth → 三列单元格(复刻 CLI status formatRow 口径) */
1005
1980
  function toRow$1(health) {
@@ -1124,8 +2099,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
1124
2099
  const { rows: projectRows, error: projectError, refresh: refreshProjects } = useProjects();
1125
2100
  const { rows: containerRows, error: containerError, following, refresh: refreshContainers, restart, stop, remove, followLogs } = useContainers();
1126
2101
  const { rows: healthRows, error: healthError, refresh: refreshHealth } = useHealth();
2102
+ const { projectName: deployProject, steps: deploySteps, lines: deployLines, running: deployRunning, done: deployDone, failedStep: deployFailedStep, start: startDeploy } = useDeployRun();
1127
2103
  const activePanel = ref("projects");
1128
2104
  const helpVisible = ref(false);
2105
+ const wizardOpen = ref(false);
1129
2106
  useKeymap({
1130
2107
  onPanel: (panel) => {
1131
2108
  activePanel.value = panel;
@@ -1150,7 +2127,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
1150
2127
  async function onContainerAction(action, name) {
1151
2128
  info(`${ACTION_LABEL[action]}容器: ${name}`);
1152
2129
  try {
1153
- const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name);
2130
+ const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name, { force: true });
1154
2131
  if (result.code === 0) {
1155
2132
  success(`${ACTION_LABEL[action]}容器成功: ${name}`);
1156
2133
  await refreshContainers();
@@ -1164,6 +2141,19 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
1164
2141
  function onLogs(name) {
1165
2142
  followLogs(name);
1166
2143
  }
2144
+ /** Projects d → 部署执行面(useDeployRun)并切到 Deploy 面板看步骤流(T6 接线) */
2145
+ function onDeploy(name) {
2146
+ activePanel.value = "deploy";
2147
+ startDeploy(name);
2148
+ }
2149
+ /** 创建向导落盘成功(WizardPanel 经 ConfirmModal 确认后):日志 + 关闭时刷新列表 */
2150
+ function onWizardCreated(result) {
2151
+ success(`创建托管项目成功: ${result.config.name}(${result.dir})`);
2152
+ }
2153
+ function onWizardClose() {
2154
+ wizardOpen.value = false;
2155
+ refreshProjects();
2156
+ }
1167
2157
  const __returned__ = {
1168
2158
  exit,
1169
2159
  logs,
@@ -1184,11 +2174,22 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
1184
2174
  healthRows,
1185
2175
  healthError,
1186
2176
  refreshHealth,
2177
+ deployProject,
2178
+ deploySteps,
2179
+ deployLines,
2180
+ deployRunning,
2181
+ deployDone,
2182
+ deployFailedStep,
2183
+ startDeploy,
1187
2184
  activePanel,
1188
2185
  helpVisible,
2186
+ wizardOpen,
1189
2187
  ACTION_LABEL,
1190
2188
  onContainerAction,
1191
2189
  onLogs,
2190
+ onDeploy,
2191
+ onWizardCreated,
2192
+ onWizardClose,
1192
2193
  panelTitle: computed(() => `${PANEL_IDS.indexOf(activePanel.value) + 1}. ${PANEL_TITLES[activePanel.value]}`),
1193
2194
  get Box() {
1194
2195
  return Box;
@@ -1197,10 +2198,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
1197
2198
  return Text;
1198
2199
  },
1199
2200
  ContainersPanel: ContainersPanel_default,
2201
+ DeployPanel: DeployPanel_default,
1200
2202
  OutputPanel: OutputPanel_default,
1201
2203
  ProjectsPanel: ProjectsPanel_default,
1202
2204
  StatusPanel: StatusPanel_default,
1203
2205
  StatusBar: StatusBar_default,
2206
+ WizardPanel: WizardPanel_default,
1204
2207
  get PANEL_IDS() {
1205
2208
  return PANEL_IDS;
1206
2209
  },
@@ -1232,46 +2235,67 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1232
2235
  bold: "",
1233
2236
  color: "cyan"
1234
2237
  }, {
1235
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("Deploy CLI", -1)])]),
2238
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("Deploy CLI", -1)])]),
1236
2239
  _: 1
1237
2240
  }), createVNode($setup["Text"], { dimColor: "" }, {
1238
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
2241
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
1239
2242
  _: 1
1240
2243
  })]),
1241
2244
  _: 1
1242
2245
  }),
1243
- createCommentVNode(" 主面板区:1/2/4/6 实装,3 Deploy(T6)/5 Tunnels(T7)骨架占位 "),
2246
+ createCommentVNode(" 主面板区:1/2/3/4/6 实装,5 Tunnels(T7)骨架占位;创建向导(n)打开时独占主区 "),
1244
2247
  createVNode($setup["Box"], {
1245
2248
  flexDirection: "column",
1246
2249
  flexGrow: 1,
1247
2250
  paddingX: 1
1248
2251
  }, {
1249
- default: withCtx(() => [createCommentVNode(" 项目动作出口(deploy)先挂 emit,T6 接线 "), $setup.activePanel === "projects" ? (openBlock(), createBlock($setup["ProjectsPanel"], {
2252
+ default: withCtx(() => [$setup.wizardOpen ? (openBlock(), createBlock($setup["WizardPanel"], {
1250
2253
  key: 0,
2254
+ onCreated: $setup.onWizardCreated,
2255
+ onClose: $setup.onWizardClose
2256
+ })) : $setup.activePanel === "projects" ? (openBlock(), createBlock($setup["ProjectsPanel"], {
2257
+ key: 1,
1251
2258
  rows: $setup.projectRows,
1252
2259
  error: $setup.projectError,
2260
+ onDeploy: $setup.onDeploy,
2261
+ onCreate: _cache[0] || (_cache[0] = ($event) => $setup.wizardOpen = true),
1253
2262
  onRefresh: $setup.refreshProjects
1254
2263
  }, null, 8, [
1255
2264
  "rows",
1256
2265
  "error",
1257
2266
  "onRefresh"
1258
2267
  ])) : $setup.activePanel === "containers" ? (openBlock(), createBlock($setup["ContainersPanel"], {
1259
- key: 1,
2268
+ key: 2,
1260
2269
  rows: $setup.containerRows,
1261
2270
  error: $setup.containerError,
1262
2271
  following: $setup.following,
1263
2272
  onLogs: $setup.onLogs,
1264
- onRestart: _cache[0] || (_cache[0] = (name) => $setup.onContainerAction("restart", name)),
1265
- onStop: _cache[1] || (_cache[1] = (name) => $setup.onContainerAction("stop", name)),
1266
- onRemove: _cache[2] || (_cache[2] = (name) => $setup.onContainerAction("remove", name)),
2273
+ onRestart: _cache[1] || (_cache[1] = (name) => $setup.onContainerAction("restart", name)),
2274
+ onStop: _cache[2] || (_cache[2] = (name) => $setup.onContainerAction("stop", name)),
2275
+ onRemove: _cache[3] || (_cache[3] = (name) => $setup.onContainerAction("remove", name)),
1267
2276
  onRefresh: $setup.refreshContainers
1268
2277
  }, null, 8, [
1269
2278
  "rows",
1270
2279
  "error",
1271
2280
  "following",
1272
2281
  "onRefresh"
2282
+ ])) : $setup.activePanel === "deploy" ? (openBlock(), createBlock($setup["DeployPanel"], {
2283
+ key: 3,
2284
+ "project-name": $setup.deployProject,
2285
+ steps: $setup.deploySteps,
2286
+ lines: $setup.deployLines,
2287
+ running: $setup.deployRunning,
2288
+ done: $setup.deployDone,
2289
+ "failed-step": $setup.deployFailedStep
2290
+ }, null, 8, [
2291
+ "project-name",
2292
+ "steps",
2293
+ "lines",
2294
+ "running",
2295
+ "done",
2296
+ "failed-step"
1273
2297
  ])) : $setup.activePanel === "status" ? (openBlock(), createBlock($setup["StatusPanel"], {
1274
- key: 2,
2298
+ key: 4,
1275
2299
  rows: $setup.healthRows,
1276
2300
  error: $setup.healthError,
1277
2301
  onRefresh: $setup.refreshHealth
@@ -1280,10 +2304,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1280
2304
  "error",
1281
2305
  "onRefresh"
1282
2306
  ])) : $setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
1283
- key: 3,
2307
+ key: 5,
1284
2308
  logs: $setup.logs
1285
2309
  }, null, 8, ["logs"])) : (openBlock(), createBlock($setup["Box"], {
1286
- key: 4,
2310
+ key: 6,
1287
2311
  flexDirection: "column",
1288
2312
  flexGrow: 1,
1289
2313
  borderStyle: "round",
@@ -1296,7 +2320,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1296
2320
  default: withCtx(() => [createTextVNode(toDisplayString($setup.panelTitle), 1)]),
1297
2321
  _: 1
1298
2322
  }), createVNode($setup["Text"], { dimColor: "" }, {
1299
- default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
2323
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
1300
2324
  _: 1
1301
2325
  })]),
1302
2326
  _: 1
@@ -1317,7 +2341,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1317
2341
  bold: "",
1318
2342
  color: "yellow"
1319
2343
  }, {
1320
- default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("快捷键帮助", -1)])]),
2344
+ default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("快捷键帮助", -1)])]),
1321
2345
  _: 1
1322
2346
  }),
1323
2347
  (openBlock(true), createElementBlock(Fragment, null, renderList($setup.PANEL_IDS, (id, i) => {
@@ -1327,7 +2351,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1327
2351
  }, 1024);
1328
2352
  }), 128)),
1329
2353
  createVNode($setup["Text"], null, {
1330
- default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
2354
+ default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
1331
2355
  _: 1
1332
2356
  })
1333
2357
  ]),