fix: remove dead code, update stale versions, tag-based release workflow

Dead code removed:
- Module.php: remove addIPv4() method (no endpoint, feature removed per CLAUDE.md)
- Curl.php: remove useCookies(), setLog() (security risk — wrote tokens to
  web-accessible CURL.log), head(), getHeadersData() — all unused
- module.css: remove .vf-button, .vf-button-small (never referenced in DOM)
- module.css: remove vestigial #vf-data-server-traffic-sep rule
- module.css: merge duplicate #vf-server-info-error declarations
- publish-release.yml: remove dead version.json generation step (nothing reads it)

Fixes:
- AdminHTML.php: update stale cache version strings 20260207 → 20260319
- hooks.php: update stale keygen.js version string
- hooks.php: remove unused `use WHMCS\User\User` import
- ConfigureService.php: remove unused `use JsonException` import
- module.css: fix .vf-os-details class selector → #vf-os-details ID selector
- client.php + admin.php: reuse existing $vf instead of new Module()
- Module.php: use Cache::forget() instead of forgetPattern() for known key
  (forgetPattern is a no-op on filesystem cache fallback)

Workflow:
- Rewrite publish-release.yml: tag-based triggers only (no automatic releases)
- Triggers on push of v* tags, creates GitHub release with auto-generated notes
- Uses softprops/action-gh-release@v2 — compatible with both Gitea and GitHub

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Prophet731
2026-03-19 13:59:18 -05:00
parent 3d3df6e2dc
commit d3d75b4752
9 changed files with 36 additions and 127 deletions

View File

@@ -1,52 +1,43 @@
# .github/workflows/semantic-versioning-release.yml name: Publish Release
name: Automated Semantic Versioning Release
on: on:
push: push:
branches: tags:
- main - 'v*'
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write # for creating tags and releases contents: write
issues: write # for commenting on issues
pull-requests: write # for commenting on PRs
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
# This is required to analyze the full commit history
fetch-depth: 0
- name: Automated Semantic Release - name: Extract tag name
# This action wraps the popular semantic-release tool id: tag
uses: cycjimmy/semantic-release-action@v4 run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
with:
# You can specify the branches to release from
branch: main
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
# GITHUB_TOKEN is required for authentication
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate cache busting version hashes - name: Generate release notes
id: notes
run: | run: |
CSS_HASH=$(md5sum modules/servers/VirtFusionDirect/templates/css/module.css | cut -c1-8) # Get previous tag
JS_HASH=$(md5sum modules/servers/VirtFusionDirect/templates/js/module.js | cut -c1-8) PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "{\"css\":\"$CSS_HASH\",\"js\":\"$JS_HASH\"}" > modules/servers/VirtFusionDirect/templates/version.json if [ -n "$PREV_TAG" ]; then
git config user.name "github-actions[bot]" NOTES=$(git log --pretty=format:"- %s" "$PREV_TAG"..HEAD)
git config user.email "github-actions[bot]@users.noreply.github.com" else
git add modules/servers/VirtFusionDirect/templates/version.json NOTES=$(git log --pretty=format:"- %s")
git diff --cached --quiet || git commit -m "chore: update asset version hashes [skip ci]" fi
git push || true # Write to file for the release body
echo "$NOTES" > /tmp/release-notes.txt
# To make this work, you must follow the Conventional Commits specification. - name: Create release
# Examples: uses: softprops/action-gh-release@v2
# - fix: correct a typo in the documentation with:
# - feat: add a new user authentication endpoint tag_name: ${{ steps.tag.outputs.version }}
# - feat(api): add rate limiting name: ${{ steps.tag.outputs.version }}
# BREAKING CHANGE: The API now returns 429 when rate limit is exceeded. body_path: /tmp/release-notes.txt
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -40,7 +40,7 @@ switch ($vf->validateAction(true)) {
} }
(new Module())->updateWhmcsServiceParamsOnServerObject((int)$_GET['serviceID'], $data); $vf->updateWhmcsServiceParamsOnServerObject((int)$_GET['serviceID'], $data);
$vf->output(['success' => true, 'data' => (new ServerResource())->process($data)], true, true, 200); $vf->output(['success' => true, 'data' => (new ServerResource())->process($data)], true, true, 200);
} }

