You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
6.4 KiB
PHP
85 lines
6.4 KiB
PHP
<?php
|
|
|
|
// Static source graph only: no application boot, database or browser network.
|
|
$root = dirname(__DIR__);
|
|
$public = $root . '/public/cloud';
|
|
$assert = static function ($condition, $message) {
|
|
if (!$condition) throw new RuntimeException($message);
|
|
};
|
|
$entry = $public . '/vendor/novnc/core/rfb.js';
|
|
$queue = [$entry];
|
|
$seen = [];
|
|
while ($queue !== []) {
|
|
$file = array_pop($queue);
|
|
$resolved = realpath($file);
|
|
$assert($resolved !== false && str_starts_with($resolved, realpath($public) . DIRECTORY_SEPARATOR), 'Missing or external noVNC module: ' . $file);
|
|
if (isset($seen[$resolved])) continue;
|
|
$seen[$resolved] = true;
|
|
$source = file_get_contents($resolved);
|
|
preg_match_all('/(?:import|export)\s+(?:[^;]*?\s+from\s+)?[\'"]([^\'"]+)[\'"]\s*;/', $source, $imports);
|
|
foreach ($imports[1] as $path) {
|
|
if (str_starts_with($path, './') || str_starts_with($path, '../')) $queue[] = dirname($resolved) . '/' . $path;
|
|
}
|
|
}
|
|
$assert(count($seen) > 20, 'noVNC dependency graph was not validated');
|
|
$assert(is_file($public . '/vendor/novnc/LICENSE.txt'), 'Vendored noVNC license missing');
|
|
foreach (['almalinux', 'ubuntu', 'debian', 'centos'] as $system) {
|
|
$assert(is_file($public . '/' . $system . '-icon.svg'), 'Local OS icon missing: ' . $system);
|
|
}
|
|
foreach (['user/layout_header.tpl', 'user/layout_plain_header.tpl', 'auth/layout_header.tpl'] as $template) {
|
|
$source = file_get_contents($root . '/resources/views/venix/' . $template);
|
|
$assert(str_contains($source, '/cloud/styles.css') && str_contains($source, '/cloud/account.css'), 'Unified user styles missing: ' . $template);
|
|
$assert(!str_contains($source, 'user-home.css') && !str_contains($source, '/css/auth.css'), 'Retired user stylesheet still active: ' . $template);
|
|
}
|
|
$views = $root . '/resources/views/venix';
|
|
$cloudTemplate = file_get_contents($views . '/cloud/index.tpl');
|
|
$userLayout = file_get_contents($views . '/user/layout_header.tpl');
|
|
$sharedSidebar = file_get_contents($views . '/user/panel_sidebar.tpl');
|
|
$sharedTopbar = file_get_contents($views . '/user/panel_topbar.tpl');
|
|
$clientScript = file_get_contents($public . '/app.js');
|
|
$clientStyles = file_get_contents($public . '/client.css');
|
|
$baseStyles = file_get_contents($public . '/styles.css');
|
|
$shopFormScript = file_get_contents($views . '/admin/shop/form_js.tpl');
|
|
$templateAdmin = file_get_contents($views . '/admin/cloud/templates.tpl');
|
|
$adminScript = file_get_contents($public . '/admin.js');
|
|
$cloudAdminController = file_get_contents($root . '/app/Controllers/CloudAdminController.php');
|
|
$assert(str_contains($cloudTemplate, "file='user/panel_sidebar.tpl'")
|
|
&& str_contains($userLayout, "file='user/panel_sidebar.tpl'"), 'Cloud and account pages must share one sidebar partial');
|
|
$assert(str_contains($cloudTemplate, "file='user/panel_topbar.tpl'")
|
|
&& str_contains($userLayout, "file='user/panel_topbar.tpl'"), 'Cloud and account pages must share one topbar partial');
|
|
$assert(!str_contains($cloudTemplate, '<aside class="sidebar"')
|
|
&& !str_contains($userLayout, 'vu-sidebar'), 'A duplicate user sidebar shell remains active');
|
|
$assert(str_contains($userLayout, '/cloud/client.css'), 'Account pages must load the shared VM-panel navigation styles');
|
|
$assert(str_contains($sharedSidebar, 'mdi-server') && str_contains($sharedSidebar, 'mdi-lifebuoy'), 'Shared sidebar must retain Venix iconography');
|
|
$assert(str_contains($sharedSidebar, '/user/logout') && !str_contains($clientScript, "location.assign('/auth/logout')"), 'Logged-in logout must use the authenticated user route');
|
|
$assert(str_contains($clientScript, 'event.preventDefault()'), 'Cloud hash navigation anchors must not trigger duplicate browser navigation');
|
|
$assert(str_contains($baseStyles, '#create-view.workspace-form-page,#reinstall-view.workspace-form-page{width:100%;margin-left:0;margin-right:0}'), 'Create and reinstall pages must align to the full VM-list content width');
|
|
$assert(str_contains($cloudTemplate, '>实例管理</h1>') && str_contains($cloudTemplate, '>部署实例</button>'), 'Instance page terminology missing');
|
|
$assert(str_contains($sharedSidebar, '>我的实例</span>') && str_contains($sharedSidebar, '>部署实例</span>'), 'Shared sidebar instance terminology missing');
|
|
$assert(!str_contains($cloudTemplate, '购买并开通') && !str_contains($sharedSidebar, '我的虚拟机'), 'Retired VM sales labels remain');
|
|
$assert(str_contains($shopFormScript, 'Array.isArray(data.hosts)'), 'Plan editor must read the hosts collection returned by the admin API');
|
|
$assert(preg_match('/<input id="template-sha256"([^>]*)>/', $templateAdmin, $shaInput) === 1
|
|
&& !str_contains($shaInput[1], 'required'), 'Cloud image SHA-256 must be optional');
|
|
$assert(str_contains($adminScript, 'if (sha256) body.sha256 = sha256;'), 'Blank cloud image SHA-256 must be omitted from the request');
|
|
$assert(str_contains($adminScript, 'function unixTime(value)')
|
|
&& str_contains($adminScript, 'orderStatus(record.status)'),
|
|
'Order diagnostics must format timestamps and localize task status');
|
|
$assert(str_contains($clientScript, "makeElement('div', 'cloud-order-actions')")
|
|
&& str_contains($clientStyles, '.cloud-orders { min-height: 0;'),
|
|
'Provisioning orders must use grouped actions without inheriting the inventory minimum height');
|
|
$assert(str_contains($cloudAdminController, "'known_owners' => (object) CloudInstanceDiscovery::knownOwners"),
|
|
'Empty VM ownership maps must be encoded as a JSON object for engine discovery');
|
|
foreach (['hosts/index.tpl', 'cloud/orders.tpl', 'cloud/instances.tpl', 'cloud/rescue.tpl', 'cloud/templates.tpl'] as $template) {
|
|
$source = file_get_contents($views . '/admin/' . $template);
|
|
$assert(str_contains($source, '/cloud/admin.js?v={$venix_asset_version}'),
|
|
'Cloud admin script cache busting missing: ' . $template);
|
|
}
|
|
foreach (glob($views . '/user/*.tpl') as $template) {
|
|
$source = file_get_contents($template);
|
|
$assert(!str_contains($source, 'href="/user/shop"'), 'Obsolete package link remains: ' . basename($template));
|
|
$assert(!str_contains($source, 'href="/user"'), 'Ambiguous user-home link remains: ' . basename($template));
|
|
}
|
|
$assert(str_contains($sharedTopbar, 'panel-topbar') && str_contains($sharedTopbar, 'breadcrumb-current'), 'Shared topbar contract missing');
|
|
$assert(!str_contains(file_get_contents($root . '/.gitignore'), "\nvendor/"), 'Nested noVNC vendor directory would be omitted from Git');
|
|
echo 'Unified user styles, local icons and noVNC source modules passed: ' . count($seen) . " modules.\n";
|