pan-stack-cli 0.2.1 → 0.2.2
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 +37 -731
- package/bin/pan.js +4955 -269
- package/package.json +17 -5
- package/lib/ai-skills.js +0 -829
- package/lib/create.js +0 -105
- package/lib/discover.js +0 -294
- package/lib/git/git-checkout.js +0 -395
- package/lib/git/git-clone.js +0 -206
- package/lib/git/git-fetch-all.js +0 -129
- package/lib/git/git-grv.js +0 -125
- package/lib/git/git-gst.js +0 -165
- package/lib/git/git-mr.js +0 -546
- package/lib/git/git-pull.js +0 -137
- package/lib/git/git-push.js +0 -185
- package/lib/git/git-sync-main.js +0 -334
- package/lib/git/helpers/bulk-report.js +0 -202
- package/lib/git/helpers/cli.js +0 -188
- package/lib/git/helpers/colors.js +0 -19
- package/lib/git/helpers/git.js +0 -136
- package/lib/git/helpers/manifest.js +0 -223
- package/lib/git/helpers/repo-select.js +0 -416
- package/lib/git/helpers/repo-summary.js +0 -161
- package/lib/i18n.js +0 -61
- package/lib/inquirer-theme.js +0 -20
- package/lib/language.js +0 -121
- package/lib/languages.js +0 -14
- package/lib/manifest.js +0 -467
- package/lib/menu-prompt.js +0 -201
- package/lib/menu.js +0 -134
- package/lib/messages.js +0 -647
- package/lib/platform.js +0 -140
- package/lib/run-command.js +0 -334
- package/lib/select.js +0 -0
- package/lib/serve.js +0 -75
- package/lib/skill-registry-client.js +0 -173
- package/lib/stats/aggregate.js +0 -51
- package/lib/stats/identity.js +0 -20
- package/lib/stats/index.js +0 -189
- package/lib/stats/parse.js +0 -46
- package/lib/stats/range.js +0 -38
- package/lib/stats/report.js +0 -264
- package/lib/stats/review.js +0 -157
- package/lib/stats/scan.js +0 -92
- package/lib/stats/serve.js +0 -25
- package/lib/ui/api.js +0 -202
- package/lib/ui/clone.js +0 -115
- package/lib/ui/config.js +0 -182
- package/lib/ui/diff.js +0 -128
- package/lib/ui/export-gate.js +0 -79
- package/lib/ui/gen-react-mobile-code.js +0 -6
- package/lib/ui/gen-react-web-code.js +0 -75
- package/lib/ui/index.js +0 -89
- package/lib/ui/init.js +0 -252
- package/lib/ui/login.js +0 -128
- package/lib/ui/logout.js +0 -22
- package/lib/ui/palettes.js +0 -103
- package/lib/ui/published-html.js +0 -24
- package/lib/ui/sync.js +0 -137
- package/lib/ui/workspace.js +0 -213
package/lib/menu.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// Menu tương tác khi gõ `pan` trống (TTY): chọn DỰ ÁN → chọn LỆNH → chạy — khỏi nhớ lệnh.
|
|
2
|
-
// Ưu tiên custom prompt (menu-prompt) có PHÍM TẮT nhấn-1-phím (h/v/b/x); thiếu @inquirer/core →
|
|
3
|
-
// fallback @inquirer/prompts select (phím tắt thành item chọn). Chuỗi theo ngôn ngữ (i18n, mặc định en).
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { loadAllCommandSources } = require("./discover");
|
|
6
|
-
const { listCommands } = require("./manifest");
|
|
7
|
-
const { runProjectCommand, sourceLabel } = require("./run-command");
|
|
8
|
-
const { loadInquirer } = require("./select");
|
|
9
|
-
const { menuSelect, buildMenuPrompt } = require("./menu-prompt");
|
|
10
|
-
const { helpTheme } = require("./inquirer-theme");
|
|
11
|
-
const { t } = require("./i18n");
|
|
12
|
-
|
|
13
|
-
function isCancel(err) {
|
|
14
|
-
const s = String((err && (err.name + " " + err.message)) || "");
|
|
15
|
-
return /ExitPromptError|force closed|SIGINT|cancel/i.test(s);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Chọn 1 item; hotkeys hiện ở footer (custom prompt) hoặc thành item cuối (fallback select).
|
|
19
|
-
async function pick({ message, choices, hotkeys = [] }) {
|
|
20
|
-
try {
|
|
21
|
-
return await menuSelect({ message, choices, hotkeys });
|
|
22
|
-
} catch (err) {
|
|
23
|
-
if (String(err && err.message) !== "no-core") throw err;
|
|
24
|
-
const inq = await loadInquirer();
|
|
25
|
-
if (!inq || typeof inq.select !== "function") return "__exit__";
|
|
26
|
-
const extra = hotkeys.map((h) => ({ name: `${h.key} ${h.label}`, value: h.value }));
|
|
27
|
-
const list = extra.length ? [...choices, new inq.Separator(), ...extra] : choices;
|
|
28
|
-
return inq.select({ message, choices: list, pageSize: 20, loop: false, theme: helpTheme(false) });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function runInteractiveMenu({ printUsage, version } = {}) {
|
|
33
|
-
// Có ít nhất 1 backend picker? (core hoặc prompts). Không → trả false để caller in usage.
|
|
34
|
-
const core = await buildMenuPrompt();
|
|
35
|
-
const inqMod = await loadInquirer();
|
|
36
|
-
if (!core && (!inqMod || typeof inqMod.select !== "function")) return false;
|
|
37
|
-
|
|
38
|
-
// Sort A-Z theo tên hiển thị — dễ dò khi .project.yaml có nhiều repo/project.
|
|
39
|
-
const sources = loadAllCommandSources()
|
|
40
|
-
.filter((s) => listCommands(s).length > 0)
|
|
41
|
-
.sort((a, b) => sourceLabel(a).localeCompare(sourceLabel(b)));
|
|
42
|
-
if (sources.length === 0) {
|
|
43
|
-
// Không có .pan.yaml (project commands) — KHÔNG coi là lỗi/dead-end: các lệnh git
|
|
44
|
-
// built-in (pull/push/fetch/checkout/...) vẫn dùng được nhờ fallback quét git repo
|
|
45
|
-
// con quanh cwd (xem lib/git/helpers/cli.js). In gợi ý rồi để caller in usage đầy đủ.
|
|
46
|
-
console.log(t("NO_PAN_YAML_WITH_COMMANDS"));
|
|
47
|
-
console.log(t("NO_PAN_YAML_BUT_GIT_STILL_WORKS"));
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
for (;;) {
|
|
53
|
-
// ── Tầng 1: dự án ──
|
|
54
|
-
const proj = await pick({
|
|
55
|
-
message: t("MENU_SELECT_PROJECT"),
|
|
56
|
-
choices: sources.map((s, i) => ({
|
|
57
|
-
name: sourceLabel(s),
|
|
58
|
-
value: i,
|
|
59
|
-
description: `${listCommands(s).length} ${t("COMMANDS_LABEL")} · ${s.root}`,
|
|
60
|
-
})),
|
|
61
|
-
hotkeys: [
|
|
62
|
-
{ key: "h", label: t("HELP_LABEL"), value: "__help__" },
|
|
63
|
-
{ key: "v", label: t("VERSION_LABEL"), value: "__version__" },
|
|
64
|
-
{ key: "x", label: t("EXIT_LABEL"), value: "__exit__" },
|
|
65
|
-
],
|
|
66
|
-
});
|
|
67
|
-
if (proj === "__exit__") return true;
|
|
68
|
-
if (proj === "__version__") {
|
|
69
|
-
console.log(`pan-stack-cli ${version || "?"}`);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (proj === "__help__") {
|
|
73
|
-
if (typeof printUsage === "function") printUsage();
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const source = sources[proj];
|
|
77
|
-
|
|
78
|
-
// ── Tầng 2: lệnh ──
|
|
79
|
-
const cmds = listCommands(source);
|
|
80
|
-
const cmd = await pick({
|
|
81
|
-
message: `[${sourceLabel(source)}] ${t("MENU_SELECT_COMMAND")}`,
|
|
82
|
-
choices: cmds.map((c) => ({
|
|
83
|
-
name:
|
|
84
|
-
c.name +
|
|
85
|
-
(c.aliases && c.aliases.length ? ` (${c.aliases.join(", ")})` : "") +
|
|
86
|
-
(c.hasTargets ? ` [${c.targets.join("|")}]` : ""),
|
|
87
|
-
value: c.name,
|
|
88
|
-
description: c.description || "",
|
|
89
|
-
})),
|
|
90
|
-
hotkeys: [
|
|
91
|
-
{ key: "b", label: t("BACK_LABEL"), value: "__back__" },
|
|
92
|
-
{ key: "x", label: t("EXIT_LABEL"), value: "__exit__" },
|
|
93
|
-
],
|
|
94
|
-
});
|
|
95
|
-
if (cmd === "__exit__") return true;
|
|
96
|
-
if (cmd === "__back__") continue;
|
|
97
|
-
|
|
98
|
-
// ── Tầng 3: target (nếu có) ──
|
|
99
|
-
const def = source.commands[cmd];
|
|
100
|
-
const args = [];
|
|
101
|
-
if (def && def.targets && Object.keys(def.targets).length > 0) {
|
|
102
|
-
const targets = Object.keys(def.targets);
|
|
103
|
-
const tgt = await pick({
|
|
104
|
-
message: t("SELECT_TARGET__CMD", { cmd }),
|
|
105
|
-
choices: [
|
|
106
|
-
...targets.map((x) => ({ name: x, value: x })),
|
|
107
|
-
{ name: t("DEFAULT_LABEL"), value: "__default__" },
|
|
108
|
-
],
|
|
109
|
-
hotkeys: [{ key: "b", label: t("BACK_LABEL"), value: "__back__" }],
|
|
110
|
-
});
|
|
111
|
-
if (tgt === "__back__") continue;
|
|
112
|
-
if (tgt !== "__default__") args.push(tgt);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
console.error(`\n▶ pan ${cmd}${args.length ? " " + args.join(" ") : ""} (${path.basename(source.root)})\n`);
|
|
116
|
-
// runProjectCommand tự process.exit() khi lệnh THẬT chạy xong — chỉ trả về (không exit) khi
|
|
117
|
-
// user bấm 'b' ở bước chọn (selectFrom/selectChoices) bên trong lệnh đó. Lúc đó `continue`
|
|
118
|
-
// để quay lại Tầng 1 (chọn dự án) thay vì thoát hẳn CLI, đúng quy ước 'b' = quay lại.
|
|
119
|
-
const result = await runProjectCommand(source, cmd, args);
|
|
120
|
-
if (result && result.backed) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
} catch (err) {
|
|
126
|
-
if (isCancel(err)) {
|
|
127
|
-
console.error("\n" + t("EXITED"));
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
module.exports = { runInteractiveMenu };
|