From 7340cb481f12f8c36fd7a75463506d9ee17c33ea Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Sat, 14 Mar 2026 16:45:01 +0800 Subject: [PATCH] chore: align Flathub ordering and commit guidance Resolves #222 --- CLAUDE.md | 7 ++ README.md | 133 +++++++++++++++--------------- README.zh-Hans.md | 133 +++++++++++++++--------------- README.zh-Hant.md | 133 +++++++++++++++--------------- src/config/platforms.js | 4 +- src/utils/rewrite.js | 5 +- test/unit/flathub-rewrite.test.js | 8 +- 7 files changed, 215 insertions(+), 208 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 11436c2..76dbdab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,6 +41,13 @@ npm run commitlint # Validate the latest commit message - Common types: `feat`, `fix`, `docs`, `refactor`, `perf`, `test`, `chore` - The repository installs a `commit-msg` hook via `npm install`; do not bypass it unless explicitly required +## Pre-Commit Requirements + +- Before every commit, run the local CI-equivalent checks from `.github/workflows/ci.yml` +- Required commands: `npm run lint`, `npm run format:check`, `npm run test:run`, and `npm run type-check` +- If any required check fails, do not commit until the failure is resolved +- Apply this rule to every commit, including documentation-only changes, unless the user explicitly asks for a different workflow + ### Testing Workflow - Tests use Vitest with `@cloudflare/vitest-pool-workers` for Workers-specific testing diff --git a/README.md b/README.md index f13e68c..04ab6ef 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ [![NuGet](https://img.shields.io/badge/NuGet-004880?logo=nuget&logoColor=white)](#nuget-package-acceleration) [![Rust](https://img.shields.io/badge/Rust-000000?logo=rust&logoColor=white)](#rust-package-acceleration) [![Packagist](https://img.shields.io/badge/Packagist-F28D1A?logo=packagist&logoColor=white)](#php-package-acceleration) +[![Flathub](https://img.shields.io/badge/Flathub-000000?logo=flathub&logoColor=white)](#flathub-repository-mirror) [![Debian](https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=white)](#debianubuntu-apt-configuration) [![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu&logoColor=white)](#debianubuntu-apt-configuration) [![Fedora](https://img.shields.io/badge/Fedora-51A2DA?logo=fedora&logoColor=white)](#fedora-dnf-configuration) @@ -249,6 +250,7 @@ Using the pre-deployed instance **`xget.xi-xu.me`** or your own deployed instanc | NuGet | `nuget` | `https://api.nuget.org/...` | `https://xget.xi-xu.me/nuget/...` | | Rust Crates | `crates` | `https://crates.io/...` | `https://xget.xi-xu.me/crates/...` | | Packagist | `packagist` | `https://repo.packagist.org/...` | `https://xget.xi-xu.me/packagist/...` | +| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | Debian | `debian` | `https://deb.debian.org/...` | `https://xget.xi-xu.me/debian/...` | | Ubuntu | `ubuntu` | `https://archive.ubuntu.com/...` | `https://xget.xi-xu.me/ubuntu/...` | | Fedora | `fedora` | `https://dl.fedoraproject.org/...` | `https://xget.xi-xu.me/fedora/...` | @@ -256,7 +258,6 @@ Using the pre-deployed instance **`xget.xi-xu.me`** or your own deployed instanc | openSUSE | `opensuse` | `https://download.opensuse.org/...` | `https://xget.xi-xu.me/opensuse/...` | | Arch Linux | `arch` | `https://geo.mirror.pkgbuild.com/...` | `https://xget.xi-xu.me/arch/...` | | arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` | -| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` | | Jenkins Plugins | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` | | Container Registries | `cr` | See [Container Registries](#container-registries) | See [Container Registries](#container-registries) | @@ -636,6 +637,22 @@ https://repo.packagist.org/packages/list.json https://xget.xi-xu.me/packagist/packages/list.json ``` +#### Flathub + +```url +# Flathub repository original URL +https://dl.flathub.org/repo/summary + +# Converted (add flathub prefix) +https://xget.xi-xu.me/flathub/repo/summary + +# Flathub app reference original URL +https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref + +# Converted (add flathub prefix) +https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref +``` + #### Linux Distributions ```url @@ -708,22 +725,6 @@ https://f-droid.org/api/v1/packages/org.fdroid.fdroid https://xget.xi-xu.me/fdroid/api/v1/packages/org.fdroid.fdroid ``` -#### Flathub - -```url -# Flathub repository original URL -https://dl.flathub.org/repo/summary - -# Converted (add flathub prefix) -https://xget.xi-xu.me/flathub/repo/summary - -# Flathub app reference original URL -https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref - -# Converted (add flathub prefix) -https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref -``` - #### Jenkins Plugins ```url @@ -1681,6 +1682,55 @@ composer config -l } ``` +### Flathub Repository Mirror + +#### Configure Flatpak / Flathub to Use Xget Mirror + +```bash +# Add the Flathub remote via the rewritten .flatpakrepo descriptor +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# Or add the OSTree repository directly +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/ +``` + +#### Supported Flathub Services + +```url +# OSTree repository metadata +https://xget.xi-xu.me/flathub/repo/summary +https://xget.xi-xu.me/flathub/repo/summary.sig + +# Flatpak remote descriptor +https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# App reference descriptor +https://xget.xi-xu.me/flathub/repo/appstream/[app-id].flatpakref + +# Repository objects and static deltas +https://xget.xi-xu.me/flathub/repo/objects/... +https://xget.xi-xu.me/flathub/repo/deltas/... +``` + +#### Usage Examples + +```bash +# Inspect remote contents +flatpak remote-ls flathub + +# Install an app from the Xget-backed Flathub mirror +flatpak install flathub org.gnome.gedit + +# Install directly from a rewritten .flatpakref +flatpak install --from \ + https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref + +# Update installed apps and runtimes +flatpak update +``` + ### Linux Distribution Acceleration #### Debian/Ubuntu APT Configuration @@ -1883,55 +1933,6 @@ task checkFDroidAvailability { } ``` -### Flathub Repository Mirror - -#### Configure Flatpak / Flathub to Use Xget Mirror - -```bash -# Add the Flathub remote via the rewritten .flatpakrepo descriptor -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# Or add the OSTree repository directly -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/ -``` - -#### Supported Flathub Services - -```url -# OSTree repository metadata -https://xget.xi-xu.me/flathub/repo/summary -https://xget.xi-xu.me/flathub/repo/summary.sig - -# Flatpak remote descriptor -https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# App reference descriptor -https://xget.xi-xu.me/flathub/repo/appstream/[app-id].flatpakref - -# Repository objects and static deltas -https://xget.xi-xu.me/flathub/repo/objects/... -https://xget.xi-xu.me/flathub/repo/deltas/... -``` - -#### Usage Examples - -```bash -# Inspect remote contents -flatpak remote-ls flathub - -# Install an app from the Xget-backed Flathub mirror -flatpak install flathub org.gnome.gedit - -# Install directly from a rewritten .flatpakref -flatpak install --from \ - https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref - -# Update installed apps and runtimes -flatpak update -``` - ### Jenkins Plugin Download #### Use Xget to Accelerate Jenkins Plugin Download and Update diff --git a/README.zh-Hans.md b/README.zh-Hans.md index 6d581a6..ebb651b 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -44,6 +44,7 @@ [![NuGet](https://img.shields.io/badge/NuGet-004880?logo=nuget&logoColor=white)](#nuget-包管理加速) [![Rust](https://img.shields.io/badge/Rust-000000?logo=rust&logoColor=white)](#rust-包管理加速) [![Packagist](https://img.shields.io/badge/Packagist-F28D1A?logo=packagist&logoColor=white)](#php-包管理加速) +[![Flathub](https://img.shields.io/badge/Flathub-000000?logo=flathub&logoColor=white)](#flathub-存储库镜像) [![Debian](https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=white)](#debianubuntu-apt-配置) [![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu&logoColor=white)](#debianubuntu-apt-配置) [![Fedora](https://img.shields.io/badge/Fedora-51A2DA?logo=fedora&logoColor=white)](#fedora-dnf-配置) @@ -249,6 +250,7 @@ classDiagram | NuGet | `nuget` | `https://api.nuget.org/...` | `https://xget.xi-xu.me/nuget/...` | | Rust Crates | `crates` | `https://crates.io/...` | `https://xget.xi-xu.me/crates/...` | | Packagist | `packagist` | `https://repo.packagist.org/...` | `https://xget.xi-xu.me/packagist/...` | +| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | Debian | `debian` | `https://deb.debian.org/...` | `https://xget.xi-xu.me/debian/...` | | Ubuntu | `ubuntu` | `https://archive.ubuntu.com/...` | `https://xget.xi-xu.me/ubuntu/...` | | Fedora | `fedora` | `https://dl.fedoraproject.org/...` | `https://xget.xi-xu.me/fedora/...` | @@ -256,7 +258,6 @@ classDiagram | openSUSE | `opensuse` | `https://download.opensuse.org/...` | `https://xget.xi-xu.me/opensuse/...` | | Arch Linux | `arch` | `https://geo.mirror.pkgbuild.com/...` | `https://xget.xi-xu.me/arch/...` | | arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` | -| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` | | Jenkins 插件 | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` | | 容器注册表 | `cr` | 见[容器注册表](#容器注册表) | 见[容器注册表](#容器注册表) | @@ -636,6 +637,22 @@ https://repo.packagist.org/packages/list.json https://xget.xi-xu.me/packagist/packages/list.json ``` +#### Flathub + +```url +# Flathub 存储库原始 URL +https://dl.flathub.org/repo/summary + +# 转换后(添加 flathub 前缀) +https://xget.xi-xu.me/flathub/repo/summary + +# Flathub 应用引用原始 URL +https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref + +# 转换后(添加 flathub 前缀) +https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref +``` + #### Linux 发行版 ```url @@ -708,22 +725,6 @@ https://f-droid.org/api/v1/packages/org.fdroid.fdroid https://xget.xi-xu.me/fdroid/api/v1/packages/org.fdroid.fdroid ``` -#### Flathub - -```url -# Flathub 存储库原始 URL -https://dl.flathub.org/repo/summary - -# 转换后(添加 flathub 前缀) -https://xget.xi-xu.me/flathub/repo/summary - -# Flathub 应用引用原始 URL -https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref - -# 转换后(添加 flathub 前缀) -https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref -``` - #### Jenkins 插件 ```url @@ -1681,6 +1682,55 @@ composer config -l } ``` +### Flathub 存储库镜像 + +#### 配置 Flatpak / Flathub 使用 Xget 镜像 + +```bash +# 通过重写后的 .flatpakrepo 描述文件添加 Flathub 远程仓库 +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# 或者直接添加 OSTree 存储库地址 +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/ +``` + +#### 支持的 Flathub 服务 + +```url +# OSTree 存储库元数据 +https://xget.xi-xu.me/flathub/repo/summary +https://xget.xi-xu.me/flathub/repo/summary.sig + +# Flatpak 远程仓库描述文件 +https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# 应用引用描述文件 +https://xget.xi-xu.me/flathub/repo/appstream/[应用 ID].flatpakref + +# 存储库对象与静态增量 +https://xget.xi-xu.me/flathub/repo/objects/... +https://xget.xi-xu.me/flathub/repo/deltas/... +``` + +#### 使用示例 + +```bash +# 查看远程仓库内容 +flatpak remote-ls flathub + +# 从 Xget 加速的 Flathub 镜像安装应用 +flatpak install flathub org.gnome.gedit + +# 直接通过重写后的 .flatpakref 安装 +flatpak install --from \ + https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref + +# 更新已安装的应用和运行时 +flatpak update +``` + ### Linux 发行版加速 #### Debian/Ubuntu APT 配置 @@ -1883,55 +1933,6 @@ task checkFDroidAvailability { } ``` -### Flathub 存储库镜像 - -#### 配置 Flatpak / Flathub 使用 Xget 镜像 - -```bash -# 通过重写后的 .flatpakrepo 描述文件添加 Flathub 远程仓库 -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# 或者直接添加 OSTree 存储库地址 -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/ -``` - -#### 支持的 Flathub 服务 - -```url -# OSTree 存储库元数据 -https://xget.xi-xu.me/flathub/repo/summary -https://xget.xi-xu.me/flathub/repo/summary.sig - -# Flatpak 远程仓库描述文件 -https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# 应用引用描述文件 -https://xget.xi-xu.me/flathub/repo/appstream/[应用 ID].flatpakref - -# 存储库对象与静态增量 -https://xget.xi-xu.me/flathub/repo/objects/... -https://xget.xi-xu.me/flathub/repo/deltas/... -``` - -#### 使用示例 - -```bash -# 查看远程仓库内容 -flatpak remote-ls flathub - -# 从 Xget 加速的 Flathub 镜像安装应用 -flatpak install flathub org.gnome.gedit - -# 直接通过重写后的 .flatpakref 安装 -flatpak install --from \ - https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref - -# 更新已安装的应用和运行时 -flatpak update -``` - ### Jenkins 插件下载 #### 使用 Xget 加速 Jenkins 插件下载和更新 diff --git a/README.zh-Hant.md b/README.zh-Hant.md index 17688ee..e072cd1 100644 --- a/README.zh-Hant.md +++ b/README.zh-Hant.md @@ -44,6 +44,7 @@ [![NuGet](https://img.shields.io/badge/NuGet-004880?logo=nuget&logoColor=white)](#nuget-軟體包管理加速) [![Rust](https://img.shields.io/badge/Rust-000000?logo=rust&logoColor=white)](#rust-軟體包管理加速) [![Packagist](https://img.shields.io/badge/Packagist-F28D1A?logo=packagist&logoColor=white)](#php-軟體包管理加速) +[![Flathub](https://img.shields.io/badge/Flathub-000000?logo=flathub&logoColor=white)](#flathub-儲存庫鏡像) [![Debian](https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=white)](#debianubuntu-apt-配置) [![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu&logoColor=white)](#debianubuntu-apt-配置) [![Fedora](https://img.shields.io/badge/Fedora-51A2DA?logo=fedora&logoColor=white)](#fedora-dnf-配置) @@ -249,6 +250,7 @@ classDiagram | NuGet | `nuget` | `https://api.nuget.org/...` | `https://xget.xi-xu.me/nuget/...` | | Rust Crates | `crates` | `https://crates.io/...` | `https://xget.xi-xu.me/crates/...` | | Packagist | `packagist` | `https://repo.packagist.org/...` | `https://xget.xi-xu.me/packagist/...` | +| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | Debian | `debian` | `https://deb.debian.org/...` | `https://xget.xi-xu.me/debian/...` | | Ubuntu | `ubuntu` | `https://archive.ubuntu.com/...` | `https://xget.xi-xu.me/ubuntu/...` | | Fedora | `fedora` | `https://dl.fedoraproject.org/...` | `https://xget.xi-xu.me/fedora/...` | @@ -256,7 +258,6 @@ classDiagram | openSUSE | `opensuse` | `https://download.opensuse.org/...` | `https://xget.xi-xu.me/opensuse/...` | | Arch Linux | `arch` | `https://geo.mirror.pkgbuild.com/...` | `https://xget.xi-xu.me/arch/...` | | arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` | -| Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` | | Jenkins 外掛程式 | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` | | 容器註冊表 | `cr` | 見[容器註冊表](#容器註冊表) | 見[容器註冊表](#容器註冊表) | @@ -636,6 +637,22 @@ https://repo.packagist.org/packages/list.json https://xget.xi-xu.me/packagist/packages/list.json ``` +#### Flathub + +```url +# Flathub 儲存庫原始 URL +https://dl.flathub.org/repo/summary + +# 轉換後(新增 flathub 前綴) +https://xget.xi-xu.me/flathub/repo/summary + +# Flathub 應用程式引用原始 URL +https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref + +# 轉換後(新增 flathub 前綴) +https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref +``` + #### Linux 發行版 ```url @@ -708,22 +725,6 @@ https://f-droid.org/api/v1/packages/org.fdroid.fdroid https://xget.xi-xu.me/fdroid/api/v1/packages/org.fdroid.fdroid ``` -#### Flathub - -```url -# Flathub 儲存庫原始 URL -https://dl.flathub.org/repo/summary - -# 轉換後(新增 flathub 前綴) -https://xget.xi-xu.me/flathub/repo/summary - -# Flathub 應用程式引用原始 URL -https://dl.flathub.org/repo/appstream/org.gnome.gedit.flatpakref - -# 轉換後(新增 flathub 前綴) -https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref -``` - #### Jenkins 外掛程式 ```url @@ -1681,6 +1682,55 @@ composer config -l } ``` +### Flathub 儲存庫鏡像 + +#### 配置 Flatpak / Flathub 使用 Xget 鏡像 + +```bash +# 透過重寫後的 .flatpakrepo 描述檔新增 Flathub 遠端儲存庫 +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# 或者直接新增 OSTree 儲存庫位址 +flatpak remote-add --if-not-exists flathub \ + https://xget.xi-xu.me/flathub/repo/ +``` + +#### 支援的 Flathub 服務 + +```url +# OSTree 儲存庫中繼資料 +https://xget.xi-xu.me/flathub/repo/summary +https://xget.xi-xu.me/flathub/repo/summary.sig + +# Flatpak 遠端儲存庫描述檔 +https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo + +# 應用程式引用描述檔 +https://xget.xi-xu.me/flathub/repo/appstream/[應用程式 ID].flatpakref + +# 儲存庫物件與靜態增量 +https://xget.xi-xu.me/flathub/repo/objects/... +https://xget.xi-xu.me/flathub/repo/deltas/... +``` + +#### 使用範例 + +```bash +# 檢視遠端儲存庫內容 +flatpak remote-ls flathub + +# 從 Xget 加速的 Flathub 鏡像安裝應用程式 +flatpak install flathub org.gnome.gedit + +# 直接透過重寫後的 .flatpakref 安裝 +flatpak install --from \ + https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref + +# 更新已安裝的應用程式與執行時 +flatpak update +``` + ### Linux 發行版加速 #### Debian/Ubuntu APT 配置 @@ -1883,55 +1933,6 @@ task checkFDroidAvailability { } ``` -### Flathub 儲存庫鏡像 - -#### 配置 Flatpak / Flathub 使用 Xget 鏡像 - -```bash -# 透過重寫後的 .flatpakrepo 描述檔新增 Flathub 遠端儲存庫 -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# 或者直接新增 OSTree 儲存庫位址 -flatpak remote-add --if-not-exists flathub \ - https://xget.xi-xu.me/flathub/repo/ -``` - -#### 支援的 Flathub 服務 - -```url -# OSTree 儲存庫中繼資料 -https://xget.xi-xu.me/flathub/repo/summary -https://xget.xi-xu.me/flathub/repo/summary.sig - -# Flatpak 遠端儲存庫描述檔 -https://xget.xi-xu.me/flathub/repo/flathub.flatpakrepo - -# 應用程式引用描述檔 -https://xget.xi-xu.me/flathub/repo/appstream/[應用程式 ID].flatpakref - -# 儲存庫物件與靜態增量 -https://xget.xi-xu.me/flathub/repo/objects/... -https://xget.xi-xu.me/flathub/repo/deltas/... -``` - -#### 使用範例 - -```bash -# 檢視遠端儲存庫內容 -flatpak remote-ls flathub - -# 從 Xget 加速的 Flathub 鏡像安裝應用程式 -flatpak install flathub org.gnome.gedit - -# 直接透過重寫後的 .flatpakref 安裝 -flatpak install --from \ - https://xget.xi-xu.me/flathub/repo/appstream/org.gnome.gedit.flatpakref - -# 更新已安裝的應用程式與執行時 -flatpak update -``` - ### Jenkins 外掛程式下載 #### 使用 Xget 加速 Jenkins 外掛程式下載和更新 diff --git a/src/config/platforms.js b/src/config/platforms.js index c4d2535..9771110 100644 --- a/src/config/platforms.js +++ b/src/config/platforms.js @@ -52,6 +52,7 @@ * - `nuget` - NuGet (api.nuget.org) * - `crates` - Rust crates.io (crates.io) * - `packagist` - PHP Packagist (repo.packagist.org) + * - `flathub` - Flathub Flatpak repository (dl.flathub.org) * * **Linux Distributions:** * - `debian` - Debian packages (deb.debian.org) @@ -63,7 +64,6 @@ * * **Other Resources:** * - `arxiv` - arXiv papers (arxiv.org) - * - `flathub` - Flathub Flatpak repository (dl.flathub.org) * - `fdroid` - F-Droid Android apps (f-droid.org) * - `jenkins` - Jenkins plugins (updates.jenkins.io) * @@ -161,6 +161,7 @@ export const PLATFORMS = { nuget: 'https://api.nuget.org', crates: 'https://crates.io', packagist: 'https://repo.packagist.org', + flathub: 'https://dl.flathub.org', // Linux Distributions debian: 'https://deb.debian.org', @@ -172,7 +173,6 @@ export const PLATFORMS = { // Other Resources arxiv: 'https://arxiv.org', - flathub: 'https://dl.flathub.org', fdroid: 'https://f-droid.org', jenkins: 'https://updates.jenkins.io', diff --git a/src/utils/rewrite.js b/src/utils/rewrite.js index af94cfd..cc81d8e 100644 --- a/src/utils/rewrite.js +++ b/src/utils/rewrite.js @@ -51,10 +51,7 @@ export function rewriteTextResponse(platform, requestPath, originalText, origin) } if (platform === 'npm') { - return originalText.replace( - /https:\/\/registry\.npmjs\.org\/([^/]+)/g, - `${origin}/npm/$1` - ); + return originalText.replace(/https:\/\/registry\.npmjs\.org\/([^/]+)/g, `${origin}/npm/$1`); } if (platform === 'flathub' && isFlatpakReferenceFilePath(requestPath)) { diff --git a/test/unit/flathub-rewrite.test.js b/test/unit/flathub-rewrite.test.js index 294c6eb..b6b4070 100644 --- a/test/unit/flathub-rewrite.test.js +++ b/test/unit/flathub-rewrite.test.js @@ -60,7 +60,9 @@ describe('Flathub Response Rewriting', () => { expect(body).toContain('Url=https://example.com/flathub/repo/'); expect(body).toContain('Icon=https://example.com/flathub/repo/logo.svg'); expect(body).toContain('Homepage=https://flathub.org/'); - expect(response.headers.get('Content-Length')).toBe(String(new TextEncoder().encode(body).length)); + expect(response.headers.get('Content-Length')).toBe( + String(new TextEncoder().encode(body).length) + ); }); it('rewrites .flatpakref URLs to stay on the Xget mirror', async () => { @@ -89,9 +91,7 @@ describe('Flathub Response Rewriting', () => { const body = await readUtf8Text(response); expect(body).toContain('Url=https://example.com/flathub/repo/'); - expect(body).toContain( - 'RuntimeRepo=https://example.com/flathub/repo/flathub.flatpakrepo' - ); + expect(body).toContain('RuntimeRepo=https://example.com/flathub/repo/flathub.flatpakrepo'); }); it('does not rewrite binary repository metadata like summary files', async () => {