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