@tama-create/sf-tools 1.4.0-dev.1 → 1.4.0-dev.10
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/config/changeset-types.txt +350 -0
- package/config/install/gitmessage +6 -0
- package/config/install/release/README.md +26 -0
- package/config/install/release/deploy-target.txt +368 -0
- package/config/install/release/remove-target.txt +279 -0
- package/config/metadata-capability.txt +118 -0
- package/config/metadata-dirs.txt +79 -0
- package/config/metasync-detect.txt +52 -0
- package/config/metasync-extra.txt +30 -0
- package/config/metasync-fingerprint.txt +90 -0
- package/dist/commands/index.js +7 -6
- package/dist/commands/launcher.js +21 -4
- package/dist/commands/pr.js +1 -1
- package/dist/commands/project.js +15 -6
- package/dist/commands/push.js +1 -1
- package/dist/commands/start.js +50 -2
- package/dist/commands/switch-org.js +1 -1
- package/dist/core/ci-sequence-steps.js +2 -2
- package/dist/core/ci-validate-steps.js +1 -1
- package/dist/core/cli-update-notice.js +47 -0
- package/dist/core/create-setup.js +47 -3
- package/dist/core/diag.js +9 -9
- package/dist/core/launcher-status.js +33 -2
- package/dist/core/log-auto.js +1 -1
- package/dist/core/log-box.js +32 -8
- package/dist/core/log-pull.js +2 -2
- package/dist/core/log-select.js +1 -1
- package/dist/core/log-start.js +2 -2
- package/dist/core/log-status.js +2 -2
- package/dist/core/metasync.js +2 -2
- package/dist/core/new-version.js +93 -0
- package/dist/core/pr.js +24 -6
- package/dist/core/project-status.js +20 -9
- package/dist/core/project-tier.js +1 -1
- package/dist/core/project-upgrade.js +138 -0
- package/dist/core/promote-check.js +46 -13
- package/dist/core/push.js +16 -5
- package/dist/core/release.js +1 -1
- package/dist/core/start.js +2 -2
- package/dist/core/update-cli.js +1 -1
- package/dist/io/create-deps.js +1 -0
- package/dist/io/job-deps.js +21 -13
- package/dist/io/keys.js +15 -4
- package/dist/io/log-deps.js +2 -1
- package/dist/io/metasync-deps.js +3 -2
- package/dist/io/promote-deps.js +4 -3
- package/dist/io/temp-dir.js +15 -1
- package/dist/io/toolbox.js +1 -1
- package/dist/ui/launcher.js +43 -12
- package/lib/apexlog.js +819 -0
- package/lib/metasync.js +1364 -0
- package/lib/package.json +4 -0
- package/lib/typecheck.js +547 -0
- package/package.json +9 -2
- package/templates/.forceignore +12 -0
- package/templates/.gitattributes +58 -0
- package/templates/.github/workflows/wf-metasync.yml +177 -0
- package/templates/.github/workflows/wf-release.yml +454 -0
- package/templates/.github/workflows/wf-sequence.yml +292 -0
- package/templates/.github/workflows/wf-validate.yml +389 -0
- package/templates/.prettierignore +11 -0
- package/templates/.prettierrc +17 -0
- package/templates/.vscode/extensions.json +9 -0
- package/templates/.vscode/launch.json +16 -0
- package/templates/.vscode/settings.json +39 -0
- package/templates/AGENTS.md +3 -0
- package/templates/CLAUDE.md +4 -0
- package/templates/README.md +11 -0
- package/templates/config/project-scratch-def.json +13 -0
- package/templates/eslint.config.js +55 -0
- package/templates/force-app/main/default/.gitkeep +0 -0
- package/templates/gitignore.template +62 -0
- package/templates/jest.config.js +6 -0
- package/templates/package.json +29 -0
- package/templates/scripts/apex/hello.apex +10 -0
- package/templates/scripts/soql/account.soql +6 -0
- package/templates/sf-tools/config/branches.txt +24 -0
- package/templates/sf-tools/config/metadata.txt +576 -0
- package/templates/sfdx-project.json +12 -0
- package/templates-ts/.github/workflows/wf-metasync.yml +109 -0
- package/templates-ts/.github/workflows/wf-release.yml +263 -0
- package/templates-ts/.github/workflows/wf-sequence.yml +153 -0
- package/templates-ts/.github/workflows/wf-validate.yml +185 -0
|
@@ -70,7 +70,7 @@ export function validateCommentBody(input) {
|
|
|
70
70
|
let result;
|
|
71
71
|
if (code === "") {
|
|
72
72
|
icon = "⚠️";
|
|
73
|
-
result = "検証が実行されませんでした(
|
|
73
|
+
result = "検証が実行されませんでした(sft release の終了コードを取得できません。前のステップの失敗、または取り消し・タイムアウト)";
|
|
74
74
|
}
|
|
75
75
|
else if (code === "0") {
|
|
76
76
|
icon = "✅";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// 「Salesforce CLI の新しい版があります」の知らせ(設計 1.2 の 5・4.3)。自動では更新しない(更新は、人が sft update-cli を単独で動かす)。
|
|
2
|
+
// 今の sf の版(sf --version の `@salesforce/cli/2.1.3`)と、npm の最新(npm view @salesforce/cli version)を比べる。
|
|
3
|
+
// npm への問い合わせは、24 時間に 1 回まで(記録のファイルに書く)。失敗したら 5 分は試さず、黙って知らせない。GitHub Actions では動かさない。
|
|
4
|
+
// 記録: {"at": 時刻, "version": npm の最新}。失敗したときは {"failedAt": 時刻}。壊れていたら、確かめ直す
|
|
5
|
+
import { isNewer, LOOKUP_TIMEOUT_MS, RETRY_MS } from "./new-version.js";
|
|
6
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
7
|
+
/** sf --version の出力から、版を取り出す(読めなければ null) */
|
|
8
|
+
export function sfVersionOf(output) {
|
|
9
|
+
return /@salesforce\/cli\/(\d+\.\d+\.\d+)/.exec(output)?.[1] ?? null;
|
|
10
|
+
}
|
|
11
|
+
/** 新しい版があれば、知らせの 1 行。なければ(確かめられないときも)null */
|
|
12
|
+
export async function cliUpdateNotice(box, stampFile, signal) {
|
|
13
|
+
if (box.env("GITHUB_ACTIONS") === "true" || box.env("SFT_NO_UPDATE_CHECK") === "1")
|
|
14
|
+
return null;
|
|
15
|
+
const now = box.clock.now().getTime();
|
|
16
|
+
let latest = null;
|
|
17
|
+
try {
|
|
18
|
+
const rec = JSON.parse(box.files.readText(stampFile));
|
|
19
|
+
if (typeof rec.failedAt === "number" && now - rec.failedAt >= 0 && now - rec.failedAt < RETRY_MS)
|
|
20
|
+
return null;
|
|
21
|
+
if (typeof rec.at === "number" && typeof rec.version === "string" && now - rec.at >= 0 && now - rec.at < DAY_MS)
|
|
22
|
+
latest = rec.version;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// 記録がない・壊れている: 確かめ直す
|
|
26
|
+
}
|
|
27
|
+
if (latest === null) {
|
|
28
|
+
const r = await box.run("npm", ["view", "@salesforce/cli", "version"], { timeoutMs: LOOKUP_TIMEOUT_MS, signal }).catch(() => null);
|
|
29
|
+
if (r?.aborted)
|
|
30
|
+
return null; // 中断は失敗ではない(記録しない)
|
|
31
|
+
const v = r !== null && r.code === 0 ? r.stdout.trim() : "";
|
|
32
|
+
latest = /^\d+\.\d+\.\d+$/.test(v) ? v : null;
|
|
33
|
+
try {
|
|
34
|
+
box.files.writeText(stampFile, JSON.stringify(latest === null ? { failedAt: now } : { at: now, version: latest }));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// 記録を書けなくても、知らせはする
|
|
38
|
+
}
|
|
39
|
+
if (latest === null)
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const s = await box.run("sf", ["--version"], { timeoutMs: 20_000 }).catch(() => null);
|
|
43
|
+
const current = s !== null && s.code === 0 ? sfVersionOf(s.stdout) : null;
|
|
44
|
+
if (current === null || !isNewer(latest, current))
|
|
45
|
+
return null;
|
|
46
|
+
return `Salesforce CLI の新しい版があります(今 ${current} → ${latest})。自動では更新しません。sft update-cli を、単独で動かしてください。`;
|
|
47
|
+
}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
// sf-tools のブランチ)→ 状態ファイルを作り直す(GITHUB_OWNER・PROJECT_NAME・REPO_NAME・REPO_FULL_NAME・REPO_DIR・ENV_TYPE・
|
|
6
6
|
// SF_TOOLS_BRANCH)。シェル版の ~/sf-tools の最新化(git pull)は、しない(版の固定: doc/rebuild-design.md 2.4.2)
|
|
7
7
|
// 3. リポジトリの作成: gh repo view → なければ gh repo create --private。クローン(あれば origin を確かめ、main にして pull --ff-only)。
|
|
8
|
-
// 雛形(templates
|
|
9
|
-
// 4. 設定ファイルの作成(シェル版は sf-refresh.sh の初期化モード): sf-tools/
|
|
8
|
+
// 雛形(templates/)を全部コピー(同名は上書き)→ workflowsDir があれば、そのワークフロー(templates-ts の sft 版)で上書き・gitignore.template → .gitignore・sfdx-project.json の __REPO_NAME__ を置き換える
|
|
9
|
+
// 4. 設定ファイルの作成(シェル版は sf-refresh.sh の初期化モード): sf-tools/package.json(自分の版の固定)と package-lock.json(npm install --package-lock-only。
|
|
10
|
+
// なければ作る・あれば触らない)・sf-tools/config の metadata.txt・branches.txt(ないものだけ雛形から)・
|
|
10
11
|
// フック(sft の凍結した入口があれば)・release/ の準備・.gitmessage と commit.template
|
|
11
12
|
// 5. ブランチの構成: 1) main / staging / develop 2) main / staging 3) main。branches.txt は、# の行だけを残して書き直し、
|
|
12
13
|
// BRANCH_COUNT を状態ファイルに追記する
|
|
@@ -30,7 +31,7 @@ export async function phaseCheckEnv(ctx) {
|
|
|
30
31
|
let missing = false;
|
|
31
32
|
for (const cmd of ["git", "gh", "node", "npm", "sf", "code"]) {
|
|
32
33
|
// code は Windows で code.cmd(決まった引数だけを渡す)
|
|
33
|
-
const r = await exec(box, cmd, ["--version"], cmd === "code" ? { allowCmdShell: true } : {});
|
|
34
|
+
const r = await exec(box, cmd, ["--version"], cmd === "code" ? { allowCmdShell: true, timeoutMs: 60_000 } : { timeoutMs: 60_000 });
|
|
34
35
|
if (r === null) {
|
|
35
36
|
err(`[ERROR] ❌ ${cmd} が見つかりません`);
|
|
36
37
|
missing = true;
|
|
@@ -202,6 +203,16 @@ export async function phaseRepoCreate(ctx) {
|
|
|
202
203
|
repo.files.makeDir(to.slice(0, slash));
|
|
203
204
|
repo.files.writeText(to, box.files.readText(`${tmpl}/${rel}`));
|
|
204
205
|
}
|
|
206
|
+
// ワークフローは、sft 版(templates-ts)で上書きする(シェル版の templates/.github/workflows は、段階 6 まで残る)
|
|
207
|
+
const wf = ctx.deps.workflowsDir;
|
|
208
|
+
if (wf !== undefined) {
|
|
209
|
+
const names = box.files.walkFiles(wf);
|
|
210
|
+
if (names.length === 0)
|
|
211
|
+
throw new Error("empty-workflows");
|
|
212
|
+
repo.files.makeDir(".github/workflows");
|
|
213
|
+
for (const rel of names)
|
|
214
|
+
repo.files.writeText(`.github/workflows/${rel}`, box.files.readText(`${wf}/${rel}`));
|
|
215
|
+
}
|
|
205
216
|
}
|
|
206
217
|
catch {
|
|
207
218
|
throw new CreateStop(1, "テンプレートファイルのコピーに失敗しました。");
|
|
@@ -221,6 +232,38 @@ export async function phaseRepoCreate(ctx) {
|
|
|
221
232
|
}
|
|
222
233
|
err("[SUCCESS] 完了: リポジトリ作成 OK。");
|
|
223
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* force-* に、この sft の版を固定する(設計 4.2): sf-tools/package.json に依存を書き、package-lock.json を作る。
|
|
237
|
+
* GitHub Actions は `npm ci --prefix sf-tools` で、この版を入れる。すでに package.json があれば、上書きしない(版の更新は project upgrade)。
|
|
238
|
+
* 開発中の版(0.0.0-dev.*。ソースから動かしたとき)は、npm にないため、固定しない(警告)
|
|
239
|
+
*/
|
|
240
|
+
async function pinSftVersion(ctx, repo) {
|
|
241
|
+
const err = (l) => repo.output.err(l);
|
|
242
|
+
const pkg = "sf-tools/package.json";
|
|
243
|
+
const lockTo = async () => {
|
|
244
|
+
const r = await exec(repo, "npm", ["install", "--package-lock-only", "--ignore-scripts", "--prefix", "sf-tools"]);
|
|
245
|
+
if (r === null || r.code !== 0)
|
|
246
|
+
throw new CreateStop(1, "sf-tools/package-lock.json の作成に失敗しました(npm install --package-lock-only --prefix sf-tools)。");
|
|
247
|
+
};
|
|
248
|
+
if (repo.files.exists(pkg)) {
|
|
249
|
+
// 前回、ロックファイルの作成で止まったときは、package.json だけが残っている。ロックファイルがなければ、作る(Actions の npm ci に要る)
|
|
250
|
+
if (!repo.files.exists("sf-tools/package-lock.json")) {
|
|
251
|
+
err("[INFO] sf-tools/package-lock.json がないため、作ります。");
|
|
252
|
+
await lockTo();
|
|
253
|
+
}
|
|
254
|
+
else
|
|
255
|
+
err("[INFO] sf-tools/package.json があるため、sft の版の固定は、そのままにします。");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const version = ctx.deps.version;
|
|
259
|
+
if (/^0\.0\.0-dev/.test(version)) {
|
|
260
|
+
err(`[WARNING] この sft(${version})は開発中の版のため、force-* に版を固定しません。GitHub Actions が動くように、sf-tools/package.json を、公開された版で作ってください。`);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
repo.files.writeText(pkg, `${JSON.stringify({ private: true, dependencies: { "@tama-create/sf-tools": version } }, null, 2)}\n`);
|
|
264
|
+
await lockTo();
|
|
265
|
+
err(`[SUCCESS] sft の版を固定しました: @tama-create/sf-tools@${version}(sf-tools/package.json・package-lock.json)`);
|
|
266
|
+
}
|
|
224
267
|
export async function phaseGenFiles(ctx) {
|
|
225
268
|
const s = state(ctx, "REPO_DIR");
|
|
226
269
|
const repo = repoBox(ctx, s.REPO_DIR);
|
|
@@ -240,6 +283,7 @@ export async function phaseGenFiles(ctx) {
|
|
|
240
283
|
throw new CreateStop(1, "設定ファイルの初期化に失敗しました。");
|
|
241
284
|
}
|
|
242
285
|
err("[SUCCESS] 設定ファイルの確認が完了しました。");
|
|
286
|
+
await pinSftVersion(ctx, repo);
|
|
243
287
|
await setupHooks(repo, ctx.deps.doctor);
|
|
244
288
|
await setupReleaseDir(repo, ctx.deps.doctor);
|
|
245
289
|
// コミットメッセージの雛形(失敗は警告で続ける)
|
package/dist/core/diag.js
CHANGED
|
@@ -56,7 +56,7 @@ export async function runDiag(box, repo, tiers) {
|
|
|
56
56
|
line("ok", `GitHub に、リポジトリがあります(${repo})`);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
line("ng", `GitHub に、リポジトリが見つかりません(${repo})`, "リポジトリの作成からやり直す: プロジェクトのフォルダで
|
|
59
|
+
line("ng", `GitHub に、リポジトリが見つかりません(${repo})`, "リポジトリの作成からやり直す: プロジェクトのフォルダで sft project create");
|
|
60
60
|
}
|
|
61
61
|
const branches = await ghLinesOrNull(box, ["api", `repos/${repo}/branches`, "--paginate", "--jq", ".[].name"]);
|
|
62
62
|
if (branches !== null) {
|
|
@@ -64,7 +64,7 @@ export async function runDiag(box, repo, tiers) {
|
|
|
64
64
|
if (branches.includes(tier))
|
|
65
65
|
line("ok", `ブランチ ${tier} があります`);
|
|
66
66
|
else
|
|
67
|
-
line("ng", `ブランチ ${tier} がありません`, `force-* の中で
|
|
67
|
+
line("ng", `ブランチ ${tier} がありません`, `force-* の中で sft project add-tier ${tier}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
@@ -76,10 +76,10 @@ export async function runDiag(box, repo, tiers) {
|
|
|
76
76
|
if (workflows.includes(wf))
|
|
77
77
|
line("ok", `ワークフロー ${wf} があります`);
|
|
78
78
|
else
|
|
79
|
-
line("ng", `ワークフロー ${wf} がありません`, "force-* の中で
|
|
79
|
+
line("ng", `ワークフロー ${wf} がありません`, "force-* の中で sft project update-workflows");
|
|
80
80
|
}
|
|
81
81
|
if (workflows.includes("wf-propagate.yml")) {
|
|
82
|
-
line("warn", "廃止したワークフロー wf-propagate.yml が残っています(force-* の中で
|
|
82
|
+
line("warn", "廃止したワークフロー wf-propagate.yml が残っています(force-* の中で sft project update-workflows --remove wf-propagate.yml で消します)");
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
@@ -91,11 +91,11 @@ export async function runDiag(box, repo, tiers) {
|
|
|
91
91
|
if (secrets !== null) {
|
|
92
92
|
need(secrets, "PAT_TOKEN", "force-* の中で gh secret set PAT_TOKEN(Classic Token: repo・workflow)");
|
|
93
93
|
need(secrets, "SLACK_BOT_TOKEN", "force-* の中で gh secret set SLACK_BOT_TOKEN");
|
|
94
|
-
need(secrets, "SF_PRIVATE_KEY", "force-* の中で
|
|
94
|
+
need(secrets, "SF_PRIVATE_KEY", "force-* の中で sft project update-secret(メニュー 1: 秘密鍵)");
|
|
95
95
|
for (const tier of tiers) {
|
|
96
96
|
const sfx = tierSuffix(tier);
|
|
97
97
|
if (sfx !== "")
|
|
98
|
-
need(secrets, `SF_CONSUMER_KEY_${sfx}`, `force-* の中で
|
|
98
|
+
need(secrets, `SF_CONSUMER_KEY_${sfx}`, `force-* の中で sft project reconnect ${tier}`);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
@@ -110,10 +110,10 @@ export async function runDiag(box, repo, tiers) {
|
|
|
110
110
|
const sfx = tierSuffix(tier);
|
|
111
111
|
if (sfx === "")
|
|
112
112
|
continue;
|
|
113
|
-
need(vars, `SF_USERNAME_${sfx}`, `force-* の中で
|
|
114
|
-
need(vars, `SF_INSTANCE_URL_${sfx}`, `force-* の中で
|
|
113
|
+
need(vars, `SF_USERNAME_${sfx}`, `force-* の中で sft project reconnect ${tier}`);
|
|
114
|
+
need(vars, `SF_INSTANCE_URL_${sfx}`, `force-* の中で sft project reconnect ${tier}`);
|
|
115
115
|
if (!vars.includes(`SF_ORG_ID_${sfx}`)) {
|
|
116
|
-
line("warn", `SF_ORG_ID_${sfx} がありません(組織の種類が、記録されていません)。force-* の中で
|
|
116
|
+
line("warn", `SF_ORG_ID_${sfx} がありません(組織の種類が、記録されていません)。force-* の中で sft project reconnect ${tier} で、記録できます`);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// 1 行目: 「 >> LAUNCHER << <ブランチ> @ <組織> / 変更 N 件 / Log: <デバッグログの状態>」(ないものは出さない)
|
|
4
4
|
// ブランチの上にいなければ「(ブランチの上にいません)」(と組織)だけ
|
|
5
5
|
// Log の WARNING があれば「⚠ Log: …」をもう 1 行。環境ブランチの上なら「⚠ 環境ブランチの上です…」で終わる
|
|
6
|
-
// 2 行目: 「Branch: <段階の並び>」(sf-tools/logs/next-status.txt。HEAD=
|
|
6
|
+
// 2 行目: 「Branch: <段階の並び>」(sf-tools/logs/next-status.txt。HEAD= が今の先端と同じで、形が正しく、
|
|
7
|
+
// SKIPPED= が今の対象のファイル(作業ツリー)の空・空でないと合うときだけ使う)。
|
|
8
|
+
// 対象を書いたファイルにコミット前の変更があるときは「コミット前の変更があります」(次の PR 先は出さない・判定も頼まない)
|
|
7
9
|
// 使えないときは、裏の判定(sft pr --status)を頼み、動いているあいだは「(確かめています…)」、
|
|
8
10
|
// 終わった・頼めないときは「(<番号> PullRequest で確かめる)」
|
|
9
11
|
// 表示する値は cleanText で掃除する(制御文字・幅のない文字・文字の向きを変える文字・BOM を除き、画面を崩させない)
|
|
@@ -52,6 +54,23 @@ export function parseGitStatus(text) {
|
|
|
52
54
|
}
|
|
53
55
|
return { branch: branch === "(detached)" ? "" : branch, head: head === "(initial)" ? "" : head, changes };
|
|
54
56
|
}
|
|
57
|
+
/** git status --porcelain=v2 の出力で、このブランチの対象のファイル(deploy-target.txt・remove-target.txt)にコミット前の変更があるか */
|
|
58
|
+
export function uncommittedTargets(statusText, branch) {
|
|
59
|
+
if (branch === "")
|
|
60
|
+
return false;
|
|
61
|
+
const targets = ["deploy-target.txt", "remove-target.txt"].map((f) => `sf-tools/release/${branch}/${f}`);
|
|
62
|
+
// パスより前の欄の数(1: 変更・2: 名前の変更・u: 衝突・?: 追跡していない)
|
|
63
|
+
const skip = { "1": 8, "2": 9, u: 10, "?": 1 };
|
|
64
|
+
return statusText.split("\n").some((raw) => {
|
|
65
|
+
const fields = raw.replace(/\r$/, "").split(" ");
|
|
66
|
+
const n = skip[fields[0] ?? ""];
|
|
67
|
+
if (n === undefined)
|
|
68
|
+
return false;
|
|
69
|
+
const path = fields.slice(n).join(" ").split("\t")[0] ?? "";
|
|
70
|
+
// 追跡していないフォルダは「sf-tools/release/」のように、まとめて出る
|
|
71
|
+
return targets.some((t) => t === path || (path.endsWith("/") && t.startsWith(path)));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
55
74
|
/** .sf/config.json の target-org(読めなければ空。掃除して、60 文字を超えたら切って … を付ける) */
|
|
56
75
|
export function targetOrg(json) {
|
|
57
76
|
if (json === null)
|
|
@@ -148,10 +167,20 @@ export function statusLines(input, paint) {
|
|
|
148
167
|
lines.push(`${PAD}${paint.yellow("⚠ 環境ブランチの上です。作業は、sft job で作ったブランチで行います")}`);
|
|
149
168
|
return { lines, wantCheck: false };
|
|
150
169
|
}
|
|
170
|
+
// 対象を書いてもコミット前は、PR に入らないので、次の PR 先を出さない
|
|
171
|
+
if (input.uncommitted && input.targetsEmpty === false) {
|
|
172
|
+
lines.push(`${PAD}Branch: ${paint.yellow("コミット前の変更があります(Push のあとで確かめます)")}`);
|
|
173
|
+
return { lines, wantCheck: false };
|
|
174
|
+
}
|
|
151
175
|
const ask = paint.dim(`(${input.prNumber} PullRequest で確かめる)`);
|
|
152
|
-
|
|
176
|
+
let st = parseNextStatus(input.nextStatus, input.git.head);
|
|
177
|
+
// 判定は対象のファイルの中身にもよる。先端のコミットが同じでも、空・空でないが変わっていたら、古い結果は使わない
|
|
178
|
+
if (st && input.targetsEmpty != null && st.skipped !== input.targetsEmpty)
|
|
179
|
+
st = null;
|
|
153
180
|
let rel;
|
|
154
181
|
let wantCheck = false;
|
|
182
|
+
if (st && input.refresh)
|
|
183
|
+
wantCheck = true; // 前回の結果を出しながら、裏で判定し直す
|
|
155
184
|
if (st?.skipped) {
|
|
156
185
|
rel = `出すものなし(ターゲットファイル sf-tools/release/${branch}/ が空)`;
|
|
157
186
|
}
|
|
@@ -179,6 +208,8 @@ export function statusLines(input, paint) {
|
|
|
179
208
|
wantCheck = true;
|
|
180
209
|
rel = input.checking ? paint.dim("(確かめています…)") : ask;
|
|
181
210
|
}
|
|
211
|
+
if (st && input.checking)
|
|
212
|
+
rel += ` ${paint.dim("(更新中…)")}`;
|
|
182
213
|
lines.push(`${PAD}Branch: ${rel}`);
|
|
183
214
|
return { lines, wantCheck };
|
|
184
215
|
}
|
package/dist/core/log-auto.js
CHANGED
|
@@ -51,6 +51,6 @@ export async function runLogAuto(args, box, deps) {
|
|
|
51
51
|
}
|
|
52
52
|
box.output.out(value === "on"
|
|
53
53
|
? `[SUCCESS] このプロジェクトでは、sf-start のときにデバッグログを自動で取ります(組織: ${org})。`
|
|
54
|
-
: "[SUCCESS] このプロジェクトでは、sf-start のときにデバッグログを取りません(動いている取得は止めません。今止めるなら
|
|
54
|
+
: "[SUCCESS] このプロジェクトでは、sf-start のときにデバッグログを取りません(動いている取得は止めません。今止めるなら sft log stop)。");
|
|
55
55
|
return 0;
|
|
56
56
|
}
|
package/dist/core/log-box.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
// - 外のコマンドは、[CMD] の行(引数)と、[OUT] の行(出力)と、終了コードを書く(画面には出さない)
|
|
6
6
|
// - 伏せ字: maskSecrets に加えて、--client-id の値(コンシューマーキー)を伏せる。標準入力に渡した値(Token など)は書かない
|
|
7
7
|
// - ログが書けなくても、コマンドは止めない(ログは補助)
|
|
8
|
+
// - 毎日のコマンド(check・dryrun・deploy・release・push・pr)は commandLogged で、sf-tools/logs/<サブコマンド>.log に残す。
|
|
9
|
+
// 書くのは、画面に出した行(標準出力・標準エラー)と、[CMD] の行と、終了コードだけ。外のコマンドの出力は書かない
|
|
10
|
+
// (画面に出さない応答には、接続の確認の中身など、形の分からない秘密がありうるため)
|
|
8
11
|
import { fileLine, prefixLines, stripTermCodes, timestamp } from "./log-format.js";
|
|
9
12
|
import { maskSecrets } from "./mask.js";
|
|
10
13
|
const LEVEL_RE = /^\s*\[(HEADER|INFO|SUCCESS|WARNING|ERROR|FATAL)\]\s?(.*)$/;
|
|
@@ -26,7 +29,20 @@ export function logEntry(ts, line) {
|
|
|
26
29
|
const text = maskSecrets(m ? (m[2] ?? "") : clean.trim());
|
|
27
30
|
return fileLine(ts, level, level === "HEADER" ? text.trim() : text);
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
/** 実行のたびに sf-tools/logs/<サブコマンド>.log を書くコマンドにする。sf-tools/ のない場所と、pr --status(裏の判定)では書かない */
|
|
33
|
+
export function commandLogged(command) {
|
|
34
|
+
return {
|
|
35
|
+
...command,
|
|
36
|
+
run: (args, box) => {
|
|
37
|
+
if (!box.files.isDir("sf-tools") || args.includes("--status"))
|
|
38
|
+
return command.run(args, box);
|
|
39
|
+
const file = `sf-tools/logs/${command.name}.log`;
|
|
40
|
+
return command.run(args, fileLoggedBox(box, file, `sft ${command.name}`, { screenOnly: true }));
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** screenOnly: 標準出力の行も書き、外のコマンドの出力は書かない */
|
|
45
|
+
export function fileLoggedBox(box, file, name, options = {}) {
|
|
30
46
|
let ok = true;
|
|
31
47
|
const write = (text) => {
|
|
32
48
|
if (!ok || text === "")
|
|
@@ -49,21 +65,28 @@ export function fileLoggedBox(box, file, name) {
|
|
|
49
65
|
}
|
|
50
66
|
const now = () => timestamp(box.clock.now());
|
|
51
67
|
write(`[${now()}] [INFO] ${name} を開始しました\n`);
|
|
68
|
+
const record = (line) => {
|
|
69
|
+
const ts = now();
|
|
70
|
+
for (const l of line.split("\n"))
|
|
71
|
+
write(logEntry(ts, l) ?? "");
|
|
72
|
+
};
|
|
52
73
|
return {
|
|
53
74
|
...box,
|
|
54
75
|
output: {
|
|
55
|
-
out: (line) =>
|
|
76
|
+
out: (line) => {
|
|
77
|
+
box.output.out(line);
|
|
78
|
+
if (options.screenOnly)
|
|
79
|
+
record(line);
|
|
80
|
+
},
|
|
56
81
|
err: (line) => {
|
|
57
82
|
box.output.err(line);
|
|
58
|
-
|
|
59
|
-
for (const l of line.split("\n"))
|
|
60
|
-
write(logEntry(ts, l) ?? "");
|
|
83
|
+
record(line);
|
|
61
84
|
},
|
|
62
85
|
},
|
|
63
|
-
run: async (command, args,
|
|
86
|
+
run: async (command, args, runOptions) => {
|
|
64
87
|
write(fileLine(now(), "CMD", `[${name}] ${commandText(command, args)}`));
|
|
65
88
|
try {
|
|
66
|
-
const r = await box.run(command, args,
|
|
89
|
+
const r = await box.run(command, args, runOptions);
|
|
67
90
|
const ts = now();
|
|
68
91
|
// 出力に含まれうる、秘密を入れる引数の値(コンシューマーキー)も伏せる。Actions のログ全体(gh run view --log)は、大きいので記録しない
|
|
69
92
|
const secrets = args.filter((_, i) => i > 0 && SECRET_ARGS.has(args[i - 1]) && args[i] !== "");
|
|
@@ -71,7 +94,8 @@ export function fileLoggedBox(box, file, name) {
|
|
|
71
94
|
let text = maskSecrets(stripTermCodes(r.output));
|
|
72
95
|
for (const s of secrets)
|
|
73
96
|
text = text.split(s).join("***masked***");
|
|
74
|
-
|
|
97
|
+
if (!options.screenOnly)
|
|
98
|
+
write(quiet ? `[${ts}] [OUT] (Actions のログ全体は、記録しません)\n` : prefixLines(`[${ts}] [OUT] `, text));
|
|
75
99
|
if (r.code !== 0)
|
|
76
100
|
write(`[${ts}] [OUT] (終了コード ${r.code}${r.timedOut ? "・時間切れ" : ""}${r.aborted ? "・中断" : ""})\n`);
|
|
77
101
|
return r;
|
package/dist/core/log-pull.js
CHANGED
|
@@ -447,7 +447,7 @@ async function pull(args, box, deps) {
|
|
|
447
447
|
const collector = liveNodeCollector(box, deps);
|
|
448
448
|
const other = collector === null ? otherHandler(box) : null;
|
|
449
449
|
if (other !== null)
|
|
450
|
-
throw new Stop(1, `${other}。そちらで pull してください(
|
|
450
|
+
throw new Stop(1, `${other}。そちらで pull してください(sft log pull)。`);
|
|
451
451
|
const ctx = { box, deps, org, userId: user.userId };
|
|
452
452
|
box.files.makeDir(APEX);
|
|
453
453
|
// 取得役の組織が違うなら、しおりを書き換える前に止める(止めたあとに、しおりだけ別の組織になるのを防ぐ)
|
|
@@ -527,7 +527,7 @@ async function summarize(box, deps, parsed, notes) {
|
|
|
527
527
|
if (kvGet(now, "TRACE_FLAG_ID") === "") {
|
|
528
528
|
const status = read(box, STATUS_F);
|
|
529
529
|
const reason = kvGet(status, "STATE") === "stopped" ? kvGet(status, "REASON") : "";
|
|
530
|
-
notes.push(`sf-log の TraceFlag がありません(新しいログは出ません${reason !== "" ? `。理由: ${reason}` : ""})。人に sft の起動か
|
|
530
|
+
notes.push(`sf-log の TraceFlag がありません(新しいログは出ません${reason !== "" ? `。理由: ${reason}` : ""})。人に sft の起動か sft log start を頼んでください`);
|
|
531
531
|
}
|
|
532
532
|
const exp = kvGet(read(box, STATUS_F), "EXPIRES");
|
|
533
533
|
if (exp !== "")
|
package/dist/core/log-select.js
CHANGED
|
@@ -119,7 +119,7 @@ export function selectLogs(input) {
|
|
|
119
119
|
picked = [...picked].sort(byStartThenId);
|
|
120
120
|
if (picked.length > input.max) {
|
|
121
121
|
const omitted = picked.length - input.max;
|
|
122
|
-
notes.push(`入れなかった古いログ: ${omitted} 本(${col(picked[0], 3)}〜${col(picked[omitted - 1], 3)}。UTC)。入れるには
|
|
122
|
+
notes.push(`入れなかった古いログ: ${omitted} 本(${col(picked[0], 3)}〜${col(picked[omitted - 1], 3)}。UTC)。入れるには sft log pull --since <分> --max <本数>`);
|
|
123
123
|
picked = picked.slice(omitted);
|
|
124
124
|
}
|
|
125
125
|
return { entries: picked, mode, notes, warnings, advance: input.sinceMin === null };
|
package/dist/core/log-start.js
CHANGED
|
@@ -231,7 +231,7 @@ async function prepareOrg(box, orgArg) {
|
|
|
231
231
|
throw new Stop(1, `ユーザーの情報を取得できません(${user})。`);
|
|
232
232
|
const other = otherHandler(box);
|
|
233
233
|
if (other !== null)
|
|
234
|
-
throw new Stop(1, `${other}。そちらで操作してください(
|
|
234
|
+
throw new Stop(1, `${other}。そちらで操作してください(sft log)。`);
|
|
235
235
|
return { org, userId: user.userId };
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
@@ -362,7 +362,7 @@ async function stop(args, box, deps) {
|
|
|
362
362
|
}
|
|
363
363
|
const other = otherHandler(box);
|
|
364
364
|
if (other !== null)
|
|
365
|
-
throw new Stop(1, `${other}。そちらで止めてください(
|
|
365
|
+
throw new Stop(1, `${other}。そちらで止めてください(sft log stop)。`);
|
|
366
366
|
const ctx = { box, deps };
|
|
367
367
|
const state = read(box, STATE_F);
|
|
368
368
|
const tf = kvGet(state, "TRACE_FLAG_ID");
|
package/dist/core/log-status.js
CHANGED
|
@@ -153,7 +153,7 @@ export async function runLogStatus(args, box, deps = { pidAlive: () => false })
|
|
|
153
153
|
const status = read(".status");
|
|
154
154
|
const state = read(".state");
|
|
155
155
|
const out = (s) => box.output.out(s);
|
|
156
|
-
out("デバッグログ(
|
|
156
|
+
out("デバッグログ(sft log)の状態");
|
|
157
157
|
out(collectorLine(read(".collector"), read(".claim"), Math.floor(box.clock.now().getTime() / 1000), deps.pidAlive, collectInterval(box)));
|
|
158
158
|
for (const k of ["STATE", "ORG", "EXPIRES", "LAST_FETCH", "COUNT_TODAY", "BACKLOG", "REASON", "WARNING"]) {
|
|
159
159
|
const v = kvGet(status, k);
|
|
@@ -205,7 +205,7 @@ export async function runLogStatus(args, box, deps = { pidAlive: () => false })
|
|
|
205
205
|
if (rows.length === 0)
|
|
206
206
|
out(" なし");
|
|
207
207
|
for (const r of rows)
|
|
208
|
-
out(` ${r.id} ${r.type} ${r.state} 期限 ${r.expires} ${r.level}${r.id === mine ? " (
|
|
208
|
+
out(` ${r.id} ${r.type} ${r.state} 期限 ${r.expires} ${r.level}${r.id === mine ? " (sft log が作ったもの)" : ""}`);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
const c = await q(`SELECT COUNT(Id) n, SUM(LogLength) s FROM ApexLog WHERE LogUserId = '${userId}'`);
|
package/dist/core/metasync.js
CHANGED
|
@@ -567,7 +567,7 @@ export async function runMetasync(args, box, deps) {
|
|
|
567
567
|
committed = true;
|
|
568
568
|
await must("Git への同期中にエラーが発生しました(push)。", "push", "--no-verify", "origin", "main");
|
|
569
569
|
log("SUCCESS", "完了: リポジトリを最新に更新しました。");
|
|
570
|
-
log("INFO", "main の変更は、staging・develop のブランチへは伝播しません(開発のブランチが、
|
|
570
|
+
log("INFO", "main の変更は、staging・develop のブランチへは伝播しません(開発のブランチが、sft push で main を取り込みます)。");
|
|
571
571
|
}
|
|
572
572
|
if (planRc === METASYNC_EXIT.reserved) {
|
|
573
573
|
log("WARNING", "削除を保留したものがあります(ファイルは残しています)。原因を確かめてください(手元で --dry-run、必要なら --allow-mass-delete)。");
|
|
@@ -599,7 +599,7 @@ export async function runMetasync(args, box, deps) {
|
|
|
599
599
|
why = "リポジトリが公開(public)です";
|
|
600
600
|
else if (noToken)
|
|
601
601
|
why =
|
|
602
|
-
"リポジトリの公開・非公開を確認できませんでした(GH_TOKEN が渡されていません。wf-metasync.yml が古い可能性があります。
|
|
602
|
+
"リポジトリの公開・非公開を確認できませんでした(GH_TOKEN が渡されていません。wf-metasync.yml が古い可能性があります。sft project update-workflows で更新してください)";
|
|
603
603
|
else
|
|
604
604
|
why = `リポジトリの公開・非公開を確認できませんでした(${repoFull || "不明"})`;
|
|
605
605
|
log("ERROR", `${why}。Salesforce 組織の開発物を外部にさらさないため、取得せずに止めます。非公開(private)のリポジトリで実行してください。`);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const PACKAGE = "@tama-create/sf-tools";
|
|
2
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
3
|
+
// 失敗の後に、もう試さない時間。短い(遅い通信の一度の失敗で、1 時間も知らせを止めない)
|
|
4
|
+
export const RETRY_MS = 5 * 60 * 1000;
|
|
5
|
+
// npm view の上限。遅い通信(実機で 7〜12 秒)でも終わらせる。起動は待たせない(呼ぶ側が、先に進む。start.ts)
|
|
6
|
+
export const LOOKUP_TIMEOUT_MS = 20_000;
|
|
7
|
+
function parse(v) {
|
|
8
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(v.trim());
|
|
9
|
+
if (!m)
|
|
10
|
+
return null;
|
|
11
|
+
const pre = m[4] === undefined ? null : m[4].split(".").map((p) => (/^\d+$/.test(p) ? Number(p) : p));
|
|
12
|
+
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre };
|
|
13
|
+
}
|
|
14
|
+
/** a が b より新しいか(semver。読めない版は、新しいとしない) */
|
|
15
|
+
export function isNewer(a, b) {
|
|
16
|
+
const x = parse(a);
|
|
17
|
+
const y = parse(b);
|
|
18
|
+
if (!x || !y)
|
|
19
|
+
return false;
|
|
20
|
+
for (let i = 0; i < 3; i++)
|
|
21
|
+
if (x.nums[i] !== y.nums[i])
|
|
22
|
+
return x.nums[i] > y.nums[i];
|
|
23
|
+
if (x.pre === null || y.pre === null)
|
|
24
|
+
return x.pre === null && y.pre !== null; // 正式な版は、試しの版より新しい
|
|
25
|
+
for (let i = 0; i < Math.max(x.pre.length, y.pre.length); i++) {
|
|
26
|
+
const p = x.pre[i];
|
|
27
|
+
const q = y.pre[i];
|
|
28
|
+
if (p === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
if (q === undefined)
|
|
31
|
+
return true;
|
|
32
|
+
if (p === q)
|
|
33
|
+
continue;
|
|
34
|
+
if (typeof p === "number" && typeof q === "number")
|
|
35
|
+
return p > q;
|
|
36
|
+
if (typeof p === "number")
|
|
37
|
+
return false; // 数字は、文字より小さい
|
|
38
|
+
if (typeof q === "number")
|
|
39
|
+
return true;
|
|
40
|
+
return p > q;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
/** npm view の dist-tags の出力から、札の版を取り出す */
|
|
45
|
+
function tagVersion(stdout, tag) {
|
|
46
|
+
try {
|
|
47
|
+
const v = JSON.parse(stdout)[tag];
|
|
48
|
+
return typeof v === "string" && parse(v) ? v : null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** 新しい版があれば、知らせの 1 行。なければ(問い合わせに失敗したときも)null */
|
|
55
|
+
export async function newVersionNotice(box, deps) {
|
|
56
|
+
if (box.env("GITHUB_ACTIONS") === "true" || box.env("SFT_NO_UPDATE_CHECK") === "1")
|
|
57
|
+
return null;
|
|
58
|
+
if (/^0\.0\.0-dev/.test(deps.current))
|
|
59
|
+
return null; // ソースから動かした開発中の版は、比べない
|
|
60
|
+
const tag = deps.current.includes("-") ? "next" : "latest";
|
|
61
|
+
const now = box.clock.now().getTime();
|
|
62
|
+
let latest = null;
|
|
63
|
+
try {
|
|
64
|
+
const rec = JSON.parse(box.files.readText(deps.stampFile));
|
|
65
|
+
// 問い合わせに失敗した直後(1 時間以内)は、もう一度試さない(通信できない場所で、毎回待たせない)
|
|
66
|
+
if (typeof rec.failedAt === "number" && now - rec.failedAt >= 0 && now - rec.failedAt < RETRY_MS)
|
|
67
|
+
return null;
|
|
68
|
+
if (rec.tag === tag && typeof rec.at === "number" && typeof rec.version === "string" && now - rec.at >= 0 && now - rec.at < DAY_MS)
|
|
69
|
+
latest = rec.version;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// 記録がない・壊れている: 確かめ直す
|
|
73
|
+
}
|
|
74
|
+
if (latest === null) {
|
|
75
|
+
const r = await box
|
|
76
|
+
.run("npm", ["view", PACKAGE, "dist-tags", "--json"], { timeoutMs: LOOKUP_TIMEOUT_MS, signal: deps.signal })
|
|
77
|
+
.catch(() => null);
|
|
78
|
+
if (r?.aborted)
|
|
79
|
+
return null; // 中断は失敗ではない(記録しない)
|
|
80
|
+
latest = r !== null && r.code === 0 ? tagVersion(r.stdout, tag) : null;
|
|
81
|
+
try {
|
|
82
|
+
box.files.writeText(deps.stampFile, JSON.stringify(latest === null ? { failedAt: now } : { at: now, tag, version: latest }));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// 記録を書けなくても、知らせはする
|
|
86
|
+
}
|
|
87
|
+
if (latest === null)
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return isNewer(latest, deps.current)
|
|
91
|
+
? `sf-tools の新しい版があります(今 ${deps.current} → ${latest})。自動では入れ替えません。版を上げるのは、管理者の操作です(sft project upgrade。管理者に頼んでください)。`
|
|
92
|
+
: null;
|
|
93
|
+
}
|
package/dist/core/pr.js
CHANGED
|
@@ -91,21 +91,27 @@ export async function runPr(args, box, deps, ask) {
|
|
|
91
91
|
if (isProtectedBranch(current, list.branches))
|
|
92
92
|
return die(`${current} は保護ブランチ(${listFile})のため、実行できません。`);
|
|
93
93
|
log("INFO", "どの段階まで出たかを確かめています(promote-check --plan)...");
|
|
94
|
-
|
|
94
|
+
// --status は、前回の結果を、新しい結果が出るまで残す(ランチャーが、待つあいだ前回の結果を出せる)。判断できなかったときだけ消す
|
|
95
|
+
if (!status)
|
|
96
|
+
box.files.removeFile(NEXT_STATUS_FILE);
|
|
97
|
+
const dieStatus = (text) => {
|
|
98
|
+
box.files.removeFile(NEXT_STATUS_FILE);
|
|
99
|
+
return die(text);
|
|
100
|
+
};
|
|
95
101
|
const lines = [];
|
|
96
102
|
const capture = { ...box, output: { out: (l) => lines.push(l), err: (l) => box.output.err(l) } };
|
|
97
|
-
const rc = await runPromoteCheck(["--plan", "--json"], capture, deps.promote);
|
|
103
|
+
const rc = await runPromoteCheck(status ? ["--plan", "--json", "--quick"] : ["--plan", "--json"], capture, deps.promote);
|
|
98
104
|
const plan = readPlan(lines[lines.length - 1] ?? "");
|
|
99
105
|
if (rc === 1) {
|
|
100
106
|
log("ERROR", "一方通行のリリースの決まりを破っているため、PR を勧めません:");
|
|
101
107
|
for (const d of plan?.violations ?? [])
|
|
102
108
|
log("ERROR", ` ${d}`);
|
|
103
|
-
return
|
|
109
|
+
return dieStatus("決まりを破っています(doc/one-way-promotion-design.md)。");
|
|
104
110
|
}
|
|
105
111
|
if (rc !== 0)
|
|
106
|
-
return
|
|
112
|
+
return dieStatus(`次のPR先を判断できません: ${plan?.error || `promote-check の結果を読めません(終了コード ${rc})`}`);
|
|
107
113
|
if (plan === null || plan.next === "" || plan.tiers.length === 0)
|
|
108
|
-
return
|
|
114
|
+
return dieStatus("次のPR先を判断できません: promote-check の結果を読めません。");
|
|
109
115
|
const head = await box.run("git", ["rev-parse", "-q", "--verify", "HEAD"]).catch(() => null);
|
|
110
116
|
let statusWritten = false;
|
|
111
117
|
if (head !== null && head.code === 0) {
|
|
@@ -120,10 +126,22 @@ export async function runPr(args, box, deps, ask) {
|
|
|
120
126
|
}
|
|
121
127
|
if (status) {
|
|
122
128
|
if (!statusWritten)
|
|
123
|
-
return
|
|
129
|
+
return dieStatus(`判定の結果を書けませんでした: ${NEXT_STATUS_FILE}`);
|
|
124
130
|
log("SUCCESS", `判定の結果を書きました(${NEXT_STATUS_FILE}。次の段階: ${plan.next})`);
|
|
125
131
|
return EXIT.ok;
|
|
126
132
|
}
|
|
133
|
+
// 対象のファイルにコミット前の変更があるときは、PR に入らないので、次の PR 先を勧めない
|
|
134
|
+
if (!plan.skipped) {
|
|
135
|
+
const targets = ["deploy-target.txt", "remove-target.txt"].map((f) => `sf-tools/release/${current}/${f}`);
|
|
136
|
+
const dirty = await box.run("git", ["status", "--porcelain", "--", ...targets]).catch(() => null);
|
|
137
|
+
if (dirty !== null && dirty.code === 0 && dirty.stdout.trim() !== "") {
|
|
138
|
+
const fact = "ターゲットファイルに、コミットしていない変更があります(PR に入りません)。先に Push してください。";
|
|
139
|
+
if (create)
|
|
140
|
+
return die(fact);
|
|
141
|
+
log("WARNING", fact);
|
|
142
|
+
return EXIT.ok;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
127
145
|
// --- 表示(段階は、下から順) ---
|
|
128
146
|
const width = Math.max(...plan.tiers.map((t) => t.length));
|
|
129
147
|
box.output.err("");
|