View File

@@ -51,7 +51,7 @@ switch ($action) {
$data = $vf->fetchServerData($serviceID); $data = $vf->fetchServerData($serviceID);
if ($data) { if ($data) {
(new Module())->updateWhmcsServiceParamsOnServerObject($serviceID, $data); $vf->updateWhmcsServiceParamsOnServerObject($serviceID, $data);
$vf->output(['success' => true, 'data' => (new ServerResource())->process($data)], true, true, 200); $vf->output(['success' => true, 'data' => (new ServerResource())->process($data)], true, true, 200);
break; break;
} }

View File

@@ -2,7 +2,6 @@
use WHMCS\Module\Server\VirtFusionDirect\ConfigureService; use WHMCS\Module\Server\VirtFusionDirect\ConfigureService;
use WHMCS\Module\Server\VirtFusionDirect\Database; use WHMCS\Module\Server\VirtFusionDirect\Database;
use WHMCS\User\User;
if (!defined("WHMCS")) { if (!defined("WHMCS")) {
die("This file cannot be accessed directly"); die("This file cannot be accessed directly");
@@ -131,7 +130,7 @@ add_hook('ClientAreaFooterOutput', 1, function ($vars) {
return " return "
<link href=\"" . htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8') . "modules/servers/VirtFusionDirect/templates/css/module.css?v=20260319\" rel=\"stylesheet\"> <link href=\"" . htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8') . "modules/servers/VirtFusionDirect/templates/css/module.css?v=20260319\" rel=\"stylesheet\">
<script src=\"" . htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8') . "modules/servers/VirtFusionDirect/templates/js/keygen.js?v=20260207\"></script> <script src=\"" . htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8') . "modules/servers/VirtFusionDirect/templates/js/keygen.js?v=20260319\"></script>
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
var osGalleryData = " . json_encode($galleryData, JSON_THROW_ON_ERROR | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) . "; var osGalleryData = " . json_encode($galleryData, JSON_THROW_ON_ERROR | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) . ";

View File

@@ -35,8 +35,8 @@ EOT;
{ {
$systemUrl = htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8'); $systemUrl = htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8');
return <<<EOT return <<<EOT
<link href="${systemUrl}modules/servers/VirtFusionDirect/templates/css/module.css?v=20260207" rel="stylesheet"> <link href="${systemUrl}modules/servers/VirtFusionDirect/templates/css/module.css?v=20260319" rel="stylesheet">
<script src="${systemUrl}modules/servers/VirtFusionDirect/templates/js/module.js?v=20260207"></script> <script src="${systemUrl}modules/servers/VirtFusionDirect/templates/js/module.js?v=20260319"></script>
<div id="vf-loader" class="vf-loader"> <div id="vf-loader" class="vf-loader">
<div id="vf-loading"></div> <div id="vf-loading"></div>
</div> </div>

View File

@@ -2,7 +2,6 @@
namespace WHMCS\Module\Server\VirtFusionDirect; namespace WHMCS\Module\Server\VirtFusionDirect;
use JsonException;
use WHMCS\Database\Capsule as DB; use WHMCS\Database\Capsule as DB;
use WHMCS\User\User; use WHMCS\User\User;

View File

@@ -24,23 +24,6 @@ class Curl
$this->ch = curl_init(); $this->ch = curl_init();
} }
public function useCookies()
{
$cookiesFile = tempnam(sys_get_temp_dir(), 'virtfusion_cookies');
$this->defaultOptions[CURLOPT_COOKIEFILE] = $cookiesFile;
$this->defaultOptions[CURLOPT_COOKIEJAR] = $cookiesFile;
}
public function setLog()
{
$log = fopen(__DIR__ . '/CURL.log', 'a');
if ($log) {
fwrite($log, str_repeat('=', 80) . PHP_EOL);
$this->addOption(CURLOPT_STDERR, $log);
$this->addOption(CURLOPT_VERBOSE, true);
}
}
/** /**
* @param $name * @param $name
* @param $value * @param $value
@@ -166,15 +149,6 @@ class Curl
return $this->send('POST', $url); return $this->send('POST', $url);
} }
/**
* @param null $url
* @return bool|string|void
*/
public function head($url = null)
{
return $this->send('HEAD', $url);
}
/** /**
* @param false $param * @param false $param
* @return mixed|null * @return mixed|null
@@ -202,16 +176,4 @@ class Curl
} }
} }
/**
* @param false $param
* @return mixed|null
*/
public function getHeadersData($param = false)
{
if ($param) {
return $this->getDataItem('data', $param);
}
return $this->data['data'];
}
} }

