@2api-store/activate 0.4.2 → 0.4.3
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 +13 -1
- 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) {
|