Import make-index.mjs
This commit is contained in:
parent
6824d446e1
commit
69fda57200
|
|
@ -17,14 +17,12 @@
|
|||
// overwrite); DSH's native update button does not apply to git sources.
|
||||
//
|
||||
// node make-index.mjs
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const API = 'https://git.qyhhh.top/api/v1'
|
||||
const WEB = 'https://git.qyhhh.top/DeepsSeekHarness'
|
||||
const ROOT = dirname(fileURLToPath(import.meta.url))
|
||||
const MANIFEST = join(ROOT, 'release-manifest.json')
|
||||
|
||||
const PLUGINS = [
|
||||
{
|
||||
|
|
@ -59,9 +57,18 @@ const PLUGINS = [
|
|||
icon: 'icons/chat.png',
|
||||
repo: 'dsh-better-chat',
|
||||
branch: 'main',
|
||||
title: 'dsh-better-chat · 聊天增强与阅读视图',
|
||||
description: '审批卡快捷键(可自定义)、权限界面移除「完全权限」、插件商店更新按钮,以及合并自 dsh-better-display 的阅读视图(过程折叠、毛玻璃、mcp-app 交互卡片)。',
|
||||
keywords: ['chat', 'approval', 'permission', 'reader'],
|
||||
title: 'dsh-better-chat · 聊天增强',
|
||||
description: '审批卡回车确认 / Esc 拒绝;默认自动审查,并从界面移除「完全权限」选项。',
|
||||
keywords: ['chat', 'approval', 'permission'],
|
||||
},
|
||||
{
|
||||
name: 'ds-harness-remote-fast',
|
||||
icon: 'icons/remote-fast.png',
|
||||
repo: 'ds-harness-remote-fast',
|
||||
branch: 'lite',
|
||||
title: 'ds-harness-remote-fast · 远程极速版',
|
||||
description: 'ds-harness-remote 的极速分支(rainow):主机端首屏快照裁剪,解决大会话帧超限断连;服务端与客户端不用换,加密与配对与原版一致。本仓库为本机中转快照,源头是 GitHub 上的 rainow/ds-harness-remote-fast。',
|
||||
keywords: ['remote', '远程', 'fast'],
|
||||
},
|
||||
]
|
||||
|
||||
|
|
@ -72,35 +79,15 @@ async function headOf(repo, branch) {
|
|||
return { commit: body.commit.id, timestamp: Math.floor(Date.parse(body.commit.timestamp) / 1000) }
|
||||
}
|
||||
|
||||
const release = existsSync(MANIFEST) ? JSON.parse(readFileSync(MANIFEST, 'utf8')) : null
|
||||
const componentByRepo = new Map()
|
||||
for (const component of release?.components ?? []) componentByRepo.set(component.repo, component)
|
||||
|
||||
const plugins = []
|
||||
for (const plugin of PLUGINS) {
|
||||
let version
|
||||
let commit
|
||||
let timestamp
|
||||
const pinned = componentByRepo.get(plugin.repo)
|
||||
if (pinned !== undefined) {
|
||||
// The checked-in release manifest is the source of truth for a published
|
||||
// batch: version, commit and index entry are generated from the SAME record.
|
||||
if (pinned.package !== plugin.name) throw new Error(`release manifest package mismatch for ${plugin.repo}: ${pinned.package} vs ${plugin.name}`)
|
||||
version = pinned.version
|
||||
commit = pinned.sourceCommit
|
||||
timestamp = pinned.publishTimestamp ?? Math.floor(Date.now() / 1000)
|
||||
if (!/^[0-9a-f]{40}$/i.test(commit)) throw new Error(`release manifest has no pinned commit for ${plugin.repo}`)
|
||||
} else {
|
||||
const head = await headOf(plugin.repo, plugin.branch)
|
||||
const pkgResponse = await fetch(`${API}/repos/DeepsSeekHarness/${plugin.repo}/contents/package.json?ref=${plugin.branch}`)
|
||||
if (!pkgResponse.ok) throw new Error(`package.json fetch failed for ${plugin.repo}: HTTP ${pkgResponse.status}`)
|
||||
const pkgFile = await pkgResponse.json()
|
||||
const pkg = JSON.parse(Buffer.from(pkgFile.content, 'base64').toString('utf8'))
|
||||
if (pkg.name !== plugin.name) throw new Error(`name mismatch for ${plugin.repo}: index says ${plugin.name}, package.json says ${pkg.name}`)
|
||||
version = pkg.version
|
||||
commit = head.commit
|
||||
timestamp = head.timestamp
|
||||
}
|
||||
const head = await headOf(plugin.repo, plugin.branch)
|
||||
const pkgResponse = await fetch(`${API}/repos/DeepsSeekHarness/${plugin.repo}/contents/package.json?ref=${plugin.branch}`)
|
||||
if (!pkgResponse.ok) throw new Error(`package.json fetch failed for ${plugin.repo}: HTTP ${pkgResponse.status}`)
|
||||
const pkgFile = await pkgResponse.json()
|
||||
const pkg = JSON.parse(Buffer.from(pkgFile.content, 'base64').toString('utf8'))
|
||||
if (pkg.name !== plugin.name) throw new Error(`name mismatch for ${plugin.repo}: index says ${plugin.name}, package.json says ${pkg.name}`)
|
||||
const version = pkg.version
|
||||
plugins.push({
|
||||
name: plugin.name,
|
||||
title: plugin.title,
|
||||
|
|
@ -113,13 +100,13 @@ for (const plugin of PLUGINS) {
|
|||
versions: [
|
||||
{
|
||||
version: version,
|
||||
publishTimestamp: timestamp,
|
||||
source: { type: 'git', url: `${WEB}/${plugin.repo}`, commit: commit },
|
||||
publishTimestamp: head.timestamp,
|
||||
source: { type: 'git', url: `${WEB}/${plugin.repo}`, commit: head.commit },
|
||||
engines: {},
|
||||
},
|
||||
],
|
||||
})
|
||||
console.log(`${plugin.name} ${version} @ ${String(commit).slice(0, 8)}${pinned ? ' (release-manifest)' : ' (live)'}`)
|
||||
console.log(`${plugin.name} ${version} @ ${head.commit.slice(0, 8)}`)
|
||||
}
|
||||
|
||||
const index = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue