@2api-store/activate 0.4.5 → 0.4.6
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 +18 -7
- package/package.json +1 -1
package/lib/cmds.mjs
CHANGED
|
@@ -245,18 +245,29 @@ 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
|
-
//
|
|
249
|
-
|
|
248
|
+
// 从备份内容提取关键信息(key 尾号 + base_url + model),一行展示
|
|
249
|
+
const parts = []
|
|
250
250
|
for (const b of group) {
|
|
251
251
|
try {
|
|
252
252
|
const content = fs.readFileSync(b.bakPath, 'utf8')
|
|
253
|
-
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
// key:sk- 开头,取尾 6 位(放宽正则:sk-后任意字母数字,至少 10 字符)
|
|
254
|
+
if (!parts.find((p) => p.startsWith('sk-'))) {
|
|
255
|
+
const m = content.match(/sk-([a-zA-Z0-9]{10,})/)
|
|
256
|
+
if (m) parts.push(`sk-…${m[1].slice(-6)}`)
|
|
257
|
+
}
|
|
258
|
+
// base_url / apiBase
|
|
259
|
+
if (!parts.find((p) => p.startsWith('http'))) {
|
|
260
|
+
const m2 = content.match(/(https?:\/\/[^\s"'`}]+)/)
|
|
261
|
+
if (m2) parts.push(m2[1].replace(/\/+$/, ''))
|
|
262
|
+
}
|
|
263
|
+
// model(如果有)
|
|
264
|
+
if (!parts.find((p) => p.startsWith('model'))) {
|
|
265
|
+
const m3 = content.match(/(?:^|\n)\s*model\s*[=:]\s*["']?([a-zA-Z0-9][\w.-]+)/)
|
|
266
|
+
if (m3) parts.push(`model:${m3[1]}`)
|
|
267
|
+
}
|
|
257
268
|
} catch { /* ignore */ }
|
|
258
269
|
}
|
|
259
|
-
const hint =
|
|
270
|
+
const hint = parts.length > 0 ? ` ${chalk.yellow(parts.join(' | '))}` : ''
|
|
260
271
|
return { label: `${chalk.dim(tsDisplay)}(${group.length} 文件:${files})${hint}`, ts, group }
|
|
261
272
|
})
|
|
262
273
|
const timeIdx = await select('选择时间点(回车=最新)', timeItems, { defaultIndex: 0 })
|