mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-05-25 20:54:56 +00:00
- Add manifest.json generation script (scripts/generate-manifest.php)
- Add Updater::cleanStaleFiles() that removes files not in manifest
- Add /api/v1/update/clean endpoint with backward compatibility
- Add configurable update_protected_paths in config/invoiceshelf.php
- Update frontend to use clean step instead of delete step
- Add GitHub Actions release workflow triggered on version tags
- Add .github/release.yml for auto-generated changelog categories
- Update Makefile to include manifest generation and scripts directory
Backport from v3.0 (e6452946). Adapted for master's existing structure: master uses one-controller-per-action under app/Http/Controllers/V1/Admin/Update/, so the new endpoint is implemented as a dedicated CleanFilesController matching the existing DeleteFilesController/CopyFilesController/etc. pattern instead of v3.0's unified UpdateController. The legacy /update/delete route and DeleteFilesController are retained for compatibility — only the frontend (resources/scripts/admin/views/settings/UpdateAppSetting.vue) is updated to call /update/clean. Updater service lives at app/Space/Updater.php on master (not yet refactored to app/Services/Update/Updater.php like v3.0).
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Generate manifest.json for the InvoiceShelf updater.
|
|
*
|
|
* Usage: php scripts/generate-manifest.php [base-directory]
|
|
*
|
|
* Outputs a sorted JSON array of all relative file paths in the given
|
|
* directory. The manifest is written to {base-directory}/manifest.json
|
|
* and is used by the updater to detect and remove stale files after
|
|
* copying a new release.
|
|
*/
|
|
$basePath = rtrim($argv[1] ?? '.', '/');
|
|
|
|
if (! is_dir($basePath)) {
|
|
fwrite(STDERR, "Error: '{$basePath}' is not a directory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
$excludedPrefixes = [
|
|
'.env',
|
|
'.git/',
|
|
'storage/',
|
|
'vendor/',
|
|
'node_modules/',
|
|
'Modules/',
|
|
'bootstrap/cache/',
|
|
'public/storage/',
|
|
];
|
|
|
|
$files = [];
|
|
|
|
$iterator = new RecursiveIteratorIterator(
|
|
new RecursiveDirectoryIterator($basePath, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
RecursiveIteratorIterator::SELF_FIRST
|
|
);
|
|
|
|
foreach ($iterator as $file) {
|
|
if (! $file->isFile()) {
|
|
continue;
|
|
}
|
|
|
|
$relativePath = substr($file->getPathname(), strlen($basePath) + 1);
|
|
|
|
foreach ($excludedPrefixes as $prefix) {
|
|
if (str_starts_with($relativePath, $prefix)) {
|
|
continue 2;
|
|
}
|
|
}
|
|
|
|
$files[] = $relativePath;
|
|
}
|
|
|
|
sort($files);
|
|
|
|
$json = json_encode($files, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
|
|
|
file_put_contents($basePath.'/manifest.json', $json."\n");
|
|
|
|
$count = count($files);
|
|
fwrite(STDOUT, "manifest.json written with {$count} files.\n");
|