@tama-create/sf-tools 0.0.0-stage → 1.4.0-dev.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/LICENSE +24 -0
- package/README.md +212 -2
- package/bin/sft.js +22 -0
- package/dist/cli.js +35 -0
- package/dist/commands/admin.js +46 -0
- package/dist/commands/check.js +20 -0
- package/dist/commands/ci.js +123 -0
- package/dist/commands/deploy.js +31 -0
- package/dist/commands/doctor.js +11 -0
- package/dist/commands/dryrun.js +17 -0
- package/dist/commands/hook.js +46 -0
- package/dist/commands/index.js +36 -0
- package/dist/commands/job.js +31 -0
- package/dist/commands/launcher.js +40 -0
- package/dist/commands/log.js +58 -0
- package/dist/commands/metasync.js +21 -0
- package/dist/commands/pr.js +32 -0
- package/dist/commands/project.js +93 -0
- package/dist/commands/push.js +16 -0
- package/dist/commands/release.js +19 -0
- package/dist/commands/start.js +19 -0
- package/dist/commands/switch-org.js +12 -0
- package/dist/commands/update-cli.js +11 -0
- package/dist/commands/version.js +18 -0
- package/dist/core/admin-clone.js +79 -0
- package/dist/core/ai-answers.js +40 -0
- package/dist/core/branches.js +88 -0
- package/dist/core/check-targets.js +170 -0
- package/dist/core/check.js +34 -0
- package/dist/core/ci-check-branch.js +150 -0
- package/dist/core/ci-login-steps.js +73 -0
- package/dist/core/ci-release-steps.js +193 -0
- package/dist/core/ci-sequence-steps.js +188 -0
- package/dist/core/ci-validate-steps.js +140 -0
- package/dist/core/command.js +25 -0
- package/dist/core/create-connect.js +519 -0
- package/dist/core/create-setup.js +314 -0
- package/dist/core/create-state.js +82 -0
- package/dist/core/delegate.js +45 -0
- package/dist/core/deploy.js +66 -0
- package/dist/core/diag.js +200 -0
- package/dist/core/doctor.js +211 -0
- package/dist/core/eca.js +259 -0
- package/dist/core/exit-codes.js +12 -0
- package/dist/core/gh-identity.js +46 -0
- package/dist/core/hook-install.js +130 -0
- package/dist/core/hook.js +116 -0
- package/dist/core/identity.js +48 -0
- package/dist/core/job.js +243 -0
- package/dist/core/launcher-status.js +184 -0
- package/dist/core/lines.js +25 -0
- package/dist/core/log-auto.js +56 -0
- package/dist/core/log-box.js +85 -0
- package/dist/core/log-collector.js +370 -0
- package/dist/core/log-format.js +44 -0
- package/dist/core/log-pull.js +565 -0
- package/dist/core/log-select.js +126 -0
- package/dist/core/log-session.js +362 -0
- package/dist/core/log-start.js +421 -0
- package/dist/core/log-status.js +223 -0
- package/dist/core/log-summarize.js +127 -0
- package/dist/core/logger.js +71 -0
- package/dist/core/login-url.js +50 -0
- package/dist/core/manifest-build.js +118 -0
- package/dist/core/mask.js +70 -0
- package/dist/core/metadata-types.js +79 -0
- package/dist/core/metasync.js +684 -0
- package/dist/core/org.js +115 -0
- package/dist/core/origin.js +62 -0
- package/dist/core/package-xml.js +157 -0
- package/dist/core/pr.js +199 -0
- package/dist/core/project-create.js +733 -0
- package/dist/core/project-reconnect.js +126 -0
- package/dist/core/project-status.js +235 -0
- package/dist/core/project-tier.js +374 -0
- package/dist/core/project-verify.js +517 -0
- package/dist/core/promote-check.js +380 -0
- package/dist/core/promote.js +141 -0
- package/dist/core/push.js +152 -0
- package/dist/core/release.js +256 -0
- package/dist/core/scoped-box.js +29 -0
- package/dist/core/start.js +155 -0
- package/dist/core/switch-org.js +49 -0
- package/dist/core/test-types.js +212 -0
- package/dist/core/toolbox.js +4 -0
- package/dist/core/update-cli.js +156 -0
- package/dist/core/update-secret.js +301 -0
- package/dist/core/update-workflows.js +132 -0
- package/dist/core/verify-gh.js +286 -0
- package/dist/core/verify-samples.js +152 -0
- package/dist/core/windows-shim.js +21 -0
- package/dist/io/capability-file.js +11 -0
- package/dist/io/create-deps.js +68 -0
- package/dist/io/doctor-deps.js +32 -0
- package/dist/io/hook-install-deps.js +11 -0
- package/dist/io/job-deps.js +31 -0
- package/dist/io/key-file.js +17 -0
- package/dist/io/keys.js +161 -0
- package/dist/io/log-deps.js +106 -0
- package/dist/io/metasync-deps.js +21 -0
- package/dist/io/open-browser.js +21 -0
- package/dist/io/package-version.js +10 -0
- package/dist/io/pinned-project.js +111 -0
- package/dist/io/promote-deps.js +27 -0
- package/dist/io/push-refs.js +20 -0
- package/dist/io/resolve.js +74 -0
- package/dist/io/run.js +201 -0
- package/dist/io/switch-org-deps.js +10 -0
- package/dist/io/temp-dir.js +10 -0
- package/dist/io/tool-versions.js +14 -0
- package/dist/io/toolbox.js +68 -0
- package/dist/io/update-cli-deps.js +75 -0
- package/dist/io/update-secret-deps.js +27 -0
- package/dist/launch.js +152 -0
- package/dist/ui/confirm.js +18 -0
- package/dist/ui/launcher.js +132 -0
- package/dist/ui/prompt.js +66 -0
- package/package.json +37 -4
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// ランチャー(sft を引数なしで、force-* の中で打ったときのメニュー)。phases/start/launcher.sh の移し先(doc/rebuild-design.md 6.1)。
|
|
2
|
+
// 項目は、サブコマンドの表(menu を持つもの)から作る。番号のキーを押すとすぐ動き(Enter は要らない)、終わるとメニューに戻る。
|
|
3
|
+
// q と入力の終わりで終了(0)。範囲外の数字・ほかのキーは聞き直す。Ctrl+C は、メニューの中では無効(誤って閉じない: 6.3)。
|
|
4
|
+
// 見出し(core/launcher-status.ts)は、メニューを描くたびに作る。入力を 5 秒ずつ待ち、デバッグログの状態(準備中・取得中)が
|
|
5
|
+
// 変わった・裏の判定(sft pr --status)が終わったら、コマンドを動かさずに描き直す(待っている入力は、そのまま続ける)。
|
|
6
|
+
// 結果は 1 行: 0 →「✓ <名前>: 終わりました(成功)」/ それ以外 →「✗ <名前>: 失敗、または中断しました(終了コード N)」。
|
|
7
|
+
// なくしたもの: 自分のファイルの書き換わりを見て読み込み直す動き(版を固定するため: 設計 2.4.2)。
|
|
8
|
+
// 組織への接続・doctor・デバッグログの取得は、開く前に src/core/start.ts が行う。未了: Start の項目(sft 自身のため、今は出さない)
|
|
9
|
+
import { apexlogState, makePaint, parseGitStatus, statusLines, targetOrg } from "../core/launcher-status.js";
|
|
10
|
+
const LINE = "──────────────────────────────────────────────────";
|
|
11
|
+
const readOrNull = (box, path) => {
|
|
12
|
+
try {
|
|
13
|
+
return box.files.exists(path) ? box.files.readText(path) : null;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export async function runLauncher(args, box, deps) {
|
|
20
|
+
const paint = makePaint(deps.color);
|
|
21
|
+
const err = (l) => box.output.err(l);
|
|
22
|
+
if (args.length > 0) {
|
|
23
|
+
err(paint.yellow(" ⚠ 引数は付けません"));
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
if (!deps.folderName.startsWith("force-")) {
|
|
27
|
+
err(paint.yellow(" ⚠ force-* ディレクトリ内で実行してください。"));
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
const { items } = deps;
|
|
31
|
+
const prNumber = items.findIndex((i) => i.name === "pr") + 1;
|
|
32
|
+
const prompt = ` 番号を入力 (1-${items.length} / q で終了): `;
|
|
33
|
+
let checkedHead = "";
|
|
34
|
+
let checking = false;
|
|
35
|
+
let checkDone = false;
|
|
36
|
+
const wantCheckFor = (head) => head !== "" && head !== checkedHead;
|
|
37
|
+
const envBranches = () => {
|
|
38
|
+
const text = readOrNull(box, "sf-tools/config/branches.txt") ?? "";
|
|
39
|
+
return text
|
|
40
|
+
.split("\n")
|
|
41
|
+
.map((l) => l.replace(/\r$/, "").trim())
|
|
42
|
+
.filter((l) => l !== "" && !l.startsWith("#"));
|
|
43
|
+
};
|
|
44
|
+
const draw = async () => {
|
|
45
|
+
const st = await box.run("git", ["status", "--porcelain=v2", "--branch"]).catch(() => null);
|
|
46
|
+
const git = parseGitStatus(st !== null && st.code === 0 ? st.stdout : "");
|
|
47
|
+
const { lines, wantCheck } = statusLines({
|
|
48
|
+
git,
|
|
49
|
+
org: targetOrg(readOrNull(box, ".sf/config.json")),
|
|
50
|
+
apexlog: readOrNull(box, "logs/apex/.status"),
|
|
51
|
+
nextStatus: readOrNull(box, "sf-tools/logs/next-status.txt"),
|
|
52
|
+
envBranches: envBranches(),
|
|
53
|
+
checking: checking || (wantCheckFor(git.head) && deps.startPrStatus !== null), // これから始める分も「確かめています」
|
|
54
|
+
prNumber,
|
|
55
|
+
}, paint);
|
|
56
|
+
// 使える結果がない → 裏で判定する(先端のコミットごとに 1 回。失敗しても繰り返さない)
|
|
57
|
+
if (wantCheck && wantCheckFor(git.head) && deps.startPrStatus !== null) {
|
|
58
|
+
checkedHead = git.head;
|
|
59
|
+
checking = true;
|
|
60
|
+
deps
|
|
61
|
+
.startPrStatus()
|
|
62
|
+
.catch(() => undefined)
|
|
63
|
+
.finally(() => {
|
|
64
|
+
checking = false;
|
|
65
|
+
checkDone = true;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
err("");
|
|
69
|
+
err(paint.dim(` ${LINE}`));
|
|
70
|
+
for (const l of lines)
|
|
71
|
+
err(l);
|
|
72
|
+
err(paint.dim(` ${LINE}`));
|
|
73
|
+
items.forEach((item, i) => {
|
|
74
|
+
if (i > 0 && item.group !== items[i - 1]?.group)
|
|
75
|
+
err(paint.dim(" ──────────"));
|
|
76
|
+
err(` ${paint.cyan(`[${i + 1}]`)} ${paint.bold(item.label.padEnd(11))} ${paint.dim(item.description)}`);
|
|
77
|
+
});
|
|
78
|
+
err(paint.dim(` ${LINE}`));
|
|
79
|
+
};
|
|
80
|
+
for (;;) {
|
|
81
|
+
await draw();
|
|
82
|
+
let shown = apexlogState(readOrNull(box, "logs/apex/.status"));
|
|
83
|
+
let pending = box.input.readKey(prompt);
|
|
84
|
+
let chosen = null;
|
|
85
|
+
while (chosen === null) {
|
|
86
|
+
const got = await Promise.race([pending.then((key) => ({ key })), deps.tick().then(() => null)]);
|
|
87
|
+
if (got === null) {
|
|
88
|
+
// 待ち切れ: 準備中・取得中の状態が変わった・裏の判定が終わったら、描き直す(本数・期限の更新では描き直さない)
|
|
89
|
+
const now = apexlogState(readOrNull(box, "logs/apex/.status"));
|
|
90
|
+
const logChanged = (shown === "starting" || shown === "collecting") && now !== shown;
|
|
91
|
+
if (logChanged || checkDone) {
|
|
92
|
+
checkDone = false;
|
|
93
|
+
await draw();
|
|
94
|
+
shown = now;
|
|
95
|
+
err(prompt);
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const { key } = got;
|
|
100
|
+
if (key === null) {
|
|
101
|
+
err("");
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
if (key === "q" || key === "Q") {
|
|
105
|
+
err(paint.dim(" 終了しました"));
|
|
106
|
+
err("");
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
const n = /^[1-9]$/.test(key) ? Number(key) : 0;
|
|
110
|
+
const item = n >= 1 && n <= items.length ? items[n - 1] : undefined;
|
|
111
|
+
if (item)
|
|
112
|
+
chosen = item;
|
|
113
|
+
else
|
|
114
|
+
pending = box.input.readKey(prompt); // 範囲外・ほかのキー・Ctrl+C は聞き直す
|
|
115
|
+
}
|
|
116
|
+
err("");
|
|
117
|
+
err(paint.green(` ▶ sft ${chosen.name}`));
|
|
118
|
+
err("");
|
|
119
|
+
let rc;
|
|
120
|
+
try {
|
|
121
|
+
rc = await chosen.run();
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
err(`[ERROR] ${e instanceof Error ? e.message : String(e)}`);
|
|
125
|
+
rc = 1;
|
|
126
|
+
}
|
|
127
|
+
err("");
|
|
128
|
+
err(rc === 0
|
|
129
|
+
? paint.boldGreen(` ✓ ${chosen.label}: 終わりました(成功)`)
|
|
130
|
+
: paint.boldRed(` ✗ ${chosen.label}: 失敗、または中断しました(終了コード ${rc})`));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const ctrlC = String.fromCharCode(3);
|
|
2
|
+
/** 空でない 1 行を読む(空の Enter は聞き直す)。q だけの行は中断 */
|
|
3
|
+
export async function readOrQuit(input, prompt) {
|
|
4
|
+
for (;;) {
|
|
5
|
+
const line = await input.readLine(prompt);
|
|
6
|
+
if (line === null)
|
|
7
|
+
return { kind: "quit" };
|
|
8
|
+
if (line === ctrlC)
|
|
9
|
+
return { kind: "interrupted" };
|
|
10
|
+
if (line === "")
|
|
11
|
+
continue;
|
|
12
|
+
if (line === "q" || line === "Q")
|
|
13
|
+
return { kind: "quit" };
|
|
14
|
+
return { kind: "text", value: line };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** 表示しない入力(空の Enter は聞き直す)。端末でなければ受け付けない(設計 5.5)。値は、画面にもログにも出さない */
|
|
18
|
+
export async function readSecretValue(input, prompt) {
|
|
19
|
+
for (;;) {
|
|
20
|
+
const value = await input.readSecret(prompt);
|
|
21
|
+
if (value === "no-tty")
|
|
22
|
+
return { kind: "no-tty" };
|
|
23
|
+
if (value === null)
|
|
24
|
+
return { kind: "quit" };
|
|
25
|
+
if (value === ctrlC)
|
|
26
|
+
return { kind: "interrupted" };
|
|
27
|
+
if (value === "")
|
|
28
|
+
continue;
|
|
29
|
+
return { kind: "secret", value };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 番号で選ぶ(1 から)。9 個までは、キー 1 つ(端末では Enter が要らない)。10 個からは、番号を打って Enter。
|
|
34
|
+
* 範囲の外・数字でない入力は、聞き直す
|
|
35
|
+
*/
|
|
36
|
+
export async function chooseNumber(input, output, title, items) {
|
|
37
|
+
output.err(title);
|
|
38
|
+
for (const [i, item] of items.entries())
|
|
39
|
+
output.err(` ${i + 1}) ${item}`);
|
|
40
|
+
const prompt = ` 番号を選んでください(1〜${items.length} / q で中断): `;
|
|
41
|
+
for (;;) {
|
|
42
|
+
const got = items.length <= 9 ? await input.readKey(prompt) : await input.readLine(prompt);
|
|
43
|
+
if (got === null)
|
|
44
|
+
return { kind: "quit" };
|
|
45
|
+
if (got === ctrlC)
|
|
46
|
+
return { kind: "interrupted" };
|
|
47
|
+
const v = got.trim();
|
|
48
|
+
if (v === "q" || v === "Q")
|
|
49
|
+
return { kind: "quit" };
|
|
50
|
+
if (/^[0-9]+$/.test(v)) {
|
|
51
|
+
const n = Number(v);
|
|
52
|
+
if (n >= 1 && n <= items.length)
|
|
53
|
+
return { kind: "chosen", index: n - 1 };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** ログイン先の選択(core/login-url.ts)などに渡す、1 行の入力の組(text: 空は聞き直し・q で "quit" / line: 空も返す) */
|
|
58
|
+
export function loginPrompts(input) {
|
|
59
|
+
return {
|
|
60
|
+
text: async (prompt) => {
|
|
61
|
+
const r = await readOrQuit(input, prompt);
|
|
62
|
+
return r.kind === "text" ? r.value : "quit";
|
|
63
|
+
},
|
|
64
|
+
line: (prompt) => input.readLine(prompt),
|
|
65
|
+
};
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tama-create/sf-tools",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.4.0-dev.2",
|
|
4
|
+
"description": "Salesforce 開発の環境構築と毎日の作業を自動化する(TypeScript 版・開発中)",
|
|
5
|
+
"license": "Unlicense",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/tama-create/sf-tools.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"sft": "bin/sft.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/sft.js",
|
|
16
|
+
"dist/"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=24"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
24
|
+
"lint": "biome check --error-on-warnings",
|
|
25
|
+
"format": "biome check --write",
|
|
26
|
+
"test": "node --test --test-timeout=120000 \"tests/ts/**/*.test.ts\"",
|
|
27
|
+
"check": "npm run typecheck && npm run lint && npm run build && npm run test",
|
|
28
|
+
"prepublishOnly": "npm run check"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@biomejs/biome": "2.6.7",
|
|
32
|
+
"@types/node": "24.19.2",
|
|
33
|
+
"typescript": "7.0.2"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"tag": "next"
|
|
38
|
+
}
|
|
39
|
+
}
|