@dongnanyang/deploy-cli 0.13.1 → 0.14.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/main.js DELETED
@@ -1,1504 +0,0 @@
1
- import { n as loadConfig, r as saveConfig, t as expandPath } from "./config-xUl8Oa3T.js";
2
- import { t as export_helper_default } from "./export-helper-CIEcxb5I.js";
3
- import { readFileSync, readdirSync } from "fs";
4
- import { dirname, join, resolve } from "path";
5
- import { Box, Text, createApp, useApp, useInput } from "@vue-tui/runtime";
6
- import { Fragment, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, nextTick, onMounted, onUnmounted, openBlock, ref, renderList, shallowRef, toDisplayString, watch, withCtx } from "vue";
7
- import { ScrollBox } from "@vue-tui/components";
8
- import { createServer } from "net";
9
- import { Client } from "ssh2";
10
- import { spawn } from "child_process";
11
- //#region src/components/TunnelPanel.vue
12
- const _sfc_main$6 = /*@__PURE__*/ defineComponent({
13
- __name: "TunnelPanel",
14
- props: {
15
- tunnels: {
16
- type: Array,
17
- required: true
18
- },
19
- isActive: {
20
- type: Boolean,
21
- required: true
22
- }
23
- },
24
- emits: [
25
- "start",
26
- "stop",
27
- "startAll"
28
- ],
29
- setup(__props, { expose: __expose, emit: __emit }) {
30
- __expose();
31
- const props = __props;
32
- const emit = __emit;
33
- const selected = ref(0);
34
- watch(() => props.tunnels.length, (len) => {
35
- if (selected.value >= len) selected.value = Math.max(0, len - 1);
36
- });
37
- useInput((event) => {
38
- if (!props.isActive) return;
39
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
40
- if (name === void 0) return;
41
- if (name === "j" || name === "down") selected.value = Math.min(selected.value + 1, props.tunnels.length - 1);
42
- else if (name === "k" || name === "up") selected.value = Math.max(selected.value - 1, 0);
43
- else if (name === "s") {
44
- const t = props.tunnels[selected.value];
45
- if (t) emit("start", t.name);
46
- } else if (name === "x") {
47
- const t = props.tunnels[selected.value];
48
- if (t) emit("stop", t.name);
49
- } else if (name === "a") emit("startAll");
50
- }, { isActive: () => props.isActive });
51
- const __returned__ = {
52
- props,
53
- emit,
54
- selected,
55
- get Box() {
56
- return Box;
57
- },
58
- get Text() {
59
- return Text;
60
- }
61
- };
62
- Object.defineProperty(__returned__, "__isScriptSetup", {
63
- enumerable: false,
64
- value: true
65
- });
66
- return __returned__;
67
- }
68
- });
69
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
70
- return openBlock(), createBlock($setup["Box"], {
71
- flexDirection: "column",
72
- borderStyle: "single",
73
- borderColor: $props.isActive ? "cyan" : "gray",
74
- padding: 1,
75
- flexGrow: 1,
76
- flexShrink: 0
77
- }, {
78
- default: withCtx(() => [
79
- createVNode($setup["Text"], {
80
- bold: "",
81
- color: "cyan"
82
- }, {
83
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Tunnels", -1)])]),
84
- _: 1
85
- }),
86
- $props.tunnels.length === 0 ? (openBlock(), createBlock($setup["Box"], {
87
- key: 0,
88
- flexDirection: "column"
89
- }, {
90
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
91
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("暂无隧道配置", -1)])]),
92
- _: 1
93
- }), createVNode($setup["Text"], { dimColor: "" }, {
94
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("编辑 ~/.deploy-cli/config.json 添加", -1)])]),
95
- _: 1
96
- })]),
97
- _: 1
98
- })) : (openBlock(), createBlock($setup["Box"], {
99
- key: 1,
100
- flexDirection: "column",
101
- marginTop: 1
102
- }, {
103
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($props.tunnels, (t, i) => {
104
- return openBlock(), createBlock($setup["Box"], {
105
- key: t.name,
106
- flexDirection: "row",
107
- gap: 1,
108
- flexShrink: 0
109
- }, {
110
- default: withCtx(() => [
111
- createVNode($setup["Text"], { color: t.status === "running" ? "green" : t.status === "error" ? "red" : "gray" }, {
112
- default: withCtx(() => [createTextVNode(toDisplayString(t.status === "running" ? "●" : t.status === "error" ? "✗" : "○"), 1)]),
113
- _: 2
114
- }, 1032, ["color"]),
115
- createVNode($setup["Text"], {
116
- bold: i === $setup.selected,
117
- color: i === $setup.selected ? "cyan" : "default"
118
- }, {
119
- default: withCtx(() => [createTextVNode(toDisplayString(t.name), 1)]),
120
- _: 2
121
- }, 1032, ["bold", "color"]),
122
- createVNode($setup["Text"], { dimColor: "" }, {
123
- default: withCtx(() => [createTextVNode(":" + toDisplayString(t.localPort) + " -> " + toDisplayString(t.remoteHost) + ":" + toDisplayString(t.remotePort), 1)]),
124
- _: 2
125
- }, 1024),
126
- t.autoStart ? (openBlock(), createBlock($setup["Text"], {
127
- key: 0,
128
- dimColor: ""
129
- }, {
130
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("(auto)", -1)])]),
131
- _: 1
132
- })) : createCommentVNode("v-if", true)
133
- ]),
134
- _: 2
135
- }, 1024);
136
- }), 128))]),
137
- _: 1
138
- })),
139
- createVNode($setup["Box"], {
140
- flexDirection: "row",
141
- marginTop: 1,
142
- gap: 2,
143
- flexShrink: 0
144
- }, {
145
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
146
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("[s]tart [x]stop [a]ll", -1)])]),
147
- _: 1
148
- })]),
149
- _: 1
150
- })
151
- ]),
152
- _: 1
153
- }, 8, ["borderColor"]);
154
- }
155
- var TunnelPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$6, [["render", _sfc_render$6], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/TunnelPanel.vue"]]);
156
- //#endregion
157
- //#region src/components/DeployPanel.vue
158
- const _sfc_main$5 = /*@__PURE__*/ defineComponent({
159
- __name: "DeployPanel",
160
- props: {
161
- scripts: {
162
- type: Array,
163
- required: true
164
- },
165
- isActive: {
166
- type: Boolean,
167
- required: true
168
- },
169
- running: {
170
- type: [String, null],
171
- required: true
172
- }
173
- },
174
- emits: ["run", "runWithParams"],
175
- setup(__props, { expose: __expose, emit: __emit }) {
176
- __expose();
177
- const props = __props;
178
- const emit = __emit;
179
- const selected = ref(0);
180
- watch(() => props.scripts.length, (len) => {
181
- if (selected.value >= len) selected.value = Math.max(0, len - 1);
182
- });
183
- useInput((event) => {
184
- if (!props.isActive) return;
185
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
186
- if (name === void 0) return;
187
- if (name === "j" || name === "down") selected.value = Math.min(selected.value + 1, props.scripts.length - 1);
188
- else if (name === "k" || name === "up") selected.value = Math.max(selected.value - 1, 0);
189
- else if (name === "enter") {
190
- const s = props.scripts[selected.value];
191
- if (s) emit("run", s, []);
192
- } else if (name === "p") {
193
- const s = props.scripts[selected.value];
194
- if (s) emit("runWithParams", s);
195
- }
196
- }, { isActive: () => props.isActive });
197
- const __returned__ = {
198
- props,
199
- emit,
200
- selected,
201
- get Box() {
202
- return Box;
203
- },
204
- get Text() {
205
- return Text;
206
- }
207
- };
208
- Object.defineProperty(__returned__, "__isScriptSetup", {
209
- enumerable: false,
210
- value: true
211
- });
212
- return __returned__;
213
- }
214
- });
215
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
216
- return openBlock(), createBlock($setup["Box"], {
217
- flexDirection: "column",
218
- borderStyle: "single",
219
- borderColor: $props.isActive ? "cyan" : "gray",
220
- padding: 1,
221
- flexGrow: 1,
222
- flexShrink: 0
223
- }, {
224
- default: withCtx(() => [
225
- createVNode($setup["Text"], {
226
- bold: "",
227
- color: "cyan"
228
- }, {
229
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Deploy", -1)])]),
230
- _: 1
231
- }),
232
- $props.scripts.length === 0 ? (openBlock(), createBlock($setup["Box"], {
233
- key: 0,
234
- flexDirection: "column"
235
- }, {
236
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
237
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("暂无部署脚本", -1)])]),
238
- _: 1
239
- }), createVNode($setup["Text"], { dimColor: "" }, {
240
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("按 [n] 添加项目", -1)])]),
241
- _: 1
242
- })]),
243
- _: 1
244
- })) : (openBlock(), createBlock($setup["Box"], {
245
- key: 1,
246
- flexDirection: "column",
247
- marginTop: 1
248
- }, {
249
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($props.scripts, (s, i) => {
250
- return openBlock(), createBlock($setup["Box"], {
251
- key: `${s.project}/${s.name}`,
252
- flexDirection: "row",
253
- gap: 1,
254
- flexShrink: 0
255
- }, {
256
- default: withCtx(() => [
257
- createVNode($setup["Text"], { color: i === $setup.selected ? "cyan" : "gray" }, {
258
- default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.selected ? "▸" : " "), 1)]),
259
- _: 2
260
- }, 1032, ["color"]),
261
- createVNode($setup["Text"], { bold: i === $setup.selected }, {
262
- default: withCtx(() => [createTextVNode(toDisplayString(s.project) + "/" + toDisplayString(s.name), 1)]),
263
- _: 2
264
- }, 1032, ["bold"]),
265
- $props.running === `${s.project}/${s.name}` ? (openBlock(), createBlock($setup["Text"], {
266
- key: 0,
267
- color: "yellow"
268
- }, {
269
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("running...", -1)])]),
270
- _: 1
271
- })) : s.lastResult === "success" ? (openBlock(), createBlock($setup["Text"], {
272
- key: 1,
273
- color: "green",
274
- dimColor: ""
275
- }, {
276
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("✓", -1)])]),
277
- _: 1
278
- })) : s.lastResult === "fail" ? (openBlock(), createBlock($setup["Text"], {
279
- key: 2,
280
- color: "red",
281
- dimColor: ""
282
- }, {
283
- default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("✗", -1)])]),
284
- _: 1
285
- })) : createCommentVNode("v-if", true)
286
- ]),
287
- _: 2
288
- }, 1024);
289
- }), 128))]),
290
- _: 1
291
- })),
292
- createVNode($setup["Box"], {
293
- flexDirection: "row",
294
- marginTop: 1,
295
- gap: 2,
296
- flexShrink: 0
297
- }, {
298
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
299
- default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("[Enter] run [p]arams", -1)])]),
300
- _: 1
301
- })]),
302
- _: 1
303
- })
304
- ]),
305
- _: 1
306
- }, 8, ["borderColor"]);
307
- }
308
- var DeployPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [["render", _sfc_render$5], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/DeployPanel.vue"]]);
309
- //#endregion
310
- //#region src/components/OutputPanel.vue
311
- const _sfc_main$4 = /*@__PURE__*/ defineComponent({
312
- __name: "OutputPanel",
313
- props: {
314
- logs: {
315
- type: Array,
316
- required: true
317
- },
318
- isActive: {
319
- type: Boolean,
320
- required: true
321
- }
322
- },
323
- setup(__props, { expose: __expose }) {
324
- __expose();
325
- const props = __props;
326
- const scrollRef = shallowRef(null);
327
- watch(() => props.logs.length, async () => {
328
- await nextTick();
329
- scrollRef.value?.scrollToBottom();
330
- });
331
- useInput((event) => {
332
- if (!props.isActive) return;
333
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
334
- if (name === void 0) return;
335
- if (name === "up") scrollRef.value?.scrollByLines(-1);
336
- else if (name === "down") scrollRef.value?.scrollByLines(1);
337
- else if (name === "g") scrollRef.value?.scrollToTop();
338
- else if (name === "G") scrollRef.value?.scrollToBottom();
339
- }, { isActive: () => props.isActive });
340
- function levelColor(level) {
341
- return level === "success" ? "green" : level === "error" ? "red" : level === "warn" ? "yellow" : "default";
342
- }
343
- function levelIcon(level) {
344
- return level === "success" ? "✓" : level === "error" ? "✗" : level === "warn" ? "⚠" : " ";
345
- }
346
- const __returned__ = {
347
- props,
348
- scrollRef,
349
- levelColor,
350
- levelIcon,
351
- get Box() {
352
- return Box;
353
- },
354
- get Text() {
355
- return Text;
356
- },
357
- get ScrollBox() {
358
- return ScrollBox;
359
- }
360
- };
361
- Object.defineProperty(__returned__, "__isScriptSetup", {
362
- enumerable: false,
363
- value: true
364
- });
365
- return __returned__;
366
- }
367
- });
368
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
369
- return openBlock(), createBlock($setup["Box"], {
370
- flexDirection: "column",
371
- borderStyle: "single",
372
- borderColor: $props.isActive ? "cyan" : "gray",
373
- padding: 0,
374
- flexGrow: 2,
375
- overflow: "hidden"
376
- }, {
377
- default: withCtx(() => [createVNode($setup["Box"], { paddingX: 1 }, {
378
- default: withCtx(() => [createVNode($setup["Text"], {
379
- bold: "",
380
- color: "cyan"
381
- }, {
382
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Output", -1)])]),
383
- _: 1
384
- })]),
385
- _: 1
386
- }), createVNode($setup["ScrollBox"], {
387
- ref: "scrollRef",
388
- flexGrow: 1
389
- }, {
390
- default: withCtx(() => [createVNode($setup["Box"], {
391
- flexDirection: "column",
392
- paddingX: 1
393
- }, {
394
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($props.logs, (log, i) => {
395
- return openBlock(), createBlock($setup["Box"], {
396
- key: i,
397
- flexDirection: "row",
398
- gap: 1
399
- }, {
400
- default: withCtx(() => [
401
- createVNode($setup["Text"], { dimColor: "" }, {
402
- default: withCtx(() => [createTextVNode(toDisplayString(log.time), 1)]),
403
- _: 2
404
- }, 1024),
405
- createVNode($setup["Text"], { color: $setup.levelColor(log.level) }, {
406
- default: withCtx(() => [createTextVNode(toDisplayString($setup.levelIcon(log.level)), 1)]),
407
- _: 2
408
- }, 1032, ["color"]),
409
- createVNode($setup["Text"], {
410
- color: $setup.levelColor(log.level),
411
- dimColor: log.level === "info"
412
- }, {
413
- default: withCtx(() => [createTextVNode(toDisplayString(log.message), 1)]),
414
- _: 2
415
- }, 1032, ["color", "dimColor"])
416
- ]),
417
- _: 2
418
- }, 1024);
419
- }), 128))]),
420
- _: 1
421
- })]),
422
- _: 1
423
- }, 512)]),
424
- _: 1
425
- }, 8, ["borderColor"]);
426
- }
427
- var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$4, [["render", _sfc_render$4], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/OutputPanel.vue"]]);
428
- //#endregion
429
- //#region src/components/StatusBar.vue
430
- const _sfc_main$3 = /*@__PURE__*/ defineComponent({
431
- __name: "StatusBar",
432
- props: {
433
- tunnelCount: {
434
- type: Number,
435
- required: true
436
- },
437
- focus: {
438
- type: String,
439
- required: true
440
- },
441
- runningDeploy: {
442
- type: [String, null],
443
- required: true
444
- }
445
- },
446
- setup(__props, { expose: __expose }) {
447
- __expose();
448
- const __returned__ = {
449
- get Box() {
450
- return Box;
451
- },
452
- get Text() {
453
- return Text;
454
- }
455
- };
456
- Object.defineProperty(__returned__, "__isScriptSetup", {
457
- enumerable: false,
458
- value: true
459
- });
460
- return __returned__;
461
- }
462
- });
463
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
464
- return openBlock(), createBlock($setup["Box"], {
465
- flexDirection: "row",
466
- paddingX: 1,
467
- flexShrink: 0
468
- }, {
469
- default: withCtx(() => [
470
- createVNode($setup["Text"], { color: $props.tunnelCount > 0 ? "green" : "gray" }, {
471
- default: withCtx(() => [createTextVNode(toDisplayString($props.tunnelCount) + " tunnels running ", 1)]),
472
- _: 1
473
- }, 8, ["color"]),
474
- createVNode($setup["Text"], { dimColor: "" }, {
475
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode(" │ ", -1)])]),
476
- _: 1
477
- }),
478
- createVNode($setup["Text"], { dimColor: "" }, {
479
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("focus: ", -1)])]),
480
- _: 1
481
- }),
482
- createVNode($setup["Text"], { bold: "" }, {
483
- default: withCtx(() => [createTextVNode(toDisplayString($props.focus), 1)]),
484
- _: 1
485
- }),
486
- $props.runningDeploy ? (openBlock(), createBlock($setup["Text"], {
487
- key: 0,
488
- dimColor: ""
489
- }, {
490
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode(" │ ", -1)])]),
491
- _: 1
492
- })) : createCommentVNode("v-if", true),
493
- $props.runningDeploy ? (openBlock(), createBlock($setup["Text"], {
494
- key: 1,
495
- color: "yellow"
496
- }, {
497
- default: withCtx(() => [createTextVNode(toDisplayString($props.runningDeploy), 1)]),
498
- _: 1
499
- })) : createCommentVNode("v-if", true),
500
- createVNode($setup["Text"], { dimColor: "" }, {
501
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode(" │ [Tab] switch [n]ew [r]escan [q] quit", -1)])]),
502
- _: 1
503
- })
504
- ]),
505
- _: 1
506
- });
507
- }
508
- var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$3, [["render", _sfc_render$3], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/StatusBar.vue"]]);
509
- //#endregion
510
- //#region src/components/InputModal.vue
511
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
512
- __name: "InputModal",
513
- props: {
514
- title: {
515
- type: String,
516
- required: true
517
- },
518
- fields: {
519
- type: Array,
520
- required: true
521
- },
522
- visible: {
523
- type: Boolean,
524
- required: true
525
- }
526
- },
527
- emits: ["submit", "cancel"],
528
- setup(__props, { expose: __expose, emit: __emit }) {
529
- __expose();
530
- const props = __props;
531
- const emit = __emit;
532
- const values = ref({});
533
- const fieldIdx = ref(0);
534
- watch(() => props.visible, (v) => {
535
- if (v) {
536
- values.value = {};
537
- for (const f of props.fields) values.value[f.key] = f.default || "";
538
- fieldIdx.value = 0;
539
- }
540
- });
541
- useInput((event) => {
542
- if (!props.visible) return;
543
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
544
- const char = event.type === "text" ? event.text : event.type === "key" ? event.key.character : void 0;
545
- if (name === "escape") {
546
- emit("cancel");
547
- return;
548
- }
549
- if (name === "enter") {
550
- emit("submit", { ...values.value });
551
- return;
552
- }
553
- if (name === "tab") {
554
- fieldIdx.value = (fieldIdx.value + 1) % props.fields.length;
555
- return;
556
- }
557
- if (name === "backspace") {
558
- const key = props.fields[fieldIdx.value].key;
559
- values.value[key] = values.value[key].slice(0, -1);
560
- return;
561
- }
562
- if (char) {
563
- const key = props.fields[fieldIdx.value].key;
564
- values.value[key] += char;
565
- }
566
- }, { isActive: () => props.visible });
567
- const __returned__ = {
568
- props,
569
- emit,
570
- values,
571
- fieldIdx,
572
- get Box() {
573
- return Box;
574
- },
575
- get Text() {
576
- return Text;
577
- }
578
- };
579
- Object.defineProperty(__returned__, "__isScriptSetup", {
580
- enumerable: false,
581
- value: true
582
- });
583
- return __returned__;
584
- }
585
- });
586
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
587
- return $props.visible ? (openBlock(), createBlock($setup["Box"], {
588
- key: 0,
589
- flexDirection: "column",
590
- borderStyle: "round",
591
- borderColor: "cyan",
592
- padding: 1,
593
- width: 60,
594
- position: "absolute",
595
- top: 2,
596
- left: 2
597
- }, {
598
- default: withCtx(() => [
599
- createVNode($setup["Text"], {
600
- bold: "",
601
- color: "cyan"
602
- }, {
603
- default: withCtx(() => [createTextVNode(toDisplayString($props.title), 1)]),
604
- _: 1
605
- }),
606
- createVNode($setup["Box"], {
607
- flexDirection: "column",
608
- marginTop: 1,
609
- gap: 1
610
- }, {
611
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($props.fields, (f, i) => {
612
- return openBlock(), createBlock($setup["Box"], {
613
- key: f.key,
614
- flexDirection: "row",
615
- gap: 1
616
- }, {
617
- default: withCtx(() => [
618
- createVNode($setup["Text"], {
619
- color: i === $setup.fieldIdx ? "cyan" : "gray",
620
- bold: i === $setup.fieldIdx
621
- }, {
622
- default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.fieldIdx ? "▸" : " "), 1)]),
623
- _: 2
624
- }, 1032, ["color", "bold"]),
625
- createVNode($setup["Text"], { dimColor: "" }, {
626
- default: withCtx(() => [createTextVNode(toDisplayString(f.label) + ":", 1)]),
627
- _: 2
628
- }, 1024),
629
- createVNode($setup["Text"], { bold: i === $setup.fieldIdx }, {
630
- default: withCtx(() => [createTextVNode(toDisplayString($setup.values[f.key] || "") + " ", 1), i === $setup.fieldIdx ? (openBlock(), createBlock($setup["Text"], {
631
- key: 0,
632
- color: "cyan"
633
- }, {
634
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("_", -1)])]),
635
- _: 1
636
- })) : createCommentVNode("v-if", true)]),
637
- _: 2
638
- }, 1032, ["bold"])
639
- ]),
640
- _: 2
641
- }, 1024);
642
- }), 128))]),
643
- _: 1
644
- }),
645
- createVNode($setup["Box"], {
646
- flexDirection: "row",
647
- marginTop: 1,
648
- gap: 2
649
- }, {
650
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
651
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("[Enter] 确认 [Esc] 取消 [Tab] 切换字段", -1)])]),
652
- _: 1
653
- })]),
654
- _: 1
655
- })
656
- ]),
657
- _: 1
658
- })) : createCommentVNode("v-if", true);
659
- }
660
- var InputModal_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/InputModal.vue"]]);
661
- //#endregion
662
- //#region src/components/ConfigPanel.vue
663
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
664
- __name: "ConfigPanel",
665
- props: {
666
- config: {
667
- type: Object,
668
- required: true
669
- },
670
- isActive: {
671
- type: Boolean,
672
- required: true
673
- },
674
- visible: {
675
- type: Boolean,
676
- required: true
677
- }
678
- },
679
- emits: ["configChanged"],
680
- setup(__props, { expose: __expose, emit: __emit }) {
681
- __expose();
682
- const props = __props;
683
- const emit = __emit;
684
- const modalType = ref(null);
685
- useInput((event) => {
686
- if (!props.visible || modalType.value !== null) return;
687
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
688
- if (name === void 0) return;
689
- if (name === "1") modalType.value = "server";
690
- else if (name === "2") modalType.value = "tunnel";
691
- else if (name === "3") modalType.value = "project";
692
- else if (name === "escape") emit("configChanged");
693
- });
694
- function handleSubmit(values) {
695
- const type = modalType.value;
696
- modalType.value = null;
697
- if (type === "server") {
698
- const server = {
699
- name: values.name,
700
- host: values.host,
701
- port: parseInt(values.port) || 22,
702
- username: values.username || "root",
703
- privateKey: values.privateKey || void 0,
704
- password: values.password || void 0
705
- };
706
- props.config.servers.push(server);
707
- } else if (type === "tunnel") {
708
- const tunnel = {
709
- name: values.name,
710
- server: values.server,
711
- localPort: parseInt(values.localPort) || 3306,
712
- remoteHost: values.remoteHost || "127.0.0.1",
713
- remotePort: parseInt(values.remotePort) || 3306,
714
- autoStart: values.autoStart === "y" || values.autoStart === "true"
715
- };
716
- props.config.tunnels.push(tunnel);
717
- } else if (type === "project") {
718
- const project = {
719
- name: values.name,
720
- path: values.path,
721
- deployDir: values.deployDir || "deploy",
722
- server: values.server || void 0
723
- };
724
- props.config.projects.push(project);
725
- }
726
- emit("configChanged");
727
- }
728
- function handleCancel() {
729
- modalType.value = null;
730
- }
731
- const __returned__ = {
732
- props,
733
- emit,
734
- modalType,
735
- handleSubmit,
736
- handleCancel,
737
- serverFields: [
738
- {
739
- key: "name",
740
- label: "名称 ",
741
- placeholder: "prod-web"
742
- },
743
- {
744
- key: "host",
745
- label: "主机 ",
746
- placeholder: "example.com"
747
- },
748
- {
749
- key: "port",
750
- label: "端口 ",
751
- default: "22"
752
- },
753
- {
754
- key: "username",
755
- label: "用户 ",
756
- default: "root"
757
- },
758
- {
759
- key: "privateKey",
760
- label: "私钥路径 ",
761
- placeholder: "~/.ssh/id_rsa"
762
- }
763
- ],
764
- tunnelFields: [
765
- {
766
- key: "name",
767
- label: "名称 ",
768
- placeholder: "MySQL"
769
- },
770
- {
771
- key: "server",
772
- label: "服务器名 ",
773
- placeholder: "prod-web"
774
- },
775
- {
776
- key: "localPort",
777
- label: "本地端口 ",
778
- placeholder: "3306"
779
- },
780
- {
781
- key: "remoteHost",
782
- label: "远程主机 ",
783
- default: "127.0.0.1"
784
- },
785
- {
786
- key: "remotePort",
787
- label: "远程端口 ",
788
- placeholder: "3306"
789
- },
790
- {
791
- key: "autoStart",
792
- label: "自动启动 ",
793
- default: "n"
794
- }
795
- ],
796
- projectFields: [
797
- {
798
- key: "name",
799
- label: "项目名 ",
800
- placeholder: "my-app"
801
- },
802
- {
803
- key: "path",
804
- label: "本地路径 ",
805
- placeholder: "~/work/my-app"
806
- },
807
- {
808
- key: "deployDir",
809
- label: "脚本目录 ",
810
- default: "deploy"
811
- },
812
- {
813
- key: "server",
814
- label: "服务器名 ",
815
- placeholder: "prod-web"
816
- }
817
- ],
818
- get Box() {
819
- return Box;
820
- },
821
- get Text() {
822
- return Text;
823
- },
824
- InputModal: InputModal_default
825
- };
826
- Object.defineProperty(__returned__, "__isScriptSetup", {
827
- enumerable: false,
828
- value: true
829
- });
830
- return __returned__;
831
- }
832
- });
833
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
834
- return openBlock(), createElementBlock(Fragment, null, [
835
- createCommentVNode(" 配置面板 "),
836
- $props.visible && $setup.modalType === null ? (openBlock(), createBlock($setup["Box"], {
837
- key: 0,
838
- flexDirection: "column",
839
- borderStyle: "round",
840
- borderColor: "yellow",
841
- padding: 1,
842
- width: 50,
843
- position: "absolute",
844
- top: 3,
845
- left: 3
846
- }, {
847
- default: withCtx(() => [
848
- createVNode($setup["Text"], {
849
- bold: "",
850
- color: "yellow"
851
- }, {
852
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("配置管理", -1)])]),
853
- _: 1
854
- }),
855
- createVNode($setup["Box"], {
856
- flexDirection: "column",
857
- marginTop: 1,
858
- gap: 1
859
- }, {
860
- default: withCtx(() => [
861
- createVNode($setup["Text"], { color: "cyan" }, {
862
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("[1] 添加服务器", -1)])]),
863
- _: 1
864
- }),
865
- createVNode($setup["Text"], { color: "cyan" }, {
866
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("[2] 添加隧道", -1)])]),
867
- _: 1
868
- }),
869
- createVNode($setup["Text"], { color: "cyan" }, {
870
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("[3] 添加项目", -1)])]),
871
- _: 1
872
- })
873
- ]),
874
- _: 1
875
- }),
876
- createVNode($setup["Box"], {
877
- flexDirection: "column",
878
- marginTop: 1
879
- }, {
880
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
881
- default: withCtx(() => [createTextVNode("当前: " + toDisplayString($props.config.servers.length) + " 服务器, " + toDisplayString($props.config.tunnels.length) + " 隧道, " + toDisplayString($props.config.projects.length) + " 项目", 1)]),
882
- _: 1
883
- })]),
884
- _: 1
885
- }),
886
- createVNode($setup["Box"], {
887
- flexDirection: "row",
888
- marginTop: 1
889
- }, {
890
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
891
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("[Esc] 保存并关闭", -1)])]),
892
- _: 1
893
- })]),
894
- _: 1
895
- })
896
- ]),
897
- _: 1
898
- })) : createCommentVNode("v-if", true),
899
- createCommentVNode(" 添加服务器弹窗 "),
900
- createVNode($setup["InputModal"], {
901
- title: "添加服务器",
902
- fields: $setup.serverFields,
903
- visible: $setup.modalType === "server",
904
- onSubmit: $setup.handleSubmit,
905
- onCancel: $setup.handleCancel
906
- }, null, 8, ["visible"]),
907
- createCommentVNode(" 添加隧道弹窗 "),
908
- createVNode($setup["InputModal"], {
909
- title: "添加隧道",
910
- fields: $setup.tunnelFields,
911
- visible: $setup.modalType === "tunnel",
912
- onSubmit: $setup.handleSubmit,
913
- onCancel: $setup.handleCancel
914
- }, null, 8, ["visible"]),
915
- createCommentVNode(" 添加项目弹窗 "),
916
- createVNode($setup["InputModal"], {
917
- title: "添加项目",
918
- fields: $setup.projectFields,
919
- visible: $setup.modalType === "project",
920
- onSubmit: $setup.handleSubmit,
921
- onCancel: $setup.handleCancel
922
- }, null, 8, ["visible"])
923
- ], 64);
924
- }
925
- var ConfigPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/Users/yangdongnan/work/deploy-cli/src/components/ConfigPanel.vue"]]);
926
- //#endregion
927
- //#region src/lib/tunnel.ts
928
- const activeTunnels = /* @__PURE__ */ new Map();
929
- /** 读取私钥文件内容 */
930
- function readPrivateKey(keyPath) {
931
- const expanded = expandPath(keyPath);
932
- return readFileSync(expanded, "utf-8");
933
- }
934
- /** 建立 SSH 连接 */
935
- function createSSHConn(server) {
936
- return new Promise((resolve, reject) => {
937
- const conn = new Client();
938
- const config = {
939
- host: server.host,
940
- port: server.port,
941
- username: server.username,
942
- readyTimeout: 1e4
943
- };
944
- if (server.privateKey) config.privateKey = readPrivateKey(server.privateKey);
945
- else if (server.password) config.password = server.password;
946
- const timer = setTimeout(() => reject(/* @__PURE__ */ new Error("SSH 连接超时")), 12e3);
947
- conn.on("ready", () => {
948
- clearTimeout(timer);
949
- resolve(conn);
950
- });
951
- conn.on("error", (err) => {
952
- clearTimeout(timer);
953
- reject(err);
954
- });
955
- conn.connect(config);
956
- });
957
- }
958
- /** 启动隧道 */
959
- async function startTunnel(tunnel, server, onLog) {
960
- if (activeTunnels.has(tunnel.name)) throw new Error(`隧道 "${tunnel.name}" 已在运行`);
961
- onLog("info", `正在连接 ${server.host}...`);
962
- const conn = await createSSHConn(server);
963
- onLog("info", `SSH 已连接 ${server.username}@${server.host}`);
964
- const netServer = createServer((socket) => {
965
- conn.forwardOut(socket.remoteAddress || "127.0.0.1", socket.remotePort || 0, tunnel.remoteHost, tunnel.remotePort, (err, stream) => {
966
- if (err) {
967
- socket.destroy();
968
- return;
969
- }
970
- socket.pipe(stream);
971
- stream.pipe(socket);
972
- socket.on("error", () => stream.end());
973
- socket.on("close", () => stream.end());
974
- stream.on("error", () => socket.destroy());
975
- stream.on("close", () => socket.destroy());
976
- });
977
- });
978
- await new Promise((resolve, reject) => {
979
- netServer.on("error", reject);
980
- netServer.listen(tunnel.localPort, "127.0.0.1", resolve);
981
- });
982
- conn.on("close", () => {
983
- if (activeTunnels.has(tunnel.name)) {
984
- stopTunnel(tunnel.name);
985
- onLog("warn", `隧道 "${tunnel.name}" SSH 连接断开`);
986
- }
987
- });
988
- conn.on("error", () => {
989
- if (activeTunnels.has(tunnel.name)) {
990
- stopTunnel(tunnel.name);
991
- onLog("error", `隧道 "${tunnel.name}" SSH 错误`);
992
- }
993
- });
994
- activeTunnels.set(tunnel.name, {
995
- server: netServer,
996
- conn
997
- });
998
- onLog("success", `隧道 "${tunnel.name}" 已启动: localhost:${tunnel.localPort} -> ${tunnel.remoteHost}:${tunnel.remotePort}`);
999
- }
1000
- /** 停止隧道 */
1001
- function stopTunnel(name) {
1002
- const active = activeTunnels.get(name);
1003
- if (!active) return;
1004
- active.server.close();
1005
- active.conn.end();
1006
- activeTunnels.delete(name);
1007
- }
1008
- /** 查询隧道运行状态 */
1009
- function getTunnelStatus(name) {
1010
- return activeTunnels.has(name) ? "running" : "stopped";
1011
- }
1012
- /** 停止所有隧道 */
1013
- function stopAllTunnels() {
1014
- for (const name of activeTunnels.keys()) stopTunnel(name);
1015
- }
1016
- /** 从配置生成隧道状态列表 */
1017
- function buildTunnelStates(config) {
1018
- return config.tunnels.map((t) => ({
1019
- name: t.name,
1020
- server: t.server,
1021
- localPort: t.localPort,
1022
- remoteHost: t.remoteHost,
1023
- remotePort: t.remotePort,
1024
- autoStart: t.autoStart,
1025
- status: getTunnelStatus(t.name)
1026
- }));
1027
- }
1028
- //#endregion
1029
- //#region src/composables/useTunnels.ts
1030
- function useTunnels(config, logs) {
1031
- const tunnels = ref(buildTunnelStates(config));
1032
- const starting = ref(/* @__PURE__ */ new Set());
1033
- function log(level, message) {
1034
- logs.value.push({
1035
- time: (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false }),
1036
- level,
1037
- message
1038
- });
1039
- }
1040
- async function start(name) {
1041
- const tunnel = config.tunnels.find((t) => t.name === name);
1042
- if (!tunnel) return;
1043
- const server = config.servers.find((s) => s.name === tunnel.server);
1044
- if (!server) {
1045
- log("error", `找不到服务器: ${tunnel.server}`);
1046
- return;
1047
- }
1048
- starting.value.add(name);
1049
- const state = tunnels.value.find((t) => t.name === name);
1050
- if (state) state.status = "running";
1051
- try {
1052
- await startTunnel(tunnel, server, log);
1053
- const s = tunnels.value.find((t) => t.name === name);
1054
- if (s) {
1055
- s.status = "running";
1056
- s.message = void 0;
1057
- }
1058
- } catch (e) {
1059
- const s = tunnels.value.find((t) => t.name === name);
1060
- if (s) {
1061
- s.status = "error";
1062
- s.message = e.message;
1063
- }
1064
- log("error", `隧道 "${name}" 启动失败: ${e.message}`);
1065
- } finally {
1066
- starting.value.delete(name);
1067
- }
1068
- }
1069
- function stop(name) {
1070
- stopTunnel(name);
1071
- const s = tunnels.value.find((t) => t.name === name);
1072
- if (s) s.status = "stopped";
1073
- log("info", `隧道 "${name}" 已停止`);
1074
- }
1075
- async function startAll() {
1076
- for (const t of config.tunnels) {
1077
- if (getTunnelRunning(t.name)) continue;
1078
- await start(t.name);
1079
- }
1080
- }
1081
- function getTunnelRunning(name) {
1082
- return tunnels.value.find((t) => t.name === name)?.status === "running";
1083
- }
1084
- function cleanup() {
1085
- stopAllTunnels();
1086
- }
1087
- async function autoStart() {
1088
- for (const t of config.tunnels) if (t.autoStart) await start(t.name);
1089
- }
1090
- return {
1091
- tunnels,
1092
- starting,
1093
- start,
1094
- stop,
1095
- startAll,
1096
- autoStart,
1097
- cleanup
1098
- };
1099
- }
1100
- //#endregion
1101
- //#region src/lib/deploy-runner.ts
1102
- /** 扫描项目的部署脚本 */
1103
- function discoverScripts(project) {
1104
- const projectPath = expandPath(project.path);
1105
- const deployPath = resolve(projectPath, project.deployDir);
1106
- let files;
1107
- try {
1108
- files = readdirSync(deployPath);
1109
- } catch {
1110
- return [];
1111
- }
1112
- return files.filter((f) => f.endsWith(".sh")).map((f) => ({
1113
- project: project.name,
1114
- name: f,
1115
- path: join(deployPath, f)
1116
- })).sort((a, b) => a.name.localeCompare(b.name));
1117
- }
1118
- /** 执行部署脚本 */
1119
- function runDeployScript(script, args, onOutput, onExit) {
1120
- const cwd = dirname(script.path);
1121
- const child = spawn("bash", [script.name, ...args], {
1122
- cwd,
1123
- stdio: [
1124
- "pipe",
1125
- "pipe",
1126
- "pipe"
1127
- ],
1128
- env: { ...process.env }
1129
- });
1130
- const handleStream = (stream) => {
1131
- let buffer = "";
1132
- stream.on("data", (chunk) => {
1133
- buffer += chunk.toString();
1134
- const lines = buffer.split("\n");
1135
- buffer = lines.pop() || "";
1136
- for (const line of lines) if (line.trim()) onOutput(line);
1137
- });
1138
- stream.on("end", () => {
1139
- if (buffer.trim()) onOutput(buffer);
1140
- });
1141
- };
1142
- handleStream(child.stdout);
1143
- handleStream(child.stderr);
1144
- child.on("exit", onExit);
1145
- }
1146
- /** 记录脚本执行结果 */
1147
- function saveScriptResult(script, success) {
1148
- script.lastRun = (/* @__PURE__ */ new Date()).toISOString();
1149
- script.lastResult = success ? "success" : "fail";
1150
- }
1151
- //#endregion
1152
- //#region src/composables/useDeploy.ts
1153
- function useDeploy(config, logs) {
1154
- const scripts = ref([]);
1155
- const running = ref(null);
1156
- function log(level, message) {
1157
- logs.value.push({
1158
- time: (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false }),
1159
- level,
1160
- message
1161
- });
1162
- }
1163
- function scan() {
1164
- const all = [];
1165
- for (const project of config.projects) {
1166
- const found = discoverScripts(project);
1167
- all.push(...found);
1168
- }
1169
- scripts.value = all;
1170
- log("info", `扫描完成: ${config.projects.length} 个项目, ${all.length} 个脚本`);
1171
- }
1172
- function run(script, args = []) {
1173
- const key = `${script.project}/${script.name}`;
1174
- if (running.value) {
1175
- log("warn", `已有脚本在运行: ${running.value}`);
1176
- return;
1177
- }
1178
- running.value = key;
1179
- log("info", `▸ ${key}${args.length ? " " + args.join(" ") : ""}`);
1180
- runDeployScript(script, args, (line) => {
1181
- logs.value.push({
1182
- time: (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false }),
1183
- level: "info",
1184
- message: ` ${line}`
1185
- });
1186
- }, (code) => {
1187
- const success = code === 0;
1188
- saveScriptResult(script, success);
1189
- log(success ? "success" : "error", `${success ? "✓" : "✗"} ${key} ${success ? "完成" : `失败 (exit ${code})`}`);
1190
- running.value = null;
1191
- });
1192
- }
1193
- return {
1194
- scripts,
1195
- running,
1196
- scan,
1197
- run
1198
- };
1199
- }
1200
- //#endregion
1201
- //#region src/App.vue
1202
- const _sfc_main = /*@__PURE__*/ defineComponent({
1203
- __name: "App",
1204
- setup(__props, { expose: __expose }) {
1205
- __expose();
1206
- const { exit } = useApp();
1207
- const config = loadConfig();
1208
- const logs = ref([]);
1209
- const { tunnels, start, stop, startAll, autoStart, cleanup } = useTunnels(config, logs);
1210
- const { scripts, running, scan, run } = useDeploy(config, logs);
1211
- const activePanel = ref("tunnels");
1212
- const showConfig = ref(false);
1213
- const paramModal = ref(null);
1214
- const paramInput = ref("");
1215
- function log(level, message) {
1216
- logs.value.push({
1217
- time: (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false }),
1218
- level,
1219
- message
1220
- });
1221
- }
1222
- useInput((event) => {
1223
- const name = event.type === "text" ? event.text.length === 1 ? event.text : void 0 : event.type === "key" ? event.key.name : void 0;
1224
- const char = event.type === "text" ? event.text : event.type === "key" ? event.key.character : void 0;
1225
- if (showConfig.value) {
1226
- if (name === "escape") {
1227
- showConfig.value = false;
1228
- saveConfig(config);
1229
- log("info", "配置已保存");
1230
- scan();
1231
- }
1232
- return;
1233
- }
1234
- if (paramModal.value) {
1235
- if (name === "escape") {
1236
- paramModal.value = null;
1237
- return;
1238
- }
1239
- if (name === "enter") {
1240
- const script = paramModal.value.script;
1241
- const args = paramInput.value.trim().split(/\s+/).filter(Boolean);
1242
- paramModal.value = null;
1243
- paramInput.value = "";
1244
- run(script, args);
1245
- return;
1246
- }
1247
- if (name === "backspace") {
1248
- paramInput.value = paramInput.value.slice(0, -1);
1249
- return;
1250
- }
1251
- if (char) paramInput.value += char;
1252
- return;
1253
- }
1254
- if (name === "tab") {
1255
- const panels = [
1256
- "tunnels",
1257
- "deploy",
1258
- "output"
1259
- ];
1260
- const idx = panels.indexOf(activePanel.value);
1261
- activePanel.value = panels[(idx + 1) % panels.length];
1262
- return;
1263
- }
1264
- if (name === "1") {
1265
- activePanel.value = "tunnels";
1266
- return;
1267
- }
1268
- if (name === "2") {
1269
- activePanel.value = "deploy";
1270
- return;
1271
- }
1272
- if (name === "3") {
1273
- activePanel.value = "output";
1274
- return;
1275
- }
1276
- if (name === "n") {
1277
- showConfig.value = true;
1278
- return;
1279
- }
1280
- if (name === "r") {
1281
- scan();
1282
- log("info", "已重新扫描");
1283
- return;
1284
- }
1285
- if (name === "q" || name === "escape") {
1286
- cleanup();
1287
- exit();
1288
- return;
1289
- }
1290
- });
1291
- onMounted(async () => {
1292
- log("info", "Deploy CLI 已启动");
1293
- log("info", `配置: ${config.servers.length} 服务器, ${config.tunnels.length} 隧道, ${config.projects.length} 项目`);
1294
- log("info", "按 [n] 添加配置, [r] 重新扫描, [p] 传参执行");
1295
- scan();
1296
- await autoStart();
1297
- });
1298
- onUnmounted(() => {
1299
- cleanup();
1300
- });
1301
- function handleRun(script, _args) {
1302
- run(script, []);
1303
- }
1304
- function handleRunWithParams(script) {
1305
- paramModal.value = { script };
1306
- paramInput.value = "";
1307
- }
1308
- function handleConfigChanged() {
1309
- saveConfig(config);
1310
- log("info", "配置已更新");
1311
- scan();
1312
- }
1313
- const __returned__ = {
1314
- exit,
1315
- config,
1316
- logs,
1317
- tunnels,
1318
- start,
1319
- stop,
1320
- startAll,
1321
- autoStart,
1322
- cleanup,
1323
- scripts,
1324
- running,
1325
- scan,
1326
- run,
1327
- activePanel,
1328
- showConfig,
1329
- paramModal,
1330
- paramInput,
1331
- log,
1332
- handleRun,
1333
- handleRunWithParams,
1334
- handleConfigChanged,
1335
- get Box() {
1336
- return Box;
1337
- },
1338
- get Text() {
1339
- return Text;
1340
- },
1341
- TunnelPanel: TunnelPanel_default,
1342
- DeployPanel: DeployPanel_default,
1343
- OutputPanel: OutputPanel_default,
1344
- StatusBar: StatusBar_default,
1345
- ConfigPanel: ConfigPanel_default
1346
- };
1347
- Object.defineProperty(__returned__, "__isScriptSetup", {
1348
- enumerable: false,
1349
- value: true
1350
- });
1351
- return __returned__;
1352
- }
1353
- });
1354
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1355
- return openBlock(), createBlock($setup["Box"], {
1356
- flexDirection: "column",
1357
- flexGrow: 1
1358
- }, {
1359
- default: withCtx(() => [
1360
- createCommentVNode(" 标题栏 "),
1361
- createVNode($setup["Box"], {
1362
- paddingX: 1,
1363
- flexDirection: "row",
1364
- justifyContent: "space-between",
1365
- flexShrink: 0
1366
- }, {
1367
- default: withCtx(() => [createVNode($setup["Text"], {
1368
- bold: "",
1369
- color: "cyan"
1370
- }, {
1371
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Deploy CLI", -1)])]),
1372
- _: 1
1373
- }), createVNode($setup["Text"], { dimColor: "" }, {
1374
- default: withCtx(() => [createTextVNode(toDisplayString($setup.config.servers.length) + " servers · " + toDisplayString($setup.config.projects.length) + " projects · [n]ew [r]escan", 1)]),
1375
- _: 1
1376
- })]),
1377
- _: 1
1378
- }),
1379
- createCommentVNode(" 主区域:左面板 + 右输出 "),
1380
- createVNode($setup["Box"], {
1381
- flexDirection: "row",
1382
- flexGrow: 1,
1383
- gap: 1
1384
- }, {
1385
- default: withCtx(() => [
1386
- createCommentVNode(" 左列:隧道 + 部署 "),
1387
- createVNode($setup["Box"], {
1388
- flexDirection: "column",
1389
- flexGrow: 1,
1390
- gap: 1
1391
- }, {
1392
- default: withCtx(() => [createVNode($setup["TunnelPanel"], {
1393
- tunnels: $setup.tunnels,
1394
- "is-active": $setup.activePanel === "tunnels" && !$setup.showConfig && !$setup.paramModal,
1395
- onStart: $setup.start,
1396
- onStop: $setup.stop,
1397
- onStartAll: $setup.startAll
1398
- }, null, 8, [
1399
- "tunnels",
1400
- "is-active",
1401
- "onStart",
1402
- "onStop",
1403
- "onStartAll"
1404
- ]), createVNode($setup["DeployPanel"], {
1405
- scripts: $setup.scripts,
1406
- "is-active": $setup.activePanel === "deploy" && !$setup.showConfig && !$setup.paramModal,
1407
- running: $setup.running,
1408
- onRun: $setup.handleRun,
1409
- onRunWithParams: $setup.handleRunWithParams
1410
- }, null, 8, [
1411
- "scripts",
1412
- "is-active",
1413
- "running"
1414
- ])]),
1415
- _: 1
1416
- }),
1417
- createCommentVNode(" 右列:日志输出 "),
1418
- createVNode($setup["OutputPanel"], {
1419
- logs: $setup.logs,
1420
- "is-active": $setup.activePanel === "output" && !$setup.showConfig && !$setup.paramModal
1421
- }, null, 8, ["logs", "is-active"])
1422
- ]),
1423
- _: 1
1424
- }),
1425
- createCommentVNode(" 底部状态栏 "),
1426
- createVNode($setup["StatusBar"], {
1427
- "tunnel-count": $setup.tunnels.filter((t) => t.status === "running").length,
1428
- focus: $setup.activePanel,
1429
- "running-deploy": $setup.running
1430
- }, null, 8, [
1431
- "tunnel-count",
1432
- "focus",
1433
- "running-deploy"
1434
- ]),
1435
- createCommentVNode(" 配置面板 "),
1436
- createVNode($setup["ConfigPanel"], {
1437
- config: $setup.config,
1438
- "is-active": $setup.showConfig,
1439
- visible: $setup.showConfig,
1440
- onConfigChanged: $setup.handleConfigChanged
1441
- }, null, 8, [
1442
- "config",
1443
- "is-active",
1444
- "visible"
1445
- ]),
1446
- createCommentVNode(" 传参弹窗 "),
1447
- $setup.paramModal ? (openBlock(), createBlock($setup["Box"], {
1448
- key: 0,
1449
- flexDirection: "column",
1450
- borderStyle: "round",
1451
- borderColor: "cyan",
1452
- padding: 1,
1453
- width: 60,
1454
- position: "absolute",
1455
- top: 3,
1456
- left: 3
1457
- }, {
1458
- default: withCtx(() => [
1459
- createVNode($setup["Text"], {
1460
- bold: "",
1461
- color: "cyan"
1462
- }, {
1463
- default: withCtx(() => [createTextVNode("执行: " + toDisplayString($setup.paramModal.script.project) + "/" + toDisplayString($setup.paramModal.script.name), 1)]),
1464
- _: 1
1465
- }),
1466
- createVNode($setup["Box"], {
1467
- flexDirection: "row",
1468
- marginTop: 1,
1469
- gap: 1
1470
- }, {
1471
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
1472
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("参数:", -1)])]),
1473
- _: 1
1474
- }), createVNode($setup["Text"], {
1475
- bold: "",
1476
- color: "cyan"
1477
- }, {
1478
- default: withCtx(() => [createTextVNode(toDisplayString($setup.paramInput) + "_", 1)]),
1479
- _: 1
1480
- })]),
1481
- _: 1
1482
- }),
1483
- createVNode($setup["Box"], {
1484
- flexDirection: "row",
1485
- marginTop: 1
1486
- }, {
1487
- default: withCtx(() => [createVNode($setup["Text"], { dimColor: "" }, {
1488
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("[Enter] 执行 [Esc] 取消", -1)])]),
1489
- _: 1
1490
- })]),
1491
- _: 1
1492
- })
1493
- ]),
1494
- _: 1
1495
- })) : createCommentVNode("v-if", true)
1496
- ]),
1497
- _: 1
1498
- });
1499
- }
1500
- //#endregion
1501
- //#region src/main.ts
1502
- createApp(/* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/yangdongnan/work/deploy-cli/src/App.vue"]])).mount({ exitOnCtrlC: true });
1503
- //#endregion
1504
- export {};