mimi-seed 0.23.4 → 0.25.0
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,648 @@ 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
|
+
},
|
|
354
|
+
{
|
|
355
|
+
exit: (cmd, status) => `${cmd} exited with status ${status}`,
|
|
356
|
+
missingTool: (cmd) => `${cmd} is not installed`,
|
|
357
|
+
timeout: (cmd) => `${cmd} did not respond (timed out)`,
|
|
358
|
+
badKey: "the stored key is not in the expected format",
|
|
359
|
+
noBackend: (platform) => `no supported key store on this OS (${platform})`
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
var SPAWN_TIMEOUT_MS = 2e4;
|
|
363
|
+
function run(cmd, args, input) {
|
|
364
|
+
return spawnSync(cmd, args, {
|
|
365
|
+
input,
|
|
366
|
+
encoding: "utf8",
|
|
367
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
368
|
+
timeout: SPAWN_TIMEOUT_MS,
|
|
369
|
+
windowsHide: true
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function spawnProblem(cmd, result) {
|
|
373
|
+
const error = result.error;
|
|
374
|
+
if (!error) return null;
|
|
375
|
+
if (error.code === "ENOENT") return R().missingTool(cmd);
|
|
376
|
+
if (error.code === "ETIMEDOUT") return R().timeout(cmd);
|
|
377
|
+
return R().exit(cmd, error.code ?? "spawn");
|
|
378
|
+
}
|
|
379
|
+
function decodeKey(text, backend) {
|
|
380
|
+
const key = Buffer.from(text.trim(), "base64");
|
|
381
|
+
return key.length === DATA_KEY_BYTES ? { state: "ok", key, backend } : { state: "unavailable", backend, reason: R().badKey };
|
|
382
|
+
}
|
|
383
|
+
function macosLookup() {
|
|
384
|
+
const backend = "macOS Keychain";
|
|
385
|
+
const result = run("/usr/bin/security", ["find-generic-password", "-s", KEYCHAIN_SERVICE, "-a", KEYCHAIN_ACCOUNT, "-w"]);
|
|
386
|
+
const problem = spawnProblem("security", result);
|
|
387
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
388
|
+
if (result.status === 44) return { state: "absent", backend };
|
|
389
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("security", String(result.status)) };
|
|
390
|
+
return decodeKey(result.stdout, backend);
|
|
391
|
+
}
|
|
392
|
+
var DPAPI_UNPROTECT = [
|
|
393
|
+
"Add-Type -AssemblyName System.Security",
|
|
394
|
+
"$in = [Console]::In.ReadToEnd().Trim()",
|
|
395
|
+
"$out = [System.Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String($in), $null, 'CurrentUser')",
|
|
396
|
+
"[Console]::Out.Write([Convert]::ToBase64String($out))"
|
|
397
|
+
].join("; ");
|
|
398
|
+
function windowsLookup(home) {
|
|
399
|
+
const backend = "Windows DPAPI";
|
|
400
|
+
let blob;
|
|
401
|
+
try {
|
|
402
|
+
blob = fs2.readFileSync(path2.join(home, ".mimi-seed", DPAPI_KEY_FILE), "utf8");
|
|
403
|
+
} catch (error) {
|
|
404
|
+
const code = error.code;
|
|
405
|
+
if (code === "ENOENT" || code === "ENOTDIR") return { state: "absent", backend };
|
|
406
|
+
return { state: "unavailable", backend, reason: R().exit(DPAPI_KEY_FILE, code ?? "read") };
|
|
407
|
+
}
|
|
408
|
+
const result = run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", DPAPI_UNPROTECT], blob);
|
|
409
|
+
const problem = spawnProblem("powershell.exe", result);
|
|
410
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
411
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("powershell.exe", String(result.status)) };
|
|
412
|
+
return decodeKey(result.stdout, backend);
|
|
413
|
+
}
|
|
414
|
+
function linuxLookup() {
|
|
415
|
+
const backend = "Secret Service";
|
|
416
|
+
const result = run("secret-tool", ["lookup", "service", KEYCHAIN_SERVICE, "account", KEYCHAIN_ACCOUNT]);
|
|
417
|
+
const problem = spawnProblem("secret-tool", result);
|
|
418
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
419
|
+
if (result.status === 1 && !result.stdout.trim() && !result.stderr.trim()) return { state: "absent", backend };
|
|
420
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("secret-tool", String(result.status)) };
|
|
421
|
+
return decodeKey(result.stdout, backend);
|
|
422
|
+
}
|
|
423
|
+
function macosCreate() {
|
|
424
|
+
const key = randomBytes2(DATA_KEY_BYTES).toString("base64");
|
|
425
|
+
const command = `add-generic-password -s ${KEYCHAIN_SERVICE} -a ${KEYCHAIN_ACCOUNT} -w ${key}
|
|
426
|
+
`;
|
|
427
|
+
const result = run("/usr/bin/security", ["-i"], command);
|
|
428
|
+
const problem = spawnProblem("security", result);
|
|
429
|
+
if (problem) return { state: "unavailable", backend: "macOS Keychain", reason: problem };
|
|
430
|
+
const stored = macosLookup();
|
|
431
|
+
if (stored.state === "absent" && result.status !== 0) {
|
|
432
|
+
return { state: "unavailable", backend: "macOS Keychain", reason: R().exit("security", String(result.status)) };
|
|
433
|
+
}
|
|
434
|
+
return stored;
|
|
435
|
+
}
|
|
436
|
+
var DPAPI_PROTECT = DPAPI_UNPROTECT.replace("::Unprotect(", "::Protect(");
|
|
437
|
+
function windowsCreate(home) {
|
|
438
|
+
const backend = "Windows DPAPI";
|
|
439
|
+
const result = run(
|
|
440
|
+
"powershell.exe",
|
|
441
|
+
["-NoProfile", "-NonInteractive", "-Command", DPAPI_PROTECT],
|
|
442
|
+
randomBytes2(DATA_KEY_BYTES).toString("base64")
|
|
443
|
+
);
|
|
444
|
+
const problem = spawnProblem("powershell.exe", result);
|
|
445
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
446
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("powershell.exe", String(result.status)) };
|
|
447
|
+
const dir = path2.join(home, ".mimi-seed");
|
|
448
|
+
const target = path2.join(dir, DPAPI_KEY_FILE);
|
|
449
|
+
const temp = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
450
|
+
try {
|
|
451
|
+
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
452
|
+
fs2.writeFileSync(temp, result.stdout.trim(), { mode: 384 });
|
|
453
|
+
fs2.linkSync(temp, target);
|
|
454
|
+
} catch (error) {
|
|
455
|
+
if (error.code !== "EEXIST") {
|
|
456
|
+
return { state: "unavailable", backend, reason: R().exit(DPAPI_KEY_FILE, error.code ?? "write") };
|
|
457
|
+
}
|
|
458
|
+
} finally {
|
|
459
|
+
fs2.rmSync(temp, { force: true });
|
|
460
|
+
}
|
|
461
|
+
return windowsLookup(home);
|
|
462
|
+
}
|
|
463
|
+
var LOCK_STALE_MS = 3e4;
|
|
464
|
+
function linuxCreate(home) {
|
|
465
|
+
const backend = "Secret Service";
|
|
466
|
+
const dir = path2.join(home, ".mimi-seed");
|
|
467
|
+
const lock = path2.join(dir, ".data-key.lock");
|
|
468
|
+
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
469
|
+
const deadline = Date.now() + LOCK_STALE_MS;
|
|
470
|
+
for (; ; ) {
|
|
471
|
+
try {
|
|
472
|
+
fs2.mkdirSync(lock);
|
|
473
|
+
break;
|
|
474
|
+
} catch (error) {
|
|
475
|
+
if (error.code !== "EEXIST") {
|
|
476
|
+
return { state: "unavailable", backend, reason: R().exit(".data-key.lock", error.code ?? "mkdir") };
|
|
477
|
+
}
|
|
478
|
+
let age = 0;
|
|
479
|
+
try {
|
|
480
|
+
age = Date.now() - fs2.statSync(lock).mtimeMs;
|
|
481
|
+
} catch {
|
|
482
|
+
}
|
|
483
|
+
if (age > LOCK_STALE_MS) fs2.rmSync(lock, { recursive: true, force: true });
|
|
484
|
+
if (Date.now() > deadline) return { state: "unavailable", backend, reason: R().timeout(".data-key.lock") };
|
|
485
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
const existing = linuxLookup();
|
|
490
|
+
if (existing.state !== "absent") return existing;
|
|
491
|
+
const result = run(
|
|
492
|
+
"secret-tool",
|
|
493
|
+
["store", "--label=Mimi Seed credential key", "service", KEYCHAIN_SERVICE, "account", KEYCHAIN_ACCOUNT],
|
|
494
|
+
randomBytes2(DATA_KEY_BYTES).toString("base64")
|
|
495
|
+
);
|
|
496
|
+
const problem = spawnProblem("secret-tool", result);
|
|
497
|
+
if (problem) return { state: "unavailable", backend, reason: problem };
|
|
498
|
+
if (result.status !== 0) return { state: "unavailable", backend, reason: R().exit("secret-tool", String(result.status)) };
|
|
499
|
+
return linuxLookup();
|
|
500
|
+
} finally {
|
|
501
|
+
fs2.rmSync(lock, { recursive: true, force: true });
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function osCreateDataKey(home = os2.homedir(), platform = process.platform) {
|
|
505
|
+
if (platform === "darwin") return macosCreate();
|
|
506
|
+
if (platform === "win32") return windowsCreate(home);
|
|
507
|
+
if (platform === "linux") return linuxCreate(home);
|
|
508
|
+
return { state: "unavailable", backend: platform, reason: R().noBackend(platform) };
|
|
509
|
+
}
|
|
510
|
+
function osDataKeySource(home = os2.homedir(), platform = process.platform) {
|
|
511
|
+
if (platform === "darwin") return macosLookup();
|
|
512
|
+
if (platform === "win32") return windowsLookup(home);
|
|
513
|
+
if (platform === "linux") return linuxLookup();
|
|
514
|
+
return { state: "unavailable", backend: platform, reason: R().noBackend(platform) };
|
|
515
|
+
}
|
|
516
|
+
var FAILED_LOOKUP_TTL_MS = 1e4;
|
|
517
|
+
var source = () => osDataKeySource();
|
|
518
|
+
var creator = () => osCreateDataKey();
|
|
519
|
+
var cached;
|
|
520
|
+
var failed;
|
|
521
|
+
function lookupDataKey(now = Date.now()) {
|
|
522
|
+
if (cached) return { state: "ok", ...cached };
|
|
523
|
+
if (failed && now - failed.at < FAILED_LOOKUP_TTL_MS) return failed.result;
|
|
524
|
+
const result = source();
|
|
525
|
+
if (result.state === "ok") {
|
|
526
|
+
cached = { key: result.key, backend: result.backend };
|
|
527
|
+
failed = void 0;
|
|
528
|
+
} else {
|
|
529
|
+
failed = { result, at: now };
|
|
530
|
+
}
|
|
531
|
+
return result;
|
|
532
|
+
}
|
|
533
|
+
function obtainDataKey() {
|
|
534
|
+
const found = lookupDataKey();
|
|
535
|
+
if (found.state !== "absent") return found;
|
|
536
|
+
const made = creator();
|
|
537
|
+
if (made.state === "ok") {
|
|
538
|
+
cached = { key: made.key, backend: made.backend };
|
|
539
|
+
failed = void 0;
|
|
540
|
+
}
|
|
541
|
+
return made;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// ../core/src/credential-read.ts
|
|
545
|
+
var R2 = catalog(
|
|
546
|
+
{
|
|
547
|
+
unreadable: (c) => `\uC77D\uC744 \uC218 \uC5C6\uC74C (${c})`,
|
|
548
|
+
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",
|
|
549
|
+
malformed: "\uC554\uD638\uD654 \uD30C\uC77C\uC758 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC74C",
|
|
550
|
+
outside: "\uC790\uACA9\uC99D\uBA85 \uD3F4\uB354(~/.mimi-seed) \uBC16\uC758 \uC554\uD638\uD654 \uD30C\uC77C",
|
|
551
|
+
tampered: "\uC554\uD638\uD654 \uD30C\uC77C\uC774 \uBCC0\uC870\uB410\uAC70\uB098 \uB2E4\uB978 \uACBD\uB85C\uC5D0\uC11C \uBCF5\uC0AC\uB428",
|
|
552
|
+
absent: (backend) => `\uC554\uD638\uD654\uB3FC \uC788\uC9C0\uB9CC \uC774 \uCEF4\uD4E8\uD130\uC758 ${backend}\uC5D0 \uD0A4\uAC00 \uC5C6\uC74C`,
|
|
553
|
+
unavailable: (backend, why) => `\uC554\uD638\uD654\uB3FC \uC788\uC9C0\uB9CC ${backend}\uC5D0\uC11C \uD0A4\uB97C \uAEBC\uB0B4\uC9C0 \uBABB\uD568 (${why})`,
|
|
554
|
+
otherKey: (backend) => `${backend}\uC758 \uD0A4\uC640 \uB2E4\uB978 \uD0A4\uB85C \uC554\uD638\uD654\uB428`
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
unreadable: (c) => `unreadable (${c})`,
|
|
558
|
+
unsupported: "encrypted by a newer version of Mimi Seed \u2014 update the SDK",
|
|
559
|
+
malformed: "the encrypted file is malformed",
|
|
560
|
+
outside: "an encrypted file outside the credential folder (~/.mimi-seed)",
|
|
561
|
+
tampered: "the encrypted file was modified or copied from another path",
|
|
562
|
+
absent: (backend) => `encrypted, but this machine's ${backend} has no key for it`,
|
|
563
|
+
unavailable: (backend, why) => `encrypted, but the key could not be read from ${backend} (${why})`,
|
|
564
|
+
otherKey: (backend) => `encrypted with a different key than the one in ${backend}`
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
var MISSING_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
568
|
+
function credentialAad(file) {
|
|
569
|
+
const segments = path3.resolve(file).split(path3.sep);
|
|
570
|
+
const root = segments.lastIndexOf(".mimi-seed");
|
|
571
|
+
if (root < 0 || root === segments.length - 1) return null;
|
|
572
|
+
return segments.slice(root + 1).join("/");
|
|
573
|
+
}
|
|
574
|
+
function decodeCredentialText(file, text) {
|
|
575
|
+
if (!text.includes('"mimiSeedEncrypted"')) return { state: "ok", text };
|
|
576
|
+
let parsed;
|
|
577
|
+
try {
|
|
578
|
+
parsed = JSON.parse(text);
|
|
579
|
+
} catch {
|
|
580
|
+
return { state: "ok", text };
|
|
581
|
+
}
|
|
582
|
+
if (!looksLikeEnvelope(parsed)) return { state: "ok", text };
|
|
583
|
+
const envelope = parseEnvelope(parsed);
|
|
584
|
+
if (envelope === "unsupported") return { state: "invalid", reason: R2().unsupported };
|
|
585
|
+
if (envelope === "malformed") return { state: "invalid", reason: R2().malformed };
|
|
586
|
+
const aad = credentialAad(file);
|
|
587
|
+
if (aad === null) return { state: "invalid", reason: R2().outside };
|
|
588
|
+
const lookup = lookupDataKey();
|
|
589
|
+
if (lookup.state === "absent") return { state: "locked", reason: R2().absent(lookup.backend) };
|
|
590
|
+
if (lookup.state === "unavailable") return { state: "locked", reason: R2().unavailable(lookup.backend, lookup.reason) };
|
|
591
|
+
if (keyId(lookup.key) !== envelope.kid) return { state: "locked", reason: R2().otherKey(lookup.backend) };
|
|
592
|
+
const plaintext = openCredential(envelope, lookup.key, aad);
|
|
593
|
+
return plaintext === null ? { state: "invalid", reason: R2().tampered } : { state: "ok", text: plaintext };
|
|
594
|
+
}
|
|
595
|
+
function readCredentialText(file) {
|
|
596
|
+
let text;
|
|
597
|
+
try {
|
|
598
|
+
text = fs3.readFileSync(file, "utf-8");
|
|
599
|
+
} catch (e) {
|
|
600
|
+
const code = e.code;
|
|
601
|
+
if (code && MISSING_CODES.has(code)) return { state: "missing" };
|
|
602
|
+
return { state: "invalid", reason: R2().unreadable(code ?? String(e)) };
|
|
603
|
+
}
|
|
604
|
+
return decodeCredentialText(file, text);
|
|
605
|
+
}
|
|
606
|
+
function readCredentialFileSync(file) {
|
|
607
|
+
const read = decodeCredentialText(file, fs3.readFileSync(file, "utf-8"));
|
|
608
|
+
if (read.state === "ok") return read.text;
|
|
609
|
+
throw new Error(`${file}: ${read.state === "missing" ? "missing" : read.reason}`);
|
|
610
|
+
}
|
|
611
|
+
async function readCredentialFile(file) {
|
|
612
|
+
const read = decodeCredentialText(file, await fs3.promises.readFile(file, "utf-8"));
|
|
613
|
+
if (read.state === "ok") return read.text;
|
|
614
|
+
throw new Error(`${file}: ${read.state === "missing" ? "missing" : read.reason}`);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// ../core/src/json-file.ts
|
|
618
|
+
var REASON = catalog(
|
|
619
|
+
{
|
|
620
|
+
empty: "\uBE48 \uD30C\uC77C (\uC4F0\uAE30\uAC00 \uC911\uAC04\uC5D0 \uB04A\uACBC\uC744 \uC218 \uC788\uC74C)",
|
|
621
|
+
syntax: (at) => `JSON \uD615\uC2DD \uC624\uB958${at ? ` \u2014 ${at}` : ""}`,
|
|
622
|
+
at: (line, col) => `${line}\uD589 ${col}\uC5F4`,
|
|
623
|
+
pos: (p) => `${p}\uBC88\uC9F8 \uBB38\uC790`
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
empty: "empty file (a write may have been interrupted)",
|
|
627
|
+
syntax: (at) => `invalid JSON${at ? ` at ${at}` : ""}`,
|
|
628
|
+
at: (line, col) => `line ${line}, column ${col}`,
|
|
629
|
+
pos: (p) => `character ${p}`
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
function syntaxLocation(message, R3) {
|
|
633
|
+
const lc = /line (\d+) column (\d+)/.exec(message);
|
|
634
|
+
if (lc) return R3.at(lc[1], lc[2]);
|
|
635
|
+
const pos = /position (\d+)/.exec(message);
|
|
636
|
+
return pos ? R3.pos(pos[1]) : null;
|
|
637
|
+
}
|
|
638
|
+
function readJsonFile(file) {
|
|
639
|
+
const R3 = REASON();
|
|
640
|
+
const read = readCredentialText(file);
|
|
641
|
+
if (read.state !== "ok") return read;
|
|
642
|
+
const text = read.text;
|
|
643
|
+
if (text.trim() === "") return { state: "invalid", reason: R3.empty };
|
|
644
|
+
try {
|
|
645
|
+
return { state: "ok", value: JSON.parse(text) };
|
|
646
|
+
} catch (e) {
|
|
647
|
+
return { state: "invalid", reason: R3.syntax(syntaxLocation(e instanceof Error ? e.message : "", R3)) };
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// ../core/src/project-manifest.ts
|
|
652
|
+
import fs4 from "fs";
|
|
653
|
+
import path4 from "path";
|
|
654
|
+
var MANIFEST_FILENAME = ".mimi-seed.json";
|
|
655
|
+
var SOCIAL_PROFILE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
656
|
+
function lookupProjectManifest(startDir = process.cwd(), maxDepth = 8) {
|
|
657
|
+
let dir = path4.resolve(startDir);
|
|
658
|
+
for (let i = 0; i <= maxDepth; i++) {
|
|
659
|
+
const candidate = path4.join(dir, MANIFEST_FILENAME);
|
|
660
|
+
if (fs4.existsSync(candidate)) return parseManifest(candidate);
|
|
661
|
+
const parent = path4.dirname(dir);
|
|
662
|
+
if (parent === dir) break;
|
|
663
|
+
dir = parent;
|
|
664
|
+
}
|
|
665
|
+
return { state: "missing" };
|
|
666
|
+
}
|
|
667
|
+
function parseManifest(filePath) {
|
|
668
|
+
let raw;
|
|
669
|
+
try {
|
|
670
|
+
raw = fs4.readFileSync(filePath, "utf-8");
|
|
671
|
+
} catch {
|
|
672
|
+
return { state: "invalid", filePath, reason: "unreadable" };
|
|
673
|
+
}
|
|
674
|
+
let obj;
|
|
675
|
+
try {
|
|
676
|
+
obj = JSON.parse(raw);
|
|
677
|
+
} catch {
|
|
678
|
+
return { state: "invalid", filePath, reason: "invalid-json" };
|
|
679
|
+
}
|
|
680
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return { state: "invalid", filePath, reason: "not-an-object" };
|
|
681
|
+
return { state: "ok", loaded: { manifest: obj, filePath } };
|
|
682
|
+
}
|
|
683
|
+
function manifestServiceEntries(m) {
|
|
684
|
+
const svc = m.services ?? {};
|
|
685
|
+
return Object.keys(svc).filter((k) => svc[k] != null).map((k) => [k, svc[k]]);
|
|
686
|
+
}
|
|
687
|
+
function isValidSocialProfileId(value) {
|
|
688
|
+
return SOCIAL_PROFILE_ID_PATTERN.test(value);
|
|
84
689
|
}
|
|
85
690
|
var SOCIAL_PROFILE_MESSAGES_KO = {
|
|
86
691
|
notAnObject: `${MANIFEST_FILENAME}\uC758 socialProfiles\uB294 \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,
|
|
@@ -115,21 +720,21 @@ function credObtain(spec, lang = resolveLang()) {
|
|
|
115
720
|
return spec.obtain[lang];
|
|
116
721
|
}
|
|
117
722
|
function credDir(home) {
|
|
118
|
-
return
|
|
723
|
+
return path5.join(home, ".mimi-seed");
|
|
119
724
|
}
|
|
120
725
|
function hasFile(home, name) {
|
|
121
|
-
return
|
|
726
|
+
return readJsonFile(path5.join(credDir(home), name)).state === "ok";
|
|
122
727
|
}
|
|
123
728
|
function anyFileStarting(home, prefix) {
|
|
124
729
|
try {
|
|
125
|
-
return
|
|
730
|
+
return fs5.readdirSync(credDir(home)).some((f) => f.startsWith(prefix));
|
|
126
731
|
} catch {
|
|
127
732
|
return false;
|
|
128
733
|
}
|
|
129
734
|
}
|
|
130
735
|
function readJson(home, name) {
|
|
131
736
|
try {
|
|
132
|
-
return JSON.parse(
|
|
737
|
+
return JSON.parse(readCredentialFileSync(path5.join(credDir(home), name)));
|
|
133
738
|
} catch {
|
|
134
739
|
return null;
|
|
135
740
|
}
|
|
@@ -160,7 +765,9 @@ function detectSocialToken(home, file, idKey, tokenKey, nestedPlatform) {
|
|
|
160
765
|
function detectProjectSocialToken(home, startDir, platform) {
|
|
161
766
|
const idKey = "userId";
|
|
162
767
|
const tokenKey = "accessToken";
|
|
163
|
-
const
|
|
768
|
+
const lookup = lookupProjectManifest(startDir ?? process.cwd());
|
|
769
|
+
if (lookup.state === "invalid") return { present: false, detail: `${MANIFEST_FILENAME}: ${t().doctor.manifestReason[lookup.reason]}` };
|
|
770
|
+
const loaded = lookup.state === "ok" ? lookup.loaded : null;
|
|
164
771
|
if (!loaded) return detectSocialToken(home, `${platform}.json`, idKey, tokenKey);
|
|
165
772
|
let profile;
|
|
166
773
|
try {
|
|
@@ -171,7 +778,7 @@ function detectProjectSocialToken(home, startDir, platform) {
|
|
|
171
778
|
if (!profile) return detectSocialToken(home, `${platform}.json`, idKey, tokenKey);
|
|
172
779
|
const detected = detectSocialToken(
|
|
173
780
|
home,
|
|
174
|
-
|
|
781
|
+
path5.join("social-profiles", `${profile}.json`),
|
|
175
782
|
idKey,
|
|
176
783
|
tokenKey,
|
|
177
784
|
platform
|
|
@@ -181,13 +788,23 @@ function detectProjectSocialToken(home, startDir, platform) {
|
|
|
181
788
|
detail: detected.detail ? `${profile}: ${detected.detail}` : `profile ${profile}`
|
|
182
789
|
};
|
|
183
790
|
}
|
|
184
|
-
function
|
|
185
|
-
if (hasFile(home, "play-service-account.json")) return true;
|
|
791
|
+
function playSaDetect(home) {
|
|
792
|
+
if (hasFile(home, "play-service-account.json")) return { present: true };
|
|
793
|
+
const dir = path5.join(credDir(home), "play-service-accounts");
|
|
794
|
+
let names;
|
|
186
795
|
try {
|
|
187
|
-
|
|
796
|
+
names = fs5.readdirSync(dir).filter((f) => f.endsWith(".json")).sort();
|
|
188
797
|
} catch {
|
|
189
|
-
return false;
|
|
798
|
+
return { present: false };
|
|
190
799
|
}
|
|
800
|
+
let invalid;
|
|
801
|
+
for (const name of names) {
|
|
802
|
+
const file = path5.join(dir, name);
|
|
803
|
+
const read = readJsonFile(file);
|
|
804
|
+
if (read.state === "ok") return { present: true };
|
|
805
|
+
if ((read.state === "invalid" || read.state === "locked") && !invalid) invalid = unusable(file, read);
|
|
806
|
+
}
|
|
807
|
+
return invalid ? { present: false, invalid } : { present: false };
|
|
191
808
|
}
|
|
192
809
|
function ciDetect(home, want) {
|
|
193
810
|
const ci = readJson(home, "ci.json");
|
|
@@ -331,7 +948,7 @@ var CREDENTIALS = [
|
|
|
331
948
|
ko: "\uC120\uD0DD \u2014 \uB85C\uCEEC\uC740 OAuth \uB85C \uAC00\uB2A5, CI/\uD5E4\uB4DC\uB9AC\uC2A4\uB294 \uD544\uC218",
|
|
332
949
|
en: "optional \u2014 OAuth covers local; required for CI / headless"
|
|
333
950
|
},
|
|
334
|
-
detect: (home) => (
|
|
951
|
+
detect: (home) => playSaDetect(home)
|
|
335
952
|
},
|
|
336
953
|
{
|
|
337
954
|
id: "bigquery",
|
|
@@ -591,375 +1208,176 @@ var CREDENTIALS = [
|
|
|
591
1208
|
group: "marketing",
|
|
592
1209
|
file: "~/.mimi-seed/threads.json",
|
|
593
1210
|
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"
|
|
1211
|
+
setup: { kind: "mcp-bin", bin: "mimi-seed-social-auth", args: ["threads"] },
|
|
1212
|
+
obtain: {
|
|
1213
|
+
ko: [
|
|
1214
|
+
"Instagram \uACFC **\uBCC4\uAC1C \uACC4\uC815\xB7\uBCC4\uAC1C \uD1A0\uD070**\uC774\uB2E4 (Threads Graph API).",
|
|
1215
|
+
"\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.",
|
|
1216
|
+
"\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).",
|
|
1217
|
+
"\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.",
|
|
1218
|
+
"`--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."
|
|
1219
|
+
],
|
|
1220
|
+
en: [
|
|
1221
|
+
"A **separate account and token** from Instagram (Threads Graph API).",
|
|
1222
|
+
"Default: run `mimi-seed auth threads` and finish Threads login and consent in the browser opened by the HTTPS broker.",
|
|
1223
|
+
"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).",
|
|
1224
|
+
"Pasting a token with `--manual-token` is the advanced/headless path; the Threads account is verified before saving.",
|
|
1225
|
+
"Use `--profile <id>` for a named account; the actual expiry returned by OAuth is saved in the local profile."
|
|
1226
|
+
]
|
|
1227
|
+
},
|
|
1228
|
+
docsAnchor: "threads",
|
|
1229
|
+
detect: (home, startDir) => detectProjectSocialToken(home, startDir, "threads")
|
|
935
1230
|
},
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1231
|
+
{
|
|
1232
|
+
id: "tiktok",
|
|
1233
|
+
label: {
|
|
1234
|
+
ko: "TikTok Business",
|
|
1235
|
+
en: "TikTok Business"
|
|
1236
|
+
},
|
|
1237
|
+
requirement: "optional",
|
|
1238
|
+
group: "marketing",
|
|
1239
|
+
file: "~/.mimi-seed/tiktok-business.json",
|
|
1240
|
+
fix: "mimi-seed auth tiktok",
|
|
1241
|
+
setup: { kind: "mcp-bin", bin: "mimi-seed-tiktok-business-auth" },
|
|
1242
|
+
obtain: {
|
|
1243
|
+
ko: [
|
|
1244
|
+
"TikTok for Business Developer \uC571\uC744 \uB9CC\uB4E4\uACE0 Organic API \uC811\uADFC \uC2B9\uC778\uC744 \uBC1B\uB294\uB2E4.",
|
|
1245
|
+
"TikTok Accounts > Business Content > Video Publish \uAD8C\uD55C\uACFC account holder redirect URL\uC744 \uC124\uC815\uD55C\uB2E4.",
|
|
1246
|
+
"owned Business Account\uB97C \uC2B9\uC778\uD55C callback URL\uC758 auth_code\uB97C \uC5F0\uACB0 \uB9C8\uBC95\uC0AC\uC5D0 \uC785\uB825\uD55C\uB2E4."
|
|
1247
|
+
],
|
|
1248
|
+
en: [
|
|
1249
|
+
"Create a TikTok for Business developer app and obtain Organic API approval.",
|
|
1250
|
+
"Enable TikTok Accounts > Business Content > Video Publish and configure the account-holder redirect URL.",
|
|
1251
|
+
"Authorize the owned Business Account, then paste the callback auth_code into the setup wizard."
|
|
1252
|
+
]
|
|
1253
|
+
},
|
|
1254
|
+
docsAnchor: "tiktok-business",
|
|
1255
|
+
detect: (home) => {
|
|
1256
|
+
const cfg = readJson(
|
|
1257
|
+
home,
|
|
1258
|
+
"tiktok-business.json"
|
|
1259
|
+
);
|
|
1260
|
+
if (!cfg?.openId || !cfg.refreshTokenExpiresAt) return { present: false };
|
|
1261
|
+
const refreshRemaining = Date.parse(cfg.refreshTokenExpiresAt) - Date.now();
|
|
1262
|
+
if (!Number.isFinite(refreshRemaining) || refreshRemaining <= 0) {
|
|
1263
|
+
return { present: true, detail: cfg.openId, freshness: "expired", daysRemaining: 0 };
|
|
1264
|
+
}
|
|
1265
|
+
const accessRemaining = cfg.accessTokenExpiresAt ? Date.parse(cfg.accessTokenExpiresAt) - Date.now() : NaN;
|
|
1266
|
+
const daysRemaining = Math.max(1, Math.ceil(refreshRemaining / 864e5));
|
|
1267
|
+
if (Number.isFinite(accessRemaining) && accessRemaining <= 0) {
|
|
1268
|
+
return { present: true, detail: `${cfg.openId} (access token \uC790\uB3D9 \uAC31\uC2E0 \uC608\uC815)`, freshness: "fresh", daysRemaining };
|
|
1269
|
+
}
|
|
1270
|
+
return { present: true, detail: cfg.openId, freshness: "fresh", daysRemaining };
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
id: "anthropic",
|
|
1275
|
+
label: {
|
|
1276
|
+
ko: "ANTHROPIC_API_KEY",
|
|
1277
|
+
en: "ANTHROPIC_API_KEY"
|
|
1278
|
+
},
|
|
1279
|
+
requirement: "optional",
|
|
1280
|
+
group: "marketing",
|
|
1281
|
+
fix: "export ANTHROPIC_API_KEY=sk-ant-\u2026",
|
|
1282
|
+
setup: { kind: "env", envVar: "ANTHROPIC_API_KEY" },
|
|
1283
|
+
obtain: {
|
|
1284
|
+
ko: [
|
|
1285
|
+
"Anthropic Console (console.anthropic.com) \u2192 API Keys \uC5D0\uC11C \uBC1C\uAE09.",
|
|
1286
|
+
"\uD658\uACBD\uBCC0\uC218\uB85C\uB9CC \uC77D\uB294\uB2E4 \u2014 \uC124\uC815 \uBA85\uB839\uC774 \uB530\uB85C \uC5C6\uB2E4.",
|
|
1287
|
+
"\uC5C6\uC5B4\uB3C4 \uB41C\uB2E4: `mimi-seed notes` \uB294 AI \uC5C6\uC774 \uCEE4\uBC0B \uBAA9\uB85D \uAE30\uBC18\uC73C\uB85C \uB3D9\uC791\uD55C\uB2E4."
|
|
1288
|
+
],
|
|
1289
|
+
en: [
|
|
1290
|
+
"Anthropic Console (console.anthropic.com) \u2192 API Keys.",
|
|
1291
|
+
"Read from the environment only \u2014 there is no setup command.",
|
|
1292
|
+
"Optional: without it, `mimi-seed notes` still works, formatting your commits instead of writing prose."
|
|
1293
|
+
]
|
|
1294
|
+
},
|
|
1295
|
+
docsAnchor: "anthropic-api-key",
|
|
1296
|
+
note: {
|
|
1297
|
+
ko: "\uC120\uD0DD \u2014 AI \uB9B4\uB9AC\uC2A4 \uB178\uD2B8/\uB9AC\uBDF0 \uB2F5\uBCC0 \uC0DD\uC131\uC6A9",
|
|
1298
|
+
en: "optional \u2014 for AI-drafted release notes / review replies"
|
|
1299
|
+
},
|
|
1300
|
+
detect: () => ({ present: Boolean(process.env.ANTHROPIC_API_KEY) })
|
|
944
1301
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1302
|
+
];
|
|
1303
|
+
function tryCredById(id) {
|
|
1304
|
+
return CREDENTIALS.find((c) => c.id === id);
|
|
1305
|
+
}
|
|
1306
|
+
function detectAll(home = os3.homedir(), startDir = process.cwd()) {
|
|
1307
|
+
return new Map(CREDENTIALS.map((c) => [c.id, detectWithFileCheck(c, home, startDir)]));
|
|
1308
|
+
}
|
|
1309
|
+
function credentialFileProblemMessage(displayFile, home = os3.homedir()) {
|
|
1310
|
+
if (!displayFile.startsWith("~/")) return null;
|
|
1311
|
+
const file = path5.join(home, displayFile.slice(2));
|
|
1312
|
+
const read = readJsonFile(file);
|
|
1313
|
+
if (read.state !== "invalid" && read.state !== "locked") return null;
|
|
1314
|
+
const fix = CREDENTIALS.find((spec) => spec.file === displayFile)?.fix ?? "mimi-seed setup";
|
|
1315
|
+
return credentialProblemText(unusable(file, read), fix);
|
|
1316
|
+
}
|
|
1317
|
+
function unusable(file, read) {
|
|
1318
|
+
return read.state === "locked" ? { file, reason: read.reason, locked: true } : { file, reason: read.reason };
|
|
1319
|
+
}
|
|
1320
|
+
function credentialProblemText(invalid, fix) {
|
|
1321
|
+
const m = t().doctor;
|
|
1322
|
+
return invalid.locked ? m.credLocked(invalid.file, invalid.reason, fix) : m.credCorrupt(invalid.file, invalid.reason, fix);
|
|
1323
|
+
}
|
|
1324
|
+
function detectWithFileCheck(spec, home, startDir) {
|
|
1325
|
+
const detected = spec.detect(home, startDir);
|
|
1326
|
+
if (detected.present || detected.invalid || !spec.file?.endsWith(".json") || !spec.file.startsWith("~/")) return detected;
|
|
1327
|
+
const file = path5.join(home, spec.file.slice(2));
|
|
1328
|
+
const read = readJsonFile(file);
|
|
1329
|
+
return read.state === "invalid" || read.state === "locked" ? { ...detected, invalid: unusable(file, read) } : detected;
|
|
1330
|
+
}
|
|
1331
|
+
function isSatisfied(spec, detected) {
|
|
1332
|
+
if (detected.get(spec.id)?.present) return true;
|
|
1333
|
+
return (spec.fallbackOn ?? []).some((f) => detected.get(f)?.present);
|
|
1334
|
+
}
|
|
1335
|
+
function missingRequired(detected, platforms) {
|
|
1336
|
+
return CREDENTIALS.filter((spec) => {
|
|
1337
|
+
if (spec.requirement === "optional") return false;
|
|
1338
|
+
if (spec.requirement === "platform" && !platforms.includes(spec.platform)) return false;
|
|
1339
|
+
return !isSatisfied(spec, detected);
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
var GROUP_ORDER = { core: 0, ci: 1, marketing: 2 };
|
|
1343
|
+
var REQ_ORDER = { required: 0, platform: 1, optional: 2 };
|
|
1344
|
+
function planSetup(detected, opts = {}) {
|
|
1345
|
+
const reconnect = new Set(opts.reconnect ?? []);
|
|
1346
|
+
const only = opts.only ? new Set(opts.only) : null;
|
|
1347
|
+
const platforms = opts.platforms ?? [];
|
|
1348
|
+
return CREDENTIALS.filter((spec) => {
|
|
1349
|
+
if (only && !only.has(spec.id)) return false;
|
|
1350
|
+
if (reconnect.has(spec.id)) return true;
|
|
1351
|
+
const found = detected.get(spec.id);
|
|
1352
|
+
if (found?.freshness === "expired" || found?.freshness === "expiring") return true;
|
|
1353
|
+
if (found?.present) return false;
|
|
1354
|
+
if (spec.requirement === "platform" && platforms.length > 0 && !platforms.includes(spec.platform)) {
|
|
1355
|
+
return false;
|
|
1356
|
+
}
|
|
1357
|
+
return true;
|
|
1358
|
+
}).sort(
|
|
1359
|
+
(a, b) => GROUP_ORDER[a.group] - GROUP_ORDER[b.group] || REQ_ORDER[a.requirement] - REQ_ORDER[b.requirement]
|
|
1360
|
+
);
|
|
949
1361
|
}
|
|
950
1362
|
|
|
1363
|
+
// src/mcp-bin.ts
|
|
1364
|
+
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
1365
|
+
import { existsSync, readFileSync } from "fs";
|
|
1366
|
+
import path7 from "path";
|
|
1367
|
+
import { fileURLToPath } from "url";
|
|
1368
|
+
|
|
951
1369
|
// package.json
|
|
952
|
-
var version = "0.
|
|
1370
|
+
var version = "0.25.0";
|
|
953
1371
|
|
|
954
1372
|
// src/lib/windows-path.ts
|
|
955
|
-
import
|
|
1373
|
+
import path6 from "path";
|
|
956
1374
|
function absoluteWindowsPathDirs(env = process.env) {
|
|
957
1375
|
const key = Object.keys(env).find((k) => k.toLowerCase() === "path");
|
|
958
1376
|
const value = key ? env[key] ?? "" : "";
|
|
959
1377
|
const dirs = [];
|
|
960
1378
|
const flush = (entry) => {
|
|
961
1379
|
const dir = entry.trim();
|
|
962
|
-
if (dir &&
|
|
1380
|
+
if (dir && path6.win32.isAbsolute(dir) && !/^[\\/](?![\\/])/.test(dir)) dirs.push(dir);
|
|
963
1381
|
};
|
|
964
1382
|
let current = "";
|
|
965
1383
|
let quoted = false;
|
|
@@ -984,29 +1402,29 @@ function resolveOnPath(bin, honorForceNpx = true) {
|
|
|
984
1402
|
const names = bin.toLowerCase().endsWith(".cmd") ? [bin] : [`${bin}.cmd`, bin];
|
|
985
1403
|
for (const directory of directories) {
|
|
986
1404
|
for (const name of names) {
|
|
987
|
-
const candidate =
|
|
1405
|
+
const candidate = path7.join(directory, name);
|
|
988
1406
|
if (existsSync(candidate)) return candidate;
|
|
989
1407
|
}
|
|
990
1408
|
}
|
|
991
1409
|
return null;
|
|
992
1410
|
}
|
|
993
1411
|
const probe = "which";
|
|
994
|
-
const result =
|
|
1412
|
+
const result = spawnSync2(probe, [bin], { encoding: "utf8", shell: false });
|
|
995
1413
|
if (result.status !== 0) return null;
|
|
996
1414
|
const candidates = result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
997
1415
|
return candidates[0] ?? null;
|
|
998
1416
|
}
|
|
999
|
-
function resolveWindowsShimTarget(shimPath,
|
|
1000
|
-
const matches = [...
|
|
1417
|
+
function resolveWindowsShimTarget(shimPath, source2) {
|
|
1418
|
+
const matches = [...source2.matchAll(/["']([^"']+\.js)["']\s+%\*/gi)];
|
|
1001
1419
|
const raw = matches.at(-1)?.[1];
|
|
1002
1420
|
if (!raw) return null;
|
|
1003
|
-
return
|
|
1421
|
+
return path7.win32.normalize(raw.replace(/%~?dp0%?/gi, `${path7.win32.dirname(shimPath)}${path7.win32.sep}`));
|
|
1004
1422
|
}
|
|
1005
1423
|
function npxCliPath(shimPath) {
|
|
1006
1424
|
const candidates = [
|
|
1007
|
-
shimPath ?
|
|
1008
|
-
|
|
1009
|
-
process.env.npm_execpath ?
|
|
1425
|
+
shimPath ? path7.join(path7.dirname(shimPath), "node_modules", "npm", "bin", "npx-cli.js") : "",
|
|
1426
|
+
path7.join(path7.dirname(process.execPath), "node_modules", "npm", "bin", "npx-cli.js"),
|
|
1427
|
+
process.env.npm_execpath ? path7.join(path7.dirname(process.env.npm_execpath), "npx-cli.js") : ""
|
|
1010
1428
|
];
|
|
1011
1429
|
return candidates.find((candidate) => candidate && existsSync(candidate)) ?? null;
|
|
1012
1430
|
}
|
|
@@ -1074,14 +1492,197 @@ async function runMcpBin(bin, extraArgs = []) {
|
|
|
1074
1492
|
}
|
|
1075
1493
|
|
|
1076
1494
|
// src/jenkins-config.ts
|
|
1077
|
-
import
|
|
1078
|
-
import
|
|
1079
|
-
import
|
|
1495
|
+
import fs7 from "fs";
|
|
1496
|
+
import os5 from "os";
|
|
1497
|
+
import path10 from "path";
|
|
1080
1498
|
|
|
1081
1499
|
// ../core/src/atomic-write.ts
|
|
1082
1500
|
import { chmodSync, mkdirSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
1083
|
-
import { randomUUID } from "crypto";
|
|
1084
|
-
import
|
|
1501
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
1502
|
+
import path9 from "path";
|
|
1503
|
+
|
|
1504
|
+
// ../core/src/credential-store.ts
|
|
1505
|
+
import fs6 from "fs";
|
|
1506
|
+
import os4 from "os";
|
|
1507
|
+
import path8 from "path";
|
|
1508
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1509
|
+
var CREDENTIAL_STORE_ENV = "MIMI_SEED_CREDENTIAL_STORE";
|
|
1510
|
+
var DATA_KEY_ID_FILE = ".data-key.id";
|
|
1511
|
+
var M2 = catalog(
|
|
1512
|
+
{
|
|
1513
|
+
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`
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
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`
|
|
1517
|
+
}
|
|
1518
|
+
);
|
|
1519
|
+
function isCredentialStoreMode(value) {
|
|
1520
|
+
return value === "file" || value === "keychain" || value === "auto";
|
|
1521
|
+
}
|
|
1522
|
+
function configuredStoreMode(home = os4.homedir()) {
|
|
1523
|
+
return explicitStoreMode(home) ?? "file";
|
|
1524
|
+
}
|
|
1525
|
+
function explicitStoreMode(home = os4.homedir()) {
|
|
1526
|
+
const env = process.env[CREDENTIAL_STORE_ENV]?.trim().toLowerCase();
|
|
1527
|
+
if (isCredentialStoreMode(env)) return env;
|
|
1528
|
+
try {
|
|
1529
|
+
const saved = JSON.parse(fs6.readFileSync(path8.join(home, ".mimi-seed", "settings.json"), "utf-8"))?.credentialStore;
|
|
1530
|
+
if (isCredentialStoreMode(saved)) return saved;
|
|
1531
|
+
} catch {
|
|
1532
|
+
}
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
function recordedKeyId(home = os4.homedir()) {
|
|
1536
|
+
try {
|
|
1537
|
+
const kid = fs6.readFileSync(path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE), "utf-8").trim();
|
|
1538
|
+
return /^[0-9a-f]{16}$/.test(kid) ? kid : null;
|
|
1539
|
+
} catch {
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
function effectiveStoreMode(home = os4.homedir()) {
|
|
1544
|
+
const explicit = explicitStoreMode(home);
|
|
1545
|
+
if (recordedKeyId(home) && (explicit === null || explicit === "auto")) return "keychain";
|
|
1546
|
+
return explicit ?? "file";
|
|
1547
|
+
}
|
|
1548
|
+
var IN_SCOPE_FILES = /* @__PURE__ */ new Set([
|
|
1549
|
+
"tokens.json",
|
|
1550
|
+
"credentials.json",
|
|
1551
|
+
"appstore.json",
|
|
1552
|
+
"play-service-account.json",
|
|
1553
|
+
"bigquery-service-account.json",
|
|
1554
|
+
"drive-service-account.json",
|
|
1555
|
+
"facebook.json",
|
|
1556
|
+
"instagram.json",
|
|
1557
|
+
"threads.json",
|
|
1558
|
+
"tiktok-business.json",
|
|
1559
|
+
"google-ads.json",
|
|
1560
|
+
"jenkins.json",
|
|
1561
|
+
"ci.json",
|
|
1562
|
+
"config.json"
|
|
1563
|
+
]);
|
|
1564
|
+
var IN_SCOPE_DIRS = /* @__PURE__ */ new Set(["google-profiles", "play-service-accounts", "social-profiles"]);
|
|
1565
|
+
function isEncryptableCredential(aad) {
|
|
1566
|
+
if (!aad) return false;
|
|
1567
|
+
const parts = aad.split("/");
|
|
1568
|
+
if (parts.length === 1) return IN_SCOPE_FILES.has(parts[0]);
|
|
1569
|
+
return parts.length === 2 && IN_SCOPE_DIRS.has(parts[0]) && parts[1].endsWith(".json");
|
|
1570
|
+
}
|
|
1571
|
+
function writeKeyIdMarker(home, kid) {
|
|
1572
|
+
const file = path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE);
|
|
1573
|
+
if (recordedKeyId(home) === kid) return;
|
|
1574
|
+
const temp = `${file}.${process.pid}.${randomUUID2()}.tmp`;
|
|
1575
|
+
fs6.mkdirSync(path8.dirname(file), { recursive: true, mode: 448 });
|
|
1576
|
+
try {
|
|
1577
|
+
fs6.writeFileSync(temp, `${kid}
|
|
1578
|
+
`, { mode: 384 });
|
|
1579
|
+
fs6.renameSync(temp, file);
|
|
1580
|
+
} finally {
|
|
1581
|
+
fs6.rmSync(temp, { force: true });
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
function sealForWrite(filePath, contents) {
|
|
1585
|
+
if (typeof contents !== "string") return contents;
|
|
1586
|
+
const aad = credentialAad(filePath);
|
|
1587
|
+
if (aad === null || !isEncryptableCredential(aad)) return contents;
|
|
1588
|
+
const home = path8.resolve(filePath, ...aad.split("/").map(() => ".."), "..");
|
|
1589
|
+
const mode = effectiveStoreMode(home);
|
|
1590
|
+
if (mode === "file") return contents;
|
|
1591
|
+
const key = obtainDataKey();
|
|
1592
|
+
if (key.state !== "ok") {
|
|
1593
|
+
if (mode === "auto") return contents;
|
|
1594
|
+
throw new Error(M2().noStore(key.backend, key.state === "unavailable" ? key.reason : "no key"));
|
|
1595
|
+
}
|
|
1596
|
+
writeKeyIdMarker(home, keyId(key.key));
|
|
1597
|
+
return `${JSON.stringify(sealCredential(contents, key.key, aad), null, 2)}
|
|
1598
|
+
`;
|
|
1599
|
+
}
|
|
1600
|
+
function listCredentialFiles(home = os4.homedir()) {
|
|
1601
|
+
const root = path8.join(home, ".mimi-seed");
|
|
1602
|
+
const out = [];
|
|
1603
|
+
const isFile = (file) => {
|
|
1604
|
+
try {
|
|
1605
|
+
return fs6.statSync(file).isFile();
|
|
1606
|
+
} catch {
|
|
1607
|
+
return false;
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
for (const name of IN_SCOPE_FILES) {
|
|
1611
|
+
const file = path8.join(root, name);
|
|
1612
|
+
if (isFile(file)) out.push(file);
|
|
1613
|
+
}
|
|
1614
|
+
for (const dir of IN_SCOPE_DIRS) {
|
|
1615
|
+
let names;
|
|
1616
|
+
try {
|
|
1617
|
+
names = fs6.readdirSync(path8.join(root, dir));
|
|
1618
|
+
} catch {
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
for (const name of names.sort()) {
|
|
1622
|
+
const file = path8.join(root, dir, name);
|
|
1623
|
+
if (name.endsWith(".json") && isFile(file)) out.push(file);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return out;
|
|
1627
|
+
}
|
|
1628
|
+
function isEnvelopeText(text) {
|
|
1629
|
+
if (!text.includes('"mimiSeedEncrypted"')) return false;
|
|
1630
|
+
try {
|
|
1631
|
+
const parsed = JSON.parse(text);
|
|
1632
|
+
return typeof parsed === "object" && parsed !== null && Object.prototype.hasOwnProperty.call(parsed, "mimiSeedEncrypted");
|
|
1633
|
+
} catch {
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
function credentialStoreReport(home = os4.homedir()) {
|
|
1638
|
+
const files = listCredentialFiles(home).map((file) => {
|
|
1639
|
+
let text;
|
|
1640
|
+
try {
|
|
1641
|
+
text = fs6.readFileSync(file, "utf-8");
|
|
1642
|
+
} catch (error) {
|
|
1643
|
+
return { file, state: "invalid", reason: error.code ?? "read" };
|
|
1644
|
+
}
|
|
1645
|
+
if (!isEnvelopeText(text)) return { file, state: "plaintext" };
|
|
1646
|
+
const read = decodeCredentialText(file, text);
|
|
1647
|
+
if (read.state === "ok") return { file, state: "encrypted" };
|
|
1648
|
+
if (read.state === "locked") return { file, state: "locked", reason: read.reason };
|
|
1649
|
+
return { file, state: "invalid", reason: read.state === "invalid" ? read.reason : void 0 };
|
|
1650
|
+
});
|
|
1651
|
+
return {
|
|
1652
|
+
configured: configuredStoreMode(home),
|
|
1653
|
+
effective: effectiveStoreMode(home),
|
|
1654
|
+
explicit: explicitStoreMode(home) !== null,
|
|
1655
|
+
keyId: recordedKeyId(home),
|
|
1656
|
+
files
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
function rewriteCredentialFiles(target, write, home = os4.homedir()) {
|
|
1660
|
+
const result = { converted: [], skipped: [] };
|
|
1661
|
+
for (const file of listCredentialFiles(home)) {
|
|
1662
|
+
let raw;
|
|
1663
|
+
try {
|
|
1664
|
+
raw = fs6.readFileSync(file, "utf-8");
|
|
1665
|
+
} catch (error) {
|
|
1666
|
+
result.skipped.push({ file, reason: error.code ?? "read" });
|
|
1667
|
+
continue;
|
|
1668
|
+
}
|
|
1669
|
+
const envelope = isEnvelopeText(raw);
|
|
1670
|
+
if (target === "encrypted" === envelope) continue;
|
|
1671
|
+
const read = decodeCredentialText(file, raw);
|
|
1672
|
+
if (read.state !== "ok") {
|
|
1673
|
+
result.skipped.push({ file, reason: read.state === "missing" ? "missing" : read.reason });
|
|
1674
|
+
continue;
|
|
1675
|
+
}
|
|
1676
|
+
write(file, read.text);
|
|
1677
|
+
result.converted.push(file);
|
|
1678
|
+
}
|
|
1679
|
+
return result;
|
|
1680
|
+
}
|
|
1681
|
+
function clearKeyIdMarker(home = os4.homedir()) {
|
|
1682
|
+
fs6.rmSync(path8.join(home, ".mimi-seed", DATA_KEY_ID_FILE), { force: true });
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
// ../core/src/atomic-write.ts
|
|
1085
1686
|
var CREDENTIAL_FILE_MODE = 384;
|
|
1086
1687
|
var CREDENTIAL_DIR_MODE = 448;
|
|
1087
1688
|
var RENAME_RETRY_DELAYS_MS = [10, 20, 40, 80, 160, 320, 370];
|
|
@@ -1104,8 +1705,8 @@ function renameWithRetry(from, to, deps = {}) {
|
|
|
1104
1705
|
}
|
|
1105
1706
|
}
|
|
1106
1707
|
function writeFileAtomic(filePath, contents, options = {}) {
|
|
1107
|
-
mkdirSync(
|
|
1108
|
-
const tempPath = `${filePath}.${process.pid}.${
|
|
1708
|
+
mkdirSync(path9.dirname(filePath), { recursive: true, ...options.dirMode !== void 0 && { mode: options.dirMode } });
|
|
1709
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID3()}.tmp`;
|
|
1109
1710
|
try {
|
|
1110
1711
|
writeFileSync(tempPath, contents, {
|
|
1111
1712
|
encoding: "utf8",
|
|
@@ -1126,29 +1727,33 @@ function writeJsonAtomic(filePath, value, options = {}) {
|
|
|
1126
1727
|
`, options);
|
|
1127
1728
|
}
|
|
1128
1729
|
function writeCredentialJson(filePath, value) {
|
|
1129
|
-
|
|
1730
|
+
writeCredentialFile(filePath, `${JSON.stringify(value, null, 2)}
|
|
1731
|
+
`);
|
|
1732
|
+
}
|
|
1733
|
+
function writeCredentialFile(filePath, contents) {
|
|
1734
|
+
writeFileAtomic(filePath, sealForWrite(filePath, contents), { mode: CREDENTIAL_FILE_MODE, dirMode: CREDENTIAL_DIR_MODE });
|
|
1130
1735
|
}
|
|
1131
1736
|
|
|
1132
1737
|
// src/jenkins-config.ts
|
|
1133
|
-
var CONFIG_DIR =
|
|
1134
|
-
var JENKINS_PATH =
|
|
1135
|
-
var LEGACY_PATH =
|
|
1136
|
-
function loadJenkinsConfig(home =
|
|
1738
|
+
var CONFIG_DIR = path10.join(os5.homedir(), ".mimi-seed");
|
|
1739
|
+
var JENKINS_PATH = path10.join(CONFIG_DIR, "jenkins.json");
|
|
1740
|
+
var LEGACY_PATH = path10.join(CONFIG_DIR, "config.json");
|
|
1741
|
+
function loadJenkinsConfig(home = os5.homedir()) {
|
|
1137
1742
|
try {
|
|
1138
|
-
const p =
|
|
1139
|
-
return JSON.parse(
|
|
1743
|
+
const p = path10.join(home, ".mimi-seed", "jenkins.json");
|
|
1744
|
+
return JSON.parse(readCredentialFileSync(p));
|
|
1140
1745
|
} catch {
|
|
1141
1746
|
return null;
|
|
1142
1747
|
}
|
|
1143
1748
|
}
|
|
1144
|
-
function migrateLegacyJenkins(home =
|
|
1145
|
-
const dir =
|
|
1146
|
-
const jenkinsPath =
|
|
1147
|
-
const legacyPath =
|
|
1148
|
-
if (
|
|
1749
|
+
function migrateLegacyJenkins(home = os5.homedir()) {
|
|
1750
|
+
const dir = path10.join(home, ".mimi-seed");
|
|
1751
|
+
const jenkinsPath = path10.join(dir, "jenkins.json");
|
|
1752
|
+
const legacyPath = path10.join(dir, "config.json");
|
|
1753
|
+
if (fs7.existsSync(jenkinsPath)) return false;
|
|
1149
1754
|
let legacy;
|
|
1150
1755
|
try {
|
|
1151
|
-
legacy = JSON.parse(
|
|
1756
|
+
legacy = JSON.parse(readCredentialFileSync(legacyPath));
|
|
1152
1757
|
} catch {
|
|
1153
1758
|
return false;
|
|
1154
1759
|
}
|
|
@@ -1169,18 +1774,18 @@ function migrateLegacyJenkins(home = os3.homedir()) {
|
|
|
1169
1774
|
}
|
|
1170
1775
|
|
|
1171
1776
|
// src/detect.ts
|
|
1172
|
-
import
|
|
1173
|
-
import
|
|
1777
|
+
import fs8 from "fs/promises";
|
|
1778
|
+
import path11 from "path";
|
|
1174
1779
|
async function readIfExists(p) {
|
|
1175
1780
|
try {
|
|
1176
|
-
return await
|
|
1781
|
+
return await fs8.readFile(p, "utf8");
|
|
1177
1782
|
} catch {
|
|
1178
1783
|
return null;
|
|
1179
1784
|
}
|
|
1180
1785
|
}
|
|
1181
1786
|
async function pathExists(p) {
|
|
1182
1787
|
try {
|
|
1183
|
-
await
|
|
1788
|
+
await fs8.access(p);
|
|
1184
1789
|
return true;
|
|
1185
1790
|
} catch {
|
|
1186
1791
|
return false;
|
|
@@ -1194,9 +1799,9 @@ async function importedJsonObjects(configPath, text, root) {
|
|
|
1194
1799
|
];
|
|
1195
1800
|
for (const match of imports) {
|
|
1196
1801
|
if (!match[2].startsWith(".")) continue;
|
|
1197
|
-
const candidate =
|
|
1198
|
-
const relative =
|
|
1199
|
-
if (relative.startsWith(`..${
|
|
1802
|
+
const candidate = path11.resolve(path11.dirname(configPath), match[2]);
|
|
1803
|
+
const relative = path11.relative(root, candidate);
|
|
1804
|
+
if (relative.startsWith(`..${path11.sep}`) || relative === ".." || path11.isAbsolute(relative)) continue;
|
|
1200
1805
|
const jsonText = await readIfExists(candidate);
|
|
1201
1806
|
if (!jsonText) continue;
|
|
1202
1807
|
try {
|
|
@@ -1233,16 +1838,16 @@ async function walk(root, match, maxDepth = 5) {
|
|
|
1233
1838
|
if (depth > maxDepth) return;
|
|
1234
1839
|
let entries;
|
|
1235
1840
|
try {
|
|
1236
|
-
entries = await
|
|
1841
|
+
entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
1237
1842
|
} catch {
|
|
1238
1843
|
return;
|
|
1239
1844
|
}
|
|
1240
1845
|
for (const e of entries) {
|
|
1241
1846
|
if (e.isDirectory()) {
|
|
1242
1847
|
if (skipDirs.has(e.name)) continue;
|
|
1243
|
-
await visit(
|
|
1848
|
+
await visit(path11.join(dir, e.name), depth + 1);
|
|
1244
1849
|
} else if (e.isFile() && match(e.name)) {
|
|
1245
|
-
found.push(
|
|
1850
|
+
found.push(path11.join(dir, e.name));
|
|
1246
1851
|
}
|
|
1247
1852
|
}
|
|
1248
1853
|
}
|
|
@@ -1252,7 +1857,7 @@ async function walk(root, match, maxDepth = 5) {
|
|
|
1252
1857
|
async function detectHints(cwd) {
|
|
1253
1858
|
const hints = [];
|
|
1254
1859
|
for (const fname of ["app.json", "app.config.json"]) {
|
|
1255
|
-
const txt = await readIfExists(
|
|
1860
|
+
const txt = await readIfExists(path11.join(cwd, fname));
|
|
1256
1861
|
if (!txt) continue;
|
|
1257
1862
|
try {
|
|
1258
1863
|
const json = JSON.parse(txt);
|
|
@@ -1272,7 +1877,7 @@ async function detectHints(cwd) {
|
|
|
1272
1877
|
}
|
|
1273
1878
|
}
|
|
1274
1879
|
for (const fname of ["app.config.js", "app.config.cjs", "app.config.mjs", "app.config.ts"]) {
|
|
1275
|
-
const configPath =
|
|
1880
|
+
const configPath = path11.join(cwd, fname);
|
|
1276
1881
|
const txt = await readIfExists(configPath);
|
|
1277
1882
|
if (!txt) continue;
|
|
1278
1883
|
const imports = await importedJsonObjects(configPath, txt, cwd);
|
|
@@ -1294,7 +1899,7 @@ async function detectHints(cwd) {
|
|
|
1294
1899
|
if (m?.[1]) {
|
|
1295
1900
|
const pkg = m[1];
|
|
1296
1901
|
if (!hints.some((h) => h.packageName === pkg)) {
|
|
1297
|
-
hints.push({ packageName: pkg, source: [
|
|
1902
|
+
hints.push({ packageName: pkg, source: [path11.relative(cwd, f)] });
|
|
1298
1903
|
}
|
|
1299
1904
|
}
|
|
1300
1905
|
}
|
|
@@ -1309,7 +1914,7 @@ async function detectHints(cwd) {
|
|
|
1309
1914
|
const bid = m[1];
|
|
1310
1915
|
if (bid.includes("$(PRODUCT_BUNDLE_IDENTIFIER)")) continue;
|
|
1311
1916
|
if (!hints.some((h) => h.bundleId === bid)) {
|
|
1312
|
-
hints.push({ bundleId: bid, source: [
|
|
1917
|
+
hints.push({ bundleId: bid, source: [path11.relative(cwd, f)] });
|
|
1313
1918
|
}
|
|
1314
1919
|
}
|
|
1315
1920
|
}
|
|
@@ -1322,11 +1927,11 @@ async function detectHints(cwd) {
|
|
|
1322
1927
|
const bid = m[1].trim().replace(/^["']|["']$/g, "");
|
|
1323
1928
|
if (!bid || bid.includes("$")) continue;
|
|
1324
1929
|
if (!hints.some((h) => h.bundleId === bid)) {
|
|
1325
|
-
hints.push({ bundleId: bid, source: [
|
|
1930
|
+
hints.push({ bundleId: bid, source: [path11.relative(cwd, f)] });
|
|
1326
1931
|
}
|
|
1327
1932
|
}
|
|
1328
1933
|
}
|
|
1329
|
-
const unitySettings =
|
|
1934
|
+
const unitySettings = path11.join(cwd, "ProjectSettings", "ProjectSettings.asset");
|
|
1330
1935
|
const unityText = await readIfExists(unitySettings);
|
|
1331
1936
|
if (unityText) {
|
|
1332
1937
|
const lines = unityText.split(/\r?\n/);
|
|
@@ -1350,11 +1955,11 @@ async function detectHints(cwd) {
|
|
|
1350
1955
|
name,
|
|
1351
1956
|
packageName,
|
|
1352
1957
|
bundleId,
|
|
1353
|
-
source: [
|
|
1958
|
+
source: [path11.relative(cwd, unitySettings)]
|
|
1354
1959
|
});
|
|
1355
1960
|
}
|
|
1356
1961
|
}
|
|
1357
|
-
const pkgJson = await readIfExists(
|
|
1962
|
+
const pkgJson = await readIfExists(path11.join(cwd, "package.json"));
|
|
1358
1963
|
if (pkgJson) {
|
|
1359
1964
|
try {
|
|
1360
1965
|
const json = JSON.parse(pkgJson);
|
|
@@ -1390,23 +1995,23 @@ async function detectHints(cwd) {
|
|
|
1390
1995
|
return merged.filter((h) => h.packageName || h.bundleId);
|
|
1391
1996
|
}
|
|
1392
1997
|
async function hasAnyProjectSignal(cwd) {
|
|
1393
|
-
return await pathExists(
|
|
1998
|
+
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
1999
|
}
|
|
1395
2000
|
|
|
1396
2001
|
// src/deploy.ts
|
|
1397
2002
|
import kleur from "kleur";
|
|
1398
2003
|
import * as readline from "readline";
|
|
1399
|
-
import { randomUUID as
|
|
2004
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
1400
2005
|
|
|
1401
2006
|
// src/config.ts
|
|
1402
|
-
import
|
|
1403
|
-
import
|
|
1404
|
-
import
|
|
1405
|
-
var CONFIG_DIR2 =
|
|
1406
|
-
var CONFIG_PATH =
|
|
2007
|
+
import fs9 from "fs/promises";
|
|
2008
|
+
import path12 from "path";
|
|
2009
|
+
import os6 from "os";
|
|
2010
|
+
var CONFIG_DIR2 = path12.join(os6.homedir(), ".mimi-seed");
|
|
2011
|
+
var CONFIG_PATH = path12.join(CONFIG_DIR2, "config.json");
|
|
1407
2012
|
async function readConfig() {
|
|
1408
2013
|
try {
|
|
1409
|
-
const txt = await
|
|
2014
|
+
const txt = await readCredentialFile(CONFIG_PATH);
|
|
1410
2015
|
return JSON.parse(txt);
|
|
1411
2016
|
} catch {
|
|
1412
2017
|
return null;
|
|
@@ -1416,7 +2021,7 @@ async function writeConfig(cfg) {
|
|
|
1416
2021
|
writeCredentialJson(CONFIG_PATH, cfg);
|
|
1417
2022
|
}
|
|
1418
2023
|
async function deleteConfig() {
|
|
1419
|
-
await
|
|
2024
|
+
await fs9.rm(CONFIG_PATH, { force: true });
|
|
1420
2025
|
}
|
|
1421
2026
|
var CONFIG_LOCATION = CONFIG_PATH;
|
|
1422
2027
|
async function getEffectiveConfig() {
|
|
@@ -1526,8 +2131,8 @@ async function consumeDeployStream(reader, onEvent) {
|
|
|
1526
2131
|
}
|
|
1527
2132
|
|
|
1528
2133
|
// src/project-link.ts
|
|
1529
|
-
import
|
|
1530
|
-
import
|
|
2134
|
+
import fs10 from "fs/promises";
|
|
2135
|
+
import path13 from "path";
|
|
1531
2136
|
|
|
1532
2137
|
// ../core/src/http-errors.ts
|
|
1533
2138
|
function endpointLabel(input, fallback) {
|
|
@@ -1546,7 +2151,7 @@ function isTimeoutAbort(error) {
|
|
|
1546
2151
|
// src/lib/http.ts
|
|
1547
2152
|
var HTTP_TIMEOUT_MS = 3e4;
|
|
1548
2153
|
var HTTP_STREAM_TIMEOUT_MS = 30 * 6e4;
|
|
1549
|
-
var
|
|
2154
|
+
var M3 = catalog(
|
|
1550
2155
|
{
|
|
1551
2156
|
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
2157
|
unknownEndpoint: "\uC678\uBD80 \uC11C\uBC84"
|
|
@@ -1556,7 +2161,7 @@ var M2 = catalog(
|
|
|
1556
2161
|
unknownEndpoint: "the remote server"
|
|
1557
2162
|
}
|
|
1558
2163
|
);
|
|
1559
|
-
var endpointLabel2 = (input) => endpointLabel(input,
|
|
2164
|
+
var endpointLabel2 = (input) => endpointLabel(input, M3().unknownEndpoint);
|
|
1560
2165
|
function isBodyAbort(error) {
|
|
1561
2166
|
const named = (e) => {
|
|
1562
2167
|
const name = e?.name;
|
|
@@ -1565,7 +2170,7 @@ function isBodyAbort(error) {
|
|
|
1565
2170
|
return named(error) || named(error?.cause);
|
|
1566
2171
|
}
|
|
1567
2172
|
function timeoutError(input, timeoutMs, cause) {
|
|
1568
|
-
return new Error(
|
|
2173
|
+
return new Error(M3().timedOut(endpointLabel2(input), Math.max(1, Math.round(timeoutMs / 1e3))), { cause });
|
|
1569
2174
|
}
|
|
1570
2175
|
async function readBodyWithTimeout(input, timeoutMs, read) {
|
|
1571
2176
|
try {
|
|
@@ -1587,7 +2192,7 @@ async function fetchWithTimeout(input, init = {}, timeoutMs = HTTP_TIMEOUT_MS) {
|
|
|
1587
2192
|
|
|
1588
2193
|
// src/project-link.ts
|
|
1589
2194
|
var PROJECT_LINK_FILENAME = ".mimi-seed-link.json";
|
|
1590
|
-
var
|
|
2195
|
+
var M4 = catalog({
|
|
1591
2196
|
lookupFailed: (status) => `\uD504\uB85C\uC81D\uD2B8 \uC571 \uC5F0\uACB0 \uC870\uD68C \uC2E4\uD328 (${status}). --app <id>\uB85C \uC9C0\uC815\uD558\uC138\uC694.`,
|
|
1592
2197
|
invalidResponse: "\uD504\uB85C\uC81D\uD2B8 \uC571 \uC5F0\uACB0 \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
1593
2198
|
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 +2212,17 @@ function isLink(value) {
|
|
|
1607
2212
|
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
2213
|
}
|
|
1609
2214
|
async function findProjectLink(cwd) {
|
|
1610
|
-
let dir =
|
|
2215
|
+
let dir = path13.resolve(cwd);
|
|
1611
2216
|
for (let depth = 0; depth <= 8; depth++) {
|
|
1612
|
-
const file =
|
|
2217
|
+
const file = path13.join(dir, PROJECT_LINK_FILENAME);
|
|
1613
2218
|
try {
|
|
1614
|
-
const parsed = JSON.parse(await
|
|
1615
|
-
if (!isLink(parsed)) throw new Error(
|
|
2219
|
+
const parsed = JSON.parse(await fs10.readFile(file, "utf8"));
|
|
2220
|
+
if (!isLink(parsed)) throw new Error(M4().invalidFile);
|
|
1616
2221
|
return parsed;
|
|
1617
2222
|
} catch (error) {
|
|
1618
2223
|
if (error.code !== "ENOENT") throw error;
|
|
1619
2224
|
}
|
|
1620
|
-
const parent =
|
|
2225
|
+
const parent = path13.dirname(dir);
|
|
1621
2226
|
if (parent === dir) break;
|
|
1622
2227
|
dir = parent;
|
|
1623
2228
|
}
|
|
@@ -1626,14 +2231,14 @@ async function findProjectLink(cwd) {
|
|
|
1626
2231
|
function resolveLinkedAppId(link, webBase, explicitAppId) {
|
|
1627
2232
|
if (!link) return explicitAppId;
|
|
1628
2233
|
if (base(link.webBase) !== base(webBase) || explicitAppId && explicitAppId !== link.appId) {
|
|
1629
|
-
throw new Error(
|
|
2234
|
+
throw new Error(M4().mismatch);
|
|
1630
2235
|
}
|
|
1631
2236
|
return link.appId;
|
|
1632
2237
|
}
|
|
1633
2238
|
function validateProjectIdentity(link, hints) {
|
|
1634
2239
|
if (!link || hints.length === 0) return;
|
|
1635
2240
|
if (!hints.every((hint) => (!hint.packageName || hint.packageName === link.packageName) && (!hint.bundleId || hint.bundleId === link.bundleId))) {
|
|
1636
|
-
throw new Error(
|
|
2241
|
+
throw new Error(M4().mismatch);
|
|
1637
2242
|
}
|
|
1638
2243
|
}
|
|
1639
2244
|
async function linkProject(cwd, webBase, token, hint) {
|
|
@@ -1642,11 +2247,11 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1642
2247
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
1643
2248
|
body: JSON.stringify({ packageName: hint.packageName, bundleId: hint.bundleId })
|
|
1644
2249
|
});
|
|
1645
|
-
if (!res.ok) throw new Error(
|
|
2250
|
+
if (!res.ok) throw new Error(M4().lookupFailed(res.status));
|
|
1646
2251
|
const value = await res.json();
|
|
1647
2252
|
const app = value && typeof value === "object" && "app" in value ? value.app : null;
|
|
1648
2253
|
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(
|
|
2254
|
+
throw new Error(M4().invalidResponse);
|
|
1650
2255
|
}
|
|
1651
2256
|
const link = {
|
|
1652
2257
|
schema: 1,
|
|
@@ -1657,19 +2262,19 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1657
2262
|
};
|
|
1658
2263
|
const existing = await findProjectLink(cwd);
|
|
1659
2264
|
if (existing && (existing.appId !== link.appId || base(existing.webBase) !== link.webBase || existing.packageName !== link.packageName || existing.bundleId !== link.bundleId)) {
|
|
1660
|
-
throw new Error(
|
|
2265
|
+
throw new Error(M4().mismatch);
|
|
1661
2266
|
}
|
|
1662
2267
|
if (!existing) {
|
|
1663
|
-
await
|
|
2268
|
+
await fs10.writeFile(path13.join(cwd, PROJECT_LINK_FILENAME), `${JSON.stringify(link, null, 2)}
|
|
1664
2269
|
`, { mode: 384, flag: "wx" });
|
|
1665
2270
|
}
|
|
1666
|
-
const ignorePath =
|
|
1667
|
-
const ignore = await
|
|
2271
|
+
const ignorePath = path13.join(cwd, ".gitignore");
|
|
2272
|
+
const ignore = await fs10.readFile(ignorePath, "utf8").catch((error) => {
|
|
1668
2273
|
if (error.code !== "ENOENT") throw error;
|
|
1669
2274
|
return "";
|
|
1670
2275
|
});
|
|
1671
2276
|
if (!ignore.split(/\r?\n/).includes(PROJECT_LINK_FILENAME)) {
|
|
1672
|
-
await
|
|
2277
|
+
await fs10.appendFile(ignorePath, `${ignore && !ignore.endsWith("\n") ? "\n" : ""}${PROJECT_LINK_FILENAME}
|
|
1673
2278
|
`);
|
|
1674
2279
|
}
|
|
1675
2280
|
return link;
|
|
@@ -1677,13 +2282,13 @@ async function linkProject(cwd, webBase, token, hint) {
|
|
|
1677
2282
|
|
|
1678
2283
|
// src/deploy-runs.ts
|
|
1679
2284
|
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(
|
|
2285
|
+
if (!value || typeof value !== "object") throw new Error(M5().invalidResponse);
|
|
2286
|
+
const run2 = value;
|
|
2287
|
+
const jobId = run2.jobId ?? run2.id;
|
|
2288
|
+
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") {
|
|
2289
|
+
throw new Error(M5().invalidResponse);
|
|
1685
2290
|
}
|
|
1686
|
-
return { ...
|
|
2291
|
+
return { ...run2, jobId };
|
|
1687
2292
|
}
|
|
1688
2293
|
async function updateDeployRun(webBase, token, request) {
|
|
1689
2294
|
const res = await fetchWithTimeout(new URL("/api/deploy/runs", webBase), {
|
|
@@ -1691,7 +2296,7 @@ async function updateDeployRun(webBase, token, request) {
|
|
|
1691
2296
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
1692
2297
|
body: JSON.stringify(request)
|
|
1693
2298
|
});
|
|
1694
|
-
if (!res.ok) throw new Error(
|
|
2299
|
+
if (!res.ok) throw new Error(M5().updateFailed(res.status));
|
|
1695
2300
|
return parseRun(await res.json());
|
|
1696
2301
|
}
|
|
1697
2302
|
async function getDeployRun(webBase, token, runId) {
|
|
@@ -1700,10 +2305,10 @@ async function getDeployRun(webBase, token, runId) {
|
|
|
1700
2305
|
const res = await fetchWithTimeout(url, {
|
|
1701
2306
|
headers: { Authorization: `Bearer ${token}` }
|
|
1702
2307
|
});
|
|
1703
|
-
if (!res.ok) throw new Error(
|
|
2308
|
+
if (!res.ok) throw new Error(M5().lookupFailed(res.status));
|
|
1704
2309
|
return parseRun(await res.json());
|
|
1705
2310
|
}
|
|
1706
|
-
var
|
|
2311
|
+
var M5 = catalog({
|
|
1707
2312
|
invalidResponse: "\uBC30\uD3EC \uAE30\uB85D \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
1708
2313
|
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
2314
|
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 +2319,9 @@ var M4 = catalog({
|
|
|
1714
2319
|
});
|
|
1715
2320
|
|
|
1716
2321
|
// src/jenkins-project.ts
|
|
1717
|
-
import
|
|
1718
|
-
import
|
|
1719
|
-
var
|
|
2322
|
+
import fs11 from "fs";
|
|
2323
|
+
import path14 from "path";
|
|
2324
|
+
var M6 = catalog({
|
|
1720
2325
|
invalidManifest: "\uD504\uB85C\uC81D\uD2B8 .mimi-seed.json\uC740 \uC62C\uBC14\uB978 JSON \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4.",
|
|
1721
2326
|
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
2327
|
invalidJob: ".mimi-seed.json\uC758 services.jenkins.jobAndroid/jobIos\uC5D0 \uC62C\uBC14\uB978 \uC7A1 \uACBD\uB85C\uB97C \uC124\uC815\uD558\uC138\uC694.",
|
|
@@ -1729,26 +2334,26 @@ var M5 = catalog({
|
|
|
1729
2334
|
});
|
|
1730
2335
|
function resolveProjectJenkins(cfg, platform, cwd = process.cwd()) {
|
|
1731
2336
|
const field = platform === "android" ? "jobAndroid" : "jobIos";
|
|
1732
|
-
let dir =
|
|
2337
|
+
let dir = path14.resolve(cwd);
|
|
1733
2338
|
for (let depth = 0; depth <= 8; depth++) {
|
|
1734
|
-
const file =
|
|
1735
|
-
if (
|
|
2339
|
+
const file = path14.join(dir, MANIFEST_FILENAME);
|
|
2340
|
+
if (fs11.existsSync(file)) {
|
|
1736
2341
|
let manifest;
|
|
1737
2342
|
try {
|
|
1738
|
-
manifest = JSON.parse(
|
|
2343
|
+
manifest = JSON.parse(fs11.readFileSync(file, "utf8"));
|
|
1739
2344
|
} catch {
|
|
1740
|
-
throw new Error(
|
|
2345
|
+
throw new Error(M6().invalidManifest);
|
|
1741
2346
|
}
|
|
1742
2347
|
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
|
|
1743
|
-
throw new Error(
|
|
2348
|
+
throw new Error(M6().invalidManifest);
|
|
1744
2349
|
}
|
|
1745
2350
|
const service = manifest.services?.jenkins;
|
|
1746
2351
|
if (service?.url !== void 0 && (typeof service.url !== "string" || service.url.replace(/\/+$/, "") !== cfg.url.replace(/\/+$/, ""))) {
|
|
1747
|
-
throw new Error(
|
|
2352
|
+
throw new Error(M6().controllerMismatch);
|
|
1748
2353
|
}
|
|
1749
2354
|
return { job: validateJob(service?.[field]), source: file };
|
|
1750
2355
|
}
|
|
1751
|
-
const parent =
|
|
2356
|
+
const parent = path14.dirname(dir);
|
|
1752
2357
|
if (parent === dir) break;
|
|
1753
2358
|
dir = parent;
|
|
1754
2359
|
}
|
|
@@ -1756,7 +2361,7 @@ function resolveProjectJenkins(cfg, platform, cwd = process.cwd()) {
|
|
|
1756
2361
|
}
|
|
1757
2362
|
function validateJob(job) {
|
|
1758
2363
|
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(
|
|
2364
|
+
throw new Error(M6().invalidJob);
|
|
1760
2365
|
}
|
|
1761
2366
|
return job;
|
|
1762
2367
|
}
|
|
@@ -1768,7 +2373,7 @@ function jenkinsJobPath(job) {
|
|
|
1768
2373
|
}
|
|
1769
2374
|
function jenkinsBuildParameters(platform, ref, appId) {
|
|
1770
2375
|
if (!ref || /^[a-f0-9]{7,40}$/i.test(ref) || ref.startsWith("-") || /[\s~^:?*[\\]|\.\.|@\{/.test(ref)) {
|
|
1771
|
-
throw new Error(
|
|
2376
|
+
throw new Error(M6().invalidRef);
|
|
1772
2377
|
}
|
|
1773
2378
|
return {
|
|
1774
2379
|
BUILD_TARGET: platform,
|
|
@@ -1784,9 +2389,8 @@ function jenkinsBuildParameters(platform, ref, appId) {
|
|
|
1784
2389
|
}
|
|
1785
2390
|
|
|
1786
2391
|
// src/ci-providers.ts
|
|
1787
|
-
import
|
|
1788
|
-
import
|
|
1789
|
-
import os5 from "os";
|
|
2392
|
+
import path15 from "path";
|
|
2393
|
+
import os7 from "os";
|
|
1790
2394
|
|
|
1791
2395
|
// ../core/src/ci.ts
|
|
1792
2396
|
function githubApiBase(cfg) {
|
|
@@ -1809,8 +2413,8 @@ function gitlabProjectId(cfg) {
|
|
|
1809
2413
|
}
|
|
1810
2414
|
|
|
1811
2415
|
// src/ci-providers.ts
|
|
1812
|
-
var CI_CONFIG_PATH =
|
|
1813
|
-
var
|
|
2416
|
+
var CI_CONFIG_PATH = path15.join(os7.homedir(), ".mimi-seed", "ci.json");
|
|
2417
|
+
var M7 = catalog(
|
|
1814
2418
|
{
|
|
1815
2419
|
badToken: (provider, status) => `${provider} ${status} \u2014 \uD1A0\uD070\uC774 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC544`,
|
|
1816
2420
|
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 +2431,7 @@ var M6 = catalog(
|
|
|
1827
2431
|
);
|
|
1828
2432
|
function loadCiProviderConfig() {
|
|
1829
2433
|
try {
|
|
1830
|
-
const cfg = JSON.parse(
|
|
2434
|
+
const cfg = JSON.parse(readCredentialFileSync(CI_CONFIG_PATH));
|
|
1831
2435
|
const host = normalizeHost(cfg.host);
|
|
1832
2436
|
return host ? { ...cfg, host } : { ...cfg, host: void 0 };
|
|
1833
2437
|
} catch {
|
|
@@ -1853,18 +2457,18 @@ async function verifyCiToken(cfg) {
|
|
|
1853
2457
|
headers: { Authorization: `Bearer ${probe.token}`, Accept: "application/vnd.github+json" }
|
|
1854
2458
|
});
|
|
1855
2459
|
if (!res2.ok) {
|
|
1856
|
-
return { ok: false, reason:
|
|
2460
|
+
return { ok: false, reason: M7().badToken("GitHub", res2.status) };
|
|
1857
2461
|
}
|
|
1858
2462
|
const user2 = await res2.json();
|
|
1859
2463
|
const scopes = res2.headers.get("x-oauth-scopes");
|
|
1860
2464
|
if (scopes !== null && !scopes.split(/,\s*/).filter(Boolean).includes("workflow")) {
|
|
1861
|
-
return { ok: false, reason:
|
|
2465
|
+
return { ok: false, reason: M7().noScope(scopes) };
|
|
1862
2466
|
}
|
|
1863
2467
|
return { ok: true, login: user2.login };
|
|
1864
2468
|
}
|
|
1865
2469
|
const res = await fetchWithTimeout(`${gitlabApiBase(probe)}/user`, { headers: { "PRIVATE-TOKEN": probe.token } });
|
|
1866
2470
|
if (!res.ok) {
|
|
1867
|
-
return { ok: false, reason:
|
|
2471
|
+
return { ok: false, reason: M7().badToken("GitLab", res.status) };
|
|
1868
2472
|
}
|
|
1869
2473
|
const user = await res.json();
|
|
1870
2474
|
return { ok: true, login: user.username };
|
|
@@ -1874,8 +2478,8 @@ async function verifyCiToken(cfg) {
|
|
|
1874
2478
|
}
|
|
1875
2479
|
function isGitHubWorkflowRun(value) {
|
|
1876
2480
|
if (typeof value !== "object" || value === null) return false;
|
|
1877
|
-
const
|
|
1878
|
-
return typeof
|
|
2481
|
+
const run2 = value;
|
|
2482
|
+
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
2483
|
}
|
|
1880
2484
|
async function ghTriggerWorkflow(cfg, workflow, ref, inputs = {}) {
|
|
1881
2485
|
const startTime = /* @__PURE__ */ new Date();
|
|
@@ -1900,9 +2504,9 @@ async function ghTriggerWorkflow(cfg, workflow, ref, inputs = {}) {
|
|
|
1900
2504
|
const data = await runsRes.json();
|
|
1901
2505
|
if (typeof data !== "object" || data === null || !("workflow_runs" in data) || !Array.isArray(data.workflow_runs)) return null;
|
|
1902
2506
|
const runs = data.workflow_runs.filter(isGitHubWorkflowRun);
|
|
1903
|
-
const
|
|
1904
|
-
if (!
|
|
1905
|
-
return { runId:
|
|
2507
|
+
const run2 = runs.find((entry) => new Date(entry.created_at) >= startTime) ?? runs[0];
|
|
2508
|
+
if (!run2) return null;
|
|
2509
|
+
return { runId: run2.id, url: run2.html_url };
|
|
1906
2510
|
}
|
|
1907
2511
|
async function ghPollRun(cfg, runId, onTick, timeoutMs = 30 * 60 * 1e3, intervalMs = 15e3) {
|
|
1908
2512
|
const start = Date.now();
|
|
@@ -1917,12 +2521,12 @@ async function ghPollRun(cfg, runId, onTick, timeoutMs = 30 * 60 * 1e3, interval
|
|
|
1917
2521
|
);
|
|
1918
2522
|
} catch {
|
|
1919
2523
|
consecutiveErrors++;
|
|
1920
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2524
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailed("GitHub"));
|
|
1921
2525
|
continue;
|
|
1922
2526
|
}
|
|
1923
2527
|
if (!res.ok) {
|
|
1924
2528
|
consecutiveErrors++;
|
|
1925
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2529
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailedHttp("GitHub", res.status));
|
|
1926
2530
|
continue;
|
|
1927
2531
|
}
|
|
1928
2532
|
consecutiveErrors = 0;
|
|
@@ -1962,12 +2566,12 @@ async function glPollPipeline(cfg, pipelineId, onTick, timeoutMs = 30 * 60 * 1e3
|
|
|
1962
2566
|
);
|
|
1963
2567
|
} catch {
|
|
1964
2568
|
consecutiveErrors++;
|
|
1965
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2569
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailed("GitLab"));
|
|
1966
2570
|
continue;
|
|
1967
2571
|
}
|
|
1968
2572
|
if (!res.ok) {
|
|
1969
2573
|
consecutiveErrors++;
|
|
1970
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2574
|
+
if (consecutiveErrors >= 3) throw new Error(M7().pollFailedHttp("GitLab", res.status));
|
|
1971
2575
|
continue;
|
|
1972
2576
|
}
|
|
1973
2577
|
consecutiveErrors = 0;
|
|
@@ -1993,7 +2597,7 @@ var PHASE_ICON = {
|
|
|
1993
2597
|
function log(msg) {
|
|
1994
2598
|
process.stdout.write(msg + "\n");
|
|
1995
2599
|
}
|
|
1996
|
-
var
|
|
2600
|
+
var M8 = catalog(
|
|
1997
2601
|
{
|
|
1998
2602
|
missingValue: (option) => `${option} \uB4A4\uC5D0 \uAC12\uC744 \uC785\uB825\uD558\uC138\uC694.`,
|
|
1999
2603
|
unknownOption: (option) => `\uC54C \uC218 \uC5C6\uB294 deploy \uC635\uC158: ${option}`,
|
|
@@ -2177,7 +2781,7 @@ async function triggerBuild(cfg, jobName, params) {
|
|
|
2177
2781
|
body: qs
|
|
2178
2782
|
});
|
|
2179
2783
|
if (!res.ok) {
|
|
2180
|
-
throw new Error(
|
|
2784
|
+
throw new Error(M8().jenkinsTriggerFailed(res.status, await res.text()));
|
|
2181
2785
|
}
|
|
2182
2786
|
const location2 = res.headers.get("Location") ?? "";
|
|
2183
2787
|
const match = location2.match(/\/queue\/item\/(\d+)\//);
|
|
@@ -2193,7 +2797,7 @@ async function getQueueBuildNumber(cfg, queueItemId) {
|
|
|
2193
2797
|
async function getBuildStatus(cfg, jobName, buildNumber) {
|
|
2194
2798
|
const url = `${jenkinsBase(cfg.url)}/${jenkinsJobPath(jobName)}/${buildNumber}/api/json`;
|
|
2195
2799
|
const res = await fetchWithTimeout(url, { headers: jenkinsHeaders(cfg), redirect: "error" });
|
|
2196
|
-
if (!res.ok) throw new Error(
|
|
2800
|
+
if (!res.ok) throw new Error(M8().buildStatusFailed(res.status));
|
|
2197
2801
|
const data = await res.json();
|
|
2198
2802
|
return {
|
|
2199
2803
|
building: data.building ?? true,
|
|
@@ -2214,18 +2818,18 @@ async function pollBuildComplete(cfg, jobName, buildNumber, timeoutMs = 30 * 60
|
|
|
2214
2818
|
consecutiveErrors = 0;
|
|
2215
2819
|
} catch {
|
|
2216
2820
|
consecutiveErrors++;
|
|
2217
|
-
if (consecutiveErrors >= 3) throw new Error(
|
|
2218
|
-
process.stdout.write(`\r \u26A0 ${
|
|
2821
|
+
if (consecutiveErrors >= 3) throw new Error(M8().jenkinsConnErrorFatal);
|
|
2822
|
+
process.stdout.write(`\r \u26A0 ${M8().jenkinsConnErrorRetry(consecutiveErrors)} `);
|
|
2219
2823
|
continue;
|
|
2220
2824
|
}
|
|
2221
2825
|
dots = (dots + 1) % 4;
|
|
2222
|
-
process.stdout.write(`\r \u23F3 ${
|
|
2826
|
+
process.stdout.write(`\r \u23F3 ${M8().buildRunning}${".".repeat(dots + 1)} `);
|
|
2223
2827
|
if (!status.building) {
|
|
2224
2828
|
process.stdout.write("\n");
|
|
2225
2829
|
return status.result ?? "FAILURE";
|
|
2226
2830
|
}
|
|
2227
2831
|
}
|
|
2228
|
-
throw new Error(
|
|
2832
|
+
throw new Error(M8().buildTimeout);
|
|
2229
2833
|
}
|
|
2230
2834
|
async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = false) {
|
|
2231
2835
|
const res = await fetchWithTimeout(`${webBase}/api/deploy`, {
|
|
@@ -2239,17 +2843,17 @@ async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = fa
|
|
|
2239
2843
|
}, HTTP_STREAM_TIMEOUT_MS);
|
|
2240
2844
|
if (!res.ok) {
|
|
2241
2845
|
const text = await res.text().catch(() => "");
|
|
2242
|
-
throw new Error(
|
|
2846
|
+
throw new Error(M8().serverDeployFailed(res.status, text.slice(0, 200)));
|
|
2243
2847
|
}
|
|
2244
2848
|
const reader = res.body?.getReader();
|
|
2245
|
-
if (!reader) throw new Error(
|
|
2849
|
+
if (!reader) throw new Error(M8().noSseStream);
|
|
2246
2850
|
let linkPrinted = linkAlreadyPrinted;
|
|
2247
2851
|
try {
|
|
2248
2852
|
await readBodyWithTimeout(`${webBase}/api/deploy`, HTTP_STREAM_TIMEOUT_MS, () => consumeDeployStream(reader, (event) => {
|
|
2249
2853
|
if (event.jobId && !linkPrinted) {
|
|
2250
2854
|
const link = new URL(`/apps/${encodeURIComponent(appId)}`, webBase);
|
|
2251
2855
|
link.searchParams.set("deployment", event.jobId);
|
|
2252
|
-
log(kleur.dim(
|
|
2856
|
+
log(kleur.dim(M8().deploymentLink(link.toString())));
|
|
2253
2857
|
linkPrinted = true;
|
|
2254
2858
|
}
|
|
2255
2859
|
const icon = PHASE_ICON[event.phase] ?? "\u25B8";
|
|
@@ -2258,8 +2862,8 @@ async function streamDeploy(webBase, token, appId, body, linkAlreadyPrinted = fa
|
|
|
2258
2862
|
}));
|
|
2259
2863
|
} catch (error) {
|
|
2260
2864
|
if (error instanceof DeployStreamError) {
|
|
2261
|
-
if (error.reason === "malformed") throw new Error(
|
|
2262
|
-
if (error.reason === "incomplete") throw new Error(
|
|
2865
|
+
if (error.reason === "malformed") throw new Error(M8().malformedSse, { cause: error });
|
|
2866
|
+
if (error.reason === "incomplete") throw new Error(M8().incompleteSse, { cause: error });
|
|
2263
2867
|
}
|
|
2264
2868
|
throw error;
|
|
2265
2869
|
}
|
|
@@ -2284,7 +2888,7 @@ function parseArgs(argv) {
|
|
|
2284
2888
|
const option = argv[i];
|
|
2285
2889
|
const value = () => {
|
|
2286
2890
|
const next = argv[++i];
|
|
2287
|
-
if (!next?.trim() || next.startsWith("--")) throw new Error(
|
|
2891
|
+
if (!next?.trim() || next.startsWith("--")) throw new Error(M8().missingValue(option));
|
|
2288
2892
|
return next;
|
|
2289
2893
|
};
|
|
2290
2894
|
switch (option) {
|
|
@@ -2343,24 +2947,24 @@ function parseArgs(argv) {
|
|
|
2343
2947
|
args.setupGitlab = true;
|
|
2344
2948
|
break;
|
|
2345
2949
|
default:
|
|
2346
|
-
throw new Error(
|
|
2950
|
+
throw new Error(M8().unknownOption(option));
|
|
2347
2951
|
}
|
|
2348
2952
|
}
|
|
2349
|
-
if (!["android", "ios"].includes(args.platform)) throw new Error(
|
|
2350
|
-
if (!["auto", "jenkins", "github", "gitlab"].includes(args.ci)) throw new Error(
|
|
2953
|
+
if (!["android", "ios"].includes(args.platform)) throw new Error(M8().invalidPlatform);
|
|
2954
|
+
if (!["auto", "jenkins", "github", "gitlab"].includes(args.ci)) throw new Error(M8().invalidCi);
|
|
2351
2955
|
if (args.versionCode !== void 0 && (!Number.isSafeInteger(args.versionCode) || args.versionCode < 1 || args.versionCode > ANDROID_VERSION_CODE_MAX)) {
|
|
2352
|
-
throw new Error(
|
|
2956
|
+
throw new Error(M8().invalidVersion);
|
|
2353
2957
|
}
|
|
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(
|
|
2958
|
+
if ([args.setupJenkins, args.setupGithub, args.setupGitlab].filter(Boolean).length > 1) throw new Error(M8().multipleSetup);
|
|
2959
|
+
if (args.dryRun && (args.setupJenkins || args.setupGithub || args.setupGitlab)) throw new Error(M8().drySetup);
|
|
2960
|
+
if (args.resume && (args.skipBuild || args.prepareOnly || args.dryRun)) throw new Error(M8().invalidResume);
|
|
2357
2961
|
return args;
|
|
2358
2962
|
}
|
|
2359
2963
|
async function promptGitProviderSetup(provider) {
|
|
2360
2964
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2361
2965
|
const ask2 = (q) => new Promise((resolve) => rl.question(q, (a) => resolve(a.trim())));
|
|
2362
2966
|
const isGh = provider === "github";
|
|
2363
|
-
const m =
|
|
2967
|
+
const m = M8();
|
|
2364
2968
|
log(kleur.bold(isGh ? m.githubSetupTitle : m.gitlabSetupTitle));
|
|
2365
2969
|
const tokenLabel = isGh ? m.githubTokenPrompt : m.gitlabTokenPrompt;
|
|
2366
2970
|
const token = await ask2(tokenLabel);
|
|
@@ -2381,36 +2985,36 @@ function resolveCi(ciOption, jenkins, ciProvider) {
|
|
|
2381
2985
|
if (ciOption !== "auto") return ciOption;
|
|
2382
2986
|
if (jenkins?.url && jenkins.token) return "jenkins";
|
|
2383
2987
|
if (ciProvider) return ciProvider.provider;
|
|
2384
|
-
throw new Error(
|
|
2988
|
+
throw new Error(M8().noCiConfig);
|
|
2385
2989
|
}
|
|
2386
2990
|
async function runGitProviderBuild(cfg, args, appId) {
|
|
2387
2991
|
let runUrl;
|
|
2388
2992
|
let runId;
|
|
2389
2993
|
if (cfg.provider === "github") {
|
|
2390
2994
|
if (!args.workflow) {
|
|
2391
|
-
throw new Error(
|
|
2995
|
+
throw new Error(M8().workflowRequired);
|
|
2392
2996
|
}
|
|
2393
|
-
log(
|
|
2997
|
+
log(M8().ghTrigger(kleur.cyan(args.workflow), args.ref));
|
|
2394
2998
|
const inputs = {};
|
|
2395
2999
|
inputs.MIMI_APP_ID = appId;
|
|
2396
3000
|
inputs.PLATFORM = args.platform;
|
|
2397
3001
|
const result2 = await ghTriggerWorkflow(cfg, args.workflow, args.ref, inputs);
|
|
2398
3002
|
if (!result2) {
|
|
2399
|
-
throw new Error(
|
|
3003
|
+
throw new Error(M8().ghRunIdFailed);
|
|
2400
3004
|
}
|
|
2401
3005
|
runId = result2.runId;
|
|
2402
3006
|
runUrl = result2.url;
|
|
2403
|
-
log(kleur.dim(
|
|
3007
|
+
log(kleur.dim(M8().ghRunId(runId, runUrl)));
|
|
2404
3008
|
} else {
|
|
2405
|
-
log(
|
|
3009
|
+
log(M8().glTrigger(args.ref));
|
|
2406
3010
|
const variables = { PLATFORM: args.platform };
|
|
2407
3011
|
variables.MIMI_APP_ID = appId;
|
|
2408
3012
|
const result2 = await glTriggerPipeline(cfg, args.ref, variables);
|
|
2409
3013
|
runId = result2.pipelineId;
|
|
2410
3014
|
runUrl = result2.url;
|
|
2411
|
-
log(kleur.dim(
|
|
3015
|
+
log(kleur.dim(M8().glPipelineId(runId, runUrl)));
|
|
2412
3016
|
}
|
|
2413
|
-
log(
|
|
3017
|
+
log(M8().waitingForCompletion);
|
|
2414
3018
|
let dots = 0;
|
|
2415
3019
|
const onTick = (status) => {
|
|
2416
3020
|
dots = (dots + 1) % 4;
|
|
@@ -2418,9 +3022,9 @@ async function runGitProviderBuild(cfg, args, appId) {
|
|
|
2418
3022
|
};
|
|
2419
3023
|
const result = cfg.provider === "github" ? await ghPollRun(cfg, runId, onTick) : await glPollPipeline(cfg, runId, onTick);
|
|
2420
3024
|
process.stdout.write("\n");
|
|
2421
|
-
if (result === "success") log(kleur.green(
|
|
3025
|
+
if (result === "success") log(kleur.green(M8().buildSucceeded(runId)));
|
|
2422
3026
|
else {
|
|
2423
|
-
log(kleur.red(
|
|
3027
|
+
log(kleur.red(M8().buildEnded(result)));
|
|
2424
3028
|
log(kleur.dim(` ${runUrl}`));
|
|
2425
3029
|
}
|
|
2426
3030
|
return { runId, result };
|
|
@@ -2430,9 +3034,9 @@ async function cmdDeploy(argv) {
|
|
|
2430
3034
|
if (args.dryRun) {
|
|
2431
3035
|
const jenkins = loadJenkinsConfig() ?? void 0;
|
|
2432
3036
|
const ci = args.skipBuild ? null : resolveCi(args.ci, jenkins, loadCiProviderConfig());
|
|
2433
|
-
if (ci === "jenkins" && !jenkins) throw new Error(
|
|
3037
|
+
if (ci === "jenkins" && !jenkins) throw new Error(credentialFileProblemMessage("~/.mimi-seed/jenkins.json") ?? M8().noJenkinsConfig);
|
|
2434
3038
|
const plan = ci === "jenkins" && jenkins ? { ...resolveProjectJenkins(jenkins, args.platform), parameters: jenkinsBuildParameters(args.platform, args.ref, args.appId) } : void 0;
|
|
2435
|
-
log(
|
|
3039
|
+
log(M8().dryRunNotice);
|
|
2436
3040
|
log(JSON.stringify({
|
|
2437
3041
|
platform: args.platform,
|
|
2438
3042
|
appId: args.appId ?? null,
|
|
@@ -2446,7 +3050,7 @@ async function cmdDeploy(argv) {
|
|
|
2446
3050
|
}
|
|
2447
3051
|
const cfg = await getEffectiveConfig();
|
|
2448
3052
|
if (!cfg) {
|
|
2449
|
-
log(kleur.red(
|
|
3053
|
+
log(kleur.red(credentialFileProblemMessage("~/.mimi-seed/config.json") ?? M8().noAccount));
|
|
2450
3054
|
process.exit(1);
|
|
2451
3055
|
}
|
|
2452
3056
|
if (args.setupJenkins) {
|
|
@@ -2457,13 +3061,13 @@ async function cmdDeploy(argv) {
|
|
|
2457
3061
|
if (args.setupGithub) {
|
|
2458
3062
|
const ciCfg = await promptGitProviderSetup("github");
|
|
2459
3063
|
saveCiProviderConfig(ciCfg);
|
|
2460
|
-
log(kleur.green(
|
|
3064
|
+
log(kleur.green(M8().githubSaved));
|
|
2461
3065
|
return;
|
|
2462
3066
|
}
|
|
2463
3067
|
if (args.setupGitlab) {
|
|
2464
3068
|
const ciCfg = await promptGitProviderSetup("gitlab");
|
|
2465
3069
|
saveCiProviderConfig(ciCfg);
|
|
2466
|
-
log(kleur.green(
|
|
3070
|
+
log(kleur.green(M8().gitlabSaved));
|
|
2467
3071
|
return;
|
|
2468
3072
|
}
|
|
2469
3073
|
const resumed = args.resume ? await getDeployRun(cfg.webBase, cfg.token, args.resume) : null;
|
|
@@ -2471,16 +3075,16 @@ async function cmdDeploy(argv) {
|
|
|
2471
3075
|
const linkedAppId = resolveLinkedAppId(projectLink, cfg.webBase, args.appId);
|
|
2472
3076
|
if (projectLink) validateProjectIdentity(projectLink, await detectHints(process.cwd()));
|
|
2473
3077
|
const appId = linkedAppId ?? resumed?.appId;
|
|
2474
|
-
if (!appId) throw new Error(
|
|
2475
|
-
if (!args.yes) throw new Error(
|
|
3078
|
+
if (!appId) throw new Error(M8().noAppId);
|
|
3079
|
+
if (!args.yes) throw new Error(M8().explicitApproval);
|
|
2476
3080
|
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(
|
|
3081
|
+
if (resumed.status !== "ready") throw new Error(M8().resumeNotReady);
|
|
3082
|
+
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
3083
|
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(
|
|
3084
|
+
if (!resumed.versionCode) throw new Error(M8().versionCodeUnknown);
|
|
3085
|
+
} else if (!args.versionCode) throw new Error(M8().versionCodeUnknown);
|
|
3086
|
+
log(kleur.bold(M8().title(args.platform)));
|
|
3087
|
+
if (args.dryRun) log(kleur.yellow(M8().dryRunNotice));
|
|
2484
3088
|
log("");
|
|
2485
3089
|
const versionCode = args.versionCode ?? resumed?.versionCode ?? void 0;
|
|
2486
3090
|
let deployBuildNumber;
|
|
@@ -2494,20 +3098,22 @@ async function cmdDeploy(argv) {
|
|
|
2494
3098
|
ciProvider = loadCiProviderConfig();
|
|
2495
3099
|
jenkinsCfg = loadJenkinsConfig() ?? void 0;
|
|
2496
3100
|
kind = resolveCi(args.ci, jenkinsCfg, ciProvider);
|
|
2497
|
-
if (!["jenkins", "github", "gitlab"].includes(kind)) throw new Error(
|
|
3101
|
+
if (!["jenkins", "github", "gitlab"].includes(kind)) throw new Error(M8().invalidCi);
|
|
2498
3102
|
if (kind === "jenkins") {
|
|
2499
|
-
if (!jenkinsCfg?.url || !jenkinsCfg?.token)
|
|
3103
|
+
if (!jenkinsCfg?.url || !jenkinsCfg?.token) {
|
|
3104
|
+
throw new Error(credentialFileProblemMessage("~/.mimi-seed/jenkins.json") ?? M8().noJenkinsConfig);
|
|
3105
|
+
}
|
|
2500
3106
|
jenkinsJobName = resolveProjectJenkins(jenkinsCfg, args.platform).job;
|
|
2501
3107
|
jenkinsParams = jenkinsBuildParameters(args.platform, args.ref, appId);
|
|
2502
3108
|
} else if (!ciProvider) {
|
|
2503
|
-
throw new Error(
|
|
3109
|
+
throw new Error(credentialFileProblemMessage("~/.mimi-seed/ci.json") ?? M8().noProviderConfig(kind));
|
|
2504
3110
|
} else if (ciProvider.provider !== kind) {
|
|
2505
|
-
throw new Error(
|
|
3111
|
+
throw new Error(M8().ciProviderMismatch);
|
|
2506
3112
|
} else if (kind === "github" && !args.workflow) {
|
|
2507
|
-
throw new Error(
|
|
3113
|
+
throw new Error(M8().workflowRequired);
|
|
2508
3114
|
}
|
|
2509
3115
|
}
|
|
2510
|
-
const runId = resumed?.jobId ?? `run_${
|
|
3116
|
+
const runId = resumed?.jobId ?? `run_${randomUUID4()}`;
|
|
2511
3117
|
const runPayload = { runId, appId, platform: args.platform, fromRef: args.fromRef, toRef: args.toRef };
|
|
2512
3118
|
const failRun = async (reason) => {
|
|
2513
3119
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "failed", ...runPayload, reason });
|
|
@@ -2518,12 +3124,12 @@ async function cmdDeploy(argv) {
|
|
|
2518
3124
|
...runPayload,
|
|
2519
3125
|
...versionCode ? { versionCode } : {}
|
|
2520
3126
|
});
|
|
2521
|
-
if (started.jobId !== runId || started.appId !== appId || started.platform !== args.platform) throw new Error(
|
|
3127
|
+
if (started.jobId !== runId || started.appId !== appId || started.platform !== args.platform) throw new Error(M8().runMismatch);
|
|
2522
3128
|
}
|
|
2523
|
-
log(kleur.dim(
|
|
3129
|
+
log(kleur.dim(M8().runId(runId)));
|
|
2524
3130
|
const recordLink = new URL(`/apps/${encodeURIComponent(appId)}`, cfg.webBase);
|
|
2525
3131
|
recordLink.searchParams.set("deployment", runId);
|
|
2526
|
-
log(kleur.dim(
|
|
3132
|
+
log(kleur.dim(M8().deploymentLink(recordLink.toString())));
|
|
2527
3133
|
if (resumed) {
|
|
2528
3134
|
await streamDeploy(cfg.webBase, cfg.token, appId, {
|
|
2529
3135
|
jobId: runId,
|
|
@@ -2536,25 +3142,25 @@ async function cmdDeploy(argv) {
|
|
|
2536
3142
|
language: args.language,
|
|
2537
3143
|
dryRun: false
|
|
2538
3144
|
}, true);
|
|
2539
|
-
log(kleur.bold(
|
|
3145
|
+
log(kleur.bold(M8().done));
|
|
2540
3146
|
return;
|
|
2541
3147
|
}
|
|
2542
3148
|
if (!args.skipBuild) {
|
|
2543
3149
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "building", ...runPayload });
|
|
2544
|
-
log(kleur.dim(
|
|
3150
|
+
log(kleur.dim(M8().ciLine(kind)));
|
|
2545
3151
|
if (kind === "jenkins") {
|
|
2546
3152
|
const jenkins = jenkinsCfg;
|
|
2547
3153
|
const jobName = jenkinsJobName;
|
|
2548
|
-
log(
|
|
3154
|
+
log(M8().jenkinsTrigger(kleur.cyan(jobName)));
|
|
2549
3155
|
const queueItemId = await triggerBuild(jenkins, jobName, jenkinsParams);
|
|
2550
3156
|
if (!queueItemId) {
|
|
2551
|
-
log(kleur.yellow(
|
|
3157
|
+
log(kleur.yellow(M8().noQueueItem));
|
|
2552
3158
|
} else {
|
|
2553
|
-
log(kleur.dim(
|
|
3159
|
+
log(kleur.dim(M8().queueItem(queueItemId)));
|
|
2554
3160
|
}
|
|
2555
3161
|
let buildNumber = null;
|
|
2556
3162
|
if (queueItemId) {
|
|
2557
|
-
log(
|
|
3163
|
+
log(M8().waitingForBuildNumber);
|
|
2558
3164
|
for (let i = 0; i < 6; i++) {
|
|
2559
3165
|
await new Promise((r) => setTimeout(r, 5e3));
|
|
2560
3166
|
buildNumber = await getQueueBuildNumber(jenkins, queueItemId).catch(() => null);
|
|
@@ -2562,45 +3168,45 @@ async function cmdDeploy(argv) {
|
|
|
2562
3168
|
}
|
|
2563
3169
|
}
|
|
2564
3170
|
if (!buildNumber) {
|
|
2565
|
-
log(kleur.yellow(
|
|
2566
|
-
throw new Error(
|
|
3171
|
+
log(kleur.yellow(M8().noBuildNumber));
|
|
3172
|
+
throw new Error(M8().noBuildNumber);
|
|
2567
3173
|
}
|
|
2568
|
-
log(
|
|
3174
|
+
log(M8().buildStarted(buildNumber));
|
|
2569
3175
|
await updateDeployRun(cfg.webBase, cfg.token, { action: "building", ...runPayload, buildNumber });
|
|
2570
3176
|
const result = await pollBuildComplete(jenkins, jobName, buildNumber);
|
|
2571
3177
|
if (result !== "SUCCESS") {
|
|
2572
|
-
log(kleur.red(
|
|
2573
|
-
log(kleur.dim(
|
|
2574
|
-
log(kleur.dim(
|
|
3178
|
+
log(kleur.red(M8().buildFailed(result)));
|
|
3179
|
+
log(kleur.dim(M8().jenkinsLink(`${jenkins.url}/job/${encodeURIComponent(jobName)}/${buildNumber}/`)));
|
|
3180
|
+
log(kleur.dim(M8().alreadyBuiltHint("<N>", args.platform)));
|
|
2575
3181
|
await failRun("build_failed");
|
|
2576
|
-
throw new Error(
|
|
3182
|
+
throw new Error(M8().buildFailed(result));
|
|
2577
3183
|
}
|
|
2578
|
-
log(kleur.green(
|
|
3184
|
+
log(kleur.green(M8().buildSucceeded(buildNumber)));
|
|
2579
3185
|
deployBuildNumber = buildNumber;
|
|
2580
3186
|
if (!versionCode) {
|
|
2581
3187
|
await failRun("metadata_missing");
|
|
2582
|
-
throw new Error(
|
|
3188
|
+
throw new Error(M8().versionCodeUnsuitable("Jenkins", buildNumber) + "\n" + M8().recommendationNext);
|
|
2583
3189
|
}
|
|
2584
3190
|
} else {
|
|
2585
3191
|
const build = await runGitProviderBuild(ciProvider, args, appId);
|
|
2586
3192
|
if (build.result !== "success") {
|
|
2587
3193
|
if (build.result === "failure" || build.result === "cancelled") await failRun("build_failed");
|
|
2588
|
-
throw new Error(
|
|
3194
|
+
throw new Error(M8().buildEnded(build.result));
|
|
2589
3195
|
}
|
|
2590
3196
|
if (!versionCode) {
|
|
2591
|
-
log(kleur.red(
|
|
2592
|
-
log(kleur.dim(
|
|
2593
|
-
log(kleur.dim(
|
|
2594
|
-
log(kleur.dim(
|
|
3197
|
+
log(kleur.red(M8().versionCodeUnsuitable(kind, build.runId)));
|
|
3198
|
+
log(kleur.dim(M8().recommendation));
|
|
3199
|
+
log(kleur.dim(M8().recommendationCi));
|
|
3200
|
+
log(kleur.dim(M8().recommendationNext));
|
|
2595
3201
|
await failRun("metadata_missing");
|
|
2596
|
-
throw new Error(
|
|
3202
|
+
throw new Error(M8().versionCodeUnknown);
|
|
2597
3203
|
}
|
|
2598
3204
|
}
|
|
2599
3205
|
}
|
|
2600
3206
|
if (!versionCode) {
|
|
2601
|
-
log(kleur.red(
|
|
3207
|
+
log(kleur.red(M8().versionCodeUnknown));
|
|
2602
3208
|
await failRun("metadata_missing");
|
|
2603
|
-
throw new Error(
|
|
3209
|
+
throw new Error(M8().versionCodeUnknown);
|
|
2604
3210
|
}
|
|
2605
3211
|
await updateDeployRun(cfg.webBase, cfg.token, {
|
|
2606
3212
|
action: "ready",
|
|
@@ -2609,11 +3215,11 @@ async function cmdDeploy(argv) {
|
|
|
2609
3215
|
...deployBuildNumber ? { buildNumber: deployBuildNumber } : {}
|
|
2610
3216
|
});
|
|
2611
3217
|
if (args.prepareOnly) {
|
|
2612
|
-
log(kleur.green(
|
|
3218
|
+
log(kleur.green(M8().prepared(runId)));
|
|
2613
3219
|
return;
|
|
2614
3220
|
}
|
|
2615
3221
|
log("");
|
|
2616
|
-
log(
|
|
3222
|
+
log(M8().pipelineStarting);
|
|
2617
3223
|
log("");
|
|
2618
3224
|
await streamDeploy(cfg.webBase, cfg.token, appId, {
|
|
2619
3225
|
jobId: runId,
|
|
@@ -2627,34 +3233,34 @@ async function cmdDeploy(argv) {
|
|
|
2627
3233
|
dryRun: args.dryRun
|
|
2628
3234
|
}, true);
|
|
2629
3235
|
log("");
|
|
2630
|
-
log(kleur.bold(
|
|
3236
|
+
log(kleur.bold(M8().done));
|
|
2631
3237
|
}
|
|
2632
3238
|
|
|
2633
3239
|
// src/settings.ts
|
|
2634
|
-
import
|
|
2635
|
-
import
|
|
2636
|
-
function readSettings(home =
|
|
3240
|
+
import fs12 from "fs";
|
|
3241
|
+
import os8 from "os";
|
|
3242
|
+
function readSettings(home = os8.homedir()) {
|
|
2637
3243
|
try {
|
|
2638
|
-
return JSON.parse(
|
|
3244
|
+
return JSON.parse(fs12.readFileSync(settingsPath(home), "utf-8"));
|
|
2639
3245
|
} catch {
|
|
2640
3246
|
return {};
|
|
2641
3247
|
}
|
|
2642
3248
|
}
|
|
2643
|
-
function writeSettings(next, home =
|
|
3249
|
+
function writeSettings(next, home = os8.homedir()) {
|
|
2644
3250
|
const merged = { ...readSettings(home), ...next };
|
|
2645
3251
|
writeJsonAtomic(settingsPath(home), merged, { dirMode: 448 });
|
|
2646
3252
|
}
|
|
2647
|
-
function isLangUnset(home =
|
|
3253
|
+
function isLangUnset(home = os8.homedir()) {
|
|
2648
3254
|
return !process.env.MIMI_SEED_LANG && !readSettings(home).lang;
|
|
2649
3255
|
}
|
|
2650
3256
|
|
|
2651
3257
|
// src/telemetry.ts
|
|
2652
|
-
import
|
|
2653
|
-
import
|
|
2654
|
-
import
|
|
2655
|
-
import { createHmac, randomUUID as
|
|
3258
|
+
import fs13 from "fs";
|
|
3259
|
+
import os9 from "os";
|
|
3260
|
+
import path16 from "path";
|
|
3261
|
+
import { createHmac, randomUUID as randomUUID5 } from "crypto";
|
|
2656
3262
|
var ENDPOINT = "https://mimi-seed.pryzm.gg/api/sdk-usage";
|
|
2657
|
-
var
|
|
3263
|
+
var M9 = catalog(
|
|
2658
3264
|
{
|
|
2659
3265
|
notice: "\uC120\uD0DD\uC801 \uC0AC\uC6A9\uB7C9 \uCE21\uC815\uC740 \uAEBC\uC838 \uC788\uC2B5\uB2C8\uB2E4. \uC548\uB0B4: mimi-seed telemetry --help\n",
|
|
2660
3266
|
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 +3274,10 @@ var M8 = catalog(
|
|
|
2668
3274
|
invalid: "Usage: mimi-seed telemetry on|off|status\n"
|
|
2669
3275
|
}
|
|
2670
3276
|
);
|
|
2671
|
-
var location = () =>
|
|
3277
|
+
var location = () => path16.join(os9.homedir(), ".mimi-seed", "telemetry.json");
|
|
2672
3278
|
function readConsent() {
|
|
2673
3279
|
try {
|
|
2674
|
-
return JSON.parse(
|
|
3280
|
+
return JSON.parse(fs13.readFileSync(location(), "utf8"));
|
|
2675
3281
|
} catch {
|
|
2676
3282
|
return { enabled: false };
|
|
2677
3283
|
}
|
|
@@ -2684,26 +3290,26 @@ function telemetryEnabled() {
|
|
|
2684
3290
|
return readConsent().enabled === true;
|
|
2685
3291
|
}
|
|
2686
3292
|
function telemetryNotice() {
|
|
2687
|
-
return telemetryEnabled() ? "" :
|
|
3293
|
+
return telemetryEnabled() ? "" : M9().notice;
|
|
2688
3294
|
}
|
|
2689
3295
|
function cmdTelemetry(argv) {
|
|
2690
3296
|
const action = argv[0] ?? "status";
|
|
2691
3297
|
if (argv.length > 1 || !["on", "off", "status"].includes(action)) {
|
|
2692
|
-
process.stderr.write(
|
|
3298
|
+
process.stderr.write(M9().invalid);
|
|
2693
3299
|
process.exitCode = 2;
|
|
2694
3300
|
return;
|
|
2695
3301
|
}
|
|
2696
3302
|
if (action === "on") {
|
|
2697
3303
|
const consent = readConsent();
|
|
2698
|
-
writeConsent({ enabled: true, installationId: consent.installationId ??
|
|
3304
|
+
writeConsent({ enabled: true, installationId: consent.installationId ?? randomUUID5(), salt: consent.salt ?? randomUUID5() });
|
|
2699
3305
|
}
|
|
2700
3306
|
if (action === "off") writeConsent({ enabled: false });
|
|
2701
|
-
process.stdout.write(telemetryEnabled() ?
|
|
3307
|
+
process.stdout.write(telemetryEnabled() ? M9().enabled : M9().disabled);
|
|
2702
3308
|
}
|
|
2703
3309
|
function frameworkAt(root) {
|
|
2704
|
-
if (
|
|
3310
|
+
if (fs13.existsSync(path16.join(root, "ProjectSettings", "ProjectSettings.asset"))) return "unity";
|
|
2705
3311
|
try {
|
|
2706
|
-
const pkg = JSON.parse(
|
|
3312
|
+
const pkg = JSON.parse(fs13.readFileSync(path16.join(root, "package.json"), "utf8"));
|
|
2707
3313
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
2708
3314
|
if (deps.expo) return "expo";
|
|
2709
3315
|
if (deps["react-native"]) return "react-native";
|
|
@@ -2716,12 +3322,12 @@ function usageRun(command, projectPath) {
|
|
|
2716
3322
|
};
|
|
2717
3323
|
try {
|
|
2718
3324
|
const consent = readConsent();
|
|
2719
|
-
const installationId = consent.installationId ??
|
|
2720
|
-
const salt = consent.salt ??
|
|
3325
|
+
const installationId = consent.installationId ?? randomUUID5();
|
|
3326
|
+
const salt = consent.salt ?? randomUUID5();
|
|
2721
3327
|
if (!consent.installationId || !consent.salt) writeConsent({ enabled: consent.enabled, installationId, salt });
|
|
2722
|
-
let normalized =
|
|
3328
|
+
let normalized = path16.resolve(projectPath);
|
|
2723
3329
|
try {
|
|
2724
|
-
normalized =
|
|
3330
|
+
normalized = fs13.realpathSync(normalized);
|
|
2725
3331
|
} catch {
|
|
2726
3332
|
}
|
|
2727
3333
|
if (process.platform === "win32") normalized = normalized.toLowerCase();
|
|
@@ -2729,7 +3335,7 @@ function usageRun(command, projectPath) {
|
|
|
2729
3335
|
schema: 1,
|
|
2730
3336
|
installationId,
|
|
2731
3337
|
projectId: createHmac("sha256", salt).update(normalized).digest("hex"),
|
|
2732
|
-
runId:
|
|
3338
|
+
runId: randomUUID5(),
|
|
2733
3339
|
version,
|
|
2734
3340
|
os: process.platform,
|
|
2735
3341
|
ci: Boolean(process.env.CI),
|
|
@@ -2808,7 +3414,7 @@ function statusLine(spec, detected, platforms) {
|
|
|
2808
3414
|
else if (isSatisfied(spec, detected)) mark = kleur2.yellow("~");
|
|
2809
3415
|
else if (spec.requirement === "optional" || !relevant) mark = kleur2.dim("\xB7");
|
|
2810
3416
|
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}`);
|
|
3417
|
+
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
3418
|
return ` ${mark} ${credLabel(spec).padEnd(24)} ${tail}`;
|
|
2813
3419
|
}
|
|
2814
3420
|
function printStatus(detected, platforms) {
|
|
@@ -2895,7 +3501,7 @@ async function connectOne(spec) {
|
|
|
2895
3501
|
}
|
|
2896
3502
|
async function cmdSetup(argv) {
|
|
2897
3503
|
const opts = parseSetupArgs(argv);
|
|
2898
|
-
const home =
|
|
3504
|
+
const home = os10.homedir();
|
|
2899
3505
|
migrateLegacyJenkins(home);
|
|
2900
3506
|
if (resolveMode(opts, process.env, process.stdin.isTTY) === "interactive") {
|
|
2901
3507
|
await ensureLangChosen();
|
|
@@ -3002,25 +3608,35 @@ async function cmdSetup(argv) {
|
|
|
3002
3608
|
}
|
|
3003
3609
|
|
|
3004
3610
|
export {
|
|
3611
|
+
isLang,
|
|
3612
|
+
resolveLang,
|
|
3613
|
+
catalog,
|
|
3614
|
+
lookupDataKey,
|
|
3615
|
+
obtainDataKey,
|
|
3616
|
+
CREDENTIAL_STORE_ENV,
|
|
3617
|
+
isCredentialStoreMode,
|
|
3618
|
+
credentialStoreReport,
|
|
3619
|
+
rewriteCredentialFiles,
|
|
3620
|
+
clearKeyIdMarker,
|
|
3621
|
+
writeCredentialFile,
|
|
3005
3622
|
writeConfig,
|
|
3006
3623
|
deleteConfig,
|
|
3007
3624
|
CONFIG_LOCATION,
|
|
3008
3625
|
getEffectiveConfig,
|
|
3009
|
-
isLang,
|
|
3010
|
-
resolveLang,
|
|
3011
|
-
catalog,
|
|
3012
3626
|
t,
|
|
3013
3627
|
readBodyWithTimeout,
|
|
3014
3628
|
fetchWithTimeout,
|
|
3015
3629
|
detectHints,
|
|
3016
3630
|
hasAnyProjectSignal,
|
|
3017
|
-
|
|
3631
|
+
lookupProjectManifest,
|
|
3018
3632
|
manifestServiceEntries,
|
|
3019
3633
|
credLabel,
|
|
3020
3634
|
credNote,
|
|
3021
3635
|
CREDENTIALS,
|
|
3022
3636
|
tryCredById,
|
|
3023
3637
|
detectAll,
|
|
3638
|
+
credentialFileProblemMessage,
|
|
3639
|
+
credentialProblemText,
|
|
3024
3640
|
isSatisfied,
|
|
3025
3641
|
version,
|
|
3026
3642
|
absoluteWindowsPathDirs,
|