@2api-store/activate 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cmds.mjs +15 -2
- package/package.json +1 -1
package/lib/cmds.mjs
CHANGED
|
@@ -245,7 +245,19 @@ async function cmdRestore(argv) {
|
|
|
245
245
|
const group = byTime[ts]
|
|
246
246
|
const files = group.map((b) => path.basename(b.origPath)).join(', ')
|
|
247
247
|
const tsDisplay = fmtTime(group[0].mtime)
|
|
248
|
-
|
|
248
|
+
// 从备份内容提取 key 前缀(帮助用户区分不同激活)
|
|
249
|
+
let keyHint = ''
|
|
250
|
+
for (const b of group) {
|
|
251
|
+
try {
|
|
252
|
+
const content = fs.readFileSync(b.bakPath, 'utf8')
|
|
253
|
+
const m = content.match(/sk-[a-f0-9]{6,8}/i)
|
|
254
|
+
if (m) { keyHint = `sk-…${m[0].slice(-6)}`; break }
|
|
255
|
+
const m2 = content.match(/(?:api_key|API_KEY|OPENAI_API_KEY)["':\s]+(["']?)(sk-[a-f0-9]{6,8})/i)
|
|
256
|
+
if (m2) { keyHint = `sk-…${m2[2].slice(-6)}`; break }
|
|
257
|
+
} catch { /* ignore */ }
|
|
258
|
+
}
|
|
259
|
+
const hint = keyHint ? ` ${chalk.yellow(keyHint)}` : ''
|
|
260
|
+
return { label: `${chalk.dim(tsDisplay)}(${group.length} 文件:${files})${hint}`, ts, group }
|
|
249
261
|
})
|
|
250
262
|
const timeIdx = await select('选择时间点(回车=最新)', timeItems, { defaultIndex: 0 })
|
|
251
263
|
if (timeIdx < 0 || timeIdx >= timeItems.length) {
|
|
@@ -517,10 +529,11 @@ async function cmdReconfig(argv) {
|
|
|
517
529
|
return 1
|
|
518
530
|
}
|
|
519
531
|
|
|
520
|
-
// reconfig:
|
|
532
|
+
// reconfig: 全选主 CLI 配置(跳过独立 CLI 如 opencode)
|
|
521
533
|
const seen = new Set()
|
|
522
534
|
const selectedItems = []
|
|
523
535
|
for (const c of osConfigs) {
|
|
536
|
+
if (!isDefaultSelected(c.client_type)) continue
|
|
524
537
|
const key = `${c.platform}/${c.client_type}`
|
|
525
538
|
if (seen.has(key)) continue
|
|
526
539
|
seen.add(key)
|