View File

@@ -206,7 +206,7 @@ class Module
$httpCode = $ctx['request']->getRequestInfo('http_code'); $httpCode = $ctx['request']->getRequestInfo('http_code');
if ($httpCode == 200 || $httpCode == 201) { if ($httpCode == 200 || $httpCode == 201) {
Cache::forgetPattern('backups:' . $ctx['serverId']); Cache::forget('backups:' . $ctx['serverId']);
return json_decode($data) ?: (object) ['success' => true]; return json_decode($data) ?: (object) ['success' => true];
} }
return false; return false;
@@ -348,31 +348,6 @@ class Module
return false; return false;
} }
// =========================================================================
// IP Address Management
// =========================================================================
/**
* Add an IPv4 address to a server.
*
* @param int $serviceID
* @return object|false
*/
public function addIPv4($serviceID)
{
$ctx = $this->resolveServiceContext($serviceID);
if (!$ctx) return false;
$data = $ctx['request']->post($ctx['cp']['url'] . '/servers/' . $ctx['serverId'] . '/ipv4');
Log::insert(__FUNCTION__, $ctx['request']->getRequestInfo(), $data);
$httpCode = $ctx['request']->getRequestInfo('http_code');
if ($httpCode == 200 || $httpCode == 201) {
return json_decode($data) ?: (object) ['success' => true];
}
return false;
}
// ========================================================================= // =========================================================================
// Backup Management // Backup Management
// ========================================================================= // =========================================================================

View File

@@ -9,16 +9,6 @@
} }
/* Buttons */ /* Buttons */
.vf-button {
font-size: 0.8rem;
padding: 0.95rem 1.5rem;
font-weight: 600;
}
.vf-button-small {
font-size: 0.8rem;
padding: 0.75rem 1.3rem;
font-weight: 500;
}
.vf-spinner-margin { .vf-spinner-margin {
margin-right: 7px; margin-right: 7px;
} }
@@ -84,9 +74,7 @@
} }
#vf-server-info-error { #vf-server-info-error {
display: none; display: none;
} margin: 10px;
#vf-data-server-traffic-sep {
display: inline;
} }
/* Skeleton Loading */ /* Skeleton Loading */
@@ -159,11 +147,6 @@
} }
} }
/* Error message spacing */
#vf-server-info-error {
margin: 10px;
}
/* Network / IP Management */ /* Network / IP Management */
.vf-ip-row { .vf-ip-row {
display: flex; display: flex;
@@ -364,7 +347,7 @@
border-radius: 3px; border-radius: 3px;
margin-top: 3px; margin-top: 3px;
} }
.vf-os-details { #vf-os-details {
border-top: 1px solid #dee2e6; border-top: 1px solid #dee2e6;
padding-top: 10px; padding-top: 10px;
} }