@tama-create/sf-tools 1.4.0-dev.16 → 1.4.0-dev.17
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/core/promote-check.js +6 -2
- package/dist/ui/launcher.js +10 -3
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ const BRANCH_LIST_FILE = "sf-tools/config/branches.txt";
|
|
|
13
13
|
/** 表示用の判定(--quick)が、直近に取得した時刻(ミリ秒)と手元のブランチを残すファイル(git 管理外)。60 秒以内なら、git fetch を省く */
|
|
14
14
|
const FETCH_STAMP = "./sf-tools/logs/last-fetch.txt";
|
|
15
15
|
const FETCH_FRESH_MS = 60_000;
|
|
16
|
+
/** 表示用の判定で、git・gh の 1 回の呼び出しに許す時間(ミリ秒) */
|
|
17
|
+
const QUICK_CALL_MS = 45_000;
|
|
16
18
|
/** 起動でき、終了コードが 0 だったか(起動できなかったときは null) */
|
|
17
19
|
function succeeded(r) {
|
|
18
20
|
return r !== null && r.code === 0;
|
|
@@ -130,8 +132,10 @@ export async function runPromoteCheck(args, box, deps) {
|
|
|
130
132
|
const worktrees = [];
|
|
131
133
|
try {
|
|
132
134
|
log("HEADER", "一方通行のリリースを確かめます (sf-promote-check)");
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
+
// 表示用(--quick)は、固まらないよう、1 回の呼び出しに時間の上限を付ける(超えたら判断できない扱い)
|
|
136
|
+
const limit = quick ? { timeoutMs: QUICK_CALL_MS } : undefined;
|
|
137
|
+
const git = async (...a) => box.run("git", a, limit);
|
|
138
|
+
const gh = async (...a) => box.run("gh", a, limit);
|
|
135
139
|
const must = async (r, why) => {
|
|
136
140
|
let got;
|
|
137
141
|
try {
|
package/dist/ui/launcher.js
CHANGED
|
@@ -20,6 +20,8 @@ export function comparable(text) {
|
|
|
20
20
|
.replace(/(前回の結果。更新中…)/g, "(前回の結果)")
|
|
21
21
|
.replace(/ {2}(更新中…)/g, "");
|
|
22
22
|
}
|
|
23
|
+
/** 「更新中」の表示(Branch の行) */
|
|
24
|
+
const UPDATING = /更新中…/;
|
|
23
25
|
const LINE = "──────────────────────────────────────────────────";
|
|
24
26
|
const readOrNull = (box, path) => {
|
|
25
27
|
try {
|
|
@@ -72,6 +74,8 @@ export async function runLauncher(args, box, deps) {
|
|
|
72
74
|
};
|
|
73
75
|
/** 最後に描いた内容(comparable)。変わらないときは、タイマーによる描き直しを省く */
|
|
74
76
|
let lastDrawn = "";
|
|
77
|
+
/** 最後に描いた内容(色つき)。「更新中」が画面に残っているかを見る */
|
|
78
|
+
let lastRaw = "";
|
|
75
79
|
/** onlyIfChanged: 描く内容が前回と同じなら、何も出さない(判定は動かす)。描いたかどうかを返す */
|
|
76
80
|
const draw = async (onlyIfChanged = false) => {
|
|
77
81
|
const st = await box.run("git", ["status", "--porcelain=v2", "--branch"]).catch(() => null);
|
|
@@ -149,10 +153,13 @@ export async function runLauncher(args, box, deps) {
|
|
|
149
153
|
block.push(` ${paint.cyan(`[${i + 1}]`)} ${paint.bold(item.label.padEnd(11))} ${paint.dim(item.description)}`);
|
|
150
154
|
});
|
|
151
155
|
block.push(paint.dim(` ${LINE}`));
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
const raw = block.join("\n");
|
|
157
|
+
const same = comparable(raw);
|
|
158
|
+
// 画面が変わらないのに、メニューを流さない。ただし、画面に「更新中」が残っているときは、消すために描き直す(残すと、終わったあとも更新中に見える)
|
|
159
|
+
if (onlyIfChanged && same === lastDrawn && (raw === lastRaw || UPDATING.test(raw) || !UPDATING.test(lastRaw)))
|
|
160
|
+
return false;
|
|
155
161
|
lastDrawn = same;
|
|
162
|
+
lastRaw = raw;
|
|
156
163
|
for (const l of block)
|
|
157
164
|
err(l);
|
|
158
165
|
return true;
|