chore: 初始化 dsh-enhancements 留档仓库
- 插件源码:dsh-usage(用户头像 + DeepSeek 官方 API 消耗面板) - 工具:dl-gh.mjs(node fetch 下载 gh,绕开沙箱 curl 限制) - 文档:PLAN.md 路线图 + mmx 视觉桥接补丁说明 - 资产:DeepSeek 鲸鱼图标
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// 下载 GitHub CLI (gh) 最新 Windows x64 便携版 zip。
|
||||
// 用法: node dl-gh.mjs [输出目录] → 打印 { tag, file, bytes }
|
||||
// 沙箱内 curl/winget 的 HTTPS 被禁,但 node fetch 可用,故用 node 下载。
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
const outDir = path.resolve(process.argv[2] || '.')
|
||||
fs.mkdirSync(outDir, { recursive: true })
|
||||
|
||||
const relUrl = 'https://api.github.com/repos/cli/cli/releases/latest'
|
||||
const rel = await (await fetch(relUrl, { headers: { 'User-Agent': 'dsh-enhancements' }, signal: AbortSignal.timeout(30000) })).json()
|
||||
if (!rel.tag_name) throw new Error('bad release response: ' + JSON.stringify(rel).slice(0, 200))
|
||||
const asset = rel.assets.find((a) => a.name.endsWith('windows_amd64.zip'))
|
||||
if (!asset) throw new Error('no windows_amd64.zip asset in ' + rel.tag_name)
|
||||
|
||||
const out = path.join(outDir, asset.name)
|
||||
const res = await fetch(asset.browser_download_url, { signal: AbortSignal.timeout(300000) })
|
||||
if (!res.ok) throw new Error('download failed: HTTP ' + res.status)
|
||||
const buf = Buffer.from(await res.arrayBuffer())
|
||||
fs.writeFileSync(out, buf)
|
||||
console.log(JSON.stringify({ tag: rel.tag_name, file: out, bytes: buf.length }))
|
||||
Reference in New Issue
Block a user