fix(web): unify asset versions and remove SES
parent
2e66371a1d
commit
873acf0fd8
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Mail;
|
||||
|
||||
use App\Services\Config;
|
||||
|
||||
|
||||
class Ses extends Base
|
||||
{
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = Factory::createSes();
|
||||
}
|
||||
|
||||
public function send($to, $subject, $text, $file)
|
||||
{
|
||||
if (!empty($file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->client->sendEmail([
|
||||
'Destination' => [ // REQUIRED
|
||||
'ToAddresses' => [$to],
|
||||
],
|
||||
'Message' => [ // REQUIRED
|
||||
'Body' => [ // REQUIRED
|
||||
'Html' => [
|
||||
'Data' => $text, // REQUIRED
|
||||
],
|
||||
'Text' => [
|
||||
'Data' => $text, // REQUIRED
|
||||
],
|
||||
],
|
||||
'Subject' => [ // REQUIRED
|
||||
'Data' => $subject, // REQUIRED
|
||||
],
|
||||
],
|
||||
'Source' => $this->getSender(), // REQUIRED
|
||||
]) !== false;
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,2 @@
|
||||
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
|
||||
{assign var=venix_asset_version value='2026102409' scope='global'}
|
||||
{assign var=venix_asset_version value='2026102410' scope='global'}
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$assets = file_get_contents(
|
||||
$root . '/resources/views/venix/layout_assets.tpl'
|
||||
);
|
||||
$cloudShell = file_get_contents(
|
||||
$root . '/resources/views/venix/cloud/page.tpl'
|
||||
);
|
||||
|
||||
$assert = static function (bool $condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$assert(is_string($assets)
|
||||
&& preg_match("/venix_asset_version value='[0-9]+'/", $assets) === 1
|
||||
&& is_string($cloudShell)
|
||||
&& str_contains($cloudShell, '/cloud/app.js?v={$venix_asset_version}'),
|
||||
'The cloud application entry must use the shared Venix asset version.');
|
||||
|
||||
$dependencyFiles = [];
|
||||
foreach (glob($root . '/public/cloud/*.js') ?: [] as $file) {
|
||||
$source = file_get_contents($file);
|
||||
$relative = 'public/cloud/' . basename($file);
|
||||
$assert(is_string($source), 'Unable to read ' . $relative . '.');
|
||||
$assert(preg_match('/[?&]v=[0-9]{6,}/', $source) !== 1,
|
||||
$relative . ' contains an independent numeric asset version.');
|
||||
|
||||
if (str_contains($source, 'task-observer.js')
|
||||
|| str_contains($source, 'toast.js')
|
||||
|| str_contains($source, 'task-center.js')) {
|
||||
$dependencyFiles[] = $relative;
|
||||
$assert(str_contains($source,
|
||||
"const assetVersion = new URL(import.meta.url).searchParams.get('v');")
|
||||
&& str_contains($source, 'function versionedModuleUrl(path)')
|
||||
&& str_contains($source, "url.searchParams.set('v', assetVersion)")
|
||||
&& str_contains($source, 'import(versionedModuleUrl('),
|
||||
$relative . ' must pass the entry version to nested modules.');
|
||||
}
|
||||
}
|
||||
|
||||
sort($dependencyFiles);
|
||||
$assert($dependencyFiles === [
|
||||
'public/cloud/admin-instances.js',
|
||||
'public/cloud/admin-operations.js',
|
||||
'public/cloud/admin.js',
|
||||
'public/cloud/app.js',
|
||||
'public/cloud/detail.js',
|
||||
'public/cloud/instances.js',
|
||||
'public/cloud/invoice-detail-runtime.js',
|
||||
'public/cloud/iso-images.js',
|
||||
'public/cloud/runtime.js',
|
||||
'public/cloud/ssh-keys.js',
|
||||
'public/cloud/task-center.js',
|
||||
], 'The nested cloud-module inventory changed without an asset-version review.');
|
||||
|
||||
echo "Cloud asset version inheritance checks passed.\n";
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$mailDirectory = $root . '/app/Services/Mail';
|
||||
$mailService = file_get_contents($root . '/app/Services/Mail.php');
|
||||
$configExample = file_get_contents($root . '/config/.config.php.example');
|
||||
|
||||
function expectMailDriverRegistry($condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
fwrite(STDERR, $message . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$driverFiles = array_map('basename', glob($mailDirectory . '/*.php') ?: []);
|
||||
sort($driverFiles);
|
||||
$expectedDriverFiles = ['Base.php', 'Mailgun.php', 'NullMail.php', 'Smtp.php'];
|
||||
|
||||
expectMailDriverRegistry(
|
||||
$driverFiles === $expectedDriverFiles,
|
||||
'The mail transport directory must contain only the supported drivers.'
|
||||
);
|
||||
expectMailDriverRegistry(is_string($mailService), 'Unable to read the mail service.');
|
||||
preg_match_all('/case\s+["\']([^"\']+)["\']\s*:/', $mailService, $driverCases);
|
||||
expectMailDriverRegistry(
|
||||
($driverCases[1] ?? []) === ['mailgun', 'smtp'],
|
||||
'The mail service must register only Mailgun and SMTP transports.'
|
||||
);
|
||||
expectMailDriverRegistry(
|
||||
str_contains($mailService, 'return new NullMail();'),
|
||||
'Unknown or disabled mail transports must retain the null fallback.'
|
||||
);
|
||||
expectMailDriverRegistry(
|
||||
is_string($configExample)
|
||||
&& str_contains($configExample, "'smtp'; // mailgun or smtp"),
|
||||
'The example configuration must document the complete supported transport list.'
|
||||
);
|
||||
|
||||
echo "Mail driver registry checks passed.\n";
|
||||
Loading…
Reference in New Issue