From 1b6747d9f92fa89ec2d36efd1d781f757bdddfb0 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 31 May 2026 10:36:53 -0500 Subject: [PATCH] feat: integrate MokoGitea license system for update checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update server now points to MokoGitea's dynamic endpoint which validates license keys (dlid) and generates update XML from git releases. Users enter the download key via Joomla's native System → Update Sites interface. Legacy static URLs are auto-migrated on install/update. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 5 +++ .mokogitea/CLAUDE.md | 38 ++++++++++++------- .mokogitea/copilot-instructions.md | 37 +++++++++++------- CHANGELOG.md | 9 +++++ .../Extension/MokoWaaS.php | 1 + src/pkg_mokowaas.xml | 2 +- src/script.php | 22 ++++++++--- updates.xml | 27 ------------- 8 files changed, 82 insertions(+), 59 deletions(-) delete mode 100644 updates.xml diff --git a/.gitignore b/.gitignore index 2f7a4ac..759676e 100644 --- a/.gitignore +++ b/.gitignore @@ -93,6 +93,11 @@ sftp-settings.json .replit replit.md +# ============================================================ +# Update server (generated dynamically by MokoGitea) +# ============================================================ +updates.xml + # ============================================================ # Archives / release artifacts # ============================================================ diff --git a/.mokogitea/CLAUDE.md b/.mokogitea/CLAUDE.md index 68e796a..ea146a1 100644 --- a/.mokogitea/CLAUDE.md +++ b/.mokogitea/CLAUDE.md @@ -154,7 +154,7 @@ The version in `README.md` **must always match** the `` tag in `manifes ``` MokoWaaS/ ├── manifest.xml # Joomla installer manifest (root — required) -├── updates.xml # Update server manifest (root — required, see below) +├── (no updates.xml) # Update XML is generated dynamically by MokoGitea ├── site/ # Frontend (site) code │ ├── controller.php │ ├── controllers/ @@ -183,24 +183,35 @@ MokoWaaS/ --- -## updates.xml — Required in Repo Root +## Update Server — MokoGitea Dynamic Endpoint -`updates.xml` **must exist at the repository root**. It is the Joomla update server manifest that allows Joomla installations to check for new versions of this extension. +`updates.xml` is **NOT** stored in the repo. MokoGitea generates the update XML dynamically from git releases at: -The `manifest.xml` must reference it via: +``` +https://git.mokoconsulting.tech/{Owner}/{Repo}/updates.xml +``` + +The package manifest (`pkg_mokowaas.xml`) references it via: ```xml - - https://github.com/mokoconsulting-tech/MokoWaaS/raw/main/updates.xml + + https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/updates.xml ``` +**License Key (Download Key):** +- MokoGitea's endpoint validates license keys passed as `?dlid=MOKO-XXXX-XXXX-XXXX-XXXX` +- The generated XML includes `` to tell Joomla a key is required +- Users enter the download key via Joomla's native **System → Update Sites** interface +- Joomla stores the key in `#__update_sites.extra_query` and appends it to all update/download requests +- Invalid/expired keys receive an empty `` response + **Rules:** -- Every release must prepend a new `` block at the top of `updates.xml` — old entries must be preserved below. -- The `` in `updates.xml` must exactly match `` in `manifest.xml` and the version in `README.md`. -- The `` must be a publicly accessible direct download link (GitHub Releases asset URL). -- `` — the backslash is a **literal backslash character** in the XML attribute value; Joomla's update-server parser treats the value as a regular expression, so `\.` matches a literal dot and `[0-9]+` matches one or more digits. Do not double-escape it. +- Do NOT create or commit a static `updates.xml` — MokoGitea generates it from releases +- The `` in release tags must match `` in the manifest and `README.md` +- Release assets (ZIPs) must be attached to git releases — MokoGitea uses them for `` +- `` — the backslash is a **literal backslash character** in the XML attribute value; Joomla's update-server parser treats the value as a regular expression --- @@ -286,8 +297,8 @@ Approved prefixes: `dev/` · `rc/` · `version/` · `patch/` · `copilot/` · `d | Change type | Documentation to update | |-------------|------------------------| | New or renamed PHP class/method | PHPDoc block; `docs/api/` entry | -| New or changed manifest.xml | Update `updates.xml` version; bump README.md version | -| New release | Prepend `` block to `updates.xml`; update CHANGELOG.md; bump README.md version | +| New or changed manifest.xml | Bump README.md version | +| New release | Create git release with ZIP asset; update CHANGELOG.md; bump README.md version | | New or changed workflow | `docs/workflows/.md` | | Any modified file | Update the `VERSION` field in that file's `FILE INFORMATION` block | | **Every PR** | **Bump the patch version** — increment `XX.YY.ZZ` in `README.md`; `sync-version-on-merge` propagates it | @@ -301,4 +312,5 @@ Approved prefixes: `dev/` · `rc/` · `version/` · `patch/` · `copilot/` · `d - Never add `defined('_JEXEC') or die;` to CLI scripts or model tests — only to web-accessible PHP files - Never hardcode version numbers in body text — update `README.md` and let automation propagate - Never use `github.token` or `secrets.GITHUB_TOKEN` in workflows — always use `secrets.GH_TOKEN` -- Never let `manifest.xml` version, `updates.xml` version, and `README.md` version go out of sync +- Never let `manifest.xml` version and `README.md` version go out of sync +- Never commit a static `updates.xml` — the update feed is generated dynamically by MokoGitea diff --git a/.mokogitea/copilot-instructions.md b/.mokogitea/copilot-instructions.md index 68e796a..a46f9a2 100644 --- a/.mokogitea/copilot-instructions.md +++ b/.mokogitea/copilot-instructions.md @@ -154,7 +154,7 @@ The version in `README.md` **must always match** the `` tag in `manifes ``` MokoWaaS/ ├── manifest.xml # Joomla installer manifest (root — required) -├── updates.xml # Update server manifest (root — required, see below) +├── (no updates.xml) # Update XML is generated dynamically by MokoGitea ├── site/ # Frontend (site) code │ ├── controller.php │ ├── controllers/ @@ -183,24 +183,34 @@ MokoWaaS/ --- -## updates.xml — Required in Repo Root +## Update Server — MokoGitea Dynamic Endpoint -`updates.xml` **must exist at the repository root**. It is the Joomla update server manifest that allows Joomla installations to check for new versions of this extension. +`updates.xml` is **NOT** stored in the repo. MokoGitea generates the update XML dynamically from git releases at: -The `manifest.xml` must reference it via: +``` +https://git.mokoconsulting.tech/{Owner}/{Repo}/updates.xml +``` + +The package manifest (`pkg_mokowaas.xml`) references it via: ```xml - - https://github.com/mokoconsulting-tech/MokoWaaS/raw/main/updates.xml + + https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/updates.xml ``` +**License Key (Download Key):** +- MokoGitea's endpoint validates license keys passed as `?dlid=MOKO-XXXX-XXXX-XXXX-XXXX` +- The generated XML includes `` to tell Joomla a key is required +- Users enter the download key via Joomla's native **System → Update Sites** interface +- Joomla stores the key in `#__update_sites.extra_query` and appends it to all update/download requests +- Invalid/expired keys receive an empty `` response + **Rules:** -- Every release must prepend a new `` block at the top of `updates.xml` — old entries must be preserved below. -- The `` in `updates.xml` must exactly match `` in `manifest.xml` and the version in `README.md`. -- The `` must be a publicly accessible direct download link (GitHub Releases asset URL). -- `` — the backslash is a **literal backslash character** in the XML attribute value; Joomla's update-server parser treats the value as a regular expression, so `\.` matches a literal dot and `[0-9]+` matches one or more digits. Do not double-escape it. +- Do NOT create or commit a static `updates.xml` — MokoGitea generates it from releases +- The `` in release tags must match `` in the manifest and `README.md` +- Release assets (ZIPs) must be attached to git releases — MokoGitea uses them for `` --- @@ -286,8 +296,8 @@ Approved prefixes: `dev/` · `rc/` · `version/` · `patch/` · `copilot/` · `d | Change type | Documentation to update | |-------------|------------------------| | New or renamed PHP class/method | PHPDoc block; `docs/api/` entry | -| New or changed manifest.xml | Update `updates.xml` version; bump README.md version | -| New release | Prepend `` block to `updates.xml`; update CHANGELOG.md; bump README.md version | +| New or changed manifest.xml | Bump README.md version | +| New release | Create git release with ZIP asset; update CHANGELOG.md; bump README.md version | | New or changed workflow | `docs/workflows/.md` | | Any modified file | Update the `VERSION` field in that file's `FILE INFORMATION` block | | **Every PR** | **Bump the patch version** — increment `XX.YY.ZZ` in `README.md`; `sync-version-on-merge` propagates it | @@ -301,4 +311,5 @@ Approved prefixes: `dev/` · `rc/` · `version/` · `patch/` · `copilot/` · `d - Never add `defined('_JEXEC') or die;` to CLI scripts or model tests — only to web-accessible PHP files - Never hardcode version numbers in body text — update `README.md` and let automation propagate - Never use `github.token` or `secrets.GITHUB_TOKEN` in workflows — always use `secrets.GH_TOKEN` -- Never let `manifest.xml` version, `updates.xml` version, and `README.md` version go out of sync +- Never let `manifest.xml` version and `README.md` version go out of sync +- Never commit a static `updates.xml` — the update feed is generated dynamically by MokoGitea diff --git a/CHANGELOG.md b/CHANGELOG.md index 045aa6b..d388f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,15 @@ --> # Changelog +## [02.30.00] - 2026-05-31 +### Added +- License key support via Joomla's native Update Sites download key system (dlid) +- Update server URL migrated from static XML to MokoGitea's dynamic update feed endpoint +- Legacy static update site URLs auto-migrated to dynamic endpoint on install/update + +### Removed +- Static `updates.xml` — update feed is now generated dynamically by MokoGitea from git releases + ## [02.29.04] - 2026-05-31 ### Fixed - Remove secondary master username from enforcement — only primary master user is created/enforced diff --git a/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php b/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php index 396d757..8893b62 100644 --- a/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php +++ b/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php @@ -938,6 +938,7 @@ class MokoWaaS extends CMSPlugin implements BootableExtensionInterface ); $db->execute(); } + } /** diff --git a/src/pkg_mokowaas.xml b/src/pkg_mokowaas.xml index a3e2d57..69fa778 100644 --- a/src/pkg_mokowaas.xml +++ b/src/pkg_mokowaas.xml @@ -23,6 +23,6 @@ - https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/raw/branch/main/updates.xml + https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/updates.xml diff --git a/src/script.php b/src/script.php index 7923b24..a022b80 100644 --- a/src/script.php +++ b/src/script.php @@ -219,11 +219,12 @@ class Pkg_MokowaasInstallerScript } /** - * Ensure the MokoWaaS update server entry stays enabled. + * Ensure the MokoWaaS update server entry stays enabled and points + * to the correct dynamic endpoint with the license key attached. * - * Joomla stores update server records in #__update_sites. If a tenant - * or automation disables it, the site stops receiving updates. This - * re-enables it on every install/update. + * Migrates legacy static URLs (raw/branch/main/updates.xml) to the + * dynamic MokoGitea update feed, and syncs the license key from + * plugin params into extra_query so Joomla sends it as dlid. * * @return void * @@ -235,7 +236,18 @@ class Pkg_MokowaasInstallerScript { $db = Factory::getDbo(); - // Find update site by name or URL pattern + // Migrate legacy static URL to dynamic MokoGitea endpoint + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__update_sites')) + ->set($db->quoteName('location') . ' = ' + . $db->quote('https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/updates.xml')) + ->where($db->quoteName('location') . ' LIKE ' + . $db->quote('%MokoWaaS/raw/branch/%updates.xml%')) + ); + $db->execute(); + + // Enable all MokoWaaS update sites $query = $db->getQuery(true) ->update($db->quoteName('#__update_sites')) ->set($db->quoteName('enabled') . ' = 1') diff --git a/updates.xml b/updates.xml deleted file mode 100644 index e562b6c..0000000 --- a/updates.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - Package - MokoWaaS - Package - MokoWaaS stable build. - pkg_mokowaas - package - site - 02.29.04 - 2026-05-31 - https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/releases/tag/stable - - https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/releases/download/stable/pkg_mokowaas-02.29.04.zip - - b39d1e0d269f54a362acd5a6edafefb7e5813cdadc289617e0ab6dfdc5c97d16 - stable - https://git.mokoconsulting.tech/MokoConsulting/MokoWaaS/raw/branch/main/CHANGELOG.md - Moko Consulting - https://mokoconsulting.tech - - - -- 2.52.0