Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m27s
- publish-update.sh:只让 tauri 打 .app(含 .app.tar.gz + .sig),dmg 改 hdiutil 封 —— create-dmg 的 bundle_dmg.sh 在 macOS 26.6.2 上必失败(grep: bad regex)。 - update-releases.js 记录内容指纹 h,gen-site / gen-release-page 的下载链接带 ?h=<sha12>: Cloudflare 对 updates/*.dmg 强缓存 4 小时,同名重传会返回旧字节(本次实测哈希对不上)。 - release.sh 校验按指纹回读;说明用数组传参(不再被空格拆词)。 - CHANGELOG 记入本次发布链路修复。 发布结果:latest.json 3.25.23,双架构 tar.gz + minisign 签名就位, aarch64 dmg 8,696,185 B / sha256 774a56bb… 与 releases.json 一致。
117 lines
6.7 KiB
JavaScript
117 lines
6.7 KiB
JavaScript
#!/usr/bin/env node
|
||
'use strict'
|
||
// 站点生成器:用 site/_home.tpl.html 与 site/_plugins.tpl.html 渲染首页 / 插件页,
|
||
// 数据来自 site/releases.json(版本)与 market/index.json(插件)。
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
const root = path.resolve(__dirname, '..')
|
||
const site = path.join(root, 'site')
|
||
|
||
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]))
|
||
const mb = (n) => (Number(n) / 1048576).toFixed(1) + ' MB'
|
||
|
||
const data = JSON.parse(fs.readFileSync(path.join(site, 'releases.json'), 'utf8'))
|
||
const rel = Array.isArray(data.releases) ? data.releases.slice() : (Array.isArray(data) ? data.slice() : [])
|
||
rel.sort((a, b) => String(b.version).localeCompare(String(a.version), undefined, { numeric: true }))
|
||
const latest = rel[0] || { version: '', platforms: {} }
|
||
const V = esc(latest.version)
|
||
const STAMP = encodeURIComponent(V + '-' + Date.now().toString(36))
|
||
|
||
const marketFile = path.join(root, 'market', 'index.json')
|
||
const market = fs.existsSync(marketFile) ? JSON.parse(fs.readFileSync(marketFile, 'utf8')) : { plugins: [] }
|
||
const plugins = Array.isArray(market.plugins) ? market.plugins : []
|
||
|
||
const nav = (active) => [
|
||
'<nav><div class="wrap inner">',
|
||
' <a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>',
|
||
' <div class="links">',
|
||
' <a href="/"' + (active === 'home' ? ' class="on"' : '') + '>首页</a>',
|
||
' <a href="/download/"' + (active === 'download' ? ' class="on"' : '') + '>下载</a>',
|
||
' <a href="/plugins/"' + (active === 'plugins' ? ' class="on"' : '') + '>插件</a>',
|
||
' <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>',
|
||
' </div>',
|
||
' <div class="right">',
|
||
' <a class="btn" href="/plugins/">插件市场</a>',
|
||
' <a class="btn primary" href="/download/">下载 v' + V + '</a>',
|
||
' </div>',
|
||
'</div></nav>',
|
||
].join('\n')
|
||
|
||
const footer = [
|
||
'<footer><div class="wrap">',
|
||
' <div class="cols">',
|
||
' <div><div style="color:#fff;font-weight:640;margin-bottom:8px">Image Workbench</div>',
|
||
' <div style="font-size:13px;line-height:1.8">本地优先的 AI 生图无限画布。图片、提示词与模型配置全部留在你自己的电脑里。</div></div>',
|
||
' <div><h4>产品</h4><a href="/">首页</a><a href="/download/">下载</a><a href="/plugins/">插件市场</a></div>',
|
||
' <div><h4>资源</h4><a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码仓库</a><a href="https://git.maqiart.eu.org/malongan/iwb-plugins-desktop" target="_blank" rel="noopener">插件仓库</a><a href="/updates/latest.json" target="_blank" rel="noopener">更新源</a></div>',
|
||
' <div><h4>说明</h4><a href="/download/">安装步骤</a><a href="/plugins/">插件安装</a></div>',
|
||
' </div>',
|
||
' <div class="copy"><span>© ' + new Date().getFullYear() + ' Image Workbench</span><span>数据保存在本地 · 不上传任何图片</span></div>',
|
||
'</div></footer>',
|
||
].join('\n')
|
||
|
||
const card = (p) => [
|
||
' <div class="pcard" data-name="' + esc((p.name + ' ' + p.id + ' ' + (p.desc || '') + ' ' + (p.tags || []).join(' ')).toLowerCase()) + '" data-tags="' + esc((p.tags || []).join(',')) + '">',
|
||
' <div class="head"><span class="av" style="background:' + esc(p.color || '#eef2f6') + '">' + esc(p.icon || '◻') + '</span>',
|
||
' <div><div class="nm">' + esc(p.name || p.id) + '</div><div class="ver">v' + esc(p.version || '') + ' · ' + esc(p.author === 'official' ? '官方' : (p.author || '')) + '</div></div></div>',
|
||
' <div class="desc">' + esc(p.desc || '') + '</div>',
|
||
' <div class="tags">' + (p.tags || []).map((t) => '<span class="tag">' + esc(t) + '</span>').join('') + '</div>',
|
||
' </div>',
|
||
].join('\n')
|
||
|
||
const feats = [
|
||
['💻', '#eef2ff', '本地优先', '图片与数据保存在 ~/Documents/ImageWorkbench,不经服务器中转;可整目录备份、迁移到新电脑。'],
|
||
['🕸️', '#fff7ed', '节点式无限画布', '参考图 → 提示词 → 生成 → 图库,用连线把工作流串起来;一张画布容纳整条生产线。'],
|
||
['🧩', '#ecfdf5', '插件按需安装', '应用本体不含插件,需要什么装什么;可随时启停,关闭后入口自动隐藏。'],
|
||
]
|
||
const featCards = feats.map((f) => [
|
||
' <div class="card"><div class="ico" style="background:' + f[1] + '">' + f[0] + '</div>',
|
||
' <h3>' + f[2] + '</h3><p>' + f[3] + '</p></div>',
|
||
].join('\n')).join('\n')
|
||
|
||
const dlCards = [
|
||
['darwin-aarch64', 'macOS · Apple Silicon', 'M1 / M2 / M3 / M4'],
|
||
['darwin-x86_64', 'macOS · Intel', 'x86_64'],
|
||
['windows-x86_64', 'Windows · x64', '需要 WebView2'],
|
||
].map(([key, label, hint]) => {
|
||
const p = (latest.platforms || {})[key]
|
||
if (!p) return '<div class="none"><div class="n">' + label + '</div><div class="s">暂未提供</div></div>'
|
||
return '<a href="/' + esc(p.file) + (p.h ? '?h=' + esc(p.h) : '') + '"><div class="n">' + label + '</div><div class="s">' + hint + ' · ' + mb(p.size) + ' · .' + esc(String(p.file).split('.').pop()) + '</div></a>'
|
||
}).join('\n ')
|
||
|
||
const tags = []
|
||
for (const p of plugins) for (const t of (p.tags || [])) if (tags.indexOf(t) < 0) tags.push(t)
|
||
const tagChips = tags.map((t) => '<button class="tag" data-tag="' + esc(t) + '" style="cursor:pointer;padding:5px 12px">' + esc(t) + '</button>').join('\n ')
|
||
|
||
function render(tpl, map) {
|
||
let out = fs.readFileSync(path.join(site, tpl), 'utf8')
|
||
for (const k of Object.keys(map)) out = out.split('<!--' + k + '-->').join(map[k])
|
||
return out
|
||
}
|
||
|
||
let home = render('_home.tpl.html', {
|
||
NAV: nav('home'),
|
||
FOOTER: footer,
|
||
VERSION: V,
|
||
PLUGIN_COUNT: String(plugins.length),
|
||
FEAT_CARDS: featCards,
|
||
PLUGIN_CARDS: plugins.slice(0, 6).map((p) => card(p).replace(/^\s+/, ' ')).join('\n'),
|
||
DL_CARDS: dlCards,
|
||
})
|
||
home = home.replace('/assets/style.css', '/assets/style.css?v=' + STAMP).replace('/assets/painting.jpg', '/assets/painting.jpg?v=' + STAMP)
|
||
fs.writeFileSync(path.join(site, 'index.html'), home)
|
||
|
||
let pluginsPage = render('_plugins.tpl.html', {
|
||
NAV: nav('plugins'),
|
||
FOOTER: footer,
|
||
PLUGIN_COUNT: String(plugins.length),
|
||
TAG_CHIPS: tagChips,
|
||
PLUGIN_CARDS: plugins.map(card).join('\n'),
|
||
})
|
||
fs.mkdirSync(path.join(site, 'plugins'), { recursive: true })
|
||
pluginsPage = pluginsPage.replace('/assets/style.css', '/assets/style.css?v=' + STAMP)
|
||
fs.writeFileSync(path.join(site, 'plugins', 'index.html'), pluginsPage)
|
||
fs.writeFileSync(path.join(site, 'plugins-index.json'), JSON.stringify(market, null, 2) + '\n')
|
||
|
||
console.log('站点已生成:首页 / 插件页(' + plugins.length + ' 个插件,' + tags.length + ' 个标签,版本 v' + V + ')')
|