@dongnanyang/deploy-cli 0.8.1 → 0.10.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/api.js +2 -0
- package/dist/bin.js +28 -6
- package/dist/{cli-BcnQXZsp.js → cli-CR04-WjM.js} +62 -665
- package/dist/export-helper-CIEcxb5I.js +8 -0
- package/dist/main.js +4 -10
- package/dist/project-BzJoAv1l.js +714 -0
- package/dist/tui/main.js +359 -0
- package/package.json +5 -1
- package/dist/{config-DuBKPLi2.js → config-xUl8Oa3T.js} +1 -1
package/dist/tui/main.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { t as export_helper_default } from "../export-helper-CIEcxb5I.js";
|
|
2
|
+
import { Box, Text, createApp, useApp, useInput } from "@vue-tui/runtime";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, withCtx } from "vue";
|
|
4
|
+
//#region src/tui/components/OutputPanel.vue
|
|
5
|
+
/** 全局日志面板(spec 6.4 Output):只吃 ViewModel(logs 列表),不碰 core */
|
|
6
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: "OutputPanel",
|
|
8
|
+
props: { logs: {
|
|
9
|
+
type: Array,
|
|
10
|
+
required: true
|
|
11
|
+
} },
|
|
12
|
+
setup(__props, { expose: __expose }) {
|
|
13
|
+
__expose();
|
|
14
|
+
const __returned__ = {
|
|
15
|
+
props: __props,
|
|
16
|
+
LEVEL_COLOR: {
|
|
17
|
+
info: void 0,
|
|
18
|
+
success: "green",
|
|
19
|
+
warn: "yellow",
|
|
20
|
+
error: "red"
|
|
21
|
+
},
|
|
22
|
+
get Box() {
|
|
23
|
+
return Box;
|
|
24
|
+
},
|
|
25
|
+
get Text() {
|
|
26
|
+
return Text;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
30
|
+
enumerable: false,
|
|
31
|
+
value: true
|
|
32
|
+
});
|
|
33
|
+
return __returned__;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
37
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
38
|
+
flexDirection: "column",
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
borderStyle: "round",
|
|
41
|
+
borderColor: "cyan",
|
|
42
|
+
padding: 1
|
|
43
|
+
}, {
|
|
44
|
+
default: withCtx(() => [
|
|
45
|
+
createVNode($setup["Text"], {
|
|
46
|
+
bold: "",
|
|
47
|
+
color: "cyan"
|
|
48
|
+
}, {
|
|
49
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("6. Output 输出(全局日志)", -1)])]),
|
|
50
|
+
_: 1
|
|
51
|
+
}),
|
|
52
|
+
$setup.props.logs.length === 0 ? (openBlock(), createBlock($setup["Text"], {
|
|
53
|
+
key: 0,
|
|
54
|
+
dimColor: ""
|
|
55
|
+
}, {
|
|
56
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("(暂无日志)", -1)])]),
|
|
57
|
+
_: 1
|
|
58
|
+
})) : createCommentVNode("v-if", true),
|
|
59
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.logs, (entry, i) => {
|
|
60
|
+
return openBlock(), createBlock($setup["Text"], {
|
|
61
|
+
key: i,
|
|
62
|
+
color: $setup.LEVEL_COLOR[entry.level]
|
|
63
|
+
}, {
|
|
64
|
+
default: withCtx(() => [createTextVNode(toDisplayString(entry.time) + " [" + toDisplayString(entry.level) + "] " + toDisplayString(entry.message), 1)]),
|
|
65
|
+
_: 2
|
|
66
|
+
}, 1032, ["color"]);
|
|
67
|
+
}), 128))
|
|
68
|
+
]),
|
|
69
|
+
_: 1
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/OutputPanel.vue"]]);
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/tui/composables/useKeymap.ts
|
|
75
|
+
/** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
|
|
76
|
+
const PANEL_IDS = [
|
|
77
|
+
"projects",
|
|
78
|
+
"containers",
|
|
79
|
+
"deploy",
|
|
80
|
+
"status",
|
|
81
|
+
"tunnels",
|
|
82
|
+
"output"
|
|
83
|
+
];
|
|
84
|
+
/** 面板标题(骨架/状态栏共用;中文文案) */
|
|
85
|
+
const PANEL_TITLES = {
|
|
86
|
+
projects: "Projects 项目",
|
|
87
|
+
containers: "Containers 容器",
|
|
88
|
+
deploy: "Deploy 部署",
|
|
89
|
+
status: "Status 状态",
|
|
90
|
+
tunnels: "Tunnels 隧道",
|
|
91
|
+
output: "Output 输出"
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* 提取单字符键位:text 事件取 text、key 事件取 character/name(同一输入事实只出一个公共事件,不会双发)。
|
|
95
|
+
* 多字符文本(粘贴/连打)不分发,防误触退出。
|
|
96
|
+
*/
|
|
97
|
+
function keyChar(event) {
|
|
98
|
+
let raw;
|
|
99
|
+
if (event.type === "text") raw = event.text;
|
|
100
|
+
else if (event.type === "key") raw = event.key.character ?? event.key.name;
|
|
101
|
+
return raw !== void 0 && raw.length === 1 ? raw : void 0;
|
|
102
|
+
}
|
|
103
|
+
/** 键位分发(纯函数,单测锚点):1-6 切面板、q 退出、? 帮助;其余不分发 */
|
|
104
|
+
function dispatchKey(event) {
|
|
105
|
+
const ch = keyChar(event);
|
|
106
|
+
if (ch === void 0) return null;
|
|
107
|
+
if (ch >= "1" && ch <= "6") return {
|
|
108
|
+
kind: "panel",
|
|
109
|
+
panel: PANEL_IDS[Number(ch) - 1]
|
|
110
|
+
};
|
|
111
|
+
if (ch === "q") return { kind: "quit" };
|
|
112
|
+
if (ch === "?") return { kind: "help" };
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/** 键位路由接线:useInput 订阅 → dispatchKey → 回调;组件不碰输入流本体 */
|
|
116
|
+
function useKeymap(handlers) {
|
|
117
|
+
useInput((event) => {
|
|
118
|
+
const action = dispatchKey(event);
|
|
119
|
+
if (action === null) return;
|
|
120
|
+
if (action.kind === "panel") handlers.onPanel(action.panel);
|
|
121
|
+
else if (action.kind === "quit") handlers.onQuit();
|
|
122
|
+
else handlers.onHelp();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/tui/components/StatusBar.vue
|
|
127
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
128
|
+
__name: "StatusBar",
|
|
129
|
+
props: {
|
|
130
|
+
activePanel: {
|
|
131
|
+
type: null,
|
|
132
|
+
required: true
|
|
133
|
+
},
|
|
134
|
+
helpVisible: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
required: false
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
setup(__props, { expose: __expose }) {
|
|
140
|
+
__expose();
|
|
141
|
+
const __returned__ = {
|
|
142
|
+
props: __props,
|
|
143
|
+
get Box() {
|
|
144
|
+
return Box;
|
|
145
|
+
},
|
|
146
|
+
get Text() {
|
|
147
|
+
return Text;
|
|
148
|
+
},
|
|
149
|
+
get PANEL_TITLES() {
|
|
150
|
+
return PANEL_TITLES;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
154
|
+
enumerable: false,
|
|
155
|
+
value: true
|
|
156
|
+
});
|
|
157
|
+
return __returned__;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
161
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
162
|
+
paddingX: 1,
|
|
163
|
+
flexDirection: "row",
|
|
164
|
+
justifyContent: "space-between",
|
|
165
|
+
flexShrink: 0
|
|
166
|
+
}, {
|
|
167
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
168
|
+
bold: "",
|
|
169
|
+
color: "cyan"
|
|
170
|
+
}, {
|
|
171
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.PANEL_TITLES[$setup.props.activePanel]), 1)]),
|
|
172
|
+
_: 1
|
|
173
|
+
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
174
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.props.helpVisible ? "[?] 关闭帮助" : "[?] 帮助") + " │ 1-6 切换面板 · q 退出", 1)]),
|
|
175
|
+
_: 1
|
|
176
|
+
})]),
|
|
177
|
+
_: 1
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusBar.vue"]]);
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/tui/composables/useLogs.ts
|
|
183
|
+
/** 全局日志条目(响应式列表,单例) */
|
|
184
|
+
const entries = ref([]);
|
|
185
|
+
function now() {
|
|
186
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 全局日志 store(单例):core 事件 → 响应式列表,供 OutputPanel 渲染。
|
|
190
|
+
* 同一 App 内多处 useLogs() 拿到同一份列表。
|
|
191
|
+
*/
|
|
192
|
+
function useLogs() {
|
|
193
|
+
const log = (level, message) => {
|
|
194
|
+
entries.value.push({
|
|
195
|
+
time: now(),
|
|
196
|
+
level,
|
|
197
|
+
message
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
logs: entries,
|
|
202
|
+
log,
|
|
203
|
+
info: (message) => log("info", message),
|
|
204
|
+
success: (message) => log("success", message),
|
|
205
|
+
warn: (message) => log("warn", message),
|
|
206
|
+
error: (message) => log("error", message),
|
|
207
|
+
pushLine: (line, stream = "stdout") => log(stream === "stderr" ? "error" : "info", line),
|
|
208
|
+
clear: () => {
|
|
209
|
+
entries.value = [];
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/tui/App.vue
|
|
215
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
216
|
+
__name: "App",
|
|
217
|
+
setup(__props, { expose: __expose }) {
|
|
218
|
+
__expose();
|
|
219
|
+
const { exit } = useApp();
|
|
220
|
+
const { logs } = useLogs();
|
|
221
|
+
const activePanel = ref("projects");
|
|
222
|
+
const helpVisible = ref(false);
|
|
223
|
+
useKeymap({
|
|
224
|
+
onPanel: (panel) => {
|
|
225
|
+
activePanel.value = panel;
|
|
226
|
+
helpVisible.value = false;
|
|
227
|
+
},
|
|
228
|
+
onQuit: () => exit(),
|
|
229
|
+
onHelp: () => {
|
|
230
|
+
helpVisible.value = !helpVisible.value;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
const __returned__ = {
|
|
234
|
+
exit,
|
|
235
|
+
logs,
|
|
236
|
+
activePanel,
|
|
237
|
+
helpVisible,
|
|
238
|
+
panelTitle: computed(() => `${PANEL_IDS.indexOf(activePanel.value) + 1}. ${PANEL_TITLES[activePanel.value]}`),
|
|
239
|
+
get Box() {
|
|
240
|
+
return Box;
|
|
241
|
+
},
|
|
242
|
+
get Text() {
|
|
243
|
+
return Text;
|
|
244
|
+
},
|
|
245
|
+
OutputPanel: OutputPanel_default,
|
|
246
|
+
StatusBar: StatusBar_default,
|
|
247
|
+
get PANEL_IDS() {
|
|
248
|
+
return PANEL_IDS;
|
|
249
|
+
},
|
|
250
|
+
get PANEL_TITLES() {
|
|
251
|
+
return PANEL_TITLES;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
255
|
+
enumerable: false,
|
|
256
|
+
value: true
|
|
257
|
+
});
|
|
258
|
+
return __returned__;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
262
|
+
return openBlock(), createBlock($setup["Box"], {
|
|
263
|
+
flexDirection: "column",
|
|
264
|
+
flexGrow: 1
|
|
265
|
+
}, {
|
|
266
|
+
default: withCtx(() => [
|
|
267
|
+
createCommentVNode(" 头部:标题 + 六面板键位总览 "),
|
|
268
|
+
createVNode($setup["Box"], {
|
|
269
|
+
paddingX: 1,
|
|
270
|
+
flexDirection: "row",
|
|
271
|
+
justifyContent: "space-between",
|
|
272
|
+
flexShrink: 0
|
|
273
|
+
}, {
|
|
274
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
275
|
+
bold: "",
|
|
276
|
+
color: "cyan"
|
|
277
|
+
}, {
|
|
278
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Deploy CLI", -1)])]),
|
|
279
|
+
_: 1
|
|
280
|
+
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
281
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
|
|
282
|
+
_: 1
|
|
283
|
+
})]),
|
|
284
|
+
_: 1
|
|
285
|
+
}),
|
|
286
|
+
createCommentVNode(" 主面板区:1-5 骨架占位(内容随 M2 后续任务实现),6=全局日志 "),
|
|
287
|
+
createVNode($setup["Box"], {
|
|
288
|
+
flexDirection: "column",
|
|
289
|
+
flexGrow: 1,
|
|
290
|
+
paddingX: 1
|
|
291
|
+
}, {
|
|
292
|
+
default: withCtx(() => [$setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
|
|
293
|
+
key: 0,
|
|
294
|
+
logs: $setup.logs
|
|
295
|
+
}, null, 8, ["logs"])) : (openBlock(), createBlock($setup["Box"], {
|
|
296
|
+
key: 1,
|
|
297
|
+
flexDirection: "column",
|
|
298
|
+
flexGrow: 1,
|
|
299
|
+
borderStyle: "round",
|
|
300
|
+
padding: 1
|
|
301
|
+
}, {
|
|
302
|
+
default: withCtx(() => [createVNode($setup["Text"], {
|
|
303
|
+
bold: "",
|
|
304
|
+
color: "cyan"
|
|
305
|
+
}, {
|
|
306
|
+
default: withCtx(() => [createTextVNode(toDisplayString($setup.panelTitle), 1)]),
|
|
307
|
+
_: 1
|
|
308
|
+
}), createVNode($setup["Text"], { dimColor: "" }, {
|
|
309
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
|
|
310
|
+
_: 1
|
|
311
|
+
})]),
|
|
312
|
+
_: 1
|
|
313
|
+
}))]),
|
|
314
|
+
_: 1
|
|
315
|
+
}),
|
|
316
|
+
createCommentVNode(" 帮助浮层(? 开关) "),
|
|
317
|
+
$setup.helpVisible ? (openBlock(), createBlock($setup["Box"], {
|
|
318
|
+
key: 0,
|
|
319
|
+
flexDirection: "column",
|
|
320
|
+
borderStyle: "round",
|
|
321
|
+
borderColor: "yellow",
|
|
322
|
+
padding: 1,
|
|
323
|
+
marginX: 1
|
|
324
|
+
}, {
|
|
325
|
+
default: withCtx(() => [
|
|
326
|
+
createVNode($setup["Text"], {
|
|
327
|
+
bold: "",
|
|
328
|
+
color: "yellow"
|
|
329
|
+
}, {
|
|
330
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("快捷键帮助", -1)])]),
|
|
331
|
+
_: 1
|
|
332
|
+
}),
|
|
333
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($setup.PANEL_IDS, (id, i) => {
|
|
334
|
+
return openBlock(), createBlock($setup["Text"], { key: id }, {
|
|
335
|
+
default: withCtx(() => [createTextVNode(toDisplayString(i + 1) + " " + toDisplayString($setup.PANEL_TITLES[id]), 1)]),
|
|
336
|
+
_: 2
|
|
337
|
+
}, 1024);
|
|
338
|
+
}), 128)),
|
|
339
|
+
createVNode($setup["Text"], null, {
|
|
340
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
|
|
341
|
+
_: 1
|
|
342
|
+
})
|
|
343
|
+
]),
|
|
344
|
+
_: 1
|
|
345
|
+
})) : createCommentVNode("v-if", true),
|
|
346
|
+
createCommentVNode(" 底部状态栏 "),
|
|
347
|
+
createVNode($setup["StatusBar"], {
|
|
348
|
+
"active-panel": $setup.activePanel,
|
|
349
|
+
"help-visible": $setup.helpVisible
|
|
350
|
+
}, null, 8, ["active-panel", "help-visible"])
|
|
351
|
+
]),
|
|
352
|
+
_: 1
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/tui/main.ts
|
|
357
|
+
createApp(/* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/App.vue"]])).mount({ exitOnCtrlC: true });
|
|
358
|
+
//#endregion
|
|
359
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dongnanyang/deploy-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Local CLI TUI for SSH tunnels & deploy scripts",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/api.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/api.js"
|
|
9
|
+
},
|
|
6
10
|
"bin": {
|
|
7
11
|
"deploy-cli": "./bin/deploy-cli.js"
|
|
8
12
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
-
import { resolve } from "path";
|
|
3
2
|
import { homedir } from "os";
|
|
3
|
+
import { resolve } from "path";
|
|
4
4
|
//#region src/core/config.ts
|
|
5
5
|
const CONFIG_DIR = resolve(homedir(), ".deploy-cli");
|
|
6
6
|
const CONFIG_PATH = resolve(CONFIG_DIR, "config.json");
|