init
This commit is contained in:
54 files changed
+4604
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use function App\Support\base_path;
|
||||
|
||||
require dirname(__DIR__) . '/bootstrap/autoload.php';
|
||||
|
||||
/** Development-only export tool; cPanel needs only the generated assets. */
|
||||
function renderCommand(array $command): void
|
||||
{
|
||||
$process = proc_open($command, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
|
||||
if (!is_resource($process)) {
|
||||
throw new RuntimeException('Could not start brand renderer.');
|
||||
}
|
||||
fclose($pipes[0]);
|
||||
stream_get_contents($pipes[1]);
|
||||
$error = stream_get_contents($pipes[2]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
if (proc_close($process) !== 0) {
|
||||
throw new RuntimeException('Brand export failed: ' . $error);
|
||||
}
|
||||
}
|
||||
|
||||
$brand = base_path('public/assets/brand');
|
||||
$icon = file_get_contents($brand . '/icon.svg');
|
||||
copy($brand . '/icon.svg', base_path('public/favicon.svg'));
|
||||
foreach ([32, 192, 512, 1024] as $size) {
|
||||
renderCommand(['rsvg-convert', '-w', (string) $size, '-h', (string) $size, '-o', $brand . '/icon-' . $size . '.png', $brand . '/icon.svg']);
|
||||
}
|
||||
// Full-bleed background with the symbol inside the maskable safe area.
|
||||
$maskable = str_replace('<rect width="192" height="192" rx="44" fill="#163E37"/>',
|
||||
'<rect width="192" height="192" fill="#163E37"/><g transform="translate(19.2 19.2) scale(.8)">', $icon);
|
||||
$maskable = str_replace('</svg>', '</g></svg>', $maskable);
|
||||
file_put_contents($brand . '/icon-maskable.svg', $maskable);
|
||||
renderCommand(['rsvg-convert', '-w', '512', '-h', '512', '-o', $brand . '/icon-maskable-512.png', $brand . '/icon-maskable.svg']);
|
||||
renderCommand(['rsvg-convert', '-w', '180', '-h', '180', '-o', base_path('public/apple-touch-icon.png'), $brand . '/icon-maskable.svg']);
|
||||
renderCommand(['rsvg-convert', '-o', $brand . '/social.png', $brand . '/social.svg']);
|
||||
renderCommand(['magick', $brand . '/icon-512.png', '-define', 'icon:auto-resize=64,48,32,16', base_path('public/favicon.ico')]);
|
||||
echo "Exported Madar icons, favicons, Apple touch icon, maskable icon and social preview.\n";
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use function App\Support\base_path;
|
||||
|
||||
require dirname(__DIR__) . '/bootstrap/autoload.php';
|
||||
|
||||
if (!class_exists(ZipArchive::class)) {
|
||||
throw new RuntimeException('PHP zip is needed only to build the archive.');
|
||||
}
|
||||
if (!is_dir(base_path('dist'))) {
|
||||
mkdir(base_path('dist'), 0755);
|
||||
}
|
||||
$files = [
|
||||
'README.md', 'FEATURES.md', 'BRANDING.md', 'composer.json',
|
||||
'config/app.php', 'config/local.example.php',
|
||||
'storage/secrets/.gitkeep', 'storage/sessions/.gitkeep', 'storage/cache/.gitkeep',
|
||||
];
|
||||
// Only code, templates and public assets are collected recursively.
|
||||
// config/ and storage/ use the explicit non-secret allowlist above.
|
||||
foreach (['bootstrap', 'app', 'resources/views', 'public'] as $directory) {
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(base_path($directory), FilesystemIterator::SKIP_DOTS),
|
||||
);
|
||||
foreach ($iterator as $entry) {
|
||||
if ($entry->isLink() || !in_array($entry->getExtension(), ['php', 'js', 'css', 'ttf', 'svg', 'png', 'ico', 'webmanifest', 'html'], true)) {
|
||||
throw new RuntimeException('Unexpected deployment file: ' . $entry->getFilename());
|
||||
}
|
||||
$files[] = substr($entry->getPathname(), strlen(base_path()) + 1);
|
||||
}
|
||||
}
|
||||
sort($files, SORT_STRING);
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open(base_path('dist/madar-cpanel.zip'), ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
|
||||
throw new RuntimeException('Could not create archive.');
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if (!$zip->addFile(base_path($file), $file)) {
|
||||
throw new RuntimeException('Could not package: ' . $file);
|
||||
}
|
||||
}
|
||||
if (!$zip->close()) {
|
||||
throw new RuntimeException('Could not finalize archive.');
|
||||
}
|
||||
echo "Created dist/madar-cpanel.zip — set the document root to public/. No credentials included.\n";
|
||||
Reference in new issue
Block a user