mimi-seed 0.24.0 → 0.25.1
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.
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// src/setup.ts
|
|
4
4
|
import kleur2 from "kleur";
|
|
5
5
|
import * as readline2 from "readline";
|
|
6
|
-
import
|
|
6
|
+
import os10 from "os";
|
|
7
7
|
|
|
8
8
|
// src/credentials.ts
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import fs5 from "fs";
|
|
10
|
+
import os3 from "os";
|
|
11
|
+
import path5 from "path";
|
|
12
12
|
|
|
13
13
|
// ../core/src/lang.ts
|
|
14
14
|
import fs from "fs";
|
|
@@ -44,43 +44,694 @@ function resolveLang(home = os.homedir()) {
|
|
|
44
44
|
}
|
|
45
45
|
return systemLang();
|
|
46
46
|
}
|
|
47
|
+
function catalog(ko2, en2) {
|
|
48
|
+
return () => resolveLang() === "en" ? en2 : ko2;
|
|
49
|
+
}
|
|
47
50
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
// src/i18n.ts
|
|
52
|
+
var ko = {
|
|
53
|
+
common: {
|
|
54
|
+
yes: "y",
|
|
55
|
+
optional: "\uC120\uD0DD",
|
|
56
|
+
required: "\uD544\uC218",
|
|
57
|
+
skip: "\uAC74\uB108\uB700",
|
|
58
|
+
cancelled: "\uCDE8\uC18C\uB428",
|
|
59
|
+
unknownCommand: (cmd) => `\uC54C \uC218 \uC5C6\uB294 \uBA85\uB839: ${cmd}`,
|
|
60
|
+
error: (msg) => `\uC624\uB958: ${msg}`,
|
|
61
|
+
checkWith: "\uC810\uAC80: mimi-seed doctor"
|
|
62
|
+
},
|
|
63
|
+
lang: {
|
|
64
|
+
ask: " \uC5B8\uC5B4\uB97C \uC120\uD0DD\uD574\uC918 [1] \uD55C\uAD6D\uC5B4 [2] English (\uC5D4\uD130=\uD55C\uAD6D\uC5B4): ",
|
|
65
|
+
saved: (l) => ` \u2705 \uC5B8\uC5B4: ${l === "ko" ? "\uD55C\uAD6D\uC5B4" : "English"} (\uB098\uC911\uC5D0 \uBC14\uAFB8\uAE30: mimi-seed lang en)`,
|
|
66
|
+
usage: `${"mimi-seed lang"} \u2014 CLI \uCD9C\uB825 \uC5B8\uC5B4
|
|
67
|
+
|
|
68
|
+
mimi-seed lang \uD604\uC7AC \uC5B8\uC5B4 \uD45C\uC2DC
|
|
69
|
+
mimi-seed lang ko \uD55C\uAD6D\uC5B4
|
|
70
|
+
mimi-seed lang en English
|
|
71
|
+
|
|
72
|
+
\uD658\uACBD\uBCC0\uC218 MIMI_SEED_LANG \uAC00 \uC788\uC73C\uBA74 \uADF8\uAC8C \uC6B0\uC120\uD569\uB2C8\uB2E4.`,
|
|
73
|
+
current: (l) => `\uD604\uC7AC \uC5B8\uC5B4: ${l === "ko" ? "\uD55C\uAD6D\uC5B4 (ko)" : "English (en)"}`,
|
|
74
|
+
invalid: (v) => `\uC54C \uC218 \uC5C6\uB294 \uC5B8\uC5B4: ${v} (ko \uB610\uB294 en)`
|
|
75
|
+
},
|
|
76
|
+
setup: {
|
|
77
|
+
title: "mimi-seed setup",
|
|
78
|
+
platformsDetected: (p) => ` \uAC10\uC9C0\uB41C \uD50C\uB7AB\uD3FC: ${p}`,
|
|
79
|
+
statusTitle: "\uC5F0\uACB0 \uC0C1\uD0DC",
|
|
80
|
+
statusDir: "(~/.mimi-seed)",
|
|
81
|
+
groupCore: "\uD575\uC2EC",
|
|
82
|
+
groupCi: "\uBE4C\uB4DC / CI",
|
|
83
|
+
groupMarketing: "\uB9C8\uCF00\uD305 \xB7 AI",
|
|
84
|
+
fallbackWorking: "\uD3F4\uBC31\uC73C\uB85C \uB3D9\uC791 \uC911",
|
|
85
|
+
missingRequired: " \uD544\uC218 \uD56D\uBAA9 \uB204\uB77D:",
|
|
86
|
+
cannotInteract: " \u2717 \uC774 \uC790\uACA9\uC99D\uBA85\uC740 \uB300\uD654\uD615 \uC785\uB825\uC774 \uD544\uC694\uD574\uC11C \uC5EC\uAE30\uC11C\uB294 \uC124\uC815\uD560 \uC218 \uC5C6\uC5B4:",
|
|
87
|
+
cannotInteractHint: " \uD130\uBBF8\uB110\uC5D0\uC11C \uC2E4\uD589\uD574\uC918 (Git Bash \uB4F1 TTY \uBBF8\uAC10\uC9C0 \uD658\uACBD\uC774\uBA74 --interactive).",
|
|
88
|
+
runInTerminal: " \uB300\uD654\uD615\uC73C\uB85C \uC5F0\uACB0\uD558\uB824\uBA74 \uD130\uBBF8\uB110\uC5D0\uC11C: mimi-seed setup (Git Bash/mintty \uB294 TTY \uBBF8\uAC10\uC9C0 \u2014 --interactive \uB97C \uBD99\uC774\uAC70\uB098 PowerShell \uC5D0\uC11C)",
|
|
89
|
+
onlyAlreadyDone: " \u2705 \uC694\uCCAD\uD55C \uD56D\uBAA9\uC740 \uC774\uBBF8 \uC5F0\uACB0\uB3FC \uC788\uC5B4.",
|
|
90
|
+
onlyReconnectHint: " \uB2E4\uC2DC \uC124\uC815\uD558\uB824\uBA74: mimi-seed setup --reconnect <id>",
|
|
91
|
+
tokenExpired: "\uD1A0\uD070 \uB9CC\uB8CC \u2014 \uB2E4\uC2DC \uC5F0\uACB0 \uD544\uC694",
|
|
92
|
+
tokenExpiring: (days) => `\uD1A0\uD070 ${days}\uC77C \uD6C4 \uB9CC\uB8CC \u2014 \uC9C0\uAE08 \uAC31\uC2E0 \uAD8C\uC7A5`,
|
|
93
|
+
allDone: " \u2705 \uC5F0\uACB0\uD560 \uAC8C \uB354 \uC5C6\uC5B4. \uB2E4 \uB410\uB2E4.",
|
|
94
|
+
planCount: (n) => ` ${n}\uAC1C \uD56D\uBAA9\uC744 \uC21C\uC11C\uB300\uB85C \uBB3C\uC5B4\uBCFC\uAC8C. \uC5B8\uC81C\uB4E0 s=\uAC74\uB108\uB6F0\uAE30, q=\uC885\uB8CC.`,
|
|
95
|
+
prompt: " [c] \uC5F0\uACB0 [s] \uAC74\uB108\uB6F0\uAE30 [?] \uC774\uAC74 \uC5B4\uB5BB\uAC8C \uAD6C\uD558\uB098\uC694 [q] \uC885\uB8CC : ",
|
|
96
|
+
promptInvalid: " c / s / ? / q \uC911\uC5D0\uC11C \uACE8\uB77C\uC918.",
|
|
97
|
+
quit: " \uC911\uB2E8\uD588\uC5B4. \uC774\uC5B4\uC11C \uD558\uB824\uBA74 \uB2E4\uC2DC: mimi-seed setup",
|
|
98
|
+
skipped: (fix) => ` \uAC74\uB108\uB700. \uB098\uC911\uC5D0: ${fix}`,
|
|
99
|
+
obtainTitle: (label) => ` ${label} \u2014 \uBBF8\uB9AC \uC900\uBE44\uD560 \uAC83`,
|
|
100
|
+
obtainMore: (anchor) => ` \uC790\uC138\uD788: docs/credentials.md#${anchor}`,
|
|
101
|
+
neededFor: (platform) => `(${platform} \uBC30\uD3EC\uC5D0 \uD544\uC694)`,
|
|
102
|
+
binFailed: (label, code, fix) => ` \u26A0 ${label} \uC124\uC815\uC774 \uC644\uB8CC\uB418\uC9C0 \uC54A\uC558\uC5B4 (exit ${code}). \uB098\uC911\uC5D0 \uB2E4\uC2DC: ${fix}`,
|
|
103
|
+
verifying: " \u{1F50E} \uD1A0\uD070 \uAC80\uC99D \uC911...",
|
|
104
|
+
verifyFailed: (reason) => ` \u274C \uD1A0\uD070 \uAC80\uC99D \uC2E4\uD328: ${reason}`,
|
|
105
|
+
notSaved: (fix) => ` \uC800\uC7A5\uD558\uC9C0 \uC54A\uC558\uC5B4. \uB2E4\uC2DC: ${fix}`,
|
|
106
|
+
ciSaved: (label, who) => ` \u2705 ${label} \uC5F0\uACB0\uB428${who} \u2192 ~/.mimi-seed/ci.json`,
|
|
107
|
+
runSeparately: (cmd) => ` \uC774\uAC74 \uBCC4\uB3C4 \uBA85\uB839\uC73C\uB85C \uC2E4\uD589\uD574\uC918: ${cmd}`,
|
|
108
|
+
envVar: " \uD658\uACBD\uBCC0\uC218\uB85C \uC124\uC815\uD558\uB294 \uD56D\uBAA9\uC774\uC57C:",
|
|
109
|
+
pressEnter: " (\uC5D4\uD130\uB97C \uB204\uB974\uBA74 \uACC4\uC18D) ",
|
|
110
|
+
stillMissing: " \uC544\uC9C1 \uD544\uC218 \uD56D\uBAA9\uC774 \uB0A8\uC544 \uC788\uC5B4:",
|
|
111
|
+
requiredDone: " \u2705 \uD544\uC218 \uC5F0\uACB0 \uC644\uB8CC.",
|
|
112
|
+
nextSteps: " \uC810\uAC80: mimi-seed doctor \xB7 \uBC30\uD3EC: mimi-seed deploy",
|
|
113
|
+
tryPrompt: ' \uCCAB \uD504\uB86C\uD504\uD2B8 \u2014 Claude Code / Codex \uC0C8 \uC138\uC158\uC5D0\uC11C: "\uB0B4 \uC571 \uCD9C\uC2DC \uC900\uBE44\uB410\uC5B4?"'
|
|
114
|
+
},
|
|
115
|
+
doctor: {
|
|
116
|
+
title: "mimi-seed doctor",
|
|
117
|
+
secAuth: "\uC778\uC99D",
|
|
118
|
+
secCreds: "\uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 (~/.mimi-seed)",
|
|
119
|
+
secEnv: "\uB85C\uCEEC \uD658\uACBD",
|
|
120
|
+
secApps: "\uC571 \uAC10\uC9C0",
|
|
121
|
+
noToken: "Mimi Seed \uD1A0\uD070 \uC5C6\uC74C",
|
|
122
|
+
noTokenFix: "`mimi-seed init` \uC2E4\uD589 \uD544\uC694",
|
|
123
|
+
noTokenLocal: "Mimi Seed \uD074\uB77C\uC6B0\uB4DC \uACC4\uC815 \uBBF8\uC5F0\uACB0",
|
|
124
|
+
noTokenLocalDetail: "\uC6F9 \uCF58\uC194\xB7\uC6D0\uACA9 MCP(init \xB7 status \xB7 deploy)\uB97C \uC4F8 \uB54C\uB9CC \uD544\uC694 \u2014 \uB85C\uCEEC MCP \uB3C4\uAD6C\uB294 \uC4F0\uC9C0 \uC54A\uC74C",
|
|
125
|
+
tokenSaved: "\uD1A0\uD070 \uC800\uC7A5\uB428",
|
|
126
|
+
endpoint: "\uC5D4\uB4DC\uD3EC\uC778\uD2B8",
|
|
127
|
+
ciMode: "CI \uBAA8\uB4DC",
|
|
128
|
+
ciModeDetail: "MIMI_SEED_TOKEN \uD658\uACBD\uBCC0\uC218 \uC0AC\uC6A9 \uC911",
|
|
129
|
+
tokenInvalid: "\uD1A0\uD070 \uAC80\uC99D \uC2E4\uD328",
|
|
130
|
+
serverUnreachable: "Mimi Seed \uC11C\uBC84\uC5D0 \uC5F0\uACB0\uD560 \uC218 \uC5C6\uC74C",
|
|
131
|
+
serverOk: "Mimi Seed \uC11C\uBC84 \uC5F0\uACB0\uB428",
|
|
132
|
+
appCount: (n) => `\uC571 ${n}\uAC1C`,
|
|
133
|
+
unknownService: (id) => `${id} (\uC54C \uC218 \uC5C6\uB294 \uC11C\uBE44\uC2A4)`,
|
|
134
|
+
credentialMismatch: (field, expected, actual) => `${field} \uBD88\uC77C\uCE58 \u2014 \uC694\uAD6C\uAC12 ${expected}, \uD604\uC7AC\uAC12 ${actual ?? "\uC5C6\uC74C"}`,
|
|
135
|
+
credsHint: " \uC804\uBD80 \uC5F0\uACB0\uD558\uAE30: mimi-seed setup \xB7 OAuth \uC2E0\uC120\uB3C4: mimi-seed auth status\n",
|
|
136
|
+
nodeTooOld: (v) => `${v} \u2014 v22 \uC774\uC0C1 \uD544\uC694 (.nvmrc \uCC38\uACE0)`,
|
|
137
|
+
gitRepo: "Git \uC800\uC7A5\uC18C",
|
|
138
|
+
gitTag: (t2) => `\uCD5C\uC2E0 \uD0DC\uADF8: ${t2}`,
|
|
139
|
+
gitCommits: (n) => `\uCEE4\uBC0B ${n}\uAC1C`,
|
|
140
|
+
noGit: "Git \uC800\uC7A5\uC18C \uC5C6\uC74C",
|
|
141
|
+
noGitDetail: "mimi-seed notes \uC0AC\uC6A9 \uBD88\uAC00",
|
|
142
|
+
noApp: "\uC571 \uAC10\uC9C0 \uC5C6\uC74C",
|
|
143
|
+
noAppDetail: "Expo / Gradle / Xcode / Unity \uC571 \uC124\uC815 \uC5C6\uC74C",
|
|
144
|
+
unnamed: "(\uC774\uB984 \uBBF8\uC0C1)",
|
|
145
|
+
requirements: (proj) => `${proj} \uC694\uAD6C\uC0AC\uD56D (.mimi-seed.json)`,
|
|
146
|
+
thisProject: "\uC774 \uD504\uB85C\uC81D\uD2B8",
|
|
147
|
+
manifestInvalid: "\uD504\uB85C\uC81D\uD2B8 \uC694\uAD6C\uC0AC\uD56D (.mimi-seed.json)",
|
|
148
|
+
manifestInvalidDetail: (file, reason) => `${file} \uC744(\uB97C) \uC77D\uC744 \uC218 \uC5C6\uC5B4 \uC694\uAD6C\uC0AC\uD56D\uC744 \uC810\uAC80\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (${reason}) \u2014 \uD30C\uC77C\uC744 \uACE0\uCE5C \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694`,
|
|
149
|
+
manifestReason: { unreadable: "\uC77D\uAE30 \uC2E4\uD328", "invalid-json": "JSON \uD615\uC2DD \uC624\uB958", "not-an-object": "\uAC1D\uCCB4\uAC00 \uC544\uB2D8" },
|
|
150
|
+
credCorrupt: (file, reason, fix) => `\uD30C\uC77C\uC774 \uC190\uC0C1\uB428: ${file} \u2014 ${reason}. \uACE0\uCE58\uAC70\uB098 \uC9C0\uC6B4 \uB4A4 \uB2E4\uC2DC \uC5F0\uACB0: ${fix}`,
|
|
151
|
+
credLocked: (file, reason, fix) => `\uC554\uD638\uD654\uB41C \uD30C\uC77C\uC744 \uC5F4 \uC218 \uC5C6\uC74C: ${file} \u2014 ${reason}. \uB2E4\uC2DC \uC5F0\uACB0: ${fix}`,
|
|
152
|
+
storeLabel: "\uC790\uACA9\uC99D\uBA85 \uC800\uC7A5",
|
|
153
|
+
storePlain: "\uD3C9\uBB38 0600 \u2014 \uC554\uD638\uD654\uD558\uB824\uBA74: mimi-seed credentials mode keychain",
|
|
154
|
+
storeEncrypted: (n) => `\uC554\uD638\uD654 (${n}\uAC1C \uD30C\uC77C)`,
|
|
155
|
+
storePlainLeft: (n) => `\uC554\uD638\uD654 \uBAA8\uB4DC\uC778\uB370 \uD3C9\uBB38 \uD30C\uC77C ${n}\uAC1C\uAC00 \uB0A8\uC74C \u2192 mimi-seed credentials encrypt`
|
|
156
|
+
},
|
|
157
|
+
auth: {
|
|
158
|
+
title: "mimi-seed auth \u2014 \uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 \uC778\uC99D/\uAD00\uB9AC",
|
|
159
|
+
statusTitle: "\uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 \uC0C1\uD0DC",
|
|
160
|
+
connectAll: "\n \uD55C \uBC88\uC5D0 \uC5F0\uACB0: mimi-seed setup",
|
|
161
|
+
unknownSub: (sub) => `\uC54C \uC218 \uC5C6\uB294 auth \uC11C\uBE0C\uBA85\uB839: ${sub}`,
|
|
162
|
+
npxFailed: (cmd, msg) => `
|
|
163
|
+
\u274C ${cmd} \uC2E4\uD589 \uC2E4\uD328: ${msg}
|
|
164
|
+
`
|
|
65
165
|
}
|
|
66
|
-
|
|
166
|
+
};
|
|
167
|
+
var en = {
|
|
168
|
+
common: {
|
|
169
|
+
yes: "y",
|
|
170
|
+
optional: "optional",
|
|
171
|
+
required: "required",
|
|
172
|
+
skip: "skipped",
|
|
173
|
+
cancelled: "Cancelled",
|
|
174
|
+
unknownCommand: (cmd) => `Unknown command: ${cmd}`,
|
|
175
|
+
error: (msg) => `Error: ${msg}`,
|
|
176
|
+
checkWith: "Check with: mimi-seed doctor"
|
|
177
|
+
},
|
|
178
|
+
lang: {
|
|
179
|
+
ask: " Choose a language [1] \uD55C\uAD6D\uC5B4 [2] English (Enter = English): ",
|
|
180
|
+
saved: (l) => ` \u2705 Language: ${l === "ko" ? "\uD55C\uAD6D\uC5B4" : "English"} (change later: mimi-seed lang ko)`,
|
|
181
|
+
usage: `mimi-seed lang \u2014 CLI output language
|
|
182
|
+
|
|
183
|
+
mimi-seed lang show current language
|
|
184
|
+
mimi-seed lang ko \uD55C\uAD6D\uC5B4
|
|
185
|
+
mimi-seed lang en English
|
|
186
|
+
|
|
187
|
+
MIMI_SEED_LANG takes precedence when set.`,
|
|
188
|
+
current: (l) => `Current language: ${l === "ko" ? "\uD55C\uAD6D\uC5B4 (ko)" : "English (en)"}`,
|
|
189
|
+
invalid: (v) => `Unknown language: ${v} (use ko or en)`
|
|
190
|
+
},
|
|
191
|
+
setup: {
|
|
192
|
+
title: "mimi-seed setup",
|
|
193
|
+
platformsDetected: (p) => ` Detected platforms: ${p}`,
|
|
194
|
+
statusTitle: "Connection status",
|
|
195
|
+
statusDir: "(~/.mimi-seed)",
|
|
196
|
+
groupCore: "Core",
|
|
197
|
+
groupCi: "Build / CI",
|
|
198
|
+
groupMarketing: "Marketing \xB7 AI",
|
|
199
|
+
fallbackWorking: "working via fallback",
|
|
200
|
+
missingRequired: " Missing required:",
|
|
201
|
+
cannotInteract: " \u2717 These need interactive input and cannot be set up here:",
|
|
202
|
+
cannotInteractHint: " Run it in a terminal (add --interactive if your shell hides the TTY, e.g. Git Bash).",
|
|
203
|
+
runInTerminal: " To connect interactively, run: mimi-seed setup (Git Bash/mintty hide the TTY \u2014 add --interactive, or use PowerShell)",
|
|
204
|
+
onlyAlreadyDone: " \u2705 What you asked for is already connected.",
|
|
205
|
+
onlyReconnectHint: " To redo it: mimi-seed setup --reconnect <id>",
|
|
206
|
+
tokenExpired: "token expired \u2014 reconnect required",
|
|
207
|
+
tokenExpiring: (days) => `token expires in ${days} day(s) \u2014 refresh now`,
|
|
208
|
+
allDone: " \u2705 Nothing left to connect. You're set.",
|
|
209
|
+
planCount: (n) => ` I'll walk you through ${n} item(s). s = skip, q = quit, anytime.`,
|
|
210
|
+
prompt: " [c] connect [s] skip [?] how do I get this [q] quit : ",
|
|
211
|
+
promptInvalid: " Please choose c / s / ? / q.",
|
|
212
|
+
quit: " Stopped. To pick up where you left off: mimi-seed setup",
|
|
213
|
+
skipped: (fix) => ` Skipped. Later: ${fix}`,
|
|
214
|
+
obtainTitle: (label) => ` ${label} \u2014 what to get first`,
|
|
215
|
+
obtainMore: (anchor) => ` Details: docs/credentials.md#${anchor}`,
|
|
216
|
+
neededFor: (platform) => `(needed to ship to ${platform})`,
|
|
217
|
+
binFailed: (label, code, fix) => ` \u26A0 ${label} was not completed (exit ${code}). Try again later: ${fix}`,
|
|
218
|
+
verifying: " \u{1F50E} Verifying token...",
|
|
219
|
+
verifyFailed: (reason) => ` \u274C Token verification failed: ${reason}`,
|
|
220
|
+
notSaved: (fix) => ` Nothing was saved. Retry: ${fix}`,
|
|
221
|
+
ciSaved: (label, who) => ` \u2705 ${label} connected${who} \u2192 ~/.mimi-seed/ci.json`,
|
|
222
|
+
runSeparately: (cmd) => ` Run this one separately: ${cmd}`,
|
|
223
|
+
envVar: " This one is set through an environment variable:",
|
|
224
|
+
pressEnter: " (press Enter to continue) ",
|
|
225
|
+
stillMissing: " Still missing, and required:",
|
|
226
|
+
requiredDone: " \u2705 All required credentials connected.",
|
|
227
|
+
nextSteps: " Check: mimi-seed doctor \xB7 Ship: mimi-seed deploy",
|
|
228
|
+
tryPrompt: ' First prompt \u2014 in a new Claude Code / Codex session: "Is my app ready to ship?"'
|
|
229
|
+
},
|
|
230
|
+
doctor: {
|
|
231
|
+
title: "mimi-seed doctor",
|
|
232
|
+
secAuth: "Account",
|
|
233
|
+
secCreds: "Local credentials (~/.mimi-seed)",
|
|
234
|
+
secEnv: "Environment",
|
|
235
|
+
secApps: "App detection",
|
|
236
|
+
noToken: "No Mimi Seed token",
|
|
237
|
+
noTokenFix: "run `mimi-seed init`",
|
|
238
|
+
noTokenLocal: "Mimi Seed cloud account not connected",
|
|
239
|
+
noTokenLocalDetail: "only needed for the web console / remote MCP (init \xB7 status \xB7 deploy) \u2014 local MCP tools do not use it",
|
|
240
|
+
tokenSaved: "Token stored",
|
|
241
|
+
endpoint: "Endpoint",
|
|
242
|
+
ciMode: "CI mode",
|
|
243
|
+
ciModeDetail: "using MIMI_SEED_TOKEN",
|
|
244
|
+
tokenInvalid: "Token rejected",
|
|
245
|
+
serverUnreachable: "Cannot reach the Mimi Seed server",
|
|
246
|
+
serverOk: "Connected to Mimi Seed",
|
|
247
|
+
appCount: (n) => `${n} app(s)`,
|
|
248
|
+
unknownService: (id) => `${id} (unknown service)`,
|
|
249
|
+
credentialMismatch: (field, expected, actual) => `${field} mismatch \u2014 expected ${expected}, current ${actual ?? "missing"}`,
|
|
250
|
+
credsHint: " Connect everything: mimi-seed setup \xB7 OAuth freshness: mimi-seed auth status\n",
|
|
251
|
+
nodeTooOld: (v) => `${v} \u2014 v22+ required (see .nvmrc)`,
|
|
252
|
+
gitRepo: "Git repository",
|
|
253
|
+
gitTag: (t2) => `latest tag: ${t2}`,
|
|
254
|
+
gitCommits: (n) => `${n} commit(s)`,
|
|
255
|
+
noGit: "Not a git repository",
|
|
256
|
+
noGitDetail: "mimi-seed notes is unavailable",
|
|
257
|
+
noApp: "No app detected",
|
|
258
|
+
noAppDetail: "no Expo / Gradle / Xcode / Unity app configuration",
|
|
259
|
+
unnamed: "(unnamed)",
|
|
260
|
+
requirements: (proj) => `${proj} requirements (.mimi-seed.json)`,
|
|
261
|
+
thisProject: "This project",
|
|
262
|
+
manifestInvalid: "Project requirements (.mimi-seed.json)",
|
|
263
|
+
manifestInvalidDetail: (file, reason) => `cannot read ${file}, so its requirements were not checked (${reason}) \u2014 fix the file and run again`,
|
|
264
|
+
manifestReason: { unreadable: "unreadable", "invalid-json": "invalid JSON", "not-an-object": "not an object" },
|
|
265
|
+
credCorrupt: (file, reason, fix) => `file is damaged: ${file} \u2014 ${reason}. Fix or delete it, then reconnect: ${fix}`,
|
|
266
|
+
credLocked: (file, reason, fix) => `cannot open encrypted file: ${file} \u2014 ${reason}. Reconnect: ${fix}`,
|
|
267
|
+
storeLabel: "Credential storage",
|
|
268
|
+
storePlain: "plaintext 0600 \u2014 to encrypt: mimi-seed credentials mode keychain",
|
|
269
|
+
storeEncrypted: (n) => `encrypted (${n} file(s))`,
|
|
270
|
+
storePlainLeft: (n) => `encrypting mode, but ${n} plaintext file(s) remain \u2192 mimi-seed credentials encrypt`
|
|
271
|
+
},
|
|
272
|
+
auth: {
|
|
273
|
+
title: "mimi-seed auth \u2014 local credential setup",
|
|
274
|
+
statusTitle: "Local credential status",
|
|
275
|
+
connectAll: "\n Connect everything at once: mimi-seed setup",
|
|
276
|
+
unknownSub: (sub) => `Unknown auth subcommand: ${sub}`,
|
|
277
|
+
npxFailed: (cmd, msg) => `
|
|
278
|
+
\u274C Failed to run ${cmd}: ${msg}
|
|
279
|
+
`
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var CATALOGS = { ko, en };
|
|
283
|
+
function t() {
|
|
284
|
+
return CATALOGS[resolveLang()];
|
|
67
285
|
}
|
|
68
|
-
|
|
286
|
+
|
|
287
|
+
// ../core/src/credential-read.ts
|
|
288
|
+
import fs3 from "fs";
|
|
289
|
+
import path3 from "path";
|
|
290
|
+
|
|
291
|
+
// ../core/src/credential-envelope.ts
|
|
292
|
+
import { createCipheriv, createDecipheriv, createHash, randomBytes } from "crypto";
|
|
293
|
+
var ENVELOPE_VERSION = 1;
|
|
294
|
+
var ENVELOPE_ALG = "A256GCM";
|
|
295
|
+
var DATA_KEY_BYTES = 32;
|
|
296
|
+
function keyId(key) {
|
|
297
|
+
return createHash("sha256").update(key).digest().subarray(0, 8).toString("hex");
|
|
298
|
+
}
|
|
299
|
+
function looksLikeEnvelope(value) {
|
|
300
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.hasOwnProperty.call(value, "mimiSeedEncrypted");
|
|
301
|
+
}
|
|
302
|
+
function parseEnvelope(value) {
|
|
303
|
+
if (value.mimiSeedEncrypted !== ENVELOPE_VERSION || value.alg !== ENVELOPE_ALG) return "unsupported";
|
|
304
|
+
const { kid, iv, tag, data } = value;
|
|
305
|
+
if (typeof kid !== "string" || !/^[0-9a-f]{16}$/.test(kid)) return "malformed";
|
|
306
|
+
if (typeof iv !== "string" || Buffer.from(iv, "base64").length !== 12) return "malformed";
|
|
307
|
+
if (typeof tag !== "string" || Buffer.from(tag, "base64").length !== 16) return "malformed";
|
|
308
|
+
if (typeof data !== "string") return "malformed";
|
|
309
|
+
return { mimiSeedEncrypted: ENVELOPE_VERSION, alg: ENVELOPE_ALG, kid, iv, tag, data };
|
|
310
|
+
}
|
|
311
|
+
function sealCredential(plaintext, key, aad) {
|
|
312
|
+
if (key.length !== DATA_KEY_BYTES) throw new Error(`data key must be ${DATA_KEY_BYTES} bytes`);
|
|
313
|
+
const iv = randomBytes(12);
|
|
314
|
+
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
315
|
+
cipher.setAAD(Buffer.from(aad, "utf8"));
|
|
316
|
+
const data = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
317
|
+
return {
|
|
318
|
+
mimiSeedEncrypted: ENVELOPE_VERSION,
|
|
319
|
+
alg: ENVELOPE_ALG,
|
|
320
|
+
kid: keyId(key),
|
|
321
|
+
iv: iv.toString("base64"),
|
|
322
|
+
tag: cipher.getAuthTag().toString("base64"),
|
|
323
|
+
data: data.toString("base64")
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function openCredential(envelope, key, aad) {
|
|
69
327
|
try {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
328
|
+
const decipher = createDecipheriv("aes-256-gcm", key, Buffer.from(envelope.iv, "base64"));
|
|
329
|
+
decipher.setAAD(Buffer.from(aad, "utf8"));
|
|
330
|
+
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
331
|
+
return Buffer.concat([decipher.update(Buffer.from(envelope.data, "base64")), decipher.final()]).toString("utf8");
|
|
74
332
|
} catch {
|
|
75
333
|
return null;
|
|
76
334
|
}
|
|
77
335
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
336
|
+
|
|
337
|
+
// ../core/src/credential-keystore.ts
|
|
338
|
+
import { spawnSync } from "child_process";
|
|
339
|
+
import fs2 from "fs";
|
|
340
|
+
import os2 from "os";
|
|
341
|
+
import path2 from "path";
|
|
342
|
+
import { randomBytes as randomBytes2, randomUUID } from "crypto";
|
|
343
|
+
var KEYCHAIN_SERVICE = "mimi-seed";
|
|
344
|
+
var KEYCHAIN_ACCOUNT = "data-key";
|
|
345
|
+
var DPAPI_KEY_FILE = ".data-key.dpapi";
|
|
346
|
+
var R = catalog(
|
|
347
|
+
{
|
|
348
|
+
exit: (cmd, status) => `${cmd} \uC885\uB8CC \uCF54\uB4DC ${status}`,
|
|
349
|
+
missingTool: (cmd) => `${cmd} \uBA85\uB839\uC774 \uC5C6\uC74C`,
|
|
350
|
+
timeout: (cmd) => `${cmd} \uC751\uB2F5 \uC5C6\uC74C(\uC2DC\uAC04 \uCD08\uACFC)`,
|
|
351
|
+
badKey: "\uC800\uC7A5\uB41C \uD0A4\uC758 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC74C",
|
|
352
|
+
noBackend: (platform) => `\uC774 OS(${platform})\uC5D0\uB294 \uC9C0\uC6D0\uD558\uB294 \uD0A4 \uC800\uC7A5\uC18C\uAC00 \uC5C6\uC74C`,
|
|
353
|
+
lockedRemote: (keychain) => `\uB85C\uADF8\uC778 \uD0A4\uCCB4\uC778\uC774 \uC7A0\uACA8 \uC788\uC74C \u2014 SSH\xB7\uC6D0\uACA9 \uC138\uC158(VS Code Remote-SSH \uD3EC\uD568)\uC5D0\uC11C\uB294 \uD654\uBA74 \uC138\uC158\uACFC \uB530\uB85C \uC7A0\uAE30\uACE0 \uD655\uC778 \uCC3D\uB3C4 \uB728\uC9C0 \uC54A\uB294\uB2E4. \`security unlock-keychain ${keychain}\` \uB85C \uC774 \uC138\uC158\uC5D0\uC11C \uD480\uAC70\uB098, \uC8FC\uB85C \uC6D0\uACA9\uC73C\uB85C \uC4F0\uB294 \uCEF4\uD4E8\uD130\uB77C\uBA74 \`mimi-seed credentials mode file\``,
|
|
354
|
+
lockedLocal: "\uB85C\uADF8\uC778 \uD0A4\uCCB4\uC778\uC774 \uC7A0\uACA8 \uC788\uC74C \u2014 \uD0A4\uCCB4\uC778 \uC811\uADFC(Keychain Access)\uC5D0\uC11C \uC7A0\uAE08\uC744 \uD574\uC81C\uD558\uC138\uC694",
|
|
355
|
+
wrongPassword: "\uB85C\uADF8\uC778 \uD0A4\uCCB4\uC778 \uBE44\uBC00\uBC88\uD638\uAC00 \uB9DE\uC9C0 \uC54A\uC74C(\uB85C\uADF8\uC778 \uBE44\uBC00\uBC88\uD638\uC640 \uC5B4\uAE0B\uB0AC\uC744 \uC218 \uC788\uC74C)",
|
|
356
|
+
noKeychain: "\uAE30\uBCF8 \uD0A4\uCCB4\uC778\uC774 \uC5C6\uAC70\uB098 \uCC3E\uC744 \uC218 \uC5C6\uC74C",
|
|
357
|
+
cancelled: "\uD0A4\uCCB4\uC778 \uD655\uC778 \uCC3D\uC5D0\uC11C \uCDE8\uC18C\uB428",
|
|
358
|
+
waiting: "\uD0A4\uCCB4\uC778 \uD655\uC778 \uCC3D\uC774 \uC751\uB2F5\uC744 \uAE30\uB2E4\uB9AC\uB2E4 \uC2DC\uAC04\uC774 \uCD08\uACFC\uB428"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
exit: (cmd, status) => `${cmd} exited with status ${status}`,
|
|
362
|
+
missingTool: (cmd) => `${cmd} is not installed`,
|
|
363
|
+
timeout: (cmd) => `${cmd} did not respond (timed out)`,
|
|
364
|
+
badKey: "the stored key is not in the expected format",
|
|
365
|
+
noBackend: (platform) => `no supported key store on this OS (${platform})`,
|
|
366
|
+
lockedRemote: (keychain) => `the login keychain is locked \u2014 an SSH or remote session (including VS Code Remote-SSH) has its own lock and cannot show the unlock dialog. Run \`security unlock-keychain ${keychain}\` to unlock it for this session, or use \`mimi-seed credentials mode file\` on a machine you mostly use remotely`,
|
|
367
|
+
lockedLocal: "the login keychain is locked \u2014 unlock it in Keychain Access",
|
|
368
|
+
wrongPassword: "the login keychain password is wrong (it may be out of sync with the login password)",
|
|
369
|
+
noKeychain: "there is no default keychain, or it cannot be found",
|
|
370
|
+
cancelled: "the keychain dialog was cancelled",
|
|
371
|
+
waiting: "timed out waiting for the keychain dialog"
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
var SPAWN_TIMEOUT_MS = 2e4;
|
|
375
|
+
function run(cmd, args, input) {
|
|
376
|
+
return spawnSync(cmd, args, {
|
|
377
|
+
input,
|
|
378
|
+
encoding: "utf8",
|
|
379
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
380
|
+
timeout: SPAWN_TIMEOUT_MS,
|
|
381
|
+
windowsHide: true
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function spawnProblem(cmd, result) {
|
|
385
|
+
const error = result.error;
|
|
386
|
+
if (!error) return null;
|
|
387
|
+
if (error.code === "ENOENT") return R().missingTool(cmd);
|
|
388
|
+
if (error.code === "ETIMEDOUT") return R().timeout(cmd);
|
|
389
|
+
return R().exit(cmd, error.code ?? "spawn");
|
|
390
|
+
}
|
|
391
|
+
function decodeKey(text, backend) {
|
|
392
|
+
const key = Buffer.from(text.trim(), "base64");
|
|
393
|
+
return key.length === DATA_KEY_BYTES ? { state: "ok", key, backend } : { state: "unavailable", backend, reason: R().badKey };
|
|
394
|
+
}
|
|
395
|
+
function errorCode(result) {
|
|
396
|
+
const error = result.error;
|
|
397
|
+
return error?.code;
|
|
398
|
+
}
|
|
399
|
+
function macosLoginKeychain(home = os2.homedir()) {
|
|
400
|
+
return path2.join(home, "Library", "Keychains", "login.keychain-db");
|
|
401
|
+
}
|
|
402
|
+
function isRemoteSession() {
|
|
403
|
+
if (process.env.SSH_CONNECTION || process.env.SSH_TTY || process.env.SSH_CLIENT) return true;
|
|
404
|
+
const manager = run("/bin/launchctl", ["managername"]);
|
|
405
|
+
return manager.status === 0 && manager.stdout.trim() !== "Aqua";
|
|
406
|
+
}
|
|
407
|
+
function macosFailure(status, keychain) {
|
|
408
|
+
const backend = "macOS Keychain";
|
|
409
|
+
switch (status) {
|
|
410
|
+
case 36:
|
|
411
|
+
return { state: "unavailable", backend, locked: true, reason: isRemoteSession() ? R().lockedRemote(keychain) : R().lockedLocal };
|
|
412
|
+
case 51:
|
|
413
|
+
return { state: "unavailable", backend, reason: R().wrongPassword };
|
|
414
|
+
case 37:
|
|
415
|
+
case 50:
|
|
416
|
+
return { state: "unavailable", backend, reason: R().noKeychain };
|
|
417
|
+
case 128:
|
|
418
|
+
return { state: "unavailable", backend, reason: R().cancelled };
|
|
419
|
+
default:
|
|
420
|
+
return { state: "unavailable", backend, reason: R().exit("security", String(status)) };
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function macosLookup(home = os2.homedir()) {
|
|
424
|
+
const backend = "macOS Keychain";
|
|
425
|
+
const keychain = macosLoginKeychain(home);
|
|
426
|
+
const result = run("/usr/bin/security", ["find-generic-password", "-s", KEYCHAIN_SERVICE, "-a", KEYCHAIN_ACCOUNT, "-w", keychain]);
|
|
427
|
+
const problem = spawnProblem("security", result);
|
|
428
|
+
if (problem) return { state: "unavailable", backend, reason: errorCode(result) === "ETIMEDOUT" ? R().waiting : problem };
|
|
429
|
+
if (result.status === 44) return { state: "absent", backend };
|
|
430
|
+
if (result.status !== 0) return macosFailure(result.status, keychain);
|
|
431
|
+
return decodeKey(result.stdout, backend);
|
|
432
|
+
}
|
|
433
|
+
var DPAPI_UNPROTECT = [
|
|
434
|
+
"Add-Type -AssemblyName System.Security",
|
|
435
|
+
"$in = [Console]::In.ReadToEnd().Trim()",
|
|
436
|
+
"$out = [System.Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String($in), $null, 'CurrentUser')",
|
|
437
|
+
"[Console]::Out.Write([Convert]::ToBase64String($out))"
|
|
438
|
+
].join("; ");
|
|
439
|
+
function windowsLookup(home) {
|
|
440
|
+
const backend = "Windows DPAPI";
|
|
441
|
+
let blob;
|
|
442
|
+
try {
|
|
443
|
+
blob = fs2.readFileSync(path2.join(home, ".mimi-seed", DPAPI_KEY_FILE), "utf8");
|
|
444
|
+
} catch (error) {
|
|
445
|
+
const code = error.code;
|
|
446
|
+
if (code === "ENOENT" || code === "ENOTDIR") return { state: "absent", backend };
|
|
447
|
+
return { state: "unavailable", backend, reason: R().exit(DPAPI_KEY_FILE, code ?? "read") };
|
|
448
|
+
}
|
|
449
|
+
const result = run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", DPAPI_UNPROTECT], blob);
|
|
450
|
+
const problem = spawnProblem("powershell.exe", result);
|
|
451
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
452
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("powershell.exe", String(result.status)) };
|
|
453
|
+
return decodeKey(result.stdout, backend);
|
|
454
|
+
}
|
|
455
|
+
function linuxLookup() {
|
|
456
|
+
const backend = "Secret Service";
|
|
457
|
+
const result = run("secret-tool", ["lookup", "service", KEYCHAIN_SERVICE, "account", KEYCHAIN_ACCOUNT]);
|
|
458
|
+
const problem = spawnProblem("secret-tool", result);
|
|
459
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
460
|
+
if (result.status === 1 && !result.stdout.trim() && !result.stderr.trim()) return { state: "absent", backend };
|
|
461
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("secret-tool", String(result.status)) };
|
|
462
|
+
return decodeKey(result.stdout, backend);
|
|
463
|
+
}
|
|
464
|
+
function macosCreate(home = os2.homedir()) {
|
|
465
|
+
const keychain = macosLoginKeychain(home);
|
|
466
|
+
const target = /^[^\s"'\\]+$/.test(keychain) ? ` ${keychain}` : "";
|
|
467
|
+
const key = randomBytes2(DATA_KEY_BYTES).toString("base64");
|
|
468
|
+
const command = `add-generic-password -s ${KEYCHAIN_SERVICE} -a ${KEYCHAIN_ACCOUNT} -w ${key}${target}
|
|
469
|
+
`;
|
|
470
|
+
const result = run("/usr/bin/security", ["-i"], command);
|
|
471
|
+
const problem = spawnProblem("security", result);
|
|
472
|
+
if (problem) {
|
|
473
|
+
const timedOut = errorCode(result) === "ETIMEDOUT";
|
|
474
|
+
return { state: "unavailable", backend: "macOS Keychain", reason: timedOut ? R().waiting : problem };
|
|
475
|
+
}
|
|
476
|
+
if (result.status !== 0 && result.status !== 45) return macosFailure(result.status, keychain);
|
|
477
|
+
return macosLookup(home);
|
|
478
|
+
}
|
|
479
|
+
var DPAPI_PROTECT = DPAPI_UNPROTECT.replace("::Unprotect(", "::Protect(");
|
|
480
|
+
function windowsCreate(home) {
|
|
481
|
+
const backend = "Windows DPAPI";
|
|
482
|
+
const result = run(
|
|
483
|
+
"powershell.exe",
|
|
484
|
+
["-NoProfile", "-NonInteractive", "-Command", DPAPI_PROTECT],
|
|
485
|
+
randomBytes2(DATA_KEY_BYTES).toString("base64")
|
|
486
|
+
);
|
|
487
|
+
const problem = spawnProblem("powershell.exe", result);
|
|
488
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
489
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("powershell.exe", String(result.status)) };
|
|
490
|
+
const dir = path2.join(home, ".mimi-seed");
|
|
491
|
+
const target = path2.join(dir, DPAPI_KEY_FILE);
|
|
492
|
+
const temp = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
493
|
+
try {
|
|
494
|
+
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
495
|
+
fs2.writeFileSync(temp, result.stdout.trim(), { mode: 384 });
|
|
496
|
+
fs2.linkSync(temp, target);
|
|
497
|
+
} catch (error) {
|
|
498
|
+
if (error.code !== "EEXIST") {
|
|
499
|
+
return { state: "unavailable", backend, reason: R().exit(DPAPI_KEY_FILE, error.code ?? "write") };
|
|
500
|
+
}
|
|
501
|
+
} finally {
|
|
502
|
+
fs2.rmSync(temp, { force: true });
|
|
503
|
+
}
|
|
504
|
+
return windowsLookup(home);
|
|
505
|
+
}
|
|
506
|
+
var LOCK_STALE_MS = 3e4;
|
|
507
|
+
function linuxCreate(home) {
|
|
508
|
+
const backend = "Secret Service";
|
|
509
|
+
const dir = path2.join(home, ".mimi-seed");
|
|
510
|
+
const lock = path2.join(dir, ".data-key.lock");
|
|
511
|
+
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
512
|
+
const deadline = Date.now() + LOCK_STALE_MS;
|
|
513
|
+
for (; ; ) {
|
|
514
|
+
try {
|
|
515
|
+
fs2.mkdirSync(lock);
|
|
516
|
+
break;
|
|
517
|
+
} catch (error) {
|
|
518
|
+
if (error.code !== "EEXIST") {
|
|
519
|
+
return { state: "unavailable", backend, reason: R().exit(".data-key.lock", error.code ?? "mkdir") };
|
|
520
|
+
}
|
|
521
|
+
let age = 0;
|
|
522
|
+
try {
|
|
523
|
+
age = Date.now() - fs2.statSync(lock).mtimeMs;
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
if (age > LOCK_STALE_MS) fs2.rmSync(lock, { recursive: true, force: true });
|
|
527
|
+
if (Date.now() > deadline) return { state: "unavailable", backend, reason: R().timeout(".data-key.lock") };
|
|
528
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
const existing = linuxLookup();
|
|
533
|
+
if (existing.state !== "absent") return existing;
|
|
534
|
+
const result = run(
|
|
535
|
+
"secret-tool",
|
|
536
|
+
["store", "--label=Mimi Seed credential key", "service", KEYCHAIN_SERVICE, "account", KEYCHAIN_ACCOUNT],
|
|
537
|
+
randomBytes2(DATA_KEY_BYTES).toString("base64")
|
|
538
|
+
);
|
|
539
|
+
const problem = spawnProblem("secret-tool", result);
|
|
540
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
541
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("secret-tool", String(result.status)) };
|
|
542
|
+
return linuxLookup();
|
|
543
|
+
} finally {
|
|
544
|
+
fs2.rmSync(lock, { recursive: true, force: true });
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function osCreateDataKey(home = os2.homedir(), platform = process.platform) {
|
|
548
|
+
if (platform === "darwin") return macosCreate(home);
|
|
549
|
+
if (platform === "win32") return windowsCreate(home);
|
|
550
|
+
if (platform === "linux") return linuxCreate(home);
|
|
551
|
+
return { state: "unavailable", backend: platform, reason: R().noBackend(platform) };
|
|
552
|
+
}
|
|
553
|
+
function osDataKeySource(home = os2.homedir(), platform = process.platform) {
|
|
554
|
+
if (platform === "darwin") return macosLookup(home);
|
|
555
|
+
if (platform === "win32") return windowsLookup(home);
|
|
556
|
+
if (platform === "linux") return linuxLookup();
|
|
557
|
+
return { state: "unavailable", backend: platform, reason: R().noBackend(platform) };
|
|
558
|
+
}
|
|
559
|
+
var FAILED_LOOKUP_TTL_MS = 1e4;
|
|
560
|
+
var source = () => osDataKeySource();
|
|
561
|
+
var creator = () => osCreateDataKey();
|
|
562
|
+
var cached;
|
|
563
|
+
var failed;
|
|
564
|
+
function lookupDataKey(now = Date.now()) {
|
|
565
|
+
if (cached) return { state: "ok", ...cached };
|
|
566
|
+
if (failed && now - failed.at < FAILED_LOOKUP_TTL_MS) return failed.result;
|
|
567
|
+
const result = source();
|
|
568
|
+
if (result.state === "ok") {
|
|
569
|
+
cached = { key: result.key, backend: result.backend };
|
|
570
|
+
failed = void 0;
|
|
571
|
+
} else {
|
|
572
|
+
failed = { result, at: now };
|
|
573
|
+
}
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
576
|
+
function obtainDataKey() {
|
|
577
|
+
const found = lookupDataKey();
|
|
578
|
+
if (found.state !== "absent") return found;
|
|
579
|
+
const made = creator();
|
|
580
|
+
if (made.state === "ok") {
|
|
581
|
+
cached = { key: made.key, backend: made.backend };
|
|
582
|
+
failed = void 0;
|
|
583
|
+
}
|
|
584
|
+
return made;
|
|
585
|
+
}
|
|
586
|
+
function forgetFailedDataKeyLookup() {
|
|
587
|
+
failed = void 0;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ../core/src/credential-read.ts
|
|
591
|
+
var R2 = catalog(
|
|
592
|
+
{
|
|
593
|
+
unreadable: (c) => `\uC77D\uC744 \uC218 \uC5C6\uC74C (${c})`,
|
|
594
|
+
unsupported: "\uB354 \uC0C8 \uBC84\uC804\uC758 Mimi Seed \uAC00 \uC4F4 \uC554\uD638\uD654 \uD615\uC2DD \u2014 SDK \uB97C \uC5C5\uB370\uC774\uD2B8\uD558\uC138\uC694",
|
|
595
|
+
malformed: "\uC554\uD638\uD654 \uD30C\uC77C\uC758 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC74C",
|
|
596
|
+
outside: "\uC790\uACA9\uC99D\uBA85 \uD3F4\uB354(~/.mimi-seed) \uBC16\uC758 \uC554\uD638\uD654 \uD30C\uC77C",
|
|
597
|
+
tampered: "\uC554\uD638\uD654 \uD30C\uC77C\uC774 \uBCC0\uC870\uB410\uAC70\uB098 \uB2E4\uB978 \uACBD\uB85C\uC5D0\uC11C \uBCF5\uC0AC\uB428",
|
|
598
|
+
absent: (backend) => `\uC554\uD638\uD654\uB3FC \uC788\uC9C0\uB9CC \uC774 \uCEF4\uD4E8\uD130\uC758 ${backend}\uC5D0 \uD0A4\uAC00 \uC5C6\uC74C`,
|
|
599
|
+
unavailable: (backend, why) => `\uC554\uD638\uD654\uB3FC \uC788\uC9C0\uB9CC ${backend}\uC5D0\uC11C \uD0A4\uB97C \uAEBC\uB0B4\uC9C0 \uBABB\uD568 (${why})`,
|
|
600
|
+
otherKey: (backend) => `${backend}\uC758 \uD0A4\uC640 \uB2E4\uB978 \uD0A4\uB85C \uC554\uD638\uD654\uB428`
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
unreadable: (c) => `unreadable (${c})`,
|
|
604
|
+
unsupported: "encrypted by a newer version of Mimi Seed \u2014 update the SDK",
|
|
605
|
+
malformed: "the encrypted file is malformed",
|
|
606
|
+
outside: "an encrypted file outside the credential folder (~/.mimi-seed)",
|
|
607
|
+
tampered: "the encrypted file was modified or copied from another path",
|
|
608
|
+
absent: (backend) => `encrypted, but this machine's ${backend} has no key for it`,
|
|
609
|
+
unavailable: (backend, why) => `encrypted, but the key could not be read from ${backend} (${why})`,
|
|
610
|
+
otherKey: (backend) => `encrypted with a different key than the one in ${backend}`
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
var MISSING_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
614
|
+
function credentialAad(file) {
|
|
615
|
+
const segments = path3.resolve(file).split(path3.sep);
|
|
616
|
+
const root = segments.lastIndexOf(".mimi-seed");
|
|
617
|
+
if (root < 0 || root === segments.length - 1) return null;
|
|
618
|
+
return segments.slice(root + 1).join("/");
|
|
619
|
+
}
|
|
620
|
+
function decodeCredentialText(file, text) {
|
|
621
|
+
if (!text.includes('"mimiSeedEncrypted"')) return { state: "ok", text };
|
|
622
|
+
let parsed;
|
|
623
|
+
try {
|
|
624
|
+
parsed = JSON.parse(text);
|
|
625
|
+
} catch {
|
|
626
|
+
return { state: "ok", text };
|
|
627
|
+
}
|
|
628
|
+
if (!looksLikeEnvelope(parsed)) return { state: "ok", text };
|
|
629
|
+
const envelope = parseEnvelope(parsed);
|
|
630
|
+
if (envelope === "unsupported") return { state: "invalid", reason: R2().unsupported };
|
|
631
|
+
if (envelope === "malformed") return { state: "invalid", reason: R2().malformed };
|
|
632
|
+
const aad = credentialAad(file);
|
|
633
|
+
if (aad === null) return { state: "invalid", reason: R2().outside };
|
|
634
|
+
const lookup = lookupDataKey();
|
|
635
|
+
if (lookup.state === "absent") return { state: "locked", reason: R2().absent(lookup.backend) };
|
|
636
|
+
if (lookup.state === "unavailable") return { state: "locked", reason: R2().unavailable(lookup.backend, lookup.reason) };
|
|
637
|
+
if (keyId(lookup.key) !== envelope.kid) return { state: "locked", reason: R2().otherKey(lookup.backend) };
|
|
638
|
+
const plaintext = openCredential(envelope, lookup.key, aad);
|
|
639
|
+
return plaintext === null ? { state: "invalid", reason: R2().tampered } : { state: "ok", text: plaintext };
|
|
640
|
+
}
|
|
641
|
+
function readCredentialText(file) {
|
|
642
|
+
let text;
|
|
643
|
+
try {
|
|
644
|
+
text = fs3.readFileSync(file, "utf-8");
|
|
645
|
+
} catch (e) {
|
|
646
|
+
const code = e.code;
|
|
647
|
+
if (code && MISSING_CODES.has(code)) return { state: "missing" };
|
|
648
|
+
return { state: "invalid", reason: R2().unreadable(code ?? String(e)) };
|
|
649
|
+
}
|
|
650
|
+
return decodeCredentialText(file, text);
|
|
651
|
+
}
|
|
652
|
+
function readCredentialFileSync(file) {
|
|
653
|
+
const read = decodeCredentialText(file, fs3.readFileSync(file, "utf-8"));
|
|
654
|
+
if (read.state === "ok") return read.text;
|
|
655
|
+
throw new Error(`${file}: ${read.state === "missing" ? "missing" : read.reason}`);
|
|
656
|
+
}
|
|
657
|
+
async function readCredentialFile(file) {
|
|
658
|
+
const read = decodeCredentialText(file, await fs3.promises.readFile(file, "utf-8"));
|
|
659
|
+
if (read.state === "ok") return read.text;
|
|
660
|
+
throw new Error(`${file}: ${read.state === "missing" ? "missing" : read.reason}`);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// ../core/src/json-file.ts
|
|
664
|
+
var REASON = catalog(
|
|
665
|
+
{
|
|
666
|
+
empty: "\uBE48 \uD30C\uC77C (\uC4F0\uAE30\uAC00 \uC911\uAC04\uC5D0 \uB04A\uACBC\uC744 \uC218 \uC788\uC74C)",
|
|
667
|
+
syntax: (at) => `JSON \uD615\uC2DD \uC624\uB958${at ? ` \u2014 ${at}` : ""}`,
|
|
668
|
+
at: (line, col) => `${line}\uD589 ${col}\uC5F4`,
|
|
669
|
+
pos: (p) => `${p}\uBC88\uC9F8 \uBB38\uC790`
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
empty: "empty file (a write may have been interrupted)",
|
|
673
|
+
syntax: (at) => `invalid JSON${at ? ` at ${at}` : ""}`,
|
|
674
|
+
at: (line, col) => `line ${line}, column ${col}`,
|
|
675
|
+
pos: (p) => `character ${p}`
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
function syntaxLocation(message, R3) {
|
|
679
|
+
const lc = /line (\d+) column (\d+)/.exec(message);
|
|
680
|
+
if (lc) return R3.at(lc[1], lc[2]);
|
|
681
|
+
const pos = /position (\d+)/.exec(message);
|
|
682
|
+
return pos ? R3.pos(pos[1]) : null;
|
|
683
|
+
}
|
|
684
|
+
function readJsonFile(file) {
|
|
685
|
+
const R3 = REASON();
|
|
686
|
+
const read = readCredentialText(file);
|
|
687
|
+
if (read.state !== "ok") return read;
|
|
688
|
+
const text = read.text;
|
|
689
|
+
if (text.trim() === "") return { state: "invalid", reason: R3.empty };
|
|
690
|
+
try {
|
|
691
|
+
return { state: "ok", value: JSON.parse(text) };
|
|
692
|
+
} catch (e) {
|
|
693
|
+
return { state: "invalid", reason: R3.syntax(syntaxLocation(e instanceof Error ? e.message : "", R3)) };
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// ../core/src/project-manifest.ts
|
|
698
|
+
import fs4 from "fs";
|
|
699
|
+
import path4 from "path";
|
|
700
|
+
var MANIFEST_FILENAME = ".mimi-seed.json";
|
|
701
|
+
var SOCIAL_PROFILE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
702
|
+
function lookupProjectManifest(startDir = process.cwd(), maxDepth = 8) {
|
|
703
|
+
let dir = path4.resolve(startDir);
|
|
704
|
+
for (let i = 0; i <= maxDepth; i++) {
|
|
705
|
+
const candidate = path4.join(dir, MANIFEST_FILENAME);
|
|
706
|
+
if (fs4.existsSync(candidate)) return parseManifest(candidate);
|
|
707
|
+
const parent = path4.dirname(dir);
|
|
708
|
+
if (parent === dir) break;
|
|
709
|
+
dir = parent;
|
|
710
|
+
}
|
|
711
|
+
return { state: "missing" };
|
|
712
|
+
}
|
|
713
|
+
function parseManifest(filePath) {
|
|
714
|
+
let raw;
|
|
715
|
+
try {
|
|
716
|
+
raw = fs4.readFileSync(filePath, "utf-8");
|
|
717
|
+
} catch {
|
|
718
|
+
return { state: "invalid", filePath, reason: "unreadable" };
|
|
719
|
+
}
|
|
720
|
+
let obj;
|
|
721
|
+
try {
|
|
722
|
+
obj = JSON.parse(raw);
|
|
723
|
+
} catch {
|
|
724
|
+
return { state: "invalid", filePath, reason: "invalid-json" };
|
|
725
|
+
}
|
|
726
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return { state: "invalid", filePath, reason: "not-an-object" };
|
|
727
|
+
return { state: "ok", loaded: { manifest: obj, filePath } };
|
|
728
|
+
}
|
|
729
|
+
function manifestServiceEntries(m) {
|
|
730
|
+
const svc = m.services ?? {};
|
|
731
|
+
return Object.keys(svc).filter((k) => svc[k] != null).map((k) => [k, svc[k]]);
|
|
732
|
+
}
|
|
733
|
+
function isValidSocialProfileId(value) {
|
|
734
|
+
return SOCIAL_PROFILE_ID_PATTERN.test(value);
|
|
84
735
|
}
|
|
85
736
|
var SOCIAL_PROFILE_MESSAGES_KO = {
|
|
86
737
|
notAnObject: `${MANIFEST_FILENAME}\uC758 socialProfiles\uB294 \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,
|
|
@@ -115,21 +766,21 @@ function credObtain(spec, lang = resolveLang()) {
|
|
|
115
766
|
return spec.obtain[lang];
|
|
116
767
|
}
|
|
117
768
|
function credDir(home) {
|
|
118
|
-
return
|
|
769
|
+
return path5.join(home, ".mimi-seed");
|
|
119
770
|
}
|
|
120
771
|
function hasFile(home, name) {
|
|
121
|
-
return
|
|
772
|
+
return readJsonFile(path5.join(credDir(home), name)).state === "ok";
|
|
122
773
|
}
|
|
123
774
|
function anyFileStarting(home, prefix) {
|
|
124
775
|
try {
|
|
125
|
-
return
|
|
776
|
+
return fs5.readdirSync(credDir(home)).some((f) => f.startsWith(prefix));
|
|
126
777
|
} catch {
|
|
127
778
|
return false;
|
|
128
779
|
}
|
|
129
780
|
}
|
|
130
781
|
function readJson(home, name) {
|
|
131
782
|
try {
|
|
132
|
-
return JSON.parse(
|
|
783
|
+
return JSON.parse(readCredentialFileSync(path5.join(credDir(home), name)));
|
|
133
784
|
} catch {
|
|
134
785
|
return null;
|
|
135
786
|
}
|
|
@@ -160,7 +811,9 @@ function detectSocialToken(home, file, idKey, tokenKey, nestedPlatform) {
|
|
|
160
811
|
function detectProjectSocialToken(home, startDir, platform) {
|
|
161
812
|
const idKey = "userId";
|
|
162
813
|
const tokenKey = "accessToken";
|
|
163
|
-
const
|
|
814
|
+
const lookup = lookupProjectManifest(startDir ?? process.cwd());
|
|
815
|
+
if (lookup.state === "invalid") return { present: false, detail: `${MANIFEST_FILENAME}: ${t().doctor.manifestReason[lookup.reason]}` };
|
|
816
|
+
const loaded = lookup.state === "ok" ? lookup.loaded : null;
|
|
164
817
|
if (!loaded) return detectSocialToken(home, `${platform}.json`, idKey, tokenKey);
|
|
165
818
|
let profile;
|
|
166
819
|
try {
|
|
@@ -171,7 +824,7 @@ function detectProjectSocialToken(home, startDir, platform) {
|
|
|
171
824
|
if (!profile) return detectSocialToken(home, `${platform}.json`, idKey, tokenKey);
|
|
172
825
|
const detected = detectSocialToken(
|
|
173
826
|
home,
|
|
174
|
-
|
|
827
|
+
path5.join("social-profiles", `${profile}.json`),
|
|
175
828
|
idKey,
|
|
176
829
|
tokenKey,
|
|
177
830
|
platform
|
|
@@ -181,13 +834,23 @@ function detectProjectSocialToken(home, startDir, platform) {
|
|
|
181
834
|
detail: detected.detail ? `${profile}: ${detected.detail}` : `profile ${profile}`
|
|
182
835
|
};
|
|
183
836
|
}
|
|
184
|
-
function
|
|
185
|
-
if (hasFile(home, "play-service-account.json")) return true;
|
|
837
|
+
function playSaDetect(home) {
|
|
838
|
+
if (hasFile(home, "play-service-account.json")) return { present: true };
|
|
839
|
+
const dir = path5.join(credDir(home), "play-service-accounts");
|
|
840
|
+
let names;
|
|
186
841
|
try {
|
|
187
|
-
|
|
842
|
+
names = fs5.readdirSync(dir).filter((f) => f.endsWith(".json")).sort();
|
|
188
843
|
} catch {
|
|
189
|
-
return false;
|
|
844
|
+
return { present: false };
|
|
845
|
+
}
|
|
846
|
+
let invalid;
|
|
847
|
+
for (const name of names) {
|
|
848
|
+
const file = path5.join(dir, name);
|
|
849
|
+
const read = readJsonFile(file);
|
|
850
|
+
if (read.state === "ok") return { present: true };
|
|
851
|
+
if ((read.state === "invalid" || read.state === "locked") && !invalid) invalid = unusable(file, read);
|
|
190
852
|
}
|
|
853
|
+
return invalid ? { present: false, invalid } : { present: false };
|
|
191
854
|
}
|
|
192
855
|
function ciDetect(home, want) {
|
|
193
856
|
const ci = readJson(home, "ci.json");
|
|
@@ -331,7 +994,7 @@ var CREDENTIALS = [
|
|
|
331
994
|
ko: "\uC120\uD0DD \u2014 \uB85C\uCEEC\uC740 OAuth \uB85C \uAC00\uB2A5, CI/\uD5E4\uB4DC\uB9AC\uC2A4\uB294 \uD544\uC218",
|
|
332
995
|
en: "optional \u2014 OAuth covers local; required for CI / headless"
|
|
333
996
|
},
|
|
334
|
-
detect: (home) => (
|
|
997
|
+
detect: (home) => playSaDetect(home)
|
|
335
998
|
},
|
|
336
999
|
{
|
|
337
1000
|
id: "bigquery",
|
|
@@ -591,375 +1254,176 @@ var CREDENTIALS = [
|
|
|
591
1254
|
group: "marketing",
|
|
592
1255
|
file: "~/.mimi-seed/threads.json",
|
|
593
1256
|
fix: "mimi-seed auth threads",
|
|
594
|
-
setup: { kind: "mcp-bin", bin: "mimi-seed-social-auth", args: ["threads"] },
|
|
595
|
-
obtain: {
|
|
596
|
-
ko: [
|
|
597
|
-
"Instagram \uACFC **\uBCC4\uAC1C \uACC4\uC815\xB7\uBCC4\uAC1C \uD1A0\uD070**\uC774\uB2E4 (Threads Graph API).",
|
|
598
|
-
"\uAE30\uBCF8 \uD750\uB984: `mimi-seed auth threads`\uB97C \uC2E4\uD589\uD558\uBA74 HTTPS \uBE0C\uB85C\uCEE4\uAC00 \uC5EC\uB294 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C Threads \uB85C\uADF8\uC778\xB7\uAD8C\uD55C \uC2B9\uC778\uC744 \uC644\uB8CC\uD55C\uB2E4.",
|
|
599
|
-
"\uBE0C\uB85C\uCEE4 \uC6B4\uC601\uC790\uB294 Threads App ID/secret\uACFC \uC571\uC5D0 \uB4F1\uB85D\uD55C HTTPS callback URL\uC744 \uC124\uC815\xB7\uBC30\uD3EC\uD574\uC57C \uD55C\uB2E4 (SDK\uAC00 \uBE0C\uB85C\uCEE4\uB97C \uBC30\uD3EC\uD558\uC9C0\uB294 \uC54A\uB294\uB2E4).",
|
|
600
|
-
"\uD1A0\uD070\uC744 \uC9C1\uC811 \uBD99\uC5EC \uB123\uB294 `--manual-token`\uC740 \uACE0\uAE09/\uD5E4\uB4DC\uB9AC\uC2A4 \uD750\uB984\uC774\uB2E4. \uC800\uC7A5 \uC804\uC5D0 Threads \uACC4\uC815\uC744 \uAC80\uC99D\uD55C\uB2E4.",
|
|
601
|
-
"`--profile <id>`\uB85C \uC774\uB984 \uC788\uB294 \uACC4\uC815\uC744 \uC800\uC7A5\uD560 \uC218 \uC788\uC73C\uBA70, OAuth \uC751\uB2F5\uC758 \uC2E4\uC81C \uB9CC\uB8CC \uC2DC\uAC01\uC744 \uB85C\uCEEC \uD504\uB85C\uD544\uC5D0 \uAE30\uB85D\uD55C\uB2E4."
|
|
602
|
-
],
|
|
603
|
-
en: [
|
|
604
|
-
"A **separate account and token** from Instagram (Threads Graph API).",
|
|
605
|
-
"Default: run `mimi-seed auth threads` and finish Threads login and consent in the browser opened by the HTTPS broker.",
|
|
606
|
-
"The broker operator must deploy it with the Threads App ID/secret and the HTTPS callback URL registered in the app (the SDK does not deploy the broker).",
|
|
607
|
-
"Pasting a token with `--manual-token` is the advanced/headless path; the Threads account is verified before saving.",
|
|
608
|
-
"Use `--profile <id>` for a named account; the actual expiry returned by OAuth is saved in the local profile."
|
|
609
|
-
]
|
|
610
|
-
},
|
|
611
|
-
docsAnchor: "threads",
|
|
612
|
-
detect: (home, startDir) => detectProjectSocialToken(home, startDir, "threads")
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
id: "tiktok",
|
|
616
|
-
label: {
|
|
617
|
-
ko: "TikTok Business",
|
|
618
|
-
en: "TikTok Business"
|
|
619
|
-
},
|
|
620
|
-
requirement: "optional",
|
|
621
|
-
group: "marketing",
|
|
622
|
-
file: "~/.mimi-seed/tiktok-business.json",
|
|
623
|
-
fix: "mimi-seed auth tiktok",
|
|
624
|
-
setup: { kind: "mcp-bin", bin: "mimi-seed-tiktok-business-auth" },
|
|
625
|
-
obtain: {
|
|
626
|
-
ko: [
|
|
627
|
-
"TikTok for Business Developer \uC571\uC744 \uB9CC\uB4E4\uACE0 Organic API \uC811\uADFC \uC2B9\uC778\uC744 \uBC1B\uB294\uB2E4.",
|
|
628
|
-
"TikTok Accounts > Business Content > Video Publish \uAD8C\uD55C\uACFC account holder redirect URL\uC744 \uC124\uC815\uD55C\uB2E4.",
|
|
629
|
-
"owned Business Account\uB97C \uC2B9\uC778\uD55C callback URL\uC758 auth_code\uB97C \uC5F0\uACB0 \uB9C8\uBC95\uC0AC\uC5D0 \uC785\uB825\uD55C\uB2E4."
|
|
630
|
-
],
|
|
631
|
-
en: [
|
|
632
|
-
"Create a TikTok for Business developer app and obtain Organic API approval.",
|
|
633
|
-
"Enable TikTok Accounts > Business Content > Video Publish and configure the account-holder redirect URL.",
|
|
634
|
-
"Authorize the owned Business Account, then paste the callback auth_code into the setup wizard."
|
|
635
|
-
]
|
|
636
|
-
},
|
|
637
|
-
docsAnchor: "tiktok-business",
|
|
638
|
-
detect: (home) => {
|
|
639
|
-
const cfg = readJson(
|
|
640
|
-
home,
|
|
641
|
-
"tiktok-business.json"
|
|
642
|
-
);
|
|
643
|
-
if (!cfg?.openId || !cfg.refreshTokenExpiresAt) return { present: false };
|
|
644
|
-
const refreshRemaining = Date.parse(cfg.refreshTokenExpiresAt) - Date.now();
|
|
645
|
-
if (!Number.isFinite(refreshRemaining) || refreshRemaining <= 0) {
|
|
646
|
-
return { present: true, detail: cfg.openId, freshness: "expired", daysRemaining: 0 };
|
|
647
|
-
}
|
|
648
|
-
const accessRemaining = cfg.accessTokenExpiresAt ? Date.parse(cfg.accessTokenExpiresAt) - Date.now() : NaN;
|
|
649
|
-
const daysRemaining = Math.max(1, Math.ceil(refreshRemaining / 864e5));
|
|
650
|
-
if (Number.isFinite(accessRemaining) && accessRemaining <= 0) {
|
|
651
|
-
return { present: true, detail: `${cfg.openId} (access token \uC790\uB3D9 \uAC31\uC2E0 \uC608\uC815)`, freshness: "fresh", daysRemaining };
|
|
652
|
-
}
|
|
653
|
-
return { present: true, detail: cfg.openId, freshness: "fresh", daysRemaining };
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
id: "anthropic",
|
|
658
|
-
label: {
|
|
659
|
-
ko: "ANTHROPIC_API_KEY",
|
|
660
|
-
en: "ANTHROPIC_API_KEY"
|
|
661
|
-
},
|
|
662
|
-
requirement: "optional",
|
|
663
|
-
group: "marketing",
|
|
664
|
-
fix: "export ANTHROPIC_API_KEY=sk-ant-\u2026",
|
|
665
|
-
setup: { kind: "env", envVar: "ANTHROPIC_API_KEY" },
|
|
666
|
-
obtain: {
|
|
667
|
-
ko: [
|
|
668
|
-
"Anthropic Console (console.anthropic.com) \u2192 API Keys \uC5D0\uC11C \uBC1C\uAE09.",
|
|
669
|
-
"\uD658\uACBD\uBCC0\uC218\uB85C\uB9CC \uC77D\uB294\uB2E4 \u2014 \uC124\uC815 \uBA85\uB839\uC774 \uB530\uB85C \uC5C6\uB2E4.",
|
|
670
|
-
"\uC5C6\uC5B4\uB3C4 \uB41C\uB2E4: `mimi-seed notes` \uB294 AI \uC5C6\uC774 \uCEE4\uBC0B \uBAA9\uB85D \uAE30\uBC18\uC73C\uB85C \uB3D9\uC791\uD55C\uB2E4."
|
|
671
|
-
],
|
|
672
|
-
en: [
|
|
673
|
-
"Anthropic Console (console.anthropic.com) \u2192 API Keys.",
|
|
674
|
-
"Read from the environment only \u2014 there is no setup command.",
|
|
675
|
-
"Optional: without it, `mimi-seed notes` still works, formatting your commits instead of writing prose."
|
|
676
|
-
]
|
|
677
|
-
},
|
|
678
|
-
docsAnchor: "anthropic-api-key",
|
|
679
|
-
note: {
|
|
680
|
-
ko: "\uC120\uD0DD \u2014 AI \uB9B4\uB9AC\uC2A4 \uB178\uD2B8/\uB9AC\uBDF0 \uB2F5\uBCC0 \uC0DD\uC131\uC6A9",
|
|
681
|
-
en: "optional \u2014 for AI-drafted release notes / review replies"
|
|
682
|
-
},
|
|
683
|
-
detect: () => ({ present: Boolean(process.env.ANTHROPIC_API_KEY) })
|
|
684
|
-
}
|
|
685
|
-
];
|
|
686
|
-
function tryCredById(id) {
|
|
687
|
-
return CREDENTIALS.find((c) => c.id === id);
|
|
688
|
-
}
|
|
689
|
-
function detectAll(home = os2.homedir(), startDir = process.cwd()) {
|
|
690
|
-
return new Map(CREDENTIALS.map((c) => [c.id, c.detect(home, startDir)]));
|
|
691
|
-
}
|
|
692
|
-
function isSatisfied(spec, detected) {
|
|
693
|
-
if (detected.get(spec.id)?.present) return true;
|
|
694
|
-
return (spec.fallbackOn ?? []).some((f) => detected.get(f)?.present);
|
|
695
|
-
}
|
|
696
|
-
function missingRequired(detected, platforms) {
|
|
697
|
-
return CREDENTIALS.filter((spec) => {
|
|
698
|
-
if (spec.requirement === "optional") return false;
|
|
699
|
-
if (spec.requirement === "platform" && !platforms.includes(spec.platform)) return false;
|
|
700
|
-
return !isSatisfied(spec, detected);
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
var GROUP_ORDER = { core: 0, ci: 1, marketing: 2 };
|
|
704
|
-
var REQ_ORDER = { required: 0, platform: 1, optional: 2 };
|
|
705
|
-
function planSetup(detected, opts = {}) {
|
|
706
|
-
const reconnect = new Set(opts.reconnect ?? []);
|
|
707
|
-
const only = opts.only ? new Set(opts.only) : null;
|
|
708
|
-
const platforms = opts.platforms ?? [];
|
|
709
|
-
return CREDENTIALS.filter((spec) => {
|
|
710
|
-
if (only && !only.has(spec.id)) return false;
|
|
711
|
-
if (reconnect.has(spec.id)) return true;
|
|
712
|
-
const found = detected.get(spec.id);
|
|
713
|
-
if (found?.freshness === "expired" || found?.freshness === "expiring") return true;
|
|
714
|
-
if (found?.present) return false;
|
|
715
|
-
if (spec.requirement === "platform" && platforms.length > 0 && !platforms.includes(spec.platform)) {
|
|
716
|
-
return false;
|
|
717
|
-
}
|
|
718
|
-
return true;
|
|
719
|
-
}).sort(
|
|
720
|
-
(a, b) => GROUP_ORDER[a.group] - GROUP_ORDER[b.group] || REQ_ORDER[a.requirement] - REQ_ORDER[b.requirement]
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// src/mcp-bin.ts
|
|
725
|
-
import { spawn, spawnSync } from "child_process";
|
|
726
|
-
import { existsSync, readFileSync } from "fs";
|
|
727
|
-
import path5 from "path";
|
|
728
|
-
import { fileURLToPath } from "url";
|
|
729
|
-
|
|
730
|
-
// src/i18n.ts
|
|
731
|
-
function catalog(ko2, en2) {
|
|
732
|
-
return () => resolveLang() === "en" ? en2 : ko2;
|
|
733
|
-
}
|
|
734
|
-
var ko = {
|
|
735
|
-
common: {
|
|
736
|
-
yes: "y",
|
|
737
|
-
optional: "\uC120\uD0DD",
|
|
738
|
-
required: "\uD544\uC218",
|
|
739
|
-
skip: "\uAC74\uB108\uB700",
|
|
740
|
-
cancelled: "\uCDE8\uC18C\uB428",
|
|
741
|
-
unknownCommand: (cmd) => `\uC54C \uC218 \uC5C6\uB294 \uBA85\uB839: ${cmd}`,
|
|
742
|
-
error: (msg) => `\uC624\uB958: ${msg}`,
|
|
743
|
-
checkWith: "\uC810\uAC80: mimi-seed doctor"
|
|
744
|
-
},
|
|
745
|
-
lang: {
|
|
746
|
-
ask: " \uC5B8\uC5B4\uB97C \uC120\uD0DD\uD574\uC918 [1] \uD55C\uAD6D\uC5B4 [2] English (\uC5D4\uD130=\uD55C\uAD6D\uC5B4): ",
|
|
747
|
-
saved: (l) => ` \u2705 \uC5B8\uC5B4: ${l === "ko" ? "\uD55C\uAD6D\uC5B4" : "English"} (\uB098\uC911\uC5D0 \uBC14\uAFB8\uAE30: mimi-seed lang en)`,
|
|
748
|
-
usage: `${"mimi-seed lang"} \u2014 CLI \uCD9C\uB825 \uC5B8\uC5B4
|
|
749
|
-
|
|
750
|
-
mimi-seed lang \uD604\uC7AC \uC5B8\uC5B4 \uD45C\uC2DC
|
|
751
|
-
mimi-seed lang ko \uD55C\uAD6D\uC5B4
|
|
752
|
-
mimi-seed lang en English
|
|
753
|
-
|
|
754
|
-
\uD658\uACBD\uBCC0\uC218 MIMI_SEED_LANG \uAC00 \uC788\uC73C\uBA74 \uADF8\uAC8C \uC6B0\uC120\uD569\uB2C8\uB2E4.`,
|
|
755
|
-
current: (l) => `\uD604\uC7AC \uC5B8\uC5B4: ${l === "ko" ? "\uD55C\uAD6D\uC5B4 (ko)" : "English (en)"}`,
|
|
756
|
-
invalid: (v) => `\uC54C \uC218 \uC5C6\uB294 \uC5B8\uC5B4: ${v} (ko \uB610\uB294 en)`
|
|
757
|
-
},
|
|
758
|
-
setup: {
|
|
759
|
-
title: "mimi-seed setup",
|
|
760
|
-
platformsDetected: (p) => ` \uAC10\uC9C0\uB41C \uD50C\uB7AB\uD3FC: ${p}`,
|
|
761
|
-
statusTitle: "\uC5F0\uACB0 \uC0C1\uD0DC",
|
|
762
|
-
statusDir: "(~/.mimi-seed)",
|
|
763
|
-
groupCore: "\uD575\uC2EC",
|
|
764
|
-
groupCi: "\uBE4C\uB4DC / CI",
|
|
765
|
-
groupMarketing: "\uB9C8\uCF00\uD305 \xB7 AI",
|
|
766
|
-
fallbackWorking: "\uD3F4\uBC31\uC73C\uB85C \uB3D9\uC791 \uC911",
|
|
767
|
-
missingRequired: " \uD544\uC218 \uD56D\uBAA9 \uB204\uB77D:",
|
|
768
|
-
cannotInteract: " \u2717 \uC774 \uC790\uACA9\uC99D\uBA85\uC740 \uB300\uD654\uD615 \uC785\uB825\uC774 \uD544\uC694\uD574\uC11C \uC5EC\uAE30\uC11C\uB294 \uC124\uC815\uD560 \uC218 \uC5C6\uC5B4:",
|
|
769
|
-
cannotInteractHint: " \uD130\uBBF8\uB110\uC5D0\uC11C \uC2E4\uD589\uD574\uC918 (Git Bash \uB4F1 TTY \uBBF8\uAC10\uC9C0 \uD658\uACBD\uC774\uBA74 --interactive).",
|
|
770
|
-
runInTerminal: " \uB300\uD654\uD615\uC73C\uB85C \uC5F0\uACB0\uD558\uB824\uBA74 \uD130\uBBF8\uB110\uC5D0\uC11C: mimi-seed setup (Git Bash/mintty \uB294 TTY \uBBF8\uAC10\uC9C0 \u2014 --interactive \uB97C \uBD99\uC774\uAC70\uB098 PowerShell \uC5D0\uC11C)",
|
|
771
|
-
onlyAlreadyDone: " \u2705 \uC694\uCCAD\uD55C \uD56D\uBAA9\uC740 \uC774\uBBF8 \uC5F0\uACB0\uB3FC \uC788\uC5B4.",
|
|
772
|
-
onlyReconnectHint: " \uB2E4\uC2DC \uC124\uC815\uD558\uB824\uBA74: mimi-seed setup --reconnect <id>",
|
|
773
|
-
tokenExpired: "\uD1A0\uD070 \uB9CC\uB8CC \u2014 \uB2E4\uC2DC \uC5F0\uACB0 \uD544\uC694",
|
|
774
|
-
tokenExpiring: (days) => `\uD1A0\uD070 ${days}\uC77C \uD6C4 \uB9CC\uB8CC \u2014 \uC9C0\uAE08 \uAC31\uC2E0 \uAD8C\uC7A5`,
|
|
775
|
-
allDone: " \u2705 \uC5F0\uACB0\uD560 \uAC8C \uB354 \uC5C6\uC5B4. \uB2E4 \uB410\uB2E4.",
|
|
776
|
-
planCount: (n) => ` ${n}\uAC1C \uD56D\uBAA9\uC744 \uC21C\uC11C\uB300\uB85C \uBB3C\uC5B4\uBCFC\uAC8C. \uC5B8\uC81C\uB4E0 s=\uAC74\uB108\uB6F0\uAE30, q=\uC885\uB8CC.`,
|
|
777
|
-
prompt: " [c] \uC5F0\uACB0 [s] \uAC74\uB108\uB6F0\uAE30 [?] \uC774\uAC74 \uC5B4\uB5BB\uAC8C \uAD6C\uD558\uB098\uC694 [q] \uC885\uB8CC : ",
|
|
778
|
-
promptInvalid: " c / s / ? / q \uC911\uC5D0\uC11C \uACE8\uB77C\uC918.",
|
|
779
|
-
quit: " \uC911\uB2E8\uD588\uC5B4. \uC774\uC5B4\uC11C \uD558\uB824\uBA74 \uB2E4\uC2DC: mimi-seed setup",
|
|
780
|
-
skipped: (fix) => ` \uAC74\uB108\uB700. \uB098\uC911\uC5D0: ${fix}`,
|
|
781
|
-
obtainTitle: (label) => ` ${label} \u2014 \uBBF8\uB9AC \uC900\uBE44\uD560 \uAC83`,
|
|
782
|
-
obtainMore: (anchor) => ` \uC790\uC138\uD788: docs/credentials.md#${anchor}`,
|
|
783
|
-
neededFor: (platform) => `(${platform} \uBC30\uD3EC\uC5D0 \uD544\uC694)`,
|
|
784
|
-
binFailed: (label, code, fix) => ` \u26A0 ${label} \uC124\uC815\uC774 \uC644\uB8CC\uB418\uC9C0 \uC54A\uC558\uC5B4 (exit ${code}). \uB098\uC911\uC5D0 \uB2E4\uC2DC: ${fix}`,
|
|
785
|
-
verifying: " \u{1F50E} \uD1A0\uD070 \uAC80\uC99D \uC911...",
|
|
786
|
-
verifyFailed: (reason) => ` \u274C \uD1A0\uD070 \uAC80\uC99D \uC2E4\uD328: ${reason}`,
|
|
787
|
-
notSaved: (fix) => ` \uC800\uC7A5\uD558\uC9C0 \uC54A\uC558\uC5B4. \uB2E4\uC2DC: ${fix}`,
|
|
788
|
-
ciSaved: (label, who) => ` \u2705 ${label} \uC5F0\uACB0\uB428${who} \u2192 ~/.mimi-seed/ci.json`,
|
|
789
|
-
runSeparately: (cmd) => ` \uC774\uAC74 \uBCC4\uB3C4 \uBA85\uB839\uC73C\uB85C \uC2E4\uD589\uD574\uC918: ${cmd}`,
|
|
790
|
-
envVar: " \uD658\uACBD\uBCC0\uC218\uB85C \uC124\uC815\uD558\uB294 \uD56D\uBAA9\uC774\uC57C:",
|
|
791
|
-
pressEnter: " (\uC5D4\uD130\uB97C \uB204\uB974\uBA74 \uACC4\uC18D) ",
|
|
792
|
-
stillMissing: " \uC544\uC9C1 \uD544\uC218 \uD56D\uBAA9\uC774 \uB0A8\uC544 \uC788\uC5B4:",
|
|
793
|
-
requiredDone: " \u2705 \uD544\uC218 \uC5F0\uACB0 \uC644\uB8CC.",
|
|
794
|
-
nextSteps: " \uC810\uAC80: mimi-seed doctor \xB7 \uBC30\uD3EC: mimi-seed deploy",
|
|
795
|
-
tryPrompt: ' \uCCAB \uD504\uB86C\uD504\uD2B8 \u2014 Claude Code / Codex \uC0C8 \uC138\uC158\uC5D0\uC11C: "\uB0B4 \uC571 \uCD9C\uC2DC \uC900\uBE44\uB410\uC5B4?"'
|
|
796
|
-
},
|
|
797
|
-
doctor: {
|
|
798
|
-
title: "mimi-seed doctor",
|
|
799
|
-
secAuth: "\uC778\uC99D",
|
|
800
|
-
secCreds: "\uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 (~/.mimi-seed)",
|
|
801
|
-
secEnv: "\uB85C\uCEEC \uD658\uACBD",
|
|
802
|
-
secApps: "\uC571 \uAC10\uC9C0",
|
|
803
|
-
noToken: "Mimi Seed \uD1A0\uD070 \uC5C6\uC74C",
|
|
804
|
-
noTokenFix: "`mimi-seed init` \uC2E4\uD589 \uD544\uC694",
|
|
805
|
-
noTokenLocal: "Mimi Seed \uD074\uB77C\uC6B0\uB4DC \uACC4\uC815 \uBBF8\uC5F0\uACB0",
|
|
806
|
-
noTokenLocalDetail: "\uC6F9 \uCF58\uC194\xB7\uC6D0\uACA9 MCP(init \xB7 status \xB7 deploy)\uB97C \uC4F8 \uB54C\uB9CC \uD544\uC694 \u2014 \uB85C\uCEEC MCP \uB3C4\uAD6C\uB294 \uC4F0\uC9C0 \uC54A\uC74C",
|
|
807
|
-
tokenSaved: "\uD1A0\uD070 \uC800\uC7A5\uB428",
|
|
808
|
-
endpoint: "\uC5D4\uB4DC\uD3EC\uC778\uD2B8",
|
|
809
|
-
ciMode: "CI \uBAA8\uB4DC",
|
|
810
|
-
ciModeDetail: "MIMI_SEED_TOKEN \uD658\uACBD\uBCC0\uC218 \uC0AC\uC6A9 \uC911",
|
|
811
|
-
tokenInvalid: "\uD1A0\uD070 \uAC80\uC99D \uC2E4\uD328",
|
|
812
|
-
serverUnreachable: "Mimi Seed \uC11C\uBC84\uC5D0 \uC5F0\uACB0\uD560 \uC218 \uC5C6\uC74C",
|
|
813
|
-
serverOk: "Mimi Seed \uC11C\uBC84 \uC5F0\uACB0\uB428",
|
|
814
|
-
appCount: (n) => `\uC571 ${n}\uAC1C`,
|
|
815
|
-
unknownService: (id) => `${id} (\uC54C \uC218 \uC5C6\uB294 \uC11C\uBE44\uC2A4)`,
|
|
816
|
-
credentialMismatch: (field, expected, actual) => `${field} \uBD88\uC77C\uCE58 \u2014 \uC694\uAD6C\uAC12 ${expected}, \uD604\uC7AC\uAC12 ${actual ?? "\uC5C6\uC74C"}`,
|
|
817
|
-
credsHint: " \uC804\uBD80 \uC5F0\uACB0\uD558\uAE30: mimi-seed setup \xB7 OAuth \uC2E0\uC120\uB3C4: mimi-seed auth status\n",
|
|
818
|
-
nodeTooOld: (v) => `${v} \u2014 v22 \uC774\uC0C1 \uD544\uC694 (.nvmrc \uCC38\uACE0)`,
|
|
819
|
-
gitRepo: "Git \uC800\uC7A5\uC18C",
|
|
820
|
-
gitTag: (t2) => `\uCD5C\uC2E0 \uD0DC\uADF8: ${t2}`,
|
|
821
|
-
gitCommits: (n) => `\uCEE4\uBC0B ${n}\uAC1C`,
|
|
822
|
-
noGit: "Git \uC800\uC7A5\uC18C \uC5C6\uC74C",
|
|
823
|
-
noGitDetail: "mimi-seed notes \uC0AC\uC6A9 \uBD88\uAC00",
|
|
824
|
-
noApp: "\uC571 \uAC10\uC9C0 \uC5C6\uC74C",
|
|
825
|
-
noAppDetail: "Expo / Gradle / Xcode / Unity \uC571 \uC124\uC815 \uC5C6\uC74C",
|
|
826
|
-
unnamed: "(\uC774\uB984 \uBBF8\uC0C1)",
|
|
827
|
-
requirements: (proj) => `${proj} \uC694\uAD6C\uC0AC\uD56D (.mimi-seed.json)`,
|
|
828
|
-
thisProject: "\uC774 \uD504\uB85C\uC81D\uD2B8"
|
|
829
|
-
},
|
|
830
|
-
auth: {
|
|
831
|
-
title: "mimi-seed auth \u2014 \uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 \uC778\uC99D/\uAD00\uB9AC",
|
|
832
|
-
statusTitle: "\uB85C\uCEEC \uC790\uACA9\uC99D\uBA85 \uC0C1\uD0DC",
|
|
833
|
-
connectAll: "\n \uD55C \uBC88\uC5D0 \uC5F0\uACB0: mimi-seed setup",
|
|
834
|
-
unknownSub: (sub) => `\uC54C \uC218 \uC5C6\uB294 auth \uC11C\uBE0C\uBA85\uB839: ${sub}`,
|
|
835
|
-
npxFailed: (cmd, msg) => `
|
|
836
|
-
\u274C ${cmd} \uC2E4\uD589 \uC2E4\uD328: ${msg}
|
|
837
|
-
`
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
var en = {
|
|
841
|
-
common: {
|
|
842
|
-
yes: "y",
|
|
843
|
-
optional: "optional",
|
|
844
|
-
required: "required",
|
|
845
|
-
skip: "skipped",
|
|
846
|
-
cancelled: "Cancelled",
|
|
847
|
-
unknownCommand: (cmd) => `Unknown command: ${cmd}`,
|
|
848
|
-
error: (msg) => `Error: ${msg}`,
|
|
849
|
-
checkWith: "Check with: mimi-seed doctor"
|
|
850
|
-
},
|
|
851
|
-
lang: {
|
|
852
|
-
ask: " Choose a language [1] \uD55C\uAD6D\uC5B4 [2] English (Enter = English): ",
|
|
853
|
-
saved: (l) => ` \u2705 Language: ${l === "ko" ? "\uD55C\uAD6D\uC5B4" : "English"} (change later: mimi-seed lang ko)`,
|
|
854
|
-
usage: `mimi-seed lang \u2014 CLI output language
|
|
855
|
-
|
|
856
|
-
mimi-seed lang show current language
|
|
857
|
-
mimi-seed lang ko \uD55C\uAD6D\uC5B4
|
|
858
|
-
mimi-seed lang en English
|
|
859
|
-
|
|
860
|
-
MIMI_SEED_LANG takes precedence when set.`,
|
|
861
|
-
current: (l) => `Current language: ${l === "ko" ? "\uD55C\uAD6D\uC5B4 (ko)" : "English (en)"}`,
|
|
862
|
-
invalid: (v) => `Unknown language: ${v} (use ko or en)`
|
|
863
|
-
},
|
|
864
|
-
setup: {
|
|
865
|
-
title: "mimi-seed setup",
|
|
866
|
-
platformsDetected: (p) => ` Detected platforms: ${p}`,
|
|
867
|
-
statusTitle: "Connection status",
|
|
868
|
-
statusDir: "(~/.mimi-seed)",
|
|
869
|
-
groupCore: "Core",
|
|
870
|
-
groupCi: "Build / CI",
|
|
871
|
-
groupMarketing: "Marketing \xB7 AI",
|
|
872
|
-
fallbackWorking: "working via fallback",
|
|
873
|
-
missingRequired: " Missing required:",
|
|
874
|
-
cannotInteract: " \u2717 These need interactive input and cannot be set up here:",
|
|
875
|
-
cannotInteractHint: " Run it in a terminal (add --interactive if your shell hides the TTY, e.g. Git Bash).",
|
|
876
|
-
runInTerminal: " To connect interactively, run: mimi-seed setup (Git Bash/mintty hide the TTY \u2014 add --interactive, or use PowerShell)",
|
|
877
|
-
onlyAlreadyDone: " \u2705 What you asked for is already connected.",
|
|
878
|
-
onlyReconnectHint: " To redo it: mimi-seed setup --reconnect <id>",
|
|
879
|
-
tokenExpired: "token expired \u2014 reconnect required",
|
|
880
|
-
tokenExpiring: (days) => `token expires in ${days} day(s) \u2014 refresh now`,
|
|
881
|
-
allDone: " \u2705 Nothing left to connect. You're set.",
|
|
882
|
-
planCount: (n) => ` I'll walk you through ${n} item(s). s = skip, q = quit, anytime.`,
|
|
883
|
-
prompt: " [c] connect [s] skip [?] how do I get this [q] quit : ",
|
|
884
|
-
promptInvalid: " Please choose c / s / ? / q.",
|
|
885
|
-
quit: " Stopped. To pick up where you left off: mimi-seed setup",
|
|
886
|
-
skipped: (fix) => ` Skipped. Later: ${fix}`,
|
|
887
|
-
obtainTitle: (label) => ` ${label} \u2014 what to get first`,
|
|
888
|
-
obtainMore: (anchor) => ` Details: docs/credentials.md#${anchor}`,
|
|
889
|
-
neededFor: (platform) => `(needed to ship to ${platform})`,
|
|
890
|
-
binFailed: (label, code, fix) => ` \u26A0 ${label} was not completed (exit ${code}). Try again later: ${fix}`,
|
|
891
|
-
verifying: " \u{1F50E} Verifying token...",
|
|
892
|
-
verifyFailed: (reason) => ` \u274C Token verification failed: ${reason}`,
|
|
893
|
-
notSaved: (fix) => ` Nothing was saved. Retry: ${fix}`,
|
|
894
|
-
ciSaved: (label, who) => ` \u2705 ${label} connected${who} \u2192 ~/.mimi-seed/ci.json`,
|
|
895
|
-
runSeparately: (cmd) => ` Run this one separately: ${cmd}`,
|
|
896
|
-
envVar: " This one is set through an environment variable:",
|
|
897
|
-
pressEnter: " (press Enter to continue) ",
|
|
898
|
-
stillMissing: " Still missing, and required:",
|
|
899
|
-
requiredDone: " \u2705 All required credentials connected.",
|
|
900
|
-
nextSteps: " Check: mimi-seed doctor \xB7 Ship: mimi-seed deploy",
|
|
901
|
-
tryPrompt: ' First prompt \u2014 in a new Claude Code / Codex session: "Is my app ready to ship?"'
|
|
902
|
-
},
|
|
903
|
-
doctor: {
|
|
904
|
-
title: "mimi-seed doctor",
|
|
905
|
-
secAuth: "Account",
|
|
906
|
-
secCreds: "Local credentials (~/.mimi-seed)",
|
|
907
|
-
secEnv: "Environment",
|
|
908
|
-
secApps: "App detection",
|
|
909
|
-
noToken: "No Mimi Seed token",
|
|
910
|
-
noTokenFix: "run `mimi-seed init`",
|
|
911
|
-
noTokenLocal: "Mimi Seed cloud account not connected",
|
|
912
|
-
noTokenLocalDetail: "only needed for the web console / remote MCP (init \xB7 status \xB7 deploy) \u2014 local MCP tools do not use it",
|
|
913
|
-
tokenSaved: "Token stored",
|
|
914
|
-
endpoint: "Endpoint",
|
|
915
|
-
ciMode: "CI mode",
|
|
916
|
-
ciModeDetail: "using MIMI_SEED_TOKEN",
|
|
917
|
-
tokenInvalid: "Token rejected",
|
|
918
|
-
serverUnreachable: "Cannot reach the Mimi Seed server",
|
|
919
|
-
serverOk: "Connected to Mimi Seed",
|
|
920
|
-
appCount: (n) => `${n} app(s)`,
|
|
921
|
-
unknownService: (id) => `${id} (unknown service)`,
|
|
922
|
-
credentialMismatch: (field, expected, actual) => `${field} mismatch \u2014 expected ${expected}, current ${actual ?? "missing"}`,
|
|
923
|
-
credsHint: " Connect everything: mimi-seed setup \xB7 OAuth freshness: mimi-seed auth status\n",
|
|
924
|
-
nodeTooOld: (v) => `${v} \u2014 v22+ required (see .nvmrc)`,
|
|
925
|
-
gitRepo: "Git repository",
|
|
926
|
-
gitTag: (t2) => `latest tag: ${t2}`,
|
|
927
|
-
gitCommits: (n) => `${n} commit(s)`,
|
|
928
|
-
noGit: "Not a git repository",
|
|
929
|
-
noGitDetail: "mimi-seed notes is unavailable",
|
|
930
|
-
noApp: "No app detected",
|
|
931
|
-
noAppDetail: "no Expo / Gradle / Xcode / Unity app configuration",
|
|
932
|
-
unnamed: "(unnamed)",
|
|
933
|
-
requirements: (proj) => `${proj} requirements (.mimi-seed.json)`,
|
|
934
|
-
thisProject: "This project"
|
|
1257
|
+
setup: { kind: "mcp-bin", bin: "mimi-seed-social-auth", args: ["threads"] },
|
|
1258
|
+
obtain: {
|
|
1259
|
+
ko: [
|
|
1260
|
+
"Instagram \uACFC **\uBCC4\uAC1C \uACC4\uC815\xB7\uBCC4\uAC1C \uD1A0\uD070**\uC774\uB2E4 (Threads Graph API).",
|
|
1261
|
+
"\uAE30\uBCF8 \uD750\uB984: `mimi-seed auth threads`\uB97C \uC2E4\uD589\uD558\uBA74 HTTPS \uBE0C\uB85C\uCEE4\uAC00 \uC5EC\uB294 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C Threads \uB85C\uADF8\uC778\xB7\uAD8C\uD55C \uC2B9\uC778\uC744 \uC644\uB8CC\uD55C\uB2E4.",
|
|
1262
|
+
"\uBE0C\uB85C\uCEE4 \uC6B4\uC601\uC790\uB294 Threads App ID/secret\uACFC \uC571\uC5D0 \uB4F1\uB85D\uD55C HTTPS callback URL\uC744 \uC124\uC815\xB7\uBC30\uD3EC\uD574\uC57C \uD55C\uB2E4 (SDK\uAC00 \uBE0C\uB85C\uCEE4\uB97C \uBC30\uD3EC\uD558\uC9C0\uB294 \uC54A\uB294\uB2E4).",
|
|
1263
|
+
"\uD1A0\uD070\uC744 \uC9C1\uC811 \uBD99\uC5EC \uB123\uB294 `--manual-token`\uC740 \uACE0\uAE09/\uD5E4\uB4DC\uB9AC\uC2A4 \uD750\uB984\uC774\uB2E4. \uC800\uC7A5 \uC804\uC5D0 Threads \uACC4\uC815\uC744 \uAC80\uC99D\uD55C\uB2E4.",
|
|
1264
|
+
"`--profile <id>`\uB85C \uC774\uB984 \uC788\uB294 \uACC4\uC815\uC744 \uC800\uC7A5\uD560 \uC218 \uC788\uC73C\uBA70, OAuth \uC751\uB2F5\uC758 \uC2E4\uC81C \uB9CC\uB8CC \uC2DC\uAC01\uC744 \uB85C\uCEEC \uD504\uB85C\uD544\uC5D0 \uAE30\uB85D\uD55C\uB2E4."
|
|
1265
|
+
],
|
|
1266
|
+
en: [
|
|
1267
|
+
"A **separate account and token** from Instagram (Threads Graph API).",
|
|
1268
|
+
"Default: run `mimi-seed auth threads` and finish Threads login and consent in the browser opened by the HTTPS broker.",
|
|
1269
|
+
"The broker operator must deploy it with the Threads App ID/secret and the HTTPS callback URL registered in the app (the SDK does not deploy the broker).",
|
|
1270
|
+
"Pasting a token with `--manual-token` is the advanced/headless path; the Threads account is verified before saving.",
|
|
1271
|
+
"Use `--profile <id>` for a named account; the actual expiry returned by OAuth is saved in the local profile."
|
|
1272
|
+
]
|
|
1273
|
+
},
|
|
1274
|
+
docsAnchor: "threads",
|
|
1275
|
+
detect: (home, startDir) => detectProjectSocialToken(home, startDir, "threads")
|
|
935
1276
|
},
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1277
|
+
{
|
|
1278
|
+
id: "tiktok",
|
|
1279
|
+
label: {
|
|
1280
|
+
ko: "TikTok Business",
|
|
1281
|
+
en: "TikTok Business"
|
|
1282
|
+
},
|
|
1283
|
+
requirement: "optional",
|
|
1284
|
+
group: "marketing",
|
|
1285
|
+
file: "~/.mimi-seed/tiktok-business.json",
|
|
1286
|
+
fix: "mimi-seed auth tiktok",
|
|
1287
|
+
setup: { kind: "mcp-bin", bin: "mimi-seed-tiktok-business-auth" },
|
|
1288
|
+
obtain: {
|
|
1289
|
+
ko: [
|
|
1290
|
+
"TikTok for Business Developer \uC571\uC744 \uB9CC\uB4E4\uACE0 Organic API \uC811\uADFC \uC2B9\uC778\uC744 \uBC1B\uB294\uB2E4.",
|
|
1291
|
+
"TikTok Accounts > Business Content > Video Publish \uAD8C\uD55C\uACFC account holder redirect URL\uC744 \uC124\uC815\uD55C\uB2E4.",
|
|
1292
|
+
"owned Business Account\uB97C \uC2B9\uC778\uD55C callback URL\uC758 auth_code\uB97C \uC5F0\uACB0 \uB9C8\uBC95\uC0AC\uC5D0 \uC785\uB825\uD55C\uB2E4."
|
|
1293
|
+
],
|
|
1294
|
+
en: [
|
|
1295
|
+
"Create a TikTok for Business developer app and obtain Organic API approval.",
|
|
1296
|
+
"Enable TikTok Accounts > Business Content > Video Publish and configure the account-holder redirect URL.",
|
|
1297
|
+
"Authorize the owned Business Account, then paste the callback auth_code into the setup wizard."
|
|
1298
|
+
]
|
|
1299
|
+
},
|
|
1300
|
+
docsAnchor: "tiktok-business",
|
|
1301
|
+
detect: (home) => {
|
|
1302
|
+
const cfg = readJson(
|
|
1303
|
+
home,
|
|
1304
|
+
"tiktok-business.json"
|
|
1305
|
+
);
|
|
1306
|
+
if (!cfg?.openId || !cfg.refreshTokenExpiresAt) return { present: false };
|
|
1307
|
+
const refreshRemaining = Date.parse(cfg.refreshTokenExpiresAt) - Date.now();
|
|
1308
|
+
if (!Number.isFinite(refreshRemaining) || refreshRemaining <= 0) {
|
|
1309
|
+
return { present: true, detail: cfg.openId, freshness: "expired", daysRemaining: 0 };
|
|
1310
|
+
}
|
|
1311
|
+
const accessRemaining = cfg.accessTokenExpiresAt ? Date.parse(cfg.accessTokenExpiresAt) - Date.now() : NaN;
|
|
1312
|
+
const daysRemaining = Math.max(1, Math.ceil(refreshRemaining / 864e5));
|
|
1313
|
+
if (Number.isFinite(accessRemaining) && accessRemaining <= 0) {
|
|
1314
|
+
return { present: true, detail: `${cfg.openId} (access token \uC790\uB3D9 \uAC31\uC2E0 \uC608\uC815)`, freshness: "fresh", daysRemaining };
|
|
1315
|
+
}
|
|
1316
|
+
return { present: true, detail: cfg.openId, freshness: "fresh", daysRemaining };
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
id: "anthropic",
|
|
1321
|
+
label: {
|
|
1322
|
+
ko: "ANTHROPIC_API_KEY",
|
|
1323
|
+
en: "ANTHROPIC_API_KEY"
|
|
1324
|
+
},
|
|
1325
|
+
requirement: "optional",
|
|
1326
|
+
group: "marketing",
|
|
1327
|
+
fix: "export ANTHROPIC_API_KEY=sk-ant-\u2026",
|
|
1328
|
+
setup: { kind: "env", envVar: "ANTHROPIC_API_KEY" },
|
|
1329
|
+
obtain: {
|
|
1330
|
+
ko: [
|
|
1331
|
+
"Anthropic Console (console.anthropic.com) \u2192 API Keys \uC5D0\uC11C \uBC1C\uAE09.",
|
|
1332
|
+
"\uD658\uACBD\uBCC0\uC218\uB85C\uB9CC \uC77D\uB294\uB2E4 \u2014 \uC124\uC815 \uBA85\uB839\uC774 \uB530\uB85C \uC5C6\uB2E4.",
|
|
1333
|
+
"\uC5C6\uC5B4\uB3C4 \uB41C\uB2E4: `mimi-seed notes` \uB294 AI \uC5C6\uC774 \uCEE4\uBC0B \uBAA9\uB85D \uAE30\uBC18\uC73C\uB85C \uB3D9\uC791\uD55C\uB2E4."
|
|
1334
|
+
],
|
|
1335
|
+
en: [
|
|
1336
|
+
"Anthropic Console (console.anthropic.com) \u2192 API Keys.",
|
|
1337
|
+
"Read from the environment only \u2014 there is no setup command.",
|
|
1338
|
+
"Optional: without it, `mimi-seed notes` still works, formatting your commits instead of writing prose."
|
|
1339
|
+
]
|
|
1340
|
+
},
|
|
1341
|
+
docsAnchor: "anthropic-api-key",
|
|
1342
|
+
note: {
|
|
1343
|
+
ko: "\uC120\uD0DD \u2014 AI \uB9B4\uB9AC\uC2A4 \uB178\uD2B8/\uB9AC\uBDF0 \uB2F5\uBCC0 \uC0DD\uC131\uC6A9",
|
|
1344
|
+
en: "optional \u2014 for AI-drafted release notes / review replies"
|
|
1345
|
+
},
|
|
1346
|
+
detect: () => ({ present: Boolean(process.env.ANTHROPIC_API_KEY) })
|
|
944
1347
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1348
|
+
];
|
|
1349
|
+
function tryCredById(id) {
|
|
1350
|
+
return CREDENTIALS.find((c) => c.id === id);
|
|
1351
|
+
}
|
|
1352
|
+
function detectAll(home = os3.homedir(), startDir = process.cwd()) {
|
|
1353
|
+
return new Map(CREDENTIALS.map((c) => [c.id, detectWithFileCheck(c, home, startDir)]));
|
|
1354
|
+
}
|
|
1355
|
+
function credentialFileProblemMessage(displayFile, home = os3.homedir()) {
|
|
1356
|
+
if (!displayFile.startsWith("~/")) return null;
|
|
1357
|
+
const file = path5.join(home, displayFile.slice(2));
|
|
1358
|
+
const read = readJsonFile(file);
|
|
1359
|
+
if (read.state !== "invalid" && read.state !== "locked") return null;
|
|
1360
|
+
const fix = CREDENTIALS.find((spec) => spec.file === displayFile)?.fix ?? "mimi-seed setup";
|
|
1361
|
+
return credentialProblemText(unusable(file, read), fix);
|
|
1362
|
+
}
|
|
1363
|
+
function unusable(file, read) {
|
|
1364
|
+
return read.state === "locked" ? { file, reason: read.reason, locked: true } : { file, reason: read.reason };
|
|
1365
|
+
}
|
|
1366
|
+
function credentialProblemText(invalid, fix) {
|
|
1367
|
+
const m = t().doctor;
|
|
1368
|
+
return invalid.locked ? m.credLocked(invalid.file, invalid.reason, fix) : m.credCorrupt(invalid.file, invalid.reason, fix);
|
|
1369
|
+
}
|
|
1370
|
+
function detectWithFileCheck(spec, home, startDir) {
|
|
1371
|
+
const detected = spec.detect(home, startDir);
|
|
1372
|
+
if (detected.present || detected.invalid || !spec.file?.endsWith(".json") || !spec.file.startsWith("~/")) return detected;
|
|
1373
|
+
const file = path5.join(home, spec.file.slice(2));
|
|
1374
|
+
const read = readJsonFile(file);
|
|
1375
|
+
return read.state === "invalid" || read.state === "locked" ? { ...detected, invalid: unusable(file, read) } : detected;
|
|
1376
|
+
}
|
|
1377
|
+
function isSatisfied(spec, detected) {
|
|
1378
|
+
if (detected.get(spec.id)?.present) return true;
|
|
1379
|
+
return (spec.fallbackOn ?? []).some((f) => detected.get(f)?.present);
|
|
1380
|
+
}
|
|
1381
|
+
function missingRequired(detected, platforms) {
|
|
1382
|
+
return CREDENTIALS.filter((spec) => {
|
|
1383
|
+
if (spec.requirement === "optional") return false;
|
|
1384
|
+
if (spec.requirement === "platform" && !platforms.includes(spec.platform)) return false;
|
|
1385
|
+
return !isSatisfied(spec, detected);
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
var GROUP_ORDER = { core: 0, ci: 1, marketing: 2 };
|
|
1389
|
+
var REQ_ORDER = { required: 0, platform: 1, optional: 2 };
|
|
1390
|
+
function planSetup(detected, opts = {}) {
|
|
1391
|
+
const reconnect = new Set(opts.reconnect ?? []);
|
|
1392
|
+
const only = opts.only ? new Set(opts.only) : null;
|
|
1393
|
+
const platforms = opts.platforms ?? [];
|
|
1394
|
+
return CREDENTIALS.filter((spec) => {
|
|
1395
|
+
if (only && !only.has(spec.id)) return false;
|
|
1396
|
+
if (reconnect.has(spec.id)) return true;
|
|
1397
|
+
const found = detected.get(spec.id);
|
|
1398
|
+
if (found?.freshness === "expired" || found?.freshness === "expiring") return true;
|
|
1399
|
+
if (found?.present) return false;
|
|
1400
|
+
if (spec.requirement === "platform" && platforms.length > 0 && !platforms.includes(spec.platform)) {
|
|
1401
|
+
return false;
|
|
1402
|
+
}
|
|
1403
|
+
return true;
|
|
1404
|
+
}).sort(
|
|
1405
|
+
(a, b) => GROUP_ORDER[a.group] - GROUP_ORDER[b.group] || REQ_ORDER[a.requirement] - REQ_ORDER[b.requirement]
|
|
1406
|
+
);
|
|
949
1407
|
}
|
|
950
1408
|
|
|
1409
|
+
// src/mcp-bin.ts
|
|
1410
|
+
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
1411
|
+
import { existsSync, readFileSync } from "fs";
|
|
1412
|
+
import path7 from "path";
|
|
1413
|
+
import { fileURLToPath } from "url";
|
|
1414
|
+
|
|
951
1415
|
// package.json
|
|
952
|
-
var version = "0.
|
|
1416
|
+
var version = "0.25.1";
|
|
953
1417
|
|
|
954
1418
|
// src/lib/windows-path.ts
|
|
955
|
-
import
|
|
1419
|
+
import path6 from "path";
|
|
956
1420
|
function absoluteWindowsPathDirs(env = process.env) {
|
|
957
1421
|
const key = Object.keys(env).find((k) => k.toLowerCase() === "path");
|
|
958
1422
|
const value = key ? env[key] ?? "" : "";
|
|
959
1423
|
const dirs = [];
|
|
960
1424
|
const flush = (entry) => {
|
|
961
1425
|
const dir = entry.trim();
|
|
962
|
-
if (dir &&
|
|
1426
|
+
if (dir && path6.win32.isAbsolute(dir) && !/^[\\/](?![\\/])/.test(dir)) dirs.push(dir);
|
|
963
1427
|
};
|
|
964
1428
|
let current = "";
|
|
965
1429
|
let quoted = false;
|
|
@@ -984,29 +1448,29 @@ function resolveOnPath(bin, honorForceNpx = true) {
|
|
|
984
1448
|
const names = bin.toLowerCase().endsWith(".cmd") ? [bin] : [`${bin}.cmd`, bin];
|
|
985
1449
|
for (const directory of directories) {
|
|
986
1450
|
for (const name of names) {
|
|
987
|
-
const candidate =
|
|
1451
|
+
const candidate = path7.join(directory, name);
|
|
988
1452
|
if (existsSync(candidate)) return candidate;
|
|
989
1453
|
}
|
|
990
1454
|
}
|
|
991
1455
|
return null;
|
|
992
1456
|
}
|
|
993
1457
|
const probe = "which";
|
|
994
|
-
const result =
|
|
1458
|
+
const result = spawnSync2(probe, [bin], { encoding: "utf8", shell: false });
|
|
995
1459
|
if (result.status !== 0) return null;
|
|
996
1460
|
const candidates = result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
997
1461
|
return candidates[0] ?? null;
|
|
998
1462
|
}
|
|
999
|
-
function resolveWindowsShimTarget(shimPath,
|
|
1000
|
-
const matches = [...
|
|
1463
|
+
function resolveWindowsShimTarget(shimPath, source2) {
|
|
1464
|
+
const matches = [...source2.matchAll(/["']([^"']+\.js)["']\s+%\*/gi)];
|
|
1001
1465
|
const raw = matches.at(-1)?.[1];
|
|
1002
1466
|
if (!raw) return null;
|
|
1003
|
-
return
|
|
1467
|
+
return path7.win32.normalize(raw.replace(/%~?dp0%?/gi, `${path7.win32.dirname(shimPath)}${path7.win32.sep}`));
|
|
1004
1468
|
}
|
|
1005
1469
|
function npxCliPath(shimPath) {
|
|
1006
1470
|
const candidates = [
|
|
1007
|
-
shimPath ?
|
|
1008
|
-
|
|
1009
|
-
process.env.npm_execpath ?
|
|
1471
|
+
shimPath ? path7.join(path7.dirname(shimPath), "node_modules", "npm", "bin", "npx-cli.js") : "",
|
|
1472
|
+
path7.join(path7.dirname(process.execPath), "node_modules", "npm", "bin", "npx-cli.js"),
|
|
1473
|
+
process.env.npm_execpath ? path7.join(path7.dirname(process.env.npm_execpath), "npx-cli.js") : ""
|
|
1010
1474
|
];
|
|
1011
1475
|
return candidates.find((candidate) => candidate && existsSync(candidate)) ?? null;
|
|
1012
1476
|
}
|
|
@@ -1074,14 +1538,197 @@ async function runMcpBin(bin, extraArgs = []) {
|
|
|
1074
1538
|
}
|
|
1075
1539
|
|
|
1076
1540
|
// src/jenkins-config.ts
|
|
1077
|
-
import
|
|
1078
|
-
import
|
|
1079
|
-
import
|
|
1541
|
+
import fs7 from "fs";
|
|
1542
|
+
import os5 from "os";
|
|
1543
|
+
import path10 from "path";
|
|
1080
1544
|
|
|
1081
1545
|
// ../core/src/atomic-write.ts
|
|
1082
1546
|
import { chmodSync, mkdirSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
1083
|
-
import { randomUUID } from "crypto";
|
|
1084
|
-
import
|
|
1547
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
1548
|
+
import path9 from "path";
|
|
1549
|
+
|
|
1550
|
+
// ../core/src/credential-store.ts
|
|
1551
|
+
import fs6 from "fs";
|
|
1552
|
+
import os4 from "os";
|
|
1553
|
+
import path8 from "path";
|
|
1554
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1555
|
+
var CREDENTIAL_STORE_ENV = "MIMI_SEED_CREDENTIAL_STORE";
|
|
1556
|
+
var DATA_KEY_ID_FILE = ".data-key.id";
|
|
1557
|
+
var M2 = catalog(
|
|
1558
|
+
{
|
|
1559
|
+
noStore: (backend, why) => `\uC790\uACA9\uC99D\uBA85 \uC554\uD638\uD654(keychain \uBAA8\uB4DC)\uC5D0 \uD544\uC694\uD55C ${backend}\uC5D0 \uB2FF\uC9C0 \uBABB\uD574 \uC800\uC7A5\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4: ${why}. \uD0A4\uCCB4\uC778\uC744 \uC7A0\uAE08 \uD574\uC81C\uD558\uAC70\uB098, \uC774 \uCEF4\uD4E8\uD130\uC5D0\uC11C \uC554\uD638\uD654\uB97C \uB044\uB824\uBA74 mimi-seed credentials mode file`
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
noStore: (backend, why) => `Not saved: credential encryption (keychain mode) needs ${backend}, which could not be reached: ${why}. Unlock the keychain, or turn encryption off on this machine with mimi-seed credentials mode file`
|
|
1563
|
+
}
|
|
1564
|
+
);
|
|
1565
|
+
function isCredentialStoreMode(value) {
|
|
1566
|
+
return value === "file" || value === "keychain" || value === "auto";
|
|
1567
|
+
}
|
|
1568
|
+
function configuredStoreMode(home = os4.homedir()) {
|
|
1569
|
+
return explicitStoreMode(home) ?? "file";
|
|
1570
|
+
}
|
|
1571
|
+
function explicitStoreMode(home = os4.homedir()) {
|
|
1572
|
+
const env = process.env[CREDENTIAL_STORE_ENV]?.trim().toLowerCase();
|
|
1573
|
+
if (isCredentialStoreMode(env)) return env;
|
|
1574
|
+
try {
|
|
1575
|
+
const saved = JSON.parse(fs6.readFileSync(path8.join(home, ".mimi-seed", "settings.json"), "utf-8"))?.credentialStore;
|
|
1576
|
+
if (isCredentialStoreMode(saved)) return saved;
|
|
1577
|
+
} catch {
|
|
1578
|
+
}
|
|
1579
|
+
return null;
|
|
1580
|
+
}
|
|
1581
|
+
function recordedKeyId(home = os4.homedir()) {
|
|
1582
|
+
try {
|
|
1583
|
+
const kid = fs6.readFileSync(path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE), "utf-8").trim();
|
|
1584
|
+
return /^[0-9a-f]{16}$/.test(kid) ? kid : null;
|
|
1585
|
+
} catch {
|
|
1586
|
+
return null;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
function effectiveStoreMode(home = os4.homedir()) {
|
|
1590
|
+
const explicit = explicitStoreMode(home);
|
|
1591
|
+
if (recordedKeyId(home) && (explicit === null || explicit === "auto")) return "keychain";
|
|
1592
|
+
return explicit ?? "file";
|
|
1593
|
+
}
|
|
1594
|
+
var IN_SCOPE_FILES = /* @__PURE__ */ new Set([
|
|
1595
|
+
"tokens.json",
|
|
1596
|
+
"credentials.json",
|
|
1597
|
+
"appstore.json",
|
|
1598
|
+
"play-service-account.json",
|
|
1599
|
+
"bigquery-service-account.json",
|
|
1600
|
+
"drive-service-account.json",
|
|
1601
|
+
"facebook.json",
|
|
1602
|
+
"instagram.json",
|
|
1603
|
+
"threads.json",
|
|
1604
|
+
"tiktok-business.json",
|
|
1605
|
+
"google-ads.json",
|
|
1606
|
+
"jenkins.json",
|
|
1607
|
+
"ci.json",
|
|
1608
|
+
"config.json"
|
|
1609
|
+
]);
|
|
1610
|
+
var IN_SCOPE_DIRS = /* @__PURE__ */ new Set(["google-profiles", "play-service-accounts", "social-profiles"]);
|
|
1611
|
+
function isEncryptableCredential(aad) {
|
|
1612
|
+
if (!aad) return false;
|
|
1613
|
+
const parts = aad.split("/");
|
|
1614
|
+
if (parts.length === 1) return IN_SCOPE_FILES.has(parts[0]);
|
|
1615
|
+
return parts.length === 2 && IN_SCOPE_DIRS.has(parts[0]) && parts[1].endsWith(".json");
|
|
1616
|
+
}
|
|
1617
|
+
function writeKeyIdMarker(home, kid) {
|
|
1618
|
+
const file = path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE);
|
|
1619
|
+
if (recordedKeyId(home) === kid) return;
|
|
1620
|
+
const temp = `${file}.${process.pid}.${randomUUID2()}.tmp`;
|
|
1621
|
+
fs6.mkdirSync(path8.dirname(file), { recursive: true, mode: 448 });
|
|
1622
|
+
try {
|
|
1623
|
+
fs6.writeFileSync(temp, `${kid}
|
|
1624
|
+
`, { mode: 384 });
|
|
1625
|
+
fs6.renameSync(temp, file);
|
|
1626
|
+
} finally {
|
|
1627
|
+
fs6.rmSync(temp, { force: true });
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
function sealForWrite(filePath, contents) {
|
|
1631
|
+
if (typeof contents !== "string") return contents;
|
|
1632
|
+
const aad = credentialAad(filePath);
|
|
1633
|
+
if (aad === null || !isEncryptableCredential(aad)) return contents;
|
|
1634
|
+
const home = path8.resolve(filePath, ...aad.split("/").map(() => ".."), "..");
|
|
1635
|
+
const mode = effectiveStoreMode(home);
|
|
1636
|
+
if (mode === "file") return contents;
|
|
1637
|
+
const key = obtainDataKey();
|
|
1638
|
+
if (key.state !== "ok") {
|
|
1639
|
+
if (mode === "auto") return contents;
|
|
1640
|
+
throw new Error(M2().noStore(key.backend, key.state === "unavailable" ? key.reason : "no key"));
|
|
1641
|
+
}
|
|
1642
|
+
writeKeyIdMarker(home, keyId(key.key));
|
|
1643
|
+
return `${JSON.stringify(sealCredential(contents, key.key, aad), null, 2)}
|
|
1644
|
+
`;
|
|
1645
|
+
}
|
|
1646
|
+
function listCredentialFiles(home = os4.homedir()) {
|
|
1647
|
+
const root = path8.join(home, ".mimi-seed");
|
|
1648
|
+
const out = [];
|
|
1649
|
+
const isFile = (file) => {
|
|
1650
|
+
try {
|
|
1651
|
+
return fs6.statSync(file).isFile();
|
|
1652
|
+
} catch {
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
for (const name of IN_SCOPE_FILES) {
|
|
1657
|
+
const file = path8.join(root, name);
|
|
1658
|
+
if (isFile(file)) out.push(file);
|
|
1659
|
+
}
|
|
1660
|
+
for (const dir of IN_SCOPE_DIRS) {
|
|
1661
|
+
let names;
|
|
1662
|
+
try {
|
|
1663
|
+
names = fs6.readdirSync(path8.join(root, dir));
|
|
1664
|
+
} catch {
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
for (const name of names.sort()) {
|
|
1668
|
+
const file = path8.join(root, dir, name);
|
|
1669
|
+
if (name.endsWith(".json") && isFile(file)) out.push(file);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
return out;
|
|
1673
|
+
}
|
|
1674
|
+
function isEnvelopeText(text) {
|
|
1675
|
+
if (!text.includes('"mimiSeedEncrypted"')) return false;
|
|
1676
|
+
try {
|
|
1677
|
+
const parsed = JSON.parse(text);
|
|
1678
|
+
return typeof parsed === "object" && parsed !== null && Object.prototype.hasOwnProperty.call(parsed, "mimiSeedEncrypted");
|
|
1679
|
+
} catch {
|
|
1680
|
+
return false;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
function credentialStoreReport(home = os4.homedir()) {
|
|
1684
|
+
const files = listCredentialFiles(home).map((file) => {
|
|
1685
|
+
let text;
|
|
1686
|
+
try {
|
|
1687
|
+
text = fs6.readFileSync(file, "utf-8");
|
|
1688
|
+
} catch (error) {
|
|
1689
|
+
return { file, state: "invalid", reason: error.code ?? "read" };
|
|
1690
|
+
}
|
|
1691
|
+
if (!isEnvelopeText(text)) return { file, state: "plaintext" };
|
|
1692
|
+
const read = decodeCredentialText(file, text);
|
|
1693
|
+
if (read.state === "ok") return { file, state: "encrypted" };
|
|
1694
|
+
if (read.state === "locked") return { file, state: "locked", reason: read.reason };
|
|
1695
|
+
return { file, state: "invalid", reason: read.state === "invalid" ? read.reason : void 0 };
|
|
1696
|
+
});
|
|
1697
|
+
return {
|
|
1698
|
+
configured: configuredStoreMode(home),
|
|
1699
|
+
effective: effectiveStoreMode(home),
|
|
1700
|
+
explicit: explicitStoreMode(home) !== null,
|
|
1701
|
+
keyId: recordedKeyId(home),
|
|
1702
|
+
files
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
function rewriteCredentialFiles(target, write, home = os4.homedir()) {
|
|
1706
|
+
const result = { converted: [], skipped: [] };
|
|
1707
|
+
for (const file of listCredentialFiles(home)) {
|
|
1708
|
+
let raw;
|
|
1709
|
+
try {
|
|
1710
|
+
raw = fs6.readFileSync(file, "utf-8");
|
|
1711
|
+
} catch (error) {
|
|
1712
|
+
result.skipped.push({ file, reason: error.code ?? "read" });
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
const envelope = isEnvelopeText(raw);
|
|
1716
|
+
if (target === "encrypted" === envelope) continue;
|
|
1717
|
+
const read = decodeCredentialText(file, raw);
|
|
1718
|
+
if (read.state !== "ok") {
|
|
1719
|
+
result.skipped.push({ file, reason: read.state === "missing" ? "missing" : read.reason });
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1722
|
+
write(file, read.text);
|
|
1723
|
+
result.converted.push(file);
|
|
1724
|
+
}
|
|
1725
|
+
return result;
|
|
1726
|
+
}
|
|
1727
|
+
function clearKeyIdMarker(home = os4.homedir()) {
|
|
1728
|
+
fs6.rmSync(path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE), { force: true });
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// ../core/src/atomic-write.ts
|
|
1085
1732
|
var CREDENTIAL_FILE_MODE = 384;
|
|
1086
1733
|
var CREDENTIAL_DIR_MODE = 448;
|
|
1087
1734
|
var RENAME_RETRY_DELAYS_MS = [10, 20, 40, 80, 160, 320, 370];
|
|
@@ -1104,8 +1751,8 @@ function renameWithRetry(from, to, deps = {}) {
|
|
|
1104
1751
|
}
|
|
1105
1752
|
}
|
|
1106
1753
|
function writeFileAtomic(filePath, contents, options = {}) {
|
|
1107
|
-
mkdirSync(
|
|
1108
|
-
const tempPath = `${filePath}.${process.pid}.${
|
|
1754
|
+
mkdirSync(path9.dirname(filePath), { recursive: true, ...options.dirMode !== void 0 && { mode: options.dirMode } });
|
|
1755
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID3()}.tmp`;
|
|
1109
1756
|
try {
|
|
1110
1757
|
writeFileSync(tempPath, contents, {
|
|
1111
1758
|
encoding: "utf8",
|
|
@@ -1126,29 +1773,33 @@ function writeJsonAtomic(filePath, value, options = {}) {
|
|
|
1126
1773
|
`, options);
|
|
1127
1774
|
}
|
|
1128
1775
|
function writeCredentialJson(filePath, value) {
|
|
1129
|
-
|
|
1776
|
+
writeCredentialFile(filePath, `${JSON.stringify(value, null, 2)}
|
|
1777
|
+
`);
|
|
1778
|
+
}
|
|
1779
|
+
function writeCredentialFile(filePath, contents) {
|
|
1780
|
+
writeFileAtomic(filePath, sealForWrite(filePath, contents), { mode: CREDENTIAL_FILE_MODE, dirMode: CREDENTIAL_DIR_MODE });
|
|
1130
1781
|
}
|
|
1131
1782
|
|
|
1132
1783
|
// src/jenkins-config.ts
|
|
1133
|
-
var CONFIG_DIR =
|
|
1134
|
-
var JENKINS_PATH =
|
|
1135
|
-
var LEGACY_PATH =
|
|
1136
|
-
function loadJenkinsConfig(home =
|
|
1784
|
+
var CONFIG_DIR = path10.join(os5.homedir(), ".mimi-seed");
|
|
1785
|
+
var JENKINS_PATH = path10.join(CONFIG_DIR, "jenkins.json");
|
|
1786
|
+
var LEGACY_PATH = path10.join(CONFIG_DIR, "config.json");
|
|
1787
|
+
function loadJenkinsConfig(home = os5.homedir()) {
|
|
1137
1788
|
try {
|
|
1138
|
-
const p =
|
|
1139
|
-
return JSON.parse(
|
|
1789
|
+
const p = path10.join(home, ".mimi-seed", "jenkins.json");
|
|
1790
|
+
return JSON.parse(readCredentialFileSync(p));
|
|
1140
1791
|
} catch {
|
|
1141
1792
|
return null;
|
|
1142
1793
|
}
|
|
1143
1794
|
}
|
|
1144
|
-
function migrateLegacyJenkins(home =
|
|
1145
|
-
const dir =
|
|
1146
|
-
const jenkinsPath =
|
|
1147
|
-
const legacyPath =
|
|
1148
|
-
if (
|
|
1795
|
+
function migrateLegacyJenkins(home = os5.homedir()) {
|
|
1796
|
+
const dir = path10.join(home, ".mimi-seed");
|
|
1797
|
+
const jenkinsPath = path10.join(dir, "jenkins.json");
|
|
1798
|
+
const legacyPath = path10.join(dir, "config.json");
|
|
1799
|
+
if (fs7.existsSync(jenkinsPath)) return false;
|
|
1149
1800
|
let legacy;
|
|
1150
1801
|
try {
|
|
1151
|
-
legacy = JSON.parse(
|
|
1802
|
+
legacy = JSON.parse(readCredentialFileSync(legacyPath));
|
|
1152
1803
|
} catch {
|
|
1153
1804
|
return false;
|
|
1154
1805
|
}
|
|
@@ -1169,18 +1820,18 @@ function migrateLegacyJenkins(home = os3.homedir()) {
|
|
|
1169
1820
|
}
|
|
1170
1821
|
|
|
1171
1822
|
// src/detect.ts
|
|
1172
|
-
import
|
|
1173
|
-
import
|
|
1823
|
+
import fs8 from "fs/promises";
|
|
1824
|
+
import path11 from "path";
|
|
1174
1825
|
async function readIfExists(p) {
|
|
1175
1826
|
try {
|
|
1176
|
-
return await
|
|
1827
|
+
return await fs8.readFile(p, "utf8");
|
|
1177
1828
|
} catch {
|
|
1178
1829
|
return null;
|
|
1179
1830
|
}
|
|
1180
1831
|
}
|
|
1181
1832
|
async function pathExists(p) {
|
|
1182
1833
|
try {
|
|
1183
|
-
await
|
|
1834
|
+
await fs8.access(p);
|
|
1184
1835
|
return true;
|
|
1185
1836
|
} catch {
|
|
1186
1837
|
return false;
|
|
@@ -1194,9 +1845,9 @@ async function importedJsonObjects(configPath, text, root) {
|
|
|
1194
1845
|
];
|
|
1195
1846
|
for (const match of imports) {
|
|
1196
1847
|
if (!match[2].startsWith(".")) continue;
|
|
1197
|
-
const candidate =
|
|
1198
|
-
const relative =
|
|
1199
|
-
if (relative.startsWith(`..${
|
|
1848
|
+
const candidate = path11.resolve(path11.dirname(configPath), match[2]);
|
|
1849
|
+
const relative = path11.relative(root, candidate);
|
|
1850
|
+
if (relative.startsWith(`..${path11.sep}`) || relative === ".." || path11.isAbsolute(relative)) continue;
|
|
1200
1851
|
const jsonText = await readIfExists(candidate);
|
|
1201
1852
|
if (!jsonText) continue;
|
|
1202
1853
|
try {
|
|
@@ -1233,16 +1884,16 @@ async function walk(root, match, maxDepth = 5) {
|
|
|
1233
1884
|
if (depth > maxDepth) return;
|
|
1234
1885
|
let entries;
|
|
1235
1886
|
try {
|
|
1236
|
-
entries = await
|
|
1887
|
+
entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
1237
1888
|
} catch {
|
|
1238
1889
|
return;
|
|
1239
1890
|
}
|
|
1240
1891
|
for (const e of entries) {
|
|
1241
1892
|
if (e.isDirectory()) {
|
|
1242
1893
|
if (skipDirs.has(e.name)) continue;
|
|
1243
|
-
await visit(
|
|
1894
|
+
await visit(path11.join(dir, e.name), depth + 1);
|
|
1244
1895
|
} else if (e.isFile() && match(e.name)) {
|
|
1245
|
-
found.push(
|
|
1896
|
+
found.push(path11.join(dir, e.name));
|
|
1246
1897
|
}
|
|
1247
1898
|
}
|
|
1248
1899
|
}
|
|
@@ -1252,7 +1903,7 @@ async function walk(root, match, maxDepth = 5) {
|
|
|
1252
1903
|
async function detectHints(cwd) {
|
|
1253
1904
|
const hints = [];
|
|
1254
1905
|
for (const fname of ["app.json", "app.config.json"]) {
|
|
1255
|
-
const txt = await readIfExists(
|
|
1906
|
+
const txt = await readIfExists(path11.join(cwd, fname));
|
|
1256
1907
|
if (!txt) continue;
|
|
1257
1908
|
try {
|
|
1258
1909
|
const json = JSON.parse(txt);
|
|
@@ -1272,7 +1923,7 @@ async function detectHints(cwd) {
|
|
|
1272
1923
|
}
|
|
1273
1924
|
}
|
|
1274
1925
|
for (const fname of ["app.config.js", "app.config.cjs", "app.config.mjs", "app.config.ts"]) {
|
|
1275
|
-
const configPath =
|
|
1926
|
+
const configPath = path11.join(cwd, fname);
|
|
1276
1927
|
const txt = await readIfExists(configPath);
|
|
1277
1928
|
if (!txt) continue;
|
|
1278
1929
|
const imports = await importedJsonObjects(configPath, txt, cwd);
|
|
@@ -1294,7 +1945,7 @@ async function detectHints(cwd) {
|
|
|
1294
1945
|
if (m?.[1]) {
|
|
1295
1946
|
const pkg = m[1];
|
|
1296
1947
|
if (!hints.some((h) => h.packageName === pkg)) {
|
|
1297
|
-
hints.push({ packageName: pkg, source: [
|
|
1948
|
+
hints.push({ packageName: pkg, source: [path11.relative(cwd, f)] });
|
|
1298
1949
|
}
|
|
1299
1950
|
}
|
|
1300
1951
|
}
|
|
@@ -1309,7 +1960,7 @@ async function detectHints(cwd) {
|
|
|
1309
1960
|
const bid = m[1];
|
|
1310
1961
|
if (bid.includes("$(PRODUCT_BUNDLE_IDENTIFIER)")) continue;
|
|
1311
1962
|
if (!hints.some((h) => h.bundleId === bid)) {
|
|
1312
|
-
hints.push({ bundleId: bid, source: [
|
|
1963
|
+
hints.push({ bundleId: bid, source: [path11.relative(cwd, f)] });
|
|
1313
1964
|
}
|
|
1314
1965
|
}
|
|
1315
1966
|
}
|
|
@@ -1322,11 +1973,11 @@ async function detectHints(cwd) {
|
|
|
1322
1973
|
const bid = m[1].trim().replace(/^["']|["']$/g, "");
|
|
1323
1974
|
if (!bid || bid.includes("$")) continue;
|
|
1324
1975
|
if (!hints.some((h) => h.bundleId === bid)) {
|
|
1325
|
-
hints.push({ bundleId: bid, source: [
|
|
1976
|
+
hints.push({ bundleId: bid, source: [path11.relative(cwd, f)] });
|
|
1326
1977
|
}
|
|
1327
1978
|
}
|
|
1328
1979
|
}
|
|
1329
|
-
const unitySettings =
|
|
1980
|
+
const unitySettings = path11.join(cwd, "ProjectSettings", "ProjectSettings.asset");
|
|
1330
1981
|
const unityText = await readIfExists(unitySettings);
|
|
1331
1982
|
if (unityText) {
|
|
1332
1983
|
const lines = unityText.split(/\r?\n/);
|
|
@@ -1350,11 +2001,11 @@ async function detectHints(cwd) {
|
|
|
1350
2001
|
name,
|
|
1351
2002
|
packageName,
|
|
1352
2003
|
bundleId,
|
|
1353
|
-
source: [
|
|
2004
|
+
source: [path11.relative(cwd, unitySettings)]
|
|
1354
2005
|
});
|
|
1355
2006
|
}
|
|
1356
2007
|
}
|
|
1357
|
-
const pkgJson = await readIfExists(
|
|
2008
|
+
const pkgJson = await readIfExists(path11.join(cwd, "package.json"));
|
|
1358
2009
|
if (pkgJson) {
|
|
1359
2010
|
try {
|
|
1360
2011
|
const json = JSON.parse(pkgJson);
|
|
@@ -1390,23 +2041,23 @@ async function detectHints(cwd) {
|
|
|
1390
2041
|
return merged.filter((h) => h.packageName || h.bundleId);
|
|
1391
2042
|
}
|
|
1392
2043
|
async function hasAnyProjectSignal(cwd) {
|
|
1393
|
-
return await pathExists(
|
|
2044
|
+
return await pathExists(path11.join(cwd, "package.json")) || await pathExists(path11.join(cwd, "app.json")) || await pathExists(path11.join(cwd, "android")) || await pathExists(path11.join(cwd, "ios")) || await pathExists(path11.join(cwd, "ProjectSettings", "ProjectSettings.asset"));
|
|
1394
2045
|
}
|
|
1395
2046
|
|
|
1396
2047
|
// src/deploy.ts
|
|
1397
2048
|
import kleur from "kleur";
|
|
1398
2049
|
import * as readline from "readline";
|
|
1399
|
-
import { randomUUID as
|
|
2050
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
1400
2051
|
|
|
1401
2052
|
// src/config.ts
|
|
1402
|
-
import
|
|
1403
|
-
import
|
|
1404
|
-
import
|
|
1405
|
-
var CONFIG_DIR2 =
|
|
1406
|
-
var CONFIG_PATH =
|
|
2053
|
+
import fs9 from "fs/promises";
|
|
2054
|
+
import path12 from "path";
|
|
2055
|
+
import os6 from "os";
|
|
2056
|
+
var CONFIG_DIR2 = path12.join(os6.homedir(), ".mimi-seed");
|
|
2057
|
+
var CONFIG_PATH = path12.join(CONFIG_DIR2, "config.json");
|
|
1407
2058
|
async function readConfig() {
|
|
1408
2059
|
try {
|
|
1409
|
-
const txt = await
|
|
2060
|
+
const txt = await readCredentialFile(CONFIG_PATH);
|
|
1410
2061
|
return JSON.parse(txt);
|
|
1411
2062
|
} catch {
|
|
1412
2063
|
return null;
|
|
@@ -1416,7 +2067,7 @@ async function writeConfig(cfg) {
|
|
|
1416
2067
|
writeCredentialJson(CONFIG_PATH, cfg);
|
|
1417
2068
|
}
|
|
1418
2069
|
async function deleteConfig() {
|
|
1419
|
-
await
|
|
2070
|
+
await fs9.rm(CONFIG_PATH, { force: true });
|
|
1420
2071
|
}
|
|
1421
2072
|
var CONFIG_LOCATION = CONFIG_PATH;
|
|
1422
2073
|
async function getEffectiveConfig() {
|
|
@@ -1526,8 +2177,8 @@ async function consumeDeployStream(reader, onEvent) {
|
|
|
1526
2177
|
}
|
|
1527
2178
|
|
|
1528
2179
|
// src/project-link.ts
|
|
1529
|
-
import
|
|
1530
|
-
import
|
|
2180
|
+
import fs10 from "fs/promises";
|
|
2181
|
+
import path13 from "path";
|
|
1531
2182
|
|
|
1532
2183
|
// ../core/src/http-errors.ts
|
|
1533
2184
|
function endpointLabel(input, fallback) {
|
|
@@ -1546,7 +2197,7 @@ function isTimeoutAbort(error) {
|
|
|
1546
2197
|
// src/lib/http.ts
|
|
1547
2198
|
var HTTP_TIMEOUT_MS = 3e4;
|
|
1548
2199
|
var HTTP_STREAM_TIMEOUT_MS = 30 * 6e4;
|
|
1549
|
-
var
|
|
2200
|
+
var M3 = catalog(
|
|
1550
2201
|
{
|
|
1551
2202
|
timedOut: (endpoint, seconds) => `${endpoint} \uC694\uCCAD\uC774 ${seconds}\uCD08 \uC548\uC5D0 \uB05D\uB098\uC9C0 \uC54A\uC544 \uC911\uB2E8\uD588\uC2B5\uB2C8\uB2E4. \uB124\uD2B8\uC6CC\uD06C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uACE0 \uB2E4\uC2DC \uC2DC\uB3C4\uD558\uC138\uC694.`,
|
|
1552
2203
|
unknownEndpoint: "\uC678\uBD80 \uC11C\uBC84"
|
|
@@ -1556,7 +2207,7 @@ var M2 = catalog(
|
|
|
1556
2207
|
unknownEndpoint: "the remote server"
|
|
1557
2208
|
}
|
|
1558
2209
|
);
|
|
1559
|
-
var endpointLabel2 = (input) => endpointLabel(input,
|
|
2210
|
+
var endpointLabel2 = (input) => endpointLabel(input, M3().unknownEndpoint);
|
|
1560
2211
|
function isBodyAbort(error) {
|
|
1561
2212
|
const named = (e) => {
|
|
1562
2213
|
const name = e?.name;
|
|
@@ -1565,7 +2216,7 @@ function isBodyAbort(error) {
|
|
|
1565
2216
|
return named(error) || named(error?.cause);
|
|
1566
2217
|
}
|
|
1567
2218
|
function timeoutError(input, timeoutMs, cause) {
|
|
1568
|
-
return new Error(
|
|
2219
|
+
return new Error(M3().timedOut(endpointLabel2(input), Math.max(1, Math.round(timeoutMs / 1e3))), { cause });
|
|
1569
2220
|
}
|
|
1570
2221
|
async function readBodyWithTimeout(input, timeoutMs, read) {
|
|
1571
2222
|
try {
|
|
@@ -1587,7 +2238,7 @@ async function fetchWithTimeout(input, init = {}, timeoutMs = HTTP_TIMEOUT_MS) {
|
|
|
1587
2238
|
|
|
1588
2239
|
// src/project-link.ts
|
|
1589
2240
|
var PROJECT_LINK_FILENAME = ".mimi-seed-link.json";
|
|
1590
|
-
var
|
|
2241
|
+
var M4 = catalog({
|
|
1591
2242
|
lookupFailed: (status) => `\uD504\uB85C\uC81D\uD2B8 \uC571 \uC5F0\uACB0 \uC870\uD68C \uC2E4\uD328 (${status}). --app <id>\uB85C \uC9C0\uC815\uD558\uC138\uC694.`,
|
|
1592
2243
|
invalidResponse: "\uD504\uB85C\uC81D\uD2B8 \uC571 \uC5F0\uACB0 \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
1593
2244
|
mismatch: "\uC800\uC7A5\uB41C \uD504\uB85C\uC81D\uD2B8 \uC571 \uC5F0\uACB0\uC774 \uD604\uC7AC \uACC4\uC815\xB7\uC571\uACFC \uB2E4\uB985\uB2C8\uB2E4. \uC5F0\uACB0 \uD30C\uC77C\uC744 \uD655\uC778\uD558\uC138\uC694.",
|
|
@@ -1607,17 +2258,17 @@ function isLink(value) {
|
|
|
1607
2258
|
return link.schema === 1 && typeof link.webBase === "string" && !!link.webBase && typeof link.appId === "string" && !!link.appId && (link.packageName === void 0 || typeof link.packageName === "string") && (link.bundleId === void 0 || typeof link.bundleId === "string");
|
|
1608
2259
|
}
|
|
1609
2260
|
async function findProjectLink(cwd) {
|
|
1610
|
-
let dir =
|
|
2261
|
+
let dir = path13.resolve(cwd);
|
|
1611
2262
|
for (let depth = 0; depth <= 8; depth++) {
|
|
1612
|
-
const file =
|
|
2263
|
+
const file = path13.join(dir, PROJECT_LINK_FILENAME);
|
|
1613
2264
|
try {
|
|
1614
|
-
const parsed = JSON.parse(await
|
|
1615
|
-
if (!isLink(parsed)) throw new Error(
|
|
2265
|
+
const parsed = JSON.parse(await fs10.readFile(file, "utf8"));
|
|
2266
|
+
if (!isLink(parsed)) throw new Error(M4().invalidFile);
|
|
1616
2267
|
return parsed;
|
|
1617
2268
|
} catch (error) {
|
|
1618
2269
|
if (error.code !== "ENOENT") throw error;
|
|
1619
2270
|
}
|
|
1620
|
-
const parent =
|
|
2271
|
+
const parent = path13.dirname(dir);
|
|
1621
2272
|
if (parent === dir) break;
|
|
1622
2273
|
dir = parent;
|
|
1623
2274
|
}
|
|
@@ -1626,14 +2277,14 @@ async function findProjectLink(cwd) {
|
|
|
1626
2277
|
function resolveLinkedAppId(link, webBase, explicitAppId) {
|
|
1627
2278
|
if (!link) return explicitAppId;
|
|
1628
2279
|
if (base(link.webBase) !== base(webBase) || explicitAppId && explicitAppId !== link.appId) {
|
|
1629
|
-
throw new Error(
|
|
2280
|
+
throw new Error(M4().mismatch);
|
|
1630
2281
|
}
|
|
1631
2282
|
return link.appId;
|
|
1632
2283
|
}
|
|
1633
2284
|
function validateProjectIdentity(link, hints) {
|
|
1634
2285
|
if (!link || hints.length === 0) return;
|
|
1635
2286
|
if (!hints.every((hint) => (!hint.packageName || hint.packageName === link.packageName) && (!hint.bundleId || hint.bundleId === link.bundleId))) {
|
|
1636
|
-
throw new Error(
|
|
2287
|
+
throw new Error(M4().mismatch);
|
|
1637
2288
|
}
|
|
1638
2289
|
}
|
|
1639
2290
|
async function linkProject(cwd, webBase, token, hint) {
|
|
@@ -1642,11 +2293,11 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1642
2293
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
1643
2294
|
body: JSON.stringify({ packageName: hint.packageName, bundleId: hint.bundleId })
|
|
1644
2295
|
});
|
|
1645
|
-
if (!res.ok) throw new Error(
|
|
2296
|
+
if (!res.ok) throw new Error(M4().lookupFailed(res.status));
|
|
1646
2297
|
const value = await res.json();
|
|
1647
2298
|
const app = value && typeof value === "object" && "app" in value ? value.app : null;
|
|
1648
2299
|
if (!app || typeof app !== "object" || !("id" in app) || typeof app.id !== "string" || !app.id || hint.packageName && (!("packageName" in app) || app.packageName !== hint.packageName) || hint.bundleId && (!("bundleId" in app) || app.bundleId !== hint.bundleId)) {
|
|
1649
|
-
throw new Error(
|
|
2300
|
+
throw new Error(M4().invalidResponse);
|
|
1650
2301
|
}
|
|
1651
2302
|
const link = {
|
|
1652
2303
|
schema: 1,
|
|
@@ -1657,19 +2308,19 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1657
2308
|
};
|
|
1658
2309
|
const existing = await findProjectLink(cwd);
|
|
1659
2310
|
if (existing && (existing.appId !== link.appId || base(existing.webBase) !== link.webBase || existing.packageName !== link.packageName || existing.bundleId !== link.bundleId)) {
|
|
1660
|
-
throw new Error(
|
|
2311
|
+
throw new Error(M4().mismatch);
|
|
1661
2312
|
}
|
|
1662
2313
|
if (!existing) {
|
|
1663
|
-
await
|
|
2314
|
+
await fs10.writeFile(path13.join(cwd, PROJECT_LINK_FILENAME), `${JSON.stringify(link, null, 2)}
|
|
1664
2315
|
`, { mode: 384, flag: "wx" });
|
|
1665
2316
|
}
|
|
1666
|
-
const ignorePath =
|
|
1667
|
-
const ignore = await
|
|
2317
|
+
const ignorePath = path13.join(cwd, ".gitignore");
|
|
2318
|
+
const ignore = await fs10.readFile(ignorePath, "utf8").catch((error) => {
|
|
1668
2319
|
if (error.code !== "ENOENT") throw error;
|
|
1669
2320
|
return "";
|
|
1670
2321
|
});
|
|
1671
2322
|
if (!ignore.split(/\r?\n/).includes(PROJECT_LINK_FILENAME)) {
|
|
1672
|
-
await
|
|
2323
|
+
await fs10.appendFile(ignorePath, `${ignore && !ignore.endsWith("\n") ? "\n" : ""}${PROJECT_LINK_FILENAME}
|
|
1673
2324
|
`);
|
|
1674
2325
|
}
|
|
1675
2326
|
return link;
|
|
@@ -1677,13 +2328,13 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1677
2328
|
|
|
1678
2329
|
// src/deploy-runs.ts
|
|
1679
2330
|
function parseRun(value) {
|
|
1680
|
-
if (!value || typeof value !== "object") throw new Error(
|
|
1681
|
-
const
|
|
1682
|
-
const jobId =
|
|
1683
|
-
if (typeof jobId !== "string" || !jobId || typeof
|
|
1684
|
-
throw new Error(
|
|
2331
|
+
if (!value || typeof value !== "object") throw new Error(M5().invalidResponse);
|
|
2332
|
+
const run2 = value;
|
|
2333
|
+
const jobId = run2.jobId ?? run2.id;
|
|
2334
|
+
if (typeof jobId !== "string" || !jobId || typeof run2.appId !== "string" || !run2.appId || run2.platform !== "android" && run2.platform !== "ios" || typeof run2.status !== "string" || run2.versionCode != null && (!Number.isSafeInteger(run2.versionCode) || run2.versionCode < 1) || run2.jenkinsBuildNumber != null && (!Number.isSafeInteger(run2.jenkinsBuildNumber) || run2.jenkinsBuildNumber < 1) || run2.fromRef != null && typeof run2.fromRef !== "string" || run2.toRef != null && typeof run2.toRef !== "string") {
|
|
2335
|
+
throw new Error(M5().invalidResponse);
|
|
1685
2336
|
}
|
|
1686
|
-
return { ...
|
|
2337
|
+
return { ...run2, jobId };
|
|
1687
2338
|
}
|
|
1688
2339
|
async function updateDeployRun(webBase, token, request) {
|
|
1689
2340
|
const res = await fetchWithTimeout(new URL("/api/deploy/runs", webBase), {
|
|
@@ -1691,7 +2342,7 @@ async function updateDeployRun(webBase, token, request) {
|
|
|
1691
2342
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
1692
2343
|
body: JSON.stringify(request)
|
|
1693
2344
|
});
|
|
1694
|
-
if (!res.ok) throw new Error(
|
|
2345
|
+
if (!res.ok) throw new Error(M5().updateFailed(res.status));
|
|
1695
2346
|
return parseRun(await res.json());
|
|
1696
2347
|
}
|
|
1697
2348
|
async function getDeployRun(webBase, token, runId) {
|
|
@@ -1700,10 +2351,10 @@ async function getDeployRun(webBase, token, runId) {
|
|
|
1700
2351
|
const res = await fetchWithTimeout(url, {
|
|
1701
2352
|
headers: { Authorization: `Bearer ${token}` }
|
|
1702
2353
|
});
|
|
1703
|
-
if (!res.ok) throw new Error(
|
|
2354
|
+
if (!res.ok) throw new Error(M5().lookupFailed(res.status));
|
|
1704
2355
|
return parseRun(await res.json());
|
|
1705
2356
|
}
|
|
1706
|
-
var
|
|
2357
|
+
var M5 = catalog({
|
|
1707
2358
|
invalidResponse: "\uBC30\uD3EC \uAE30\uB85D \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
1708
2359
|
updateFailed: (status) => `\uBC30\uD3EC \uAE30\uB85D \uAC31\uC2E0 \uC2E4\uD328 (${status}). \uC6F9 \uCF58\uC194\uC5D0\uC11C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uC138\uC694.`,
|
|
1709
2360
|
lookupFailed: (status) => `\uBC30\uD3EC \uAE30\uB85D \uC870\uD68C \uC2E4\uD328 (${status}). \uC6F9 \uCF58\uC194\uC5D0\uC11C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uC138\uC694.`
|
|
@@ -1714,9 +2365,9 @@ var M4 = catalog({
|
|
|
1714
2365
|
});
|
|
1715
2366
|
|
|
1716
2367
|
// src/jenkins-project.ts
|
|
1717
|
-
import
|
|
1718
|
-
import
|
|
1719
|
-
var
|
|
2368
|
+
import fs11 from "fs";
|
|
2369
|
+
import path14 from "path";
|
|
2370
|
+
var M6 = catalog({
|
|
1720
2371
|
invalidManifest: "\uD504\uB85C\uC81D\uD2B8 .mimi-seed.json\uC740 \uC62C\uBC14\uB978 JSON \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4.",
|
|
1721
2372
|
controllerMismatch: "\uD504\uB85C\uC81D\uD2B8 Jenkins URL\uACFC \uB85C\uCEEC\uC5D0\uC11C \uC778\uC99D\uB41C \uCEE8\uD2B8\uB864\uB7EC\uAC00 \uB2E4\uB985\uB2C8\uB2E4.",
|
|
1722
2373
|
invalidJob: ".mimi-seed.json\uC758 services.jenkins.jobAndroid/jobIos\uC5D0 \uC62C\uBC14\uB978 \uC7A1 \uACBD\uB85C\uB97C \uC124\uC815\uD558\uC138\uC694.",
|
|
@@ -1729,26 +2380,26 @@ var M5 = catalog({
|
|
|
1729
2380
|
});
|
|
1730
2381
|
function resolveProjectJenkins(cfg, platform, cwd = process.cwd()) {
|
|
1731
2382
|
const field = platform === "android" ? "jobAndroid" : "jobIos";
|
|
1732
|
-
let dir =
|
|
2383
|
+
let dir = path14.resolve(cwd);
|
|
1733
2384
|
for (let depth = 0; depth <= 8; depth++) {
|
|
1734
|
-
const file =
|
|
1735
|
-
if (
|
|
2385
|
+
const file = path14.join(dir, MANIFEST_FILENAME);
|
|
2386
|
+
if (fs11.existsSync(file)) {
|
|
1736
2387
|
let manifest;
|
|
1737
2388
|
try {
|
|
1738
|
-
manifest = JSON.parse(
|
|
2389
|
+
manifest = JSON.parse(fs11.readFileSync(file, "utf8"));
|
|
1739
2390
|
} catch {
|
|
1740
|
-
throw new Error(
|
|
2391
|
+
throw new Error(M6().invalidManifest);
|
|
1741
2392
|
}
|
|
1742
2393
|
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
|
|
1743
|
-
throw new Error(
|
|
2394
|
+
throw new Error(M6().invalidManifest);
|
|
1744
2395
|
}
|
|
1745
2396
|
const service = manifest.services?.jenkins;
|
|
1746
2397
|
if (service?.url !== void 0 && (typeof service.url !== "string" || service.url.replace(/\/+$/, "") !== cfg.url.replace(/\/+$/, ""))) {
|
|
1747
|
-
throw new Error(
|
|
2398
|
+
throw new Error(M6().controllerMismatch);
|
|
1748
2399
|
}
|
|
1749
2400
|
return { job: validateJob(service?.[field]), source: file };
|
|
1750
2401
|
}
|
|
1751
|
-
const parent =
|
|
2402
|
+
const parent = path14.dirname(dir);
|
|
1752
2403
|
if (parent === dir) break;
|
|
1753
2404
|
dir = parent;
|
|
1754
2405
|
}
|
|
@@ -1756,7 +2407,7 @@ function resolveProjectJenkins(cfg, platform, cwd = process.cwd()) {
|
|
|
1756
2407
|
}
|
|
1757
2408
|
function validateJob(job) {
|
|
1758
2409
|
if (typeof job !== "string" || !job || job.split("/").some((part) => !part || part === "." || part === ".." || /[\\?#%]/.test(part) || [...part].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))) {
|
|
1759
|
-
throw new Error(
|
|
2410
|
+
throw new Error(M6().invalidJob);
|
|
1760
2411
|
}
|
|
1761
2412
|
return job;
|
|
1762
2413
|
}
|
|
@@ -1768,7 +2419,7 @@ function jenkinsJobPath(job) {
|
|
|
1768
2419
|
}
|
|
1769
2420
|
function jenkinsBuildParameters(platform, ref, appId) {
|
|
1770
2421
|
if (!ref || /^[a-f0-9]{7,40}$/i.test(ref) || ref.startsWith("-") || /[\s~^:?*[\\]|\.\.|@\{/.test(ref)) {
|
|
1771
|
-
throw new Error(
|
|
2422
|
+
throw new Error(M6().invalidRef);
|
|
1772
2423
|
}
|
|
1773
2424
|
return {
|
|
1774
2425
|
BUILD_TARGET: platform,
|
|
@@ -1784,9 +2435,8 @@ function jenkinsBuildParameters(platform, ref, appId) {
|
|
|
1784
2435
|
}
|
|
1785
2436
|
|
|
1786
2437
|
// src/ci-providers.ts
|
|
1787
|
-
import
|
|
1788
|
-
import
|
|
1789
|
-
import os5 from "os";
|
|
2438
|
+
import path15 from "path";
|
|
2439
|
+
import os7 from "os";
|
|
1790
2440
|
|
|
1791
2441
|
// ../core/src/ci.ts
|
|
1792
2442
|
function githubApiBase(cfg) {
|
|
@@ -1809,8 +2459,8 @@ function gitlabProjectId(cfg) {
|
|
|
1809
2459
|
}
|
|
1810
2460
|
|
|
1811
2461
|
// src/ci-providers.ts
|
|
1812
|
-
var CI_CONFIG_PATH =
|
|
1813
|
-
var
|
|
2462
|
+
var CI_CONFIG_PATH = path15.join(os7.homedir(), ".mimi-seed", "ci.json");
|
|
2463
|
+
var M7 = catalog(
|
|
1814
2464
|
{
|
|
1815
2465
|
badToken: (provider, status) => `${provider} ${status} \u2014 \uD1A0\uD070\uC774 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC544`,
|
|
1816
2466
|
noScope: (scopes) => `\uD1A0\uD070\uC5D0 \`workflow\` \uC2A4\uCF54\uD504\uAC00 \uC5C6\uC5B4 (\uD604\uC7AC: ${scopes || "\uC5C6\uC74C"}). \uC6CC\uD06C\uD50C\uB85C \uC2E4\uD589\uC774 403 \uC73C\uB85C \uB9C9\uD78C\uB2E4.`,
|
|
@@ -1827,7 +2477,7 @@ var M6 = catalog(
|
|
|
1827
2477
|
);
|
|
1828
2478
|
function loadCiProviderConfig() {
|
|
1829
2479
|
try {
|
|
1830
|
-
const cfg = JSON.parse(
|
|
2480
|
+
const cfg = JSON.parse(readCredentialFileSync(CI_CONFIG_PATH));
|
|
1831
2481
|
const host = normalizeHost(cfg.host);
|
|
1832
2482
|
return host ? { ...cfg, host } : { ...cfg, host: void 0 };
|
|
1833
2483
|
} catch {
|
|
@@ -1853,18 +2503,18 @@ async function verifyCiToken(cfg) {
|
|
|
1853
2503
|
headers: { Authorization: `Bearer ${probe.token}`, Accept: "application/vnd.github+json" }
|
|
1854
2504
|
});
|
|
1855
2505
|
if (!res2.ok) {
|
|
1856
|
-
return { ok: false, reason:
|
|
2506
|
+
return { ok: false, reason: M7().badToken("GitHub", res2.status) };
|
|
1857
2507
|
}
|
|
1858
2508
|
const user2 = await res2.json();
|
|
1859
2509
|
const scopes = res2.headers.get("x-oauth-scopes");
|
|
1860
2510
|
if (scopes !== null && !scopes.split(/,\s*/).filter(Boolean).includes("workflow")) {
|
|
1861
|
-
return { ok: false, reason:
|
|
2511
|
+
return { ok: false, reason: M7().noScope(scopes) };
|
|
1862
2512
|
}
|
|
1863
2513
|
return { ok: true, login: user2.login };
|
|
1864
2514
|
}
|
|
1865
2515
|
const res = await fetchWithTimeout(`${gitlabApiBase(probe)}/user`, { headers: { "PRIVATE-TOKEN": probe.token } });
|
|
1866
2516
|
if (!res.ok) {
|
|
1867
|
-
return { ok: false, reason:
|
|
2517
|
+
return { ok: false, reason: M7().badToken("GitLab", res.status) };
|
|
1868
2518
|
}
|
|
1869
2519
|
const user = await res.json();
|
|
1870
2520
|
return { ok: true, login: user.username };
|
|
@@ -1874,8 +2524,8 @@ async function verifyCiToken(cfg) {
|
|
|
1874
2524
|
}
|
|
1875
2525
|
function isGitHubWorkflowRun(value) {
|
|
1876
2526
|
if (typeof value !== "object" || value === null) return false;
|
|
1877
|
-
const
|
|
1878
|
-
return typeof
|
|
2527
|
+
const run2 = value;
|
|
2528
|
+
return typeof run2.id === "number" && Number.isSafeInteger(run2.id) && run2.id > 0 && typeof run2.html_url === "string" && run2.html_url.length > 0 && typeof run2.created_at === "string" && Number.isFinite(Date.parse(run2.created_at));
|
|
1879
2529
|
}
|
|
1880
2530
|
async function ghTriggerWorkflow(cfg, workflow, ref, inputs = {}) {
|
|
1881
2531
|
const startTime = /* @__PURE__ */ new Date();
|
|
@@ -1900,9 +2550,9 @@ async function ghTriggerWorkflow(cfg, workflow, ref, inputs = {}) {
|
|
|
1900
2550
|
const data = await runsRes.json();
|
|
1901
2551
|
if (typeof data !== "object" || data === null || !("workflow_runs" in data) || !Array.isArray(data.workflow_runs)) return null;
|
|
1902
2552
|
const runs = data.workflow_runs.filter(isGitHubWorkflowRun);
|
|
1903
|
-
const
|
|
1904
|
-
if (!
|
|
1905
|
-
return { runId:
|
|
2553
|
+
const run2 = runs.find((entry) => new Date(entry.created_at) >= startTime) ?? runs[0];
|
|
2554
|
+
if (!run2) return null;
|
|
2555
|
+
return { runId: run2.id, url: run2.html_url };
|
|
1906
2556
|
}
|
|
1907
2557
|
async function ghPollRun(cfg, runId, onTick, timeoutMs = 30 * 60 * 1e3, intervalMs = 15e3) {
|
|
1908
2558
|
const start = Date.now();
|
|
@@ -1917,12 +2567,12 @@ async function ghPollRun(cfg, runId, onTick, timeoutMs = 30 * 60 * 1e3, interval
|
|
|
1917
2567
|
);
|
|
1918
2568
|
} catch {
|
|
1919
2569
|
consecutiveErrors++;
|
|
1920
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2570
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailed("GitHub"));
|
|
1921
2571
|
continue;
|
|
1922
2572
|
}
|
|
1923
2573
|
if (!res.ok) {
|
|
1924
2574
|
consecutiveErrors++;
|
|
1925
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2575
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailedHttp("GitHub", res.status));
|
|
1926
2576
|
continue;
|
|
1927
2577
|
}
|
|
1928
2578
|
consecutiveErrors = 0;
|
|
@@ -1962,12 +2612,12 @@ async function glPollPipeline(cfg, pipelineId, onTick, timeoutMs = 30 * 60 * 1e3
|
|
|
1962
2612
|
);
|
|
1963
2613
|
} catch {
|
|
1964
2614
|
consecutiveErrors++;
|
|
1965
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2615
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailed("GitLab"));
|
|
1966
2616
|
continue;
|
|
1967
2617
|
}
|
|
1968
2618
|
if (!res.ok) {
|
|
1969
2619
|
consecutiveErrors++;
|
|
1970
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2620
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailedHttp("GitLab", res.status));
|
|
1971
2621
|
continue;
|
|
1972
2622
|
}
|
|
1973
2623
|
consecutiveErrors = 0;
|
|
@@ -1993,7 +2643,7 @@ var PHASE_ICON = {
|
|
|
1993
2643
|
function log(msg) {
|
|
1994
2644
|
process.stdout.write(msg + "\n");
|
|
1995
2645
|
}
|
|
1996
|
-
var
|
|
2646
|
+
var M8 = catalog(
|
|
1997
2647
|
{
|
|
1998
2648
|
missingValue: (option) => `${option} \uB4A4\uC5D0 \uAC12\uC744 \uC785\uB825\uD558\uC138\uC694.`,
|
|
1999
2649
|
unknownOption: (option) => `\uC54C \uC218 \uC5C6\uB294 deploy \uC635\uC158: ${option}`,
|
|
@@ -2177,7 +2827,7 @@ async function triggerBuild(cfg, jobName, params) {
|
|
|
2177
2827
|
body: qs
|
|
2178
2828
|
});
|
|
2179
2829
|
if (!res.ok) {
|
|
2180
|
-
throw new Error(
|
|
2830
|
+
throw new Error(M8().jenkinsTriggerFailed(res.status, await res.text()));
|
|
2181
2831
|
}
|
|
2182
2832
|
const location2 = res.headers.get("Location") ?? "";
|
|
2183
2833
|
const match = location2.match(/\/queue\/item\/(\d+)\//);
|
|
@@ -2193,7 +2843,7 @@ async function getQueueBuildNumber(cfg, queueItemId) {
|
|
|
2193
2843
|
async function getBuildStatus(cfg, jobName, buildNumber) {
|
|
2194
2844
|
const url = `${jenkinsBase(cfg.url)}/${jenkinsJobPath(jobName)}/${buildNumber}/api/json`;
|
|
2195
2845
|
const res = await fetchWithTimeout(url, { headers: jenkinsHeaders(cfg), redirect: "error" });
|
|
2196
|
-
if (!res.ok) throw new Error(
|
|
2846
|
+
if (!res.ok) throw new Error(M8().buildStatusFailed(res.status));
|
|
2197
2847
|
const data = await res.json();
|
|
2198
2848
|
return {
|
|
2199
2849
|
building: data.building ?? true,
|
|
@@ -2214,18 +2864,18 @@ async function pollBuildComplete(cfg, jobName, buildNumber, timeoutMs = 30 * 60
|
|
|
2214
2864
|
consecutiveErrors = 0;
|
|
2215
2865
|
} catch {
|
|
2216
2866
|
consecutiveErrors++;
|
|
2217
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2218
|
-
process.stdout.write(`\r \u26A0 ${
|
|
2867
|
+
if (consecutiveErrors >= 3) throw new Error(M8().jenkinsConnErrorFatal);
|
|
2868
|
+
process.stdout.write(`\r \u26A0 ${M8().jenkinsConnErrorRetry(consecutiveErrors)} `);
|
|
2219
2869
|
continue;
|
|
2220
2870
|
}
|
|
2221
2871
|
dots = (dots + 1) % 4;
|
|
2222
|
-
process.stdout.write(`\r \u23F3 ${
|
|
2872
|
+
process.stdout.write(`\r \u23F3 ${M8().buildRunning}${".".repeat(dots + 1)} `);
|
|
2223
2873
|
if (!status.building) {
|
|
2224
2874
|
process.stdout.write("\n");
|
|
2225
2875
|
return status.result ?? "FAILURE";
|
|
2226
2876
|
}
|
|
2227
2877
|
}
|
|
2228
|
-
throw new Error(
|
|
2878
|
+
throw new Error(M8().buildTimeout);
|
|
2229
2879
|
}
|
|
2230
2880
|
async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = false) {
|
|
2231
2881
|
const res = await fetchWithTimeout(`${webBase}/api/deploy`, {
|
|
@@ -2239,17 +2889,17 @@ async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = fa
|
|
|
2239
2889
|
}, HTTP_STREAM_TIMEOUT_MS);
|
|
2240
2890
|
if (!res.ok) {
|
|
2241
2891
|
const text = await res.text().catch(() => "");
|
|
2242
|
-
throw new Error(
|
|
2892
|
+
throw new Error(M8().serverDeployFailed(res.status, text.slice(0, 200)));
|
|
2243
2893
|
}
|
|
2244
2894
|
const reader = res.body?.getReader();
|
|
2245
|
-
if (!reader) throw new Error(
|
|
2895
|
+
if (!reader) throw new Error(M8().noSseStream);
|
|
2246
2896
|
let linkPrinted = linkAlreadyPrinted;
|
|
2247
2897
|
try {
|
|
2248
2898
|
await readBodyWithTimeout(`${webBase}/api/deploy`, HTTP_STREAM_TIMEOUT_MS, () => consumeDeployStream(reader, (event) => {
|
|
2249
2899
|
if (event.jobId && !linkPrinted) {
|
|
2250
2900
|
const link = new URL(`/apps/${encodeURIComponent(appId)}`, webBase);
|
|
2251
2901
|
link.searchParams.set("deployment", event.jobId);
|
|
2252
|
-
log(kleur.dim(
|
|
2902
|
+
log(kleur.dim(M8().deploymentLink(link.toString())));
|
|
2253
2903
|
linkPrinted = true;
|
|
2254
2904
|
}
|
|
2255
2905
|
const icon = PHASE_ICON[event.phase] ?? "\u25B8";
|
|
@@ -2258,8 +2908,8 @@ async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = fa
|
|
|
2258
2908
|
}));
|
|
2259
2909
|
} catch (error) {
|
|
2260
2910
|
if (error instanceof DeployStreamError) {
|
|
2261
|
-
if (error.reason === "malformed") throw new Error(
|
|
2262
|
-
if (error.reason === "incomplete") throw new Error(
|
|
2911
|
+
if (error.reason === "malformed") throw new Error(M8().malformedSse, { cause: error });
|
|
2912
|
+
if (error.reason === "incomplete") throw new Error(M8().incompleteSse, { cause: error });
|
|
2263
2913
|
}
|
|
2264
2914
|
throw error;
|
|
2265
2915
|
}
|
|
@@ -2284,7 +2934,7 @@ function parseArgs(argv) {
|
|
|
2284
2934
|
const option = argv[i];
|
|
2285
2935
|
const value = () => {
|
|
2286
2936
|
const next = argv[++i];
|
|
2287
|
-
if (!next?.trim() || next.startsWith("--")) throw new Error(
|
|
2937
|
+
if (!next?.trim() || next.startsWith("--")) throw new Error(M8().missingValue(option));
|
|
2288
2938
|
return next;
|
|
2289
2939
|
};
|
|
2290
2940
|
switch (option) {
|
|
@@ -2343,24 +2993,24 @@ function parseArgs(argv) {
|
|
|
2343
2993
|
args.setupGitlab = true;
|
|
2344
2994
|
break;
|
|
2345
2995
|
default:
|
|
2346
|
-
throw new Error(
|
|
2996
|
+
throw new Error(M8().unknownOption(option));
|
|
2347
2997
|
}
|
|
2348
2998
|
}
|
|
2349
|
-
if (!["android", "ios"].includes(args.platform)) throw new Error(
|
|
2350
|
-
if (!["auto", "jenkins", "github", "gitlab"].includes(args.ci)) throw new Error(
|
|
2999
|
+
if (!["android", "ios"].includes(args.platform)) throw new Error(M8().invalidPlatform);
|
|
3000
|
+
if (!["auto", "jenkins", "github", "gitlab"].includes(args.ci)) throw new Error(M8().invalidCi);
|
|
2351
3001
|
if (args.versionCode !== void 0 && (!Number.isSafeInteger(args.versionCode) || args.versionCode < 1 || args.versionCode > ANDROID_VERSION_CODE_MAX)) {
|
|
2352
|
-
throw new Error(
|
|
3002
|
+
throw new Error(M8().invalidVersion);
|
|
2353
3003
|
}
|
|
2354
|
-
if ([args.setupJenkins, args.setupGithub, args.setupGitlab].filter(Boolean).length > 1) throw new Error(
|
|
2355
|
-
if (args.dryRun && (args.setupJenkins || args.setupGithub || args.setupGitlab)) throw new Error(
|
|
2356
|
-
if (args.resume && (args.skipBuild || args.prepareOnly || args.dryRun)) throw new Error(
|
|
3004
|
+
if ([args.setupJenkins, args.setupGithub, args.setupGitlab].filter(Boolean).length > 1) throw new Error(M8().multipleSetup);
|
|
3005
|
+
if (args.dryRun && (args.setupJenkins || args.setupGithub || args.setupGitlab)) throw new Error(M8().drySetup);
|
|
3006
|
+
if (args.resume && (args.skipBuild || args.prepareOnly || args.dryRun)) throw new Error(M8().invalidResume);
|
|
2357
3007
|
return args;
|
|
2358
3008
|
}
|
|
2359
3009
|
async function promptGitProviderSetup(provider) {
|
|
2360
3010
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2361
3011
|
const ask2 = (q) => new Promise((resolve) => rl.question(q, (a) => resolve(a.trim())));
|
|
2362
3012
|
const isGh = provider === "github";
|
|
2363
|
-
const m =
|
|
3013
|
+
const m = M8();
|
|
2364
3014
|
log(kleur.bold(isGh ? m.githubSetupTitle : m.gitlabSetupTitle));
|
|
2365
3015
|
const tokenLabel = isGh ? m.githubTokenPrompt : m.gitlabTokenPrompt;
|
|
2366
3016
|
const token = await ask2(tokenLabel);
|
|
@@ -2381,36 +3031,36 @@ function resolveCi(ciOption, jenkins, ciProvider) {
|
|
|
2381
3031
|
if (ciOption !== "auto") return ciOption;
|
|
2382
3032
|
if (jenkins?.url && jenkins.token) return "jenkins";
|
|
2383
3033
|
if (ciProvider) return ciProvider.provider;
|
|
2384
|
-
throw new Error(
|
|
3034
|
+
throw new Error(M8().noCiConfig);
|
|
2385
3035
|
}
|
|
2386
3036
|
async function runGitProviderBuild(cfg, args, appId) {
|
|
2387
3037
|
let runUrl;
|
|
2388
3038
|
let runId;
|
|
2389
3039
|
if (cfg.provider === "github") {
|
|
2390
3040
|
if (!args.workflow) {
|
|
2391
|
-
throw new Error(
|
|
3041
|
+
throw new Error(M8().workflowRequired);
|
|
2392
3042
|
}
|
|
2393
|
-
log(
|
|
3043
|
+
log(M8().ghTrigger(kleur.cyan(args.workflow), args.ref));
|
|
2394
3044
|
const inputs = {};
|
|
2395
3045
|
inputs.MIMI_APP_ID = appId;
|
|
2396
3046
|
inputs.PLATFORM = args.platform;
|
|
2397
3047
|
const result2 = await ghTriggerWorkflow(cfg, args.workflow, args.ref, inputs);
|
|
2398
3048
|
if (!result2) {
|
|
2399
|
-
throw new Error(
|
|
3049
|
+
throw new Error(M8().ghRunIdFailed);
|
|
2400
3050
|
}
|
|
2401
3051
|
runId = result2.runId;
|
|
2402
3052
|
runUrl = result2.url;
|
|
2403
|
-
log(kleur.dim(
|
|
3053
|
+
log(kleur.dim(M8().ghRunId(runId, runUrl)));
|
|
2404
3054
|
} else {
|
|
2405
|
-
log(
|
|
3055
|
+
log(M8().glTrigger(args.ref));
|
|
2406
3056
|
const variables = { PLATFORM: args.platform };
|
|
2407
3057
|
variables.MIMI_APP_ID = appId;
|
|
2408
3058
|
const result2 = await glTriggerPipeline(cfg, args.ref, variables);
|
|
2409
3059
|
runId = result2.pipelineId;
|
|
2410
3060
|
runUrl = result2.url;
|
|
2411
|
-
log(kleur.dim(
|
|
3061
|
+
log(kleur.dim(M8().glPipelineId(runId, runUrl)));
|
|
2412
3062
|
}
|
|
2413
|
-
log(
|
|
3063
|
+
log(M8().waitingForCompletion);
|
|
2414
3064
|
let dots = 0;
|
|
2415
3065
|
const onTick = (status) => {
|
|
2416
3066
|
dots = (dots + 1) % 4;
|
|
@@ -2418,9 +3068,9 @@ async function runGitProviderBuild(cfg, args, appId) {
|
|
|
2418
3068
|
};
|
|
2419
3069
|
const result = cfg.provider === "github" ? await ghPollRun(cfg, runId, onTick) : await glPollPipeline(cfg, runId, onTick);
|
|
2420
3070
|
process.stdout.write("\n");
|
|
2421
|
-
if (result === "success") log(kleur.green(
|
|
3071
|
+
if (result === "success") log(kleur.green(M8().buildSucceeded(runId)));
|
|
2422
3072
|
else {
|
|
2423
|
-
log(kleur.red(
|
|
3073
|
+
log(kleur.red(M8().buildEnded(result)));
|
|
2424
3074
|
log(kleur.dim(` ${runUrl}`));
|
|
2425
3075
|
}
|
|
2426
3076
|
return { runId, result };
|
|
@@ -2430,9 +3080,9 @@ async function cmdDeploy(argv) {
|
|
|
2430
3080
|
if (args.dryRun) {
|
|
2431
3081
|
const jenkins = loadJenkinsConfig() ?? void 0;
|
|
2432
3082
|
const ci = args.skipBuild ? null : resolveCi(args.ci, jenkins, loadCiProviderConfig());
|
|
2433
|
-
if (ci === "jenkins" && !jenkins) throw new Error(
|
|
3083
|
+
if (ci === "jenkins" && !jenkins) throw new Error(credentialFileProblemMessage("~/.mimi-seed/jenkins.json") ?? M8().noJenkinsConfig);
|
|
2434
3084
|
const plan = ci === "jenkins" && jenkins ? { ...resolveProjectJenkins(jenkins, args.platform), parameters: jenkinsBuildParameters(args.platform, args.ref, args.appId) } : void 0;
|
|
2435
|
-
log(
|
|
3085
|
+
log(M8().dryRunNotice);
|
|
2436
3086
|
log(JSON.stringify({
|
|
2437
3087
|
platform: args.platform,
|
|
2438
3088
|
appId: args.appId ?? null,
|
|
@@ -2446,7 +3096,7 @@ async function cmdDeploy(argv) {
|
|
|
2446
3096
|
}
|
|
2447
3097
|
const cfg = await getEffectiveConfig();
|
|
2448
3098
|
if (!cfg) {
|
|
2449
|
-
log(kleur.red(
|
|
3099
|
+
log(kleur.red(credentialFileProblemMessage("~/.mimi-seed/config.json") ?? M8().noAccount));
|
|
2450
3100
|
process.exit(1);
|
|
2451
3101
|
}
|
|
2452
3102
|
if (args.setupJenkins) {
|
|
@@ -2457,13 +3107,13 @@ async function cmdDeploy(argv) {
|
|
|
2457
3107
|
if (args.setupGithub) {
|
|
2458
3108
|
const ciCfg = await promptGitProviderSetup("github");
|
|
2459
3109
|
saveCiProviderConfig(ciCfg);
|
|
2460
|
-
log(kleur.green(
|
|
3110
|
+
log(kleur.green(M8().githubSaved));
|
|
2461
3111
|
return;
|
|
2462
3112
|
}
|
|
2463
3113
|
if (args.setupGitlab) {
|
|
2464
3114
|
const ciCfg = await promptGitProviderSetup("gitlab");
|
|
2465
3115
|
saveCiProviderConfig(ciCfg);
|
|
2466
|
-
log(kleur.green(
|
|
3116
|
+
log(kleur.green(M8().gitlabSaved));
|
|
2467
3117
|
return;
|
|
2468
3118
|
}
|
|
2469
3119
|
const resumed = args.resume ? await getDeployRun(cfg.webBase, cfg.token, args.resume) : null;
|
|
@@ -2471,16 +3121,16 @@ async function cmdDeploy(argv) {
|
|
|
2471
3121
|
const linkedAppId = resolveLinkedAppId(projectLink, cfg.webBase, args.appId);
|
|
2472
3122
|
if (projectLink) validateProjectIdentity(projectLink, await detectHints(process.cwd()));
|
|
2473
3123
|
const appId = linkedAppId ?? resumed?.appId;
|
|
2474
|
-
if (!appId) throw new Error(
|
|
2475
|
-
if (!args.yes) throw new Error(
|
|
3124
|
+
if (!appId) throw new Error(M8().noAppId);
|
|
3125
|
+
if (!args.yes) throw new Error(M8().explicitApproval);
|
|
2476
3126
|
if (resumed) {
|
|
2477
|
-
if (resumed.status !== "ready") throw new Error(
|
|
2478
|
-
if (resumed.jobId !== args.resume || resumed.appId !== appId || args.platformExplicit && resumed.platform !== args.platform || args.versionCode && args.versionCode !== resumed.versionCode) throw new Error(
|
|
3127
|
+
if (resumed.status !== "ready") throw new Error(M8().resumeNotReady);
|
|
3128
|
+
if (resumed.jobId !== args.resume || resumed.appId !== appId || args.platformExplicit && resumed.platform !== args.platform || args.versionCode && args.versionCode !== resumed.versionCode) throw new Error(M8().runMismatch);
|
|
2479
3129
|
args.platform = resumed.platform;
|
|
2480
|
-
if (!resumed.versionCode) throw new Error(
|
|
2481
|
-
} else if (!args.versionCode) throw new Error(
|
|
2482
|
-
log(kleur.bold(
|
|
2483
|
-
if (args.dryRun) log(kleur.yellow(
|
|
3130
|
+
if (!resumed.versionCode) throw new Error(M8().versionCodeUnknown);
|
|
3131
|
+
} else if (!args.versionCode) throw new Error(M8().versionCodeUnknown);
|
|
3132
|
+
log(kleur.bold(M8().title(args.platform)));
|
|
3133
|
+
if (args.dryRun) log(kleur.yellow(M8().dryRunNotice));
|
|
2484
3134
|
log("");
|
|
2485
3135
|
const versionCode = args.versionCode ?? resumed?.versionCode ?? void 0;
|
|
2486
3136
|
let deployBuildNumber;
|
|
@@ -2494,20 +3144,22 @@ async function cmdDeploy(argv) {
|
|
|
2494
3144
|
ciProvider = loadCiProviderConfig();
|
|
2495
3145
|
jenkinsCfg = loadJenkinsConfig() ?? void 0;
|
|
2496
3146
|
kind = resolveCi(args.ci, jenkinsCfg, ciProvider);
|
|
2497
|
-
if (!["jenkins", "github", "gitlab"].includes(kind)) throw new Error(
|
|
3147
|
+
if (!["jenkins", "github", "gitlab"].includes(kind)) throw new Error(M8().invalidCi);
|
|
2498
3148
|
if (kind === "jenkins") {
|
|
2499
|
-
if (!jenkinsCfg?.url || !jenkinsCfg?.token)
|
|
3149
|
+
if (!jenkinsCfg?.url || !jenkinsCfg?.token) {
|
|
3150
|
+
throw new Error(credentialFileProblemMessage("~/.mimi-seed/jenkins.json") ?? M8().noJenkinsConfig);
|
|
3151
|
+
}
|
|
2500
3152
|
jenkinsJobName = resolveProjectJenkins(jenkinsCfg, args.platform).job;
|
|
2501
3153
|
jenkinsParams = jenkinsBuildParameters(args.platform, args.ref, appId);
|
|
2502
3154
|
} else if (!ciProvider) {
|
|
2503
|
-
throw new Error(
|
|
3155
|
+
throw new Error(credentialFileProblemMessage("~/.mimi-seed/ci.json") ?? M8().noProviderConfig(kind));
|
|
2504
3156
|
} else if (ciProvider.provider !== kind) {
|
|
2505
|
-
throw new Error(
|
|
3157
|
+
throw new Error(M8().ciProviderMismatch);
|
|
2506
3158
|
} else if (kind === "github" && !args.workflow) {
|
|
2507
|
-
throw new Error(
|
|
3159
|
+
throw new Error(M8().workflowRequired);
|
|
2508
3160
|
}
|
|
2509
3161
|
}
|
|
2510
|
-
const runId = resumed?.jobId ?? `run_${
|
|
3162
|
+
const runId = resumed?.jobId ?? `run_${randomUUID4()}`;
|
|
2511
3163
|
const runPayload = { runId, appId, platform: args.platform, fromRef: args.fromRef, toRef: args.toRef };
|
|
2512
3164
|
const failRun = async (reason) => {
|
|
2513
3165
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "failed", ...runPayload, reason });
|
|
@@ -2518,12 +3170,12 @@ async function cmdDeploy(argv) {
|
|
|
2518
3170
|
...runPayload,
|
|
2519
3171
|
...versionCode ? { versionCode } : {}
|
|
2520
3172
|
});
|
|
2521
|
-
if (started.jobId !== runId || started.appId !== appId || started.platform !== args.platform) throw new Error(
|
|
3173
|
+
if (started.jobId !== runId || started.appId !== appId || started.platform !== args.platform) throw new Error(M8().runMismatch);
|
|
2522
3174
|
}
|
|
2523
|
-
log(kleur.dim(
|
|
3175
|
+
log(kleur.dim(M8().runId(runId)));
|
|
2524
3176
|
const recordLink = new URL(`/apps/${encodeURIComponent(appId)}`, cfg.webBase);
|
|
2525
3177
|
recordLink.searchParams.set("deployment", runId);
|
|
2526
|
-
log(kleur.dim(
|
|
3178
|
+
log(kleur.dim(M8().deploymentLink(recordLink.toString())));
|
|
2527
3179
|
if (resumed) {
|
|
2528
3180
|
await streamDeploy(cfg.webBase, cfg.token, appId, {
|
|
2529
3181
|
jobId: runId,
|
|
@@ -2536,25 +3188,25 @@ async function cmdDeploy(argv) {
|
|
|
2536
3188
|
language: args.language,
|
|
2537
3189
|
dryRun: false
|
|
2538
3190
|
}, true);
|
|
2539
|
-
log(kleur.bold(
|
|
3191
|
+
log(kleur.bold(M8().done));
|
|
2540
3192
|
return;
|
|
2541
3193
|
}
|
|
2542
3194
|
if (!args.skipBuild) {
|
|
2543
3195
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "building", ...runPayload });
|
|
2544
|
-
log(kleur.dim(
|
|
3196
|
+
log(kleur.dim(M8().ciLine(kind)));
|
|
2545
3197
|
if (kind === "jenkins") {
|
|
2546
3198
|
const jenkins = jenkinsCfg;
|
|
2547
3199
|
const jobName = jenkinsJobName;
|
|
2548
|
-
log(
|
|
3200
|
+
log(M8().jenkinsTrigger(kleur.cyan(jobName)));
|
|
2549
3201
|
const queueItemId = await triggerBuild(jenkins, jobName, jenkinsParams);
|
|
2550
3202
|
if (!queueItemId) {
|
|
2551
|
-
log(kleur.yellow(
|
|
3203
|
+
log(kleur.yellow(M8().noQueueItem));
|
|
2552
3204
|
} else {
|
|
2553
|
-
log(kleur.dim(
|
|
3205
|
+
log(kleur.dim(M8().queueItem(queueItemId)));
|
|
2554
3206
|
}
|
|
2555
3207
|
let buildNumber = null;
|
|
2556
3208
|
if (queueItemId) {
|
|
2557
|
-
log(
|
|
3209
|
+
log(M8().waitingForBuildNumber);
|
|
2558
3210
|
for (let i = 0; i < 6; i++) {
|
|
2559
3211
|
await new Promise((r) => setTimeout(r, 5e3));
|
|
2560
3212
|
buildNumber = await getQueueBuildNumber(jenkins, queueItemId).catch(() => null);
|
|
@@ -2562,45 +3214,45 @@ async function cmdDeploy(argv) {
|
|
|
2562
3214
|
}
|
|
2563
3215
|
}
|
|
2564
3216
|
if (!buildNumber) {
|
|
2565
|
-
log(kleur.yellow(
|
|
2566
|
-
throw new Error(
|
|
3217
|
+
log(kleur.yellow(M8().noBuildNumber));
|
|
3218
|
+
throw new Error(M8().noBuildNumber);
|
|
2567
3219
|
}
|
|
2568
|
-
log(
|
|
3220
|
+
log(M8().buildStarted(buildNumber));
|
|
2569
3221
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "building", ...runPayload, buildNumber });
|
|
2570
3222
|
const result = await pollBuildComplete(jenkins, jobName, buildNumber);
|
|
2571
3223
|
if (result !== "SUCCESS") {
|
|
2572
|
-
log(kleur.red(
|
|
2573
|
-
log(kleur.dim(
|
|
2574
|
-
log(kleur.dim(
|
|
3224
|
+
log(kleur.red(M8().buildFailed(result)));
|
|
3225
|
+
log(kleur.dim(M8().jenkinsLink(`${jenkins.url}/job/${encodeURIComponent(jobName)}/${buildNumber}/`)));
|
|
3226
|
+
log(kleur.dim(M8().alreadyBuiltHint("<N>", args.platform)));
|
|
2575
3227
|
await failRun("build_failed");
|
|
2576
|
-
throw new Error(
|
|
3228
|
+
throw new Error(M8().buildFailed(result));
|
|
2577
3229
|
}
|
|
2578
|
-
log(kleur.green(
|
|
3230
|
+
log(kleur.green(M8().buildSucceeded(buildNumber)));
|
|
2579
3231
|
deployBuildNumber = buildNumber;
|
|
2580
3232
|
if (!versionCode) {
|
|
2581
3233
|
await failRun("metadata_missing");
|
|
2582
|
-
throw new Error(
|
|
3234
|
+
throw new Error(M8().versionCodeUnsuitable("Jenkins", buildNumber) + "\n" + M8().recommendationNext);
|
|
2583
3235
|
}
|
|
2584
3236
|
} else {
|
|
2585
3237
|
const build = await runGitProviderBuild(ciProvider, args, appId);
|
|
2586
3238
|
if (build.result !== "success") {
|
|
2587
3239
|
if (build.result === "failure" || build.result === "cancelled") await failRun("build_failed");
|
|
2588
|
-
throw new Error(
|
|
3240
|
+
throw new Error(M8().buildEnded(build.result));
|
|
2589
3241
|
}
|
|
2590
3242
|
if (!versionCode) {
|
|
2591
|
-
log(kleur.red(
|
|
2592
|
-
log(kleur.dim(
|
|
2593
|
-
log(kleur.dim(
|
|
2594
|
-
log(kleur.dim(
|
|
3243
|
+
log(kleur.red(M8().versionCodeUnsuitable(kind, build.runId)));
|
|
3244
|
+
log(kleur.dim(M8().recommendation));
|
|
3245
|
+
log(kleur.dim(M8().recommendationCi));
|
|
3246
|
+
log(kleur.dim(M8().recommendationNext));
|
|
2595
3247
|
await failRun("metadata_missing");
|
|
2596
|
-
throw new Error(
|
|
3248
|
+
throw new Error(M8().versionCodeUnknown);
|
|
2597
3249
|
}
|
|
2598
3250
|
}
|
|
2599
3251
|
}
|
|
2600
3252
|
if (!versionCode) {
|
|
2601
|
-
log(kleur.red(
|
|
3253
|
+
log(kleur.red(M8().versionCodeUnknown));
|
|
2602
3254
|
await failRun("metadata_missing");
|
|
2603
|
-
throw new Error(
|
|
3255
|
+
throw new Error(M8().versionCodeUnknown);
|
|
2604
3256
|
}
|
|
2605
3257
|
await updateDeployRun(cfg.webBase, cfg.token, {
|
|
2606
3258
|
action: "ready",
|
|
@@ -2609,11 +3261,11 @@ async function cmdDeploy(argv) {
|
|
|
2609
3261
|
...deployBuildNumber ? { buildNumber: deployBuildNumber } : {}
|
|
2610
3262
|
});
|
|
2611
3263
|
if (args.prepareOnly) {
|
|
2612
|
-
log(kleur.green(
|
|
3264
|
+
log(kleur.green(M8().prepared(runId)));
|
|
2613
3265
|
return;
|
|
2614
3266
|
}
|
|
2615
3267
|
log("");
|
|
2616
|
-
log(
|
|
3268
|
+
log(M8().pipelineStarting);
|
|
2617
3269
|
log("");
|
|
2618
3270
|
await streamDeploy(cfg.webBase, cfg.token, appId, {
|
|
2619
3271
|
jobId: runId,
|
|
@@ -2627,34 +3279,34 @@ async function cmdDeploy(argv) {
|
|
|
2627
3279
|
dryRun: args.dryRun
|
|
2628
3280
|
}, true);
|
|
2629
3281
|
log("");
|
|
2630
|
-
log(kleur.bold(
|
|
3282
|
+
log(kleur.bold(M8().done));
|
|
2631
3283
|
}
|
|
2632
3284
|
|
|
2633
3285
|
// src/settings.ts
|
|
2634
|
-
import
|
|
2635
|
-
import
|
|
2636
|
-
function readSettings(home =
|
|
3286
|
+
import fs12 from "fs";
|
|
3287
|
+
import os8 from "os";
|
|
3288
|
+
function readSettings(home = os8.homedir()) {
|
|
2637
3289
|
try {
|
|
2638
|
-
return JSON.parse(
|
|
3290
|
+
return JSON.parse(fs12.readFileSync(settingsPath(home), "utf-8"));
|
|
2639
3291
|
} catch {
|
|
2640
3292
|
return {};
|
|
2641
3293
|
}
|
|
2642
3294
|
}
|
|
2643
|
-
function writeSettings(next, home =
|
|
3295
|
+
function writeSettings(next, home = os8.homedir()) {
|
|
2644
3296
|
const merged = { ...readSettings(home), ...next };
|
|
2645
3297
|
writeJsonAtomic(settingsPath(home), merged, { dirMode: 448 });
|
|
2646
3298
|
}
|
|
2647
|
-
function isLangUnset(home =
|
|
3299
|
+
function isLangUnset(home = os8.homedir()) {
|
|
2648
3300
|
return !process.env.MIMI_SEED_LANG && !readSettings(home).lang;
|
|
2649
3301
|
}
|
|
2650
3302
|
|
|
2651
3303
|
// src/telemetry.ts
|
|
2652
|
-
import
|
|
2653
|
-
import
|
|
2654
|
-
import
|
|
2655
|
-
import { createHmac, randomUUID as
|
|
3304
|
+
import fs13 from "fs";
|
|
3305
|
+
import os9 from "os";
|
|
3306
|
+
import path16 from "path";
|
|
3307
|
+
import { createHmac, randomUUID as randomUUID5 } from "crypto";
|
|
2656
3308
|
var ENDPOINT = "https://mimi-seed.pryzm.gg/api/sdk-usage";
|
|
2657
|
-
var
|
|
3309
|
+
var M9 = catalog(
|
|
2658
3310
|
{
|
|
2659
3311
|
notice: "\uC120\uD0DD\uC801 \uC0AC\uC6A9\uB7C9 \uCE21\uC815\uC740 \uAEBC\uC838 \uC788\uC2B5\uB2C8\uB2E4. \uC548\uB0B4: mimi-seed telemetry --help\n",
|
|
2660
3312
|
enabled: "\uC0AC\uC6A9\uB7C9 \uCE21\uC815 \uCF1C\uC9D0. \uC784\uC758 \uC124\uCE58 ID\xB7\uD504\uB85C\uC81D\uD2B8 \uD574\uC2DC\xB7\uBC84\uC804\xB7OS\xB7\uACB0\uACFC \uCF54\uB4DC\xB7\uC2E4\uD589\uC2DC\uAC04\uC744 \uC804\uC1A1\uD569\uB2C8\uB2E4. \uB044\uAE30: mimi-seed telemetry off\n",
|
|
@@ -2668,10 +3320,10 @@ var M8 = catalog(
|
|
|
2668
3320
|
invalid: "Usage: mimi-seed telemetry on|off|status\n"
|
|
2669
3321
|
}
|
|
2670
3322
|
);
|
|
2671
|
-
var location = () =>
|
|
3323
|
+
var location = () => path16.join(os9.homedir(), ".mimi-seed", "telemetry.json");
|
|
2672
3324
|
function readConsent() {
|
|
2673
3325
|
try {
|
|
2674
|
-
return JSON.parse(
|
|
3326
|
+
return JSON.parse(fs13.readFileSync(location(), "utf8"));
|
|
2675
3327
|
} catch {
|
|
2676
3328
|
return { enabled: false };
|
|
2677
3329
|
}
|
|
@@ -2684,26 +3336,26 @@ function telemetryEnabled() {
|
|
|
2684
3336
|
return readConsent().enabled === true;
|
|
2685
3337
|
}
|
|
2686
3338
|
function telemetryNotice() {
|
|
2687
|
-
return telemetryEnabled() ? "" :
|
|
3339
|
+
return telemetryEnabled() ? "" : M9().notice;
|
|
2688
3340
|
}
|
|
2689
3341
|
function cmdTelemetry(argv) {
|
|
2690
3342
|
const action = argv[0] ?? "status";
|
|
2691
3343
|
if (argv.length > 1 || !["on", "off", "status"].includes(action)) {
|
|
2692
|
-
process.stderr.write(
|
|
3344
|
+
process.stderr.write(M9().invalid);
|
|
2693
3345
|
process.exitCode = 2;
|
|
2694
3346
|
return;
|
|
2695
3347
|
}
|
|
2696
3348
|
if (action === "on") {
|
|
2697
3349
|
const consent = readConsent();
|
|
2698
|
-
writeConsent({ enabled: true, installationId: consent.installationId ??
|
|
3350
|
+
writeConsent({ enabled: true, installationId: consent.installationId ?? randomUUID5(), salt: consent.salt ?? randomUUID5() });
|
|
2699
3351
|
}
|
|
2700
3352
|
if (action === "off") writeConsent({ enabled: false });
|
|
2701
|
-
process.stdout.write(telemetryEnabled() ?
|
|
3353
|
+
process.stdout.write(telemetryEnabled() ? M9().enabled : M9().disabled);
|
|
2702
3354
|
}
|
|
2703
3355
|
function frameworkAt(root) {
|
|
2704
|
-
if (
|
|
3356
|
+
if (fs13.existsSync(path16.join(root, "ProjectSettings", "ProjectSettings.asset"))) return "unity";
|
|
2705
3357
|
try {
|
|
2706
|
-
const pkg = JSON.parse(
|
|
3358
|
+
const pkg = JSON.parse(fs13.readFileSync(path16.join(root, "package.json"), "utf8"));
|
|
2707
3359
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
2708
3360
|
if (deps.expo) return "expo";
|
|
2709
3361
|
if (deps["react-native"]) return "react-native";
|
|
@@ -2716,12 +3368,12 @@ function usageRun(command, projectPath) {
|
|
|
2716
3368
|
};
|
|
2717
3369
|
try {
|
|
2718
3370
|
const consent = readConsent();
|
|
2719
|
-
const installationId = consent.installationId ??
|
|
2720
|
-
const salt = consent.salt ??
|
|
3371
|
+
const installationId = consent.installationId ?? randomUUID5();
|
|
3372
|
+
const salt = consent.salt ?? randomUUID5();
|
|
2721
3373
|
if (!consent.installationId || !consent.salt) writeConsent({ enabled: consent.enabled, installationId, salt });
|
|
2722
|
-
let normalized =
|
|
3374
|
+
let normalized = path16.resolve(projectPath);
|
|
2723
3375
|
try {
|
|
2724
|
-
normalized =
|
|
3376
|
+
normalized = fs13.realpathSync(normalized);
|
|
2725
3377
|
} catch {
|
|
2726
3378
|
}
|
|
2727
3379
|
if (process.platform === "win32") normalized = normalized.toLowerCase();
|
|
@@ -2729,7 +3381,7 @@ function usageRun(command, projectPath) {
|
|
|
2729
3381
|
schema: 1,
|
|
2730
3382
|
installationId,
|
|
2731
3383
|
projectId: createHmac("sha256", salt).update(normalized).digest("hex"),
|
|
2732
|
-
runId:
|
|
3384
|
+
runId: randomUUID5(),
|
|
2733
3385
|
version,
|
|
2734
3386
|
os: process.platform,
|
|
2735
3387
|
ci: Boolean(process.env.CI),
|
|
@@ -2808,7 +3460,7 @@ function statusLine(spec, detected, platforms) {
|
|
|
2808
3460
|
else if (isSatisfied(spec, detected)) mark = kleur2.yellow("~");
|
|
2809
3461
|
else if (spec.requirement === "optional" || !relevant) mark = kleur2.dim("\xB7");
|
|
2810
3462
|
else mark = kleur2.red("\u2717");
|
|
2811
|
-
const tail = d.freshness === "expired" ? kleur2.red(`${t().setup.tokenExpired} \u2192 ${spec.fix}`) : d.freshness === "expiring" ? kleur2.yellow(`${t().setup.tokenExpiring(d.daysRemaining ?? 0)} \u2192 ${spec.fix}`) : d.present ? kleur2.dim(d.detail ?? "") : isSatisfied(spec, detected) ? kleur2.dim(`${credNote(spec) ?? t().setup.fallbackWorking}`) : kleur2.dim(`\u2192 ${spec.fix}`);
|
|
3463
|
+
const tail = d.freshness === "expired" ? kleur2.red(`${t().setup.tokenExpired} \u2192 ${spec.fix}`) : d.freshness === "expiring" ? kleur2.yellow(`${t().setup.tokenExpiring(d.daysRemaining ?? 0)} \u2192 ${spec.fix}`) : d.present ? kleur2.dim(d.detail ?? "") : d.invalid ? kleur2.yellow(credentialProblemText(d.invalid, spec.fix)) : isSatisfied(spec, detected) ? kleur2.dim(`${credNote(spec) ?? t().setup.fallbackWorking}`) : kleur2.dim(`\u2192 ${spec.fix}`);
|
|
2812
3464
|
return ` ${mark} ${credLabel(spec).padEnd(24)} ${tail}`;
|
|
2813
3465
|
}
|
|
2814
3466
|
function printStatus(detected, platforms) {
|
|
@@ -2895,7 +3547,7 @@ async function connectOne(spec) {
|
|
|
2895
3547
|
}
|
|
2896
3548
|
async function cmdSetup(argv) {
|
|
2897
3549
|
const opts = parseSetupArgs(argv);
|
|
2898
|
-
const home =
|
|
3550
|
+
const home = os10.homedir();
|
|
2899
3551
|
migrateLegacyJenkins(home);
|
|
2900
3552
|
if (resolveMode(opts, process.env, process.stdin.isTTY) === "interactive") {
|
|
2901
3553
|
await ensureLangChosen();
|
|
@@ -3002,25 +3654,37 @@ async function cmdSetup(argv) {
|
|
|
3002
3654
|
}
|
|
3003
3655
|
|
|
3004
3656
|
export {
|
|
3657
|
+
isLang,
|
|
3658
|
+
resolveLang,
|
|
3659
|
+
catalog,
|
|
3660
|
+
macosLoginKeychain,
|
|
3661
|
+
lookupDataKey,
|
|
3662
|
+
obtainDataKey,
|
|
3663
|
+
forgetFailedDataKeyLookup,
|
|
3664
|
+
CREDENTIAL_STORE_ENV,
|
|
3665
|
+
isCredentialStoreMode,
|
|
3666
|
+
credentialStoreReport,
|
|
3667
|
+
rewriteCredentialFiles,
|
|
3668
|
+
clearKeyIdMarker,
|
|
3669
|
+
writeCredentialFile,
|
|
3005
3670
|
writeConfig,
|
|
3006
3671
|
deleteConfig,
|
|
3007
3672
|
CONFIG_LOCATION,
|
|
3008
3673
|
getEffectiveConfig,
|
|
3009
|
-
isLang,
|
|
3010
|
-
resolveLang,
|
|
3011
|
-
catalog,
|
|
3012
3674
|
t,
|
|
3013
3675
|
readBodyWithTimeout,
|
|
3014
3676
|
fetchWithTimeout,
|
|
3015
3677
|
detectHints,
|
|
3016
3678
|
hasAnyProjectSignal,
|
|
3017
|
-
|
|
3679
|
+
lookupProjectManifest,
|
|
3018
3680
|
manifestServiceEntries,
|
|
3019
3681
|
credLabel,
|
|
3020
3682
|
credNote,
|
|
3021
3683
|
CREDENTIALS,
|
|
3022
3684
|
tryCredById,
|
|
3023
3685
|
detectAll,
|
|
3686
|
+
credentialFileProblemMessage,
|
|
3687
|
+
credentialProblemText,
|
|
3024
3688
|
isSatisfied,
|
|
3025
3689
|
version,
|
|
3026
3690
|
absoluteWindowsPathDirs,
|