🎉 初始化书源插件公共模板

update.lua(只更新本插件)、打包与测试脚本、发布流程、README 模板与同步脚本。

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-18 14:28:56 +08:00
commit 98d4744c53
11 files changed
+1455

No files matched your search

Executable
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# 把模板仓库里的公共文件同步进一个插件仓库。
# 用法:tools/sync.sh <插件仓库目录>
# 同步:<包名>/update.lua、tools/package.sh、tools/run-tests.sh、.forgejo/workflows/release.yml、
# tests/update/update_spec.lua;缺失时补:<包名>/version.lua、LICENSE、.gitignore、README.md。
set -eu
T="$(cd "$(dirname "$0")/.." && pwd)"
DEST="$(cd "${1:?用法:tools/sync.sh <插件仓库目录>}" && pwd)"
DIR="$(cd "$DEST" && ls -d moonsource-*.koplugin | head -n 1)"
NAME="${DIR%.koplugin}"; NAME="${NAME#moonsource-}"
PKG="moonsource_$NAME"
TITLE="$(awk -F'\t' -v n="$NAME" '$1==n {print $2}' "$T/plugins.tsv")"
[ -n "$TITLE" ] || { echo "plugins.tsv 里没有 $NAME" >&2; exit 1; }
mkdir -p "$DEST/tools" "$DEST/.forgejo/workflows" "$DEST/tests/update"
cp "$T/common/update.lua" "$DEST/$DIR/$PKG/update.lua"
[ -f "$DEST/$DIR/$PKG/version.lua" ] || cp "$T/common/version.lua" "$DEST/$DIR/$PKG/version.lua"
cp "$T/tools/package.sh" "$T/tools/run-tests.sh" "$DEST/tools/"
cp "$T/.forgejo/workflows/release.yml" "$DEST/.forgejo/workflows/release.yml"
sed -e "s/@PKG@/$PKG/" -e "s/@DIR@/$DIR/" "$T/common/update_spec.lua" > "$DEST/tests/update/update_spec.lua"
[ -f "$DEST/LICENSE" ] || cp "$T/LICENSE" "$DEST/LICENSE"
[ -f "$DEST/.gitignore" ] || printf '.DS_Store\n*.swp\ndist/\n.idea/\n' > "$DEST/.gitignore"
[ -f "$DEST/README.md" ] || sed -e "s/@NAME@/$NAME/g" -e "s/@TITLE@/$TITLE/g" "$T/README.plugin.md" > "$DEST/README.md"