Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36ef203797 | ||
|
|
ba2d1ec1d6 | ||
|
|
d117444bae | ||
|
|
58df03216d | ||
|
|
29402a35ac | ||
|
|
63134f7de4 | ||
|
|
b8b8ee6284 | ||
|
|
b93217cc51 | ||
|
|
61b4b2b1af | ||
|
|
ec5c40c9f2 | ||
|
|
56ada0cedc | ||
|
|
f50154b96b | ||
|
|
5a482b49bb | ||
|
|
6094b6f49c | ||
|
|
e5c3a5b28f | ||
|
|
f967ef7544 |
@@ -21,8 +21,10 @@ jobs:
|
||||
run: |
|
||||
set -e
|
||||
VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
|
||||
PACKAGE_NAME=$(grep -m1 '"name"' composer.json | sed -E 's/.*"name"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
|
||||
TAG="v${VERSION}"
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "package_name=${PACKAGE_NAME}" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
@@ -98,3 +100,13 @@ jobs:
|
||||
echo "Unexpected HTTP status $STATUS publishing to the Composer registry"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Link Composer package to this repository
|
||||
if: steps.version.outputs.skip == 'false'
|
||||
run: |
|
||||
ENCODED_NAME=$(printf '%s' "${{ steps.version.outputs.package_name }}" | sed 's#/#%2F#g')
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -u "haylan:${{ secrets.RELEASE_TOKEN }}" -X POST "https://git.arthurerlich.de/api/v1/packages/haylan/composer/${ENCODED_NAME}/-/link/AeonDumpManager")
|
||||
echo "link status: $STATUS"
|
||||
if [ "$STATUS" != "201" ] && [ "$STATUS" != "400" ]; then
|
||||
echo "::warning::Unexpected status linking the Composer package to this repository (HTTP $STATUS) - not fatal, release already published"
|
||||
fi
|
||||
|
||||
+31
-12
@@ -5,6 +5,29 @@ All notable changes to AeonDumpManager will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.0.5] - 2026-09-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Changed namespace
|
||||
|
||||
## [0.0.4] - 2026-09-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Published Composer packages are now linked to this repository (previously the release workflow
|
||||
published them without a repository association, so they did not appear under the repo's
|
||||
Packages tab).
|
||||
|
||||
## [0.0.3] - 2026-09-17
|
||||
|
||||
### Added
|
||||
|
||||
- Filter the dump list by date range and sort by date or size; dates use Shopware's locale-aware
|
||||
formatting.
|
||||
|
||||
## [0.0.2] - 2026-09-21
|
||||
|
||||
### Added
|
||||
@@ -16,18 +39,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `main` is now a protected branch: no direct pushes, merges require the version/changelog check
|
||||
to pass.
|
||||
|
||||
## [Unreleased]
|
||||
## [0.0.1] - 2026-09-15
|
||||
|
||||
### Added
|
||||
|
||||
- List, create, and delete SQL database dumps from a Settings admin page (nested under Settings, per
|
||||
Shopware's [Add Menu Entry](https://developer.shopware.com/docs/v6.6/guides/plugins/plugins/administration/routing-navigation/add-menu-entry.html)
|
||||
guide) and via `aeon:dump:list`/`aeon:dump:create`/`aeon:dump:remove` console commands.
|
||||
- Dumps are created with `mysqldump`/`mariadb-dump` (auto-detected, with an optional `dumpBinaryName`
|
||||
override), gzip-compressed, and stored in the plugin's private Flysystem mount.
|
||||
- `maxDumps` auto-purges the oldest dump on creation; `retantionDays` purges dumps and stale job rows
|
||||
on a recurring scheduled task.
|
||||
- Admin UI dump creation runs asynchronously via Symfony Messenger with a polling progress bar; console
|
||||
creation runs synchronously.
|
||||
- ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and
|
||||
server-side.
|
||||
- List, create, delete, and download gzip-compressed SQL dumps from a Settings admin page (async
|
||||
creation with a polling progress bar) or via the `aeon:dump:list`, `aeon:dump:create`, and
|
||||
`aeon:dump:remove` console commands (sync). Dumps are produced with `mysqldump`/`mariadb-dump`
|
||||
(auto-detected, overridable via `dumpBinaryName`) and stored in the plugin's private filesystem.
|
||||
- Retention controls: `maxDumps` purges the oldest dump when the limit is reached; `retantionDays`
|
||||
purges expired dumps and stale job rows via a scheduled task.
|
||||
- ACL-gated by `aeon_dump_manager.viewer`/`.creator`/`.deleter`, enforced client- and server-side.
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "aeon/dump-manager",
|
||||
"name": "arthurerlich/aeon-dump-manager",
|
||||
"description": "Export database dumps for Shopware 6 environments.",
|
||||
"type": "shopware-platform-plugin",
|
||||
"license": "MIT",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.5",
|
||||
"keywords": [
|
||||
"shopware",
|
||||
"shopware6",
|
||||
@@ -35,8 +35,8 @@
|
||||
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
|
||||
"copyright": "(c) by Arthur Erlich",
|
||||
"label": {
|
||||
"de-DE": "Aeon Dump Manager",
|
||||
"en-GB": "Aeon Dump Manager"
|
||||
"de-DE": "Dump Manager",
|
||||
"en-GB": "Dump Manager"
|
||||
},
|
||||
"description": {
|
||||
"de-DE": "Verwaltet Datenbank-Dumps für Shopware 6 Entwicklungsumgebungen.",
|
||||
|
||||
@@ -11,6 +11,7 @@ use Shopware\Core\Framework\Routing\ApiRouteScope;
|
||||
use Shopware\Core\PlatformRequest;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -39,16 +40,46 @@ class DumpController
|
||||
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function list(): JsonResponse
|
||||
public function list(Request $request): JsonResponse
|
||||
{
|
||||
$dumps = array_map(
|
||||
static fn ($dumpFile) => $dumpFile->jsonSerialize(),
|
||||
$this->dumpLister->list()
|
||||
$this->dumpLister->list(
|
||||
$this->parseBoundDate($request->query->get('from'), false),
|
||||
$this->parseBoundDate($request->query->get('to'), true),
|
||||
)
|
||||
);
|
||||
|
||||
return new JsonResponse(['dumps' => $dumps]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The admin's date filter sends mixed shapes: the "from" bound is a naive local
|
||||
* date string with no timezone marker (e.g. "2026-03-01T00:00:00"), while
|
||||
* sw-date-filter widens "to" to end-of-day client-side via `Date#toISOString()`,
|
||||
* which is always UTC (e.g. "2026-03-01T23:59:59.000Z"). Re-expressing both in
|
||||
* PHP's default timezone (the same one DumpFilenameParser uses) before applying
|
||||
* our own day-boundary keeps the calendar day the user actually picked, regardless
|
||||
* of which shape arrived. An empty bound (no date set) stays null so the range is
|
||||
* open on that side.
|
||||
*/
|
||||
private function parseBoundDate(?string $value, bool $endOfDay): ?\DateTimeImmutable
|
||||
{
|
||||
if ($value === null || trim($value) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dateTime = (new \DateTimeImmutable($value))->setTimezone(new \DateTimeZone(date_default_timezone_get()));
|
||||
} catch (\Exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $endOfDay
|
||||
? $dateTime->setTime(23, 59, 59)
|
||||
: $dateTime->setTime(0, 0, 0);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/api/_action/aeon-dump-manager/dumps',
|
||||
name: 'api.action.aeon_dump_manager.dumps.create',
|
||||
|
||||
+11
-1
@@ -14,14 +14,24 @@
|
||||
|
||||
<template #content>
|
||||
<div class="aeon-dump-manager-list__content">
|
||||
<sw-filter-panel
|
||||
:filters="listFilters"
|
||||
:defaults="defaultFilters"
|
||||
:store-key="storeKey"
|
||||
@criteria-changed="onCriteriaChanged"
|
||||
/>
|
||||
|
||||
<sw-data-grid
|
||||
:data-source="dumps"
|
||||
:data-source="sortedDumps"
|
||||
:columns="columns"
|
||||
:is-loading="isLoading"
|
||||
:show-selection="acl.can('aeon_dump_manager.deleter')"
|
||||
:full-page="true"
|
||||
:sort-by="sortBy"
|
||||
:sort-direction="sortDirection"
|
||||
identifier="filename"
|
||||
@selection-change="onSelectionChange"
|
||||
@column-sort="onSortColumn"
|
||||
>
|
||||
<template #bulk>
|
||||
<a
|
||||
|
||||
+86
-12
@@ -11,6 +11,12 @@ interface PendingJob {
|
||||
|
||||
const CREATE_MODAL_AUTO_CLOSE_MS = 1500;
|
||||
|
||||
interface DateRangeCriteria {
|
||||
type: string;
|
||||
field: string;
|
||||
parameters?: { gte?: string; lte?: string };
|
||||
}
|
||||
|
||||
interface ComponentData {
|
||||
dumps: DumpFile[];
|
||||
isLoading: boolean;
|
||||
@@ -18,6 +24,12 @@ interface ComponentData {
|
||||
deleteFilenames: string[] | null;
|
||||
selection: Record<string, DumpFile>;
|
||||
pollTimer: number | null;
|
||||
dateFrom: string | null;
|
||||
dateTo: string | null;
|
||||
sortBy: string;
|
||||
sortDirection: string;
|
||||
storeKey: string;
|
||||
defaultFilters: string[];
|
||||
}
|
||||
|
||||
interface ComponentInstance extends ComponentData {
|
||||
@@ -25,17 +37,25 @@ interface ComponentInstance extends ComponentData {
|
||||
$tc: (key: string, count?: number, values?: Record<string, unknown>) => string;
|
||||
createNotificationError: (options: { message: string }) => void;
|
||||
createNotificationSuccess: (options: { message: string }) => void;
|
||||
loadList: () => Promise<void>;
|
||||
getList: () => Promise<void>;
|
||||
stopPolling: () => void;
|
||||
pollJobStatus: (jobId: string) => void;
|
||||
selectionCount: number;
|
||||
sortedDumps: DumpFile[];
|
||||
listFilters: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
Component.register('aeon-dump-manager-list', {
|
||||
template,
|
||||
|
||||
mixins: [
|
||||
// Provides createNotificationSuccess/createNotificationError, used below.
|
||||
mixins: [Mixin.getByName('notification')],
|
||||
Mixin.getByName('notification'),
|
||||
// Provides sortBy/sortDirection state, onSortColumn(), and route-query
|
||||
// persistence for them (same mixin sw-product-list etc. use) — our own
|
||||
// data() below overrides the defaults to keep "newest first".
|
||||
Mixin.getByName('listing'),
|
||||
],
|
||||
|
||||
inject: ['aeonDumpManagerApiService', 'acl'],
|
||||
|
||||
@@ -47,27 +67,56 @@ Component.register('aeon-dump-manager-list', {
|
||||
deleteFilenames: null,
|
||||
selection: {},
|
||||
pollTimer: null,
|
||||
dateFrom: null,
|
||||
dateTo: null,
|
||||
sortBy: 'datetime',
|
||||
sortDirection: 'DESC',
|
||||
storeKey: 'grid.filter.aeon-dump-manager',
|
||||
defaultFilters: ['datetime'],
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
listFilters(this: ComponentInstance) {
|
||||
return [
|
||||
{
|
||||
name: 'datetime',
|
||||
type: 'date-filter',
|
||||
property: 'datetime',
|
||||
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
|
||||
dateType: 'date',
|
||||
fromFieldLabel: this.$tc('aeon-dump-manager.list.filterFromLabel'),
|
||||
toFieldLabel: this.$tc('aeon-dump-manager.list.filterToLabel'),
|
||||
fromPlaceholder: this.$tc('aeon-dump-manager.list.filterFromPlaceholder'),
|
||||
toPlaceholder: this.$tc('aeon-dump-manager.list.filterToPlaceholder'),
|
||||
showTimeframe: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
columns() {
|
||||
return [
|
||||
{
|
||||
property: 'datetime',
|
||||
dataIndex: 'datetime',
|
||||
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
|
||||
allowResize: true,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
property: 'filename',
|
||||
dataIndex: 'filename',
|
||||
label: this.$tc('aeon-dump-manager.list.columnFilename'),
|
||||
allowResize: true,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
property: 'sizeBytes',
|
||||
dataIndex: 'sizeBytes',
|
||||
label: this.$tc('aeon-dump-manager.list.columnSize'),
|
||||
align: 'right',
|
||||
allowResize: true,
|
||||
sortable: true,
|
||||
},
|
||||
];
|
||||
},
|
||||
@@ -75,10 +124,27 @@ Component.register('aeon-dump-manager-list', {
|
||||
selectionCount(this: ComponentInstance): number {
|
||||
return Object.keys(this.selection).length;
|
||||
},
|
||||
},
|
||||
|
||||
created(this: ComponentInstance) {
|
||||
this.loadList();
|
||||
sortedDumps(this: ComponentInstance): DumpFile[] {
|
||||
const direction = this.sortDirection === 'ASC' ? 1 : -1;
|
||||
|
||||
return [...this.dumps].sort((a, b) => {
|
||||
let compareVal: number;
|
||||
|
||||
switch (this.sortBy) {
|
||||
case 'sizeBytes':
|
||||
compareVal = a.sizeBytes - b.sizeBytes;
|
||||
break;
|
||||
case 'datetime':
|
||||
compareVal = new Date(a.datetime).getTime() - new Date(b.datetime).getTime();
|
||||
break;
|
||||
default:
|
||||
compareVal = a.filename.localeCompare(b.filename, undefined, { numeric: true });
|
||||
}
|
||||
|
||||
return compareVal * direction;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
beforeDestroy(this: ComponentInstance) {
|
||||
@@ -86,10 +152,10 @@ Component.register('aeon-dump-manager-list', {
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadList(this: ComponentInstance): Promise<void> {
|
||||
getList(this: ComponentInstance): Promise<void> {
|
||||
this.isLoading = true;
|
||||
|
||||
return this.aeonDumpManagerApiService.getList()
|
||||
return this.aeonDumpManagerApiService.getList({ from: this.dateFrom, to: this.dateTo })
|
||||
.then((response) => {
|
||||
this.dumps = response.dumps;
|
||||
})
|
||||
@@ -99,7 +165,15 @@ Component.register('aeon-dump-manager-list', {
|
||||
},
|
||||
|
||||
formatDatetime(value: string): string {
|
||||
return new Date(value).toLocaleString();
|
||||
return Shopware.Utils.format.date(value);
|
||||
},
|
||||
|
||||
onCriteriaChanged(this: ComponentInstance, criteria: DateRangeCriteria[]) {
|
||||
const range = criteria.find((filter) => filter.type === 'range' && filter.field === 'datetime');
|
||||
|
||||
this.dateFrom = range?.parameters?.gte ?? null;
|
||||
this.dateTo = range?.parameters?.lte ?? null;
|
||||
this.getList();
|
||||
},
|
||||
|
||||
formatSize(bytes: number): string {
|
||||
@@ -133,7 +207,7 @@ Component.register('aeon-dump-manager-list', {
|
||||
|
||||
if (job.status === 'done') {
|
||||
this.stopPolling();
|
||||
this.loadList();
|
||||
this.getList();
|
||||
window.setTimeout(() => {
|
||||
this.pendingJob = null;
|
||||
}, CREATE_MODAL_AUTO_CLOSE_MS);
|
||||
@@ -196,19 +270,19 @@ Component.register('aeon-dump-manager-list', {
|
||||
|
||||
// Optimistic UI update: pull the rows out immediately rather than
|
||||
// waiting on a full reload, so the grid never looks stale even if
|
||||
// loadList() is slow or a later delete in the batch fails.
|
||||
// getList() is slow or a later delete in the batch fails.
|
||||
this.dumps = this.dumps.filter((dumpFile) => !filenames.includes(dumpFile.filename));
|
||||
this.selection = {};
|
||||
|
||||
return Promise.all(filenames.map((filename) => this.aeonDumpManagerApiService.remove(filename)))
|
||||
.then(() => this.loadList())
|
||||
.then(() => this.getList())
|
||||
.catch((error: Error) => {
|
||||
this.createNotificationError({
|
||||
message: this.$tc('aeon-dump-manager.list.deleteFailed', 0, { error: error.message }),
|
||||
});
|
||||
// A delete failed after the optimistic removal — reload to
|
||||
// show the real state rather than leave a wrong guess on screen.
|
||||
return this.loadList();
|
||||
return this.getList();
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
"columnFilename": "Name",
|
||||
"columnDatetime": "Erstellt am",
|
||||
"columnSize": "Größe",
|
||||
"filterFromLabel": "Von",
|
||||
"filterFromPlaceholder": "Startdatum auswählen...",
|
||||
"filterToLabel": "Bis",
|
||||
"filterToPlaceholder": "Enddatum auswählen...",
|
||||
"buttonCreate": "Dump erstellen",
|
||||
"buttonDownload": "Herunterladen",
|
||||
"buttonDelete": "Löschen",
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
"columnFilename": "Name",
|
||||
"columnDatetime": "Created at",
|
||||
"columnSize": "Size",
|
||||
"filterFromLabel": "From",
|
||||
"filterFromPlaceholder": "Select start date...",
|
||||
"filterToLabel": "To",
|
||||
"filterToPlaceholder": "Select end date...",
|
||||
"buttonCreate": "Create dump",
|
||||
"buttonDownload": "Download",
|
||||
"buttonDelete": "Delete",
|
||||
|
||||
@@ -43,9 +43,12 @@ export default class DumpApiService extends ApiService {
|
||||
super(httpClient, loginService, apiEndpoint);
|
||||
}
|
||||
|
||||
getList(): Promise<DumpList> {
|
||||
getList(filter: { from?: string | null; to?: string | null } = {}): Promise<DumpList> {
|
||||
return this.httpClient
|
||||
.get('/_action/aeon-dump-manager/dumps', { headers: this.getBasicHeaders() })
|
||||
.get('/_action/aeon-dump-manager/dumps', {
|
||||
headers: this.getBasicHeaders(),
|
||||
params: { from: filter.from ?? undefined, to: filter.to ?? undefined },
|
||||
})
|
||||
.then((response: unknown) => ApiService.handleResponse(response));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class DumpLister
|
||||
/**
|
||||
* @return DumpFile[] newest first
|
||||
*/
|
||||
public function list(): array
|
||||
public function list(?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array
|
||||
{
|
||||
$dumps = [];
|
||||
|
||||
@@ -33,6 +33,14 @@ class DumpLister
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($from !== null && $datetime < $from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($to !== null && $datetime > $to) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dumps[] = new DumpFile($filename, $datetime, $item->fileSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace AeonDumpManager\Tests\Service;
|
||||
|
||||
use AeonDumpManager\Service\DumpFilenameParser;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DumpFilenameParserTest extends TestCase
|
||||
@@ -29,9 +30,7 @@ class DumpFilenameParserTest extends TestCase
|
||||
self::assertEquals($dateTime, $this->parser->parse($filename));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidFilenameProvider
|
||||
*/
|
||||
#[DataProvider('invalidFilenameProvider')]
|
||||
public function testParseRejectsInvalidFilenames(string $filename): void
|
||||
{
|
||||
self::assertNull($this->parser->parse($filename));
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
namespace AeonDumpManager\Tests\Service;
|
||||
|
||||
use AeonDumpManager\Service\MySqlVariant;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MySqlVariantTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider versionProvider
|
||||
*/
|
||||
#[DataProvider('versionProvider')]
|
||||
public function testIsMariaDb(string $version, bool $expected): void
|
||||
{
|
||||
self::assertSame($expected, MySqlVariant::isMariaDb($version));
|
||||
|
||||
Reference in New Issue
Block a user