Compare commits
25
Commits
v0.0.1
..
a551034442
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a551034442 | ||
|
|
8efaef2042 | ||
|
|
29974928d2 | ||
|
|
36ef203797 | ||
|
|
ba2d1ec1d6 | ||
|
|
d117444bae | ||
|
|
58df03216d | ||
|
|
29402a35ac | ||
|
|
63134f7de4 | ||
|
|
b8b8ee6284 | ||
|
|
b93217cc51 | ||
|
|
61b4b2b1af | ||
|
|
ec5c40c9f2 | ||
|
|
56ada0cedc | ||
|
|
f50154b96b | ||
|
|
7aa11b0396 | ||
|
|
161c35dc8a | ||
|
|
a1f0160ab9 | ||
|
|
1ee83aad37 | ||
|
|
b2c2a8d80b | ||
|
|
31b9e61adb | ||
|
|
5a482b49bb | ||
|
|
6094b6f49c | ||
|
|
e5c3a5b28f | ||
|
|
f967ef7544 |
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
# shopware-cli extension configuration (build/package/validate)
|
||||||
|
build:
|
||||||
|
zip:
|
||||||
|
pack:
|
||||||
|
excludes:
|
||||||
|
paths:
|
||||||
|
- tests
|
||||||
|
- docs
|
||||||
|
- scripts
|
||||||
|
- phpunit.xml
|
||||||
|
- docker-compose.yml
|
||||||
|
- skills-lock.json
|
||||||
|
- AGENTS.md
|
||||||
|
- CLAUDE.md
|
||||||
|
- QWEN.md
|
||||||
|
- .claude
|
||||||
|
- .scratch
|
||||||
|
- .wayfinder
|
||||||
|
- src/Resources/config/plugin-transparent.png
|
||||||
|
validation:
|
||||||
|
ignore: []
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
name: plugin-checks
|
||||||
|
|
||||||
|
# Plugin-agnostic: nothing below names this plugin. Name, version and paths come from composer.json.
|
||||||
|
# shopware-cli is intentionally unpinned (latest); a red build after a CLI release means fix the config.
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.3'
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
- name: Install shopware-cli
|
||||||
|
run: |
|
||||||
|
curl -sL https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz | tar -xz -C /tmp shopware-cli
|
||||||
|
sudo install /tmp/shopware-cli /usr/local/bin/shopware-cli || install /tmp/shopware-cli /usr/local/bin/shopware-cli
|
||||||
|
- name: Validate extension
|
||||||
|
run: shopware-cli extension validate .
|
||||||
|
|
||||||
|
package:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
- name: Install shopware-cli
|
||||||
|
run: |
|
||||||
|
curl -sL https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz | tar -xz -C /tmp shopware-cli
|
||||||
|
sudo install /tmp/shopware-cli /usr/local/bin/shopware-cli || install /tmp/shopware-cli /usr/local/bin/shopware-cli
|
||||||
|
- name: Package extension
|
||||||
|
run: shopware-cli extension package . --output-directory .build --filename package.zip --git-commit "$GITHUB_SHA"
|
||||||
|
- name: Validate packaged zip
|
||||||
|
run: shopware-cli extension validate .build/package.zip
|
||||||
|
- name: Assert built JS is in the zip
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
LIST=$(unzip -Z1 .build/package.zip)
|
||||||
|
if [ -f src/Resources/app/administration/src/main.js ] || [ -f src/Resources/app/administration/src/main.ts ]; then
|
||||||
|
echo "$LIST" | grep -q 'Resources/public/administration/js/' || { echo "::error::admin entry exists but the zip has no built admin JS"; exit 1; }
|
||||||
|
fi
|
||||||
|
if [ -f src/Resources/app/storefront/src/main.js ] || [ -f src/Resources/app/storefront/src/main.ts ]; then
|
||||||
|
echo "$LIST" | grep -q 'Resources/app/storefront/dist/' || { echo "::error::storefront entry exists but the zip has no built storefront JS"; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
phpunit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
database:
|
||||||
|
image: mariadb:11.4
|
||||||
|
env:
|
||||||
|
MARIADB_ROOT_PASSWORD: root
|
||||||
|
options: >-
|
||||||
|
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||||
|
--health-interval=5s --health-timeout=5s --health-retries=20
|
||||||
|
env:
|
||||||
|
DATABASE_URL: mysql://root:root@database:3306/shopware
|
||||||
|
APP_ENV: test
|
||||||
|
APP_URL: http://localhost
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: plugin-src
|
||||||
|
- uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.3'
|
||||||
|
extensions: gd, intl, pdo_mysql, zip, curl, mbstring, dom, xml, fileinfo, sodium, bcmath
|
||||||
|
tools: composer
|
||||||
|
- name: Resolve plugin name
|
||||||
|
run: |
|
||||||
|
# plugin directory name = short class name of extra.shopware-plugin-class
|
||||||
|
CLASS=$(jq -r '.extra["shopware-plugin-class"]' plugin-src/composer.json)
|
||||||
|
echo "PLUGIN_NAME=${CLASS##*\\}" >> "$GITHUB_ENV"
|
||||||
|
- name: Create Shopware 6.6 project
|
||||||
|
run: composer create-project shopware/production:6.6.* shopware --no-interaction --no-scripts
|
||||||
|
- name: Install Shopware and the plugin
|
||||||
|
working-directory: shopware
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
composer require --dev phpunit/phpunit:^10 --no-interaction
|
||||||
|
bin/console system:install --basic-setup --create-database --force --no-interaction
|
||||||
|
cp -r ../plugin-src "custom/plugins/${PLUGIN_NAME}"
|
||||||
|
bin/console plugin:refresh
|
||||||
|
bin/console plugin:install --activate "${PLUGIN_NAME}"
|
||||||
|
- name: Run phpunit
|
||||||
|
working-directory: shopware
|
||||||
|
run: vendor/bin/phpunit -c "custom/plugins/${PLUGIN_NAME}/phpunit.xml"
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
name: version-changelog
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
version-changelog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check version bump and changelog entry
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
PR_VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
|
||||||
|
MAIN_VERSION=$(git show origin/main:composer.json | grep -m1 '"version"' | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
|
||||||
|
|
||||||
|
echo "main version: $MAIN_VERSION"
|
||||||
|
echo "PR version: $PR_VERSION"
|
||||||
|
|
||||||
|
if [ "$MAIN_VERSION" = "$PR_VERSION" ]; then
|
||||||
|
echo "::error::composer.json version ($PR_VERSION) was not bumped from main ($MAIN_VERSION)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
HIGHEST=$(printf '%s\n%s\n' "$MAIN_VERSION" "$PR_VERSION" | sort -V | tail -n1)
|
||||||
|
if [ "$HIGHEST" != "$PR_VERSION" ]; then
|
||||||
|
echo "::error::composer.json version ($PR_VERSION) is not greater than main's ($MAIN_VERSION)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -qF "## [$PR_VERSION]" CHANGELOG.md; then
|
||||||
|
echo "::error::CHANGELOG.md is missing a '## [$PR_VERSION]' heading"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "OK: version bumped to $PR_VERSION and documented in CHANGELOG.md"
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
# Plugin-agnostic: owner, repo, host, package name and version come from the `github` context
|
||||||
|
# and composer.json. shopware-cli is intentionally unpinned (latest).
|
||||||
|
# RELEASE_TOKEN is the single token used for releases, assets and the Composer registry.
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
|
||||||
|
- name: Determine version and guard against re-release
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
VERSION=$(jq -r .version composer.json)
|
||||||
|
PACKAGE_NAME=$(jq -r .name composer.json)
|
||||||
|
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
||||||
|
TAG="v${VERSION}"
|
||||||
|
{
|
||||||
|
echo "version=${VERSION}"
|
||||||
|
echo "package_name=${PACKAGE_NAME}"
|
||||||
|
echo "tag=${TAG}"
|
||||||
|
echo "zip=${REPO_NAME}-${TAG}.zip"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then
|
||||||
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Tag ${TAG} already exists, nothing to release."
|
||||||
|
else
|
||||||
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install shopware-cli
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: |
|
||||||
|
curl -sL https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz | tar -xz -C /tmp shopware-cli
|
||||||
|
sudo install /tmp/shopware-cli /usr/local/bin/shopware-cli || install /tmp/shopware-cli /usr/local/bin/shopware-cli
|
||||||
|
|
||||||
|
- name: Validate extension
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: shopware-cli extension validate .
|
||||||
|
|
||||||
|
- name: Package extension (prebuilt admin/storefront assets)
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: |
|
||||||
|
shopware-cli extension package . --output-directory .build \
|
||||||
|
--filename "${{ steps.meta.outputs.zip }}" --git-commit "$GITHUB_SHA"
|
||||||
|
|
||||||
|
- name: Validate packaged zip
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: shopware-cli extension validate ".build/${{ steps.meta.outputs.zip }}"
|
||||||
|
|
||||||
|
- name: Extract changelog section
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: |
|
||||||
|
awk -v ver="${{ steps.meta.outputs.version }}" '
|
||||||
|
BEGIN { found=0 }
|
||||||
|
/^## \[/ {
|
||||||
|
if (found) exit
|
||||||
|
if ($0 ~ "\\[" ver "\\]") { found=1; next }
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md > release-notes.md
|
||||||
|
cat release-notes.md
|
||||||
|
|
||||||
|
- name: Create Gitea release (creates the tag) and upload the zip
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
BODY=$(jq -n --arg tag "${{ steps.meta.outputs.tag }}" --arg sha "$GITHUB_SHA" --rawfile notes release-notes.md \
|
||||||
|
'{tag_name:$tag, target_commitish:$sha, name:$tag, body:$notes}')
|
||||||
|
RELEASE_ID=$(curl -sf -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" -d "$BODY" "${API}/releases" | jq -r .id)
|
||||||
|
echo "release id: ${RELEASE_ID}"
|
||||||
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@.build/${{ steps.meta.outputs.zip }}" \
|
||||||
|
"${API}/releases/${RELEASE_ID}/assets?name=${{ steps.meta.outputs.zip }}" > /dev/null
|
||||||
|
|
||||||
|
- name: Publish the same zip to the Composer registry
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: |
|
||||||
|
STATUS=$(curl -s -o /tmp/composer-publish.log -w "%{http_code}" \
|
||||||
|
-u "${GITHUB_REPOSITORY_OWNER}:${{ secrets.RELEASE_TOKEN }}" \
|
||||||
|
-T ".build/${{ steps.meta.outputs.zip }}" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/composer")
|
||||||
|
cat /tmp/composer-publish.log
|
||||||
|
if [ "$STATUS" != "201" ] && [ "$STATUS" != "409" ]; then
|
||||||
|
echo "Unexpected HTTP status $STATUS publishing to the Composer registry"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Link Composer package to this repository
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: |
|
||||||
|
ENCODED_NAME=$(printf '%s' "${{ steps.meta.outputs.package_name }}" | sed 's#/#%2F#g')
|
||||||
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -u "${GITHUB_REPOSITORY_OWNER}:${{ secrets.RELEASE_TOKEN }}" -X POST \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/packages/${GITHUB_REPOSITORY_OWNER}/composer/${ENCODED_NAME}/-/link/${GITHUB_REPOSITORY#*/}")
|
||||||
|
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
|
||||||
+58
-11
@@ -7,16 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-10-03
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Services and routes are now configured in YAML; the plugin requires PHP `^8.2`.
|
||||||
|
- Release pipeline: the packaged `shopware-cli` zip (with prebuilt assets) is validated and used for both the Gitea Release and the Composer registry; the release is created through the Gitea API after packaging, so a failed build no longer leaves an orphan tag.
|
||||||
|
- New PR checks: `shopware-cli` validate, package build and phpunit.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- List, create, and delete SQL database dumps from a Settings admin page (nested under Settings, per
|
- Dedicated `aeon_dump_manager` monolog channel; dump jobs, deletions and purges are logged.
|
||||||
Shopware's [Add Menu Entry](https://developer.shopware.com/docs/v6.6/guides/plugins/plugins/administration/routing-navigation/add-menu-entry.html)
|
- Extension icon and `.config/shopware-extension.yml`.
|
||||||
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`
|
### Removed
|
||||||
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
|
- Empty plugin lifecycle overrides.
|
||||||
on a recurring scheduled task.
|
|
||||||
- Admin UI dump creation runs asynchronously via Symfony Messenger with a polling progress bar; console
|
## [0.0.5] - 2026-09-21
|
||||||
creation runs synchronously.
|
|
||||||
- ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and
|
### Fixed
|
||||||
server-side.
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- Automated release pipeline: a pre-merge check enforcing a semver version bump and a matching
|
||||||
|
CHANGELOG entry on every PR into `main`, and a post-merge workflow that tags the release,
|
||||||
|
packages the plugin with `shopware-cli`, publishes a Gitea Release with the packaged zip, and
|
||||||
|
publishes the package to this Gitea instance's Composer registry.
|
||||||
|
- `main` is now a protected branch: no direct pushes, merges require the version/changelog check
|
||||||
|
to pass.
|
||||||
|
|
||||||
|
## [0.0.1] - 2026-09-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 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.
|
||||||
@@ -14,7 +14,7 @@ the full build spec live under `.scratch/admin-dump-manager/` and `.scratch/dump
|
|||||||
- Plugin bootstrap class: `src/AeonDumpManager.php` (extends `Shopware\Core\Framework\Plugin`) — this
|
- Plugin bootstrap class: `src/AeonDumpManager.php` (extends `Shopware\Core\Framework\Plugin`) — this
|
||||||
is the entry point Shopware calls for install/uninstall/activate/deactivate/update lifecycle hooks.
|
is the entry point Shopware calls for install/uninstall/activate/deactivate/update lifecycle hooks.
|
||||||
- Plugin class name is wired via `composer.json` → `extra.shopware-plugin-class`.
|
- Plugin class name is wired via `composer.json` → `extra.shopware-plugin-class`.
|
||||||
- Services are registered manually in `src/Resources/config/services.xml` (Symfony DI, XML format,
|
- Services are registered manually in `src/Resources/config/services.yaml` (Symfony DI, YAML format,
|
||||||
autowiring is not configured — every new service/command/task must be added here explicitly with
|
autowiring is not configured — every new service/command/task must be added here explicitly with
|
||||||
its tag, e.g. `console.command` or `shopware.scheduled.task`).
|
its tag, e.g. `console.command` or `shopware.scheduled.task`).
|
||||||
- Plugin store-config UI fields (e.g. `maxDumps`, `retantionDays`) are defined in
|
- Plugin store-config UI fields (e.g. `maxDumps`, `retantionDays`) are defined in
|
||||||
@@ -66,7 +66,7 @@ vendor/bin/phpunit tests/SomeTest.php # single file
|
|||||||
## Adding functionality
|
## Adding functionality
|
||||||
|
|
||||||
- New console commands go in `src/Command/`, new scheduled tasks in `src/ScheduledTask/` — both must
|
- New console commands go in `src/Command/`, new scheduled tasks in `src/ScheduledTask/` — both must
|
||||||
be registered in `src/Resources/config/services.xml` with the appropriate tag or Shopware will not
|
be registered in `src/Resources/config/services.yaml` with the appropriate tag or Shopware will not
|
||||||
discover them.
|
discover them.
|
||||||
- Scheduled tasks need a matching handler (tagged `messenger.message_handler`) to actually run; a bare
|
- Scheduled tasks need a matching handler (tagged `messenger.message_handler`) to actually run; a bare
|
||||||
`ScheduledTask` subclass like `ExampleTask` only defines the schedule, not the behavior.
|
`ScheduledTask` subclass like `ExampleTask` only defines the schedule, not the behavior.
|
||||||
+5
-5
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "aeon/dump-manager",
|
"name": "arthurerlich/aeon-dump-manager",
|
||||||
"description": "Export database dumps for Shopware 6 environments.",
|
"description": "Export database dumps for Shopware 6 environments.",
|
||||||
"type": "shopware-platform-plugin",
|
"type": "shopware-platform-plugin",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.1",
|
"version": "0.1.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"shopware",
|
"shopware",
|
||||||
"shopware6",
|
"shopware6",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"source": "https://git.arthurerlich.de/haylan/AeonDumpManager"
|
"source": "https://git.arthurerlich.de/haylan/AeonDumpManager"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.2",
|
||||||
"shopware/core": "~6.6.0"
|
"shopware/core": "~6.6.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
|
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
|
||||||
"copyright": "(c) by Arthur Erlich",
|
"copyright": "(c) by Arthur Erlich",
|
||||||
"label": {
|
"label": {
|
||||||
"de-DE": "Aeon Dump Manager",
|
"de-DE": "Dump Manager",
|
||||||
"en-GB": "Aeon Dump Manager"
|
"en-GB": "Dump Manager"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"de-DE": "Verwaltet Datenbank-Dumps für Shopware 6 Entwicklungsumgebungen.",
|
"de-DE": "Verwaltet Datenbank-Dumps für Shopware 6 Entwicklungsumgebungen.",
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Spec: Shopware plugin guideline compliance (build/release pipeline)
|
||||||
|
|
||||||
|
Outcome of the Wayfinder map `.scratch/shopware-guideline-compliance/` (tickets 01-05; research evidence
|
||||||
|
on branches `research/shopware-guideline-checklist`, `research/shopware-cli-ci-behaviour`,
|
||||||
|
`research/gitea-28-pipeline-standards`). Target: **Store-ready** artifacts, published to Gitea only
|
||||||
|
(Gitea Release + Composer registry). Uploading to the Shopware Store is out of scope.
|
||||||
|
|
||||||
|
## 1. Principles
|
||||||
|
|
||||||
|
- Workflows are **plugin-agnostic**: no plugin name, package name, owner, repo or host is hard-coded;
|
||||||
|
all derive from `composer.json` and the `gitea` context. The same files must work unchanged for a
|
||||||
|
second plugin and be extractable to Gitea's shared-workflow repository later.
|
||||||
|
- One artifact: the `shopware-cli extension package` zip (prebuilt admin/storefront JS) is used for
|
||||||
|
both the Gitea Release asset and the Composer registry.
|
||||||
|
- `shopware-cli` is intentionally **unpinned** (`latest`). Known tradeoff: a CLI release can turn PRs
|
||||||
|
red without a repo change; treat that as a signal to fix config.
|
||||||
|
- `RELEASE_TOKEN` is the only token (release, assets, registry publish, link). Workflows still declare
|
||||||
|
`permissions:`.
|
||||||
|
|
||||||
|
## 2. Plugin changes
|
||||||
|
|
||||||
|
| # | Change |
|
||||||
|
|---|--------|
|
||||||
|
| P1 | Commit `src/Resources/config/plugin.png` (256x256). Do not ship `plugin-transparent.png`. |
|
||||||
|
| P2 | Logging: monolog channel `aeon_dump_manager` (`Resources/config/packages/monolog.yaml`, `build()` in the plugin class loading `packages/*.yaml`); inject `monolog.logger.aeon_dump_manager` into `PurgeDumpsTaskHandler`, `DumpService`, `CreateDumpHandler`; log dump job start/finish/failure. |
|
||||||
|
| P3 | Migrate `services.xml` -> `services.yaml` and `routes.php` -> `routes.yaml`. No validation ignore for this. Update the "XML services" rule in `CLAUDE.md`. |
|
||||||
|
| P4 | `composer.json`: `php` -> `^8.2`. Verify Shopware 6.6's own PHP requirement. |
|
||||||
|
| P5 | Delete the empty lifecycle overrides in `AeonDumpManager`; keep `uninstall`. |
|
||||||
|
| P6 | `.config/shopware-extension.yml` for build excludes and validation settings (add ignores only for real, accepted findings). |
|
||||||
|
| P7 | Keep Keep-a-Changelog `CHANGELOG.md`; verify with a local `shopware-cli extension package --release` how the changelog is read. |
|
||||||
|
|
||||||
|
## 3. Pipeline
|
||||||
|
|
||||||
|
### PR workflows
|
||||||
|
|
||||||
|
Jobs (all required checks on `main`):
|
||||||
|
`pr-version-check.yml` (job `version-changelog`) is unchanged apart from `permissions:`; its name keeps the existing required context. New `plugin-checks.yml`:
|
||||||
|
|
||||||
|
1. `validate` - install `shopware-cli`, `extension validate .` (hard gate, no `|| true`).
|
||||||
|
2. `package` - `extension package` with `--git-commit "$GITHUB_SHA"`, then assert the zip contains built admin JS (`Resources/public/administration/js`) when an admin entry exists.
|
||||||
|
3. `phpunit` - `composer create-project shopware/production` (6.6.x) + MariaDB service, copy the plugin into `custom/plugins`, install/activate, run phpunit. PHP 8.3.
|
||||||
|
|
||||||
|
### Release workflow (`.gitea/workflows/release.yml`)
|
||||||
|
|
||||||
|
On push to `main`, guarded against re-release by an existing tag:
|
||||||
|
validate -> `extension package --git-commit "$GITHUB_SHA"` -> **validate the zip** -> create the Gitea
|
||||||
|
release via API (`POST /repos/{owner}/{repo}/releases`, creates the tag) with the zip as asset ->
|
||||||
|
upload the same zip to the Composer registry -> link package to repository.
|
||||||
|
Removes the manual `git tag` step, the `akkuman` action and the `git archive` zip. Packaging happens
|
||||||
|
before the tag exists, so a failed build leaves no orphan tag.
|
||||||
|
|
||||||
|
### Branch protection (one-time, manual)
|
||||||
|
|
||||||
|
`scripts/protect-main.sh` using `tea api PATCH repos/{owner}/{repo}/branch_protections/main` to set the
|
||||||
|
required status-check contexts (current: `version-changelog / version-changelog (pull_request)`; add
|
||||||
|
the new PR jobs). `tea branches protect` cannot set status checks. Not run by the pipeline.
|
||||||
|
|
||||||
|
## 4. Open items to verify while implementing
|
||||||
|
|
||||||
|
- Release POST creates a missing tag (fallback: tag step after packaging).
|
||||||
|
- Meaning of HTTP 400 on the package-link endpoint.
|
||||||
|
- Whether bare `validate` runs PHPStan/ESLint (needs PHP/Node on the runner); Node availability on the runner image.
|
||||||
|
- Accepted size for `metadata.icon.size`; error-vs-warning rule list of validate.
|
||||||
|
- Whether `routes.php` is flagged by validate; `shopware-cli extension fix` correctness for the YAML migration.
|
||||||
|
- Exact status-check context names of the new jobs (set after the first run).
|
||||||
|
|
||||||
|
## 5. Out of scope / later
|
||||||
|
|
||||||
|
Shopware Store upload; Gitea shared-workflow repository; phpunit lowest-version matrix; Store listing metadata.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# One-time (re-runnable) setup: require the PR checks on `main` using the Gitea `tea` CLI.
|
||||||
|
# `tea branches protect` cannot set status-check contexts, hence `tea api`.
|
||||||
|
# Usage: scripts/protect-main.sh [owner/repo] (default: derived from the git remote)
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO="${1:-$(git config --get remote.origin.url | sed -E 's#^.*[:/]([^/]+/[^/]+)$#\1#; s#\.git$##')}"
|
||||||
|
|
||||||
|
tea api -X PATCH "repos/${REPO}/branch_protections/main" -d '{
|
||||||
|
"enable_status_check": true,
|
||||||
|
"status_check_contexts": [
|
||||||
|
"version-changelog / version-changelog (pull_request)",
|
||||||
|
"plugin-checks / validate (pull_request)",
|
||||||
|
"plugin-checks / package (pull_request)",
|
||||||
|
"plugin-checks / phpunit (pull_request)"
|
||||||
|
]
|
||||||
|
}'
|
||||||
+22
-31
@@ -4,17 +4,33 @@ namespace AeonDumpManager;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Shopware\Core\Framework\Plugin;
|
use Shopware\Core\Framework\Plugin;
|
||||||
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\InstallContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
|
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
|
||||||
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
|
use Symfony\Component\Config\FileLocator;
|
||||||
|
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
|
|
||||||
class AeonDumpManager extends Plugin
|
class AeonDumpManager extends Plugin
|
||||||
{
|
{
|
||||||
public function install(InstallContext $installContext): void
|
public function build(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
// Do stuff such as creating a new payment method
|
parent::build($container);
|
||||||
|
|
||||||
|
// Registers the dedicated monolog channel (Resources/config/packages/monolog.yaml)
|
||||||
|
$locator = new FileLocator('Resources/config');
|
||||||
|
$resolver = new LoaderResolver([
|
||||||
|
new YamlFileLoader($container, $locator),
|
||||||
|
new GlobFileLoader($container, $locator),
|
||||||
|
new DirectoryLoader($container, $locator),
|
||||||
|
]);
|
||||||
|
|
||||||
|
(new DelegatingLoader($resolver))->load(
|
||||||
|
\rtrim($this->getPath(), '/') . '/Resources/config/packages/*.yaml',
|
||||||
|
'glob'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall(UninstallContext $uninstallContext): void
|
public function uninstall(UninstallContext $uninstallContext): void
|
||||||
@@ -29,29 +45,4 @@ class AeonDumpManager extends Plugin
|
|||||||
$connection = $this->container->get(Connection::class);
|
$connection = $this->container->get(Connection::class);
|
||||||
$connection->executeStatement('DROP TABLE IF EXISTS `aeon_dump_manager_job`');
|
$connection->executeStatement('DROP TABLE IF EXISTS `aeon_dump_manager_job`');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activate(ActivateContext $activateContext): void
|
|
||||||
{
|
|
||||||
// Activate entities, such as a new payment method
|
|
||||||
// Or create new entities here, because now your plugin is installed and active for sure
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deactivate(DeactivateContext $deactivateContext): void
|
|
||||||
{
|
|
||||||
// Deactivate entities, such as a new payment method
|
|
||||||
// Or remove previously created entities
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(UpdateContext $updateContext): void
|
|
||||||
{
|
|
||||||
// Update necessary stuff, mostly non-database related
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postInstall(InstallContext $installContext): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postUpdate(UpdateContext $updateContext): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ use Shopware\Core\Framework\Routing\ApiRouteScope;
|
|||||||
use Shopware\Core\PlatformRequest;
|
use Shopware\Core\PlatformRequest;
|
||||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
@@ -39,16 +40,46 @@ class DumpController
|
|||||||
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
|
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
|
||||||
methods: ['GET']
|
methods: ['GET']
|
||||||
)]
|
)]
|
||||||
public function list(): JsonResponse
|
public function list(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$dumps = array_map(
|
$dumps = array_map(
|
||||||
static fn ($dumpFile) => $dumpFile->jsonSerialize(),
|
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]);
|
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(
|
#[Route(
|
||||||
path: '/api/_action/aeon-dump-manager/dumps',
|
path: '/api/_action/aeon-dump-manager/dumps',
|
||||||
name: 'api.action.aeon_dump_manager.dumps.create',
|
name: 'api.action.aeon_dump_manager.dumps.create',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace AeonDumpManager\MessageQueue\Handler;
|
|||||||
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
|
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
|
||||||
use AeonDumpManager\Service\DumpJobStatusService;
|
use AeonDumpManager\Service\DumpJobStatusService;
|
||||||
use AeonDumpManager\Service\DumpService;
|
use AeonDumpManager\Service\DumpService;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||||
|
|
||||||
#[AsMessageHandler]
|
#[AsMessageHandler]
|
||||||
@@ -13,6 +14,7 @@ class CreateDumpHandler
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly DumpService $dumpService,
|
private readonly DumpService $dumpService,
|
||||||
private readonly DumpJobStatusService $jobStatus,
|
private readonly DumpJobStatusService $jobStatus,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,10 +22,12 @@ class CreateDumpHandler
|
|||||||
{
|
{
|
||||||
$jobId = $message->getJobId();
|
$jobId = $message->getJobId();
|
||||||
$this->jobStatus->markRunning($jobId);
|
$this->jobStatus->markRunning($jobId);
|
||||||
|
$this->logger->info('Dump job started.', ['jobId' => $jobId]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->dumpService->createAsync($jobId, $this->jobStatus);
|
$this->dumpService->createAsync($jobId, $this->jobStatus);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
$this->logger->error('Dump job failed.', ['jobId' => $jobId, 'exception' => $exception]);
|
||||||
$this->jobStatus->markFailed($jobId, $exception->getMessage());
|
$this->jobStatus->markFailed($jobId, $exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -14,14 +14,24 @@
|
|||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="aeon-dump-manager-list__content">
|
<div class="aeon-dump-manager-list__content">
|
||||||
|
<sw-filter-panel
|
||||||
|
:filters="listFilters"
|
||||||
|
:defaults="defaultFilters"
|
||||||
|
:store-key="storeKey"
|
||||||
|
@criteria-changed="onCriteriaChanged"
|
||||||
|
/>
|
||||||
|
|
||||||
<sw-data-grid
|
<sw-data-grid
|
||||||
:data-source="dumps"
|
:data-source="sortedDumps"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:is-loading="isLoading"
|
:is-loading="isLoading"
|
||||||
:show-selection="acl.can('aeon_dump_manager.deleter')"
|
:show-selection="acl.can('aeon_dump_manager.deleter')"
|
||||||
:full-page="true"
|
:full-page="true"
|
||||||
|
:sort-by="sortBy"
|
||||||
|
:sort-direction="sortDirection"
|
||||||
identifier="filename"
|
identifier="filename"
|
||||||
@selection-change="onSelectionChange"
|
@selection-change="onSelectionChange"
|
||||||
|
@column-sort="onSortColumn"
|
||||||
>
|
>
|
||||||
<template #bulk>
|
<template #bulk>
|
||||||
<a
|
<a
|
||||||
|
|||||||
+87
-13
@@ -11,6 +11,12 @@ interface PendingJob {
|
|||||||
|
|
||||||
const CREATE_MODAL_AUTO_CLOSE_MS = 1500;
|
const CREATE_MODAL_AUTO_CLOSE_MS = 1500;
|
||||||
|
|
||||||
|
interface DateRangeCriteria {
|
||||||
|
type: string;
|
||||||
|
field: string;
|
||||||
|
parameters?: { gte?: string; lte?: string };
|
||||||
|
}
|
||||||
|
|
||||||
interface ComponentData {
|
interface ComponentData {
|
||||||
dumps: DumpFile[];
|
dumps: DumpFile[];
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
@@ -18,6 +24,12 @@ interface ComponentData {
|
|||||||
deleteFilenames: string[] | null;
|
deleteFilenames: string[] | null;
|
||||||
selection: Record<string, DumpFile>;
|
selection: Record<string, DumpFile>;
|
||||||
pollTimer: number | null;
|
pollTimer: number | null;
|
||||||
|
dateFrom: string | null;
|
||||||
|
dateTo: string | null;
|
||||||
|
sortBy: string;
|
||||||
|
sortDirection: string;
|
||||||
|
storeKey: string;
|
||||||
|
defaultFilters: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ComponentInstance extends ComponentData {
|
interface ComponentInstance extends ComponentData {
|
||||||
@@ -25,17 +37,25 @@ interface ComponentInstance extends ComponentData {
|
|||||||
$tc: (key: string, count?: number, values?: Record<string, unknown>) => string;
|
$tc: (key: string, count?: number, values?: Record<string, unknown>) => string;
|
||||||
createNotificationError: (options: { message: string }) => void;
|
createNotificationError: (options: { message: string }) => void;
|
||||||
createNotificationSuccess: (options: { message: string }) => void;
|
createNotificationSuccess: (options: { message: string }) => void;
|
||||||
loadList: () => Promise<void>;
|
getList: () => Promise<void>;
|
||||||
stopPolling: () => void;
|
stopPolling: () => void;
|
||||||
pollJobStatus: (jobId: string) => void;
|
pollJobStatus: (jobId: string) => void;
|
||||||
selectionCount: number;
|
selectionCount: number;
|
||||||
|
sortedDumps: DumpFile[];
|
||||||
|
listFilters: Record<string, unknown>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.register('aeon-dump-manager-list', {
|
Component.register('aeon-dump-manager-list', {
|
||||||
template,
|
template,
|
||||||
|
|
||||||
// Provides createNotificationSuccess/createNotificationError, used below.
|
mixins: [
|
||||||
mixins: [Mixin.getByName('notification')],
|
// Provides createNotificationSuccess/createNotificationError, used below.
|
||||||
|
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'],
|
inject: ['aeonDumpManagerApiService', 'acl'],
|
||||||
|
|
||||||
@@ -47,27 +67,56 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
deleteFilenames: null,
|
deleteFilenames: null,
|
||||||
selection: {},
|
selection: {},
|
||||||
pollTimer: null,
|
pollTimer: null,
|
||||||
|
dateFrom: null,
|
||||||
|
dateTo: null,
|
||||||
|
sortBy: 'datetime',
|
||||||
|
sortDirection: 'DESC',
|
||||||
|
storeKey: 'grid.filter.aeon-dump-manager',
|
||||||
|
defaultFilters: ['datetime'],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
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() {
|
columns() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
property: 'datetime',
|
property: 'datetime',
|
||||||
|
dataIndex: 'datetime',
|
||||||
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
|
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
|
||||||
allowResize: true,
|
allowResize: true,
|
||||||
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'filename',
|
property: 'filename',
|
||||||
|
dataIndex: 'filename',
|
||||||
label: this.$tc('aeon-dump-manager.list.columnFilename'),
|
label: this.$tc('aeon-dump-manager.list.columnFilename'),
|
||||||
allowResize: true,
|
allowResize: true,
|
||||||
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'sizeBytes',
|
property: 'sizeBytes',
|
||||||
|
dataIndex: 'sizeBytes',
|
||||||
label: this.$tc('aeon-dump-manager.list.columnSize'),
|
label: this.$tc('aeon-dump-manager.list.columnSize'),
|
||||||
align: 'right',
|
align: 'right',
|
||||||
allowResize: true,
|
allowResize: true,
|
||||||
|
sortable: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
@@ -75,10 +124,27 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
selectionCount(this: ComponentInstance): number {
|
selectionCount(this: ComponentInstance): number {
|
||||||
return Object.keys(this.selection).length;
|
return Object.keys(this.selection).length;
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
created(this: ComponentInstance) {
|
sortedDumps(this: ComponentInstance): DumpFile[] {
|
||||||
this.loadList();
|
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) {
|
beforeDestroy(this: ComponentInstance) {
|
||||||
@@ -86,10 +152,10 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
loadList(this: ComponentInstance): Promise<void> {
|
getList(this: ComponentInstance): Promise<void> {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
return this.aeonDumpManagerApiService.getList()
|
return this.aeonDumpManagerApiService.getList({ from: this.dateFrom, to: this.dateTo })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.dumps = response.dumps;
|
this.dumps = response.dumps;
|
||||||
})
|
})
|
||||||
@@ -99,7 +165,15 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatDatetime(value: string): string {
|
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 {
|
formatSize(bytes: number): string {
|
||||||
@@ -133,7 +207,7 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
|
|
||||||
if (job.status === 'done') {
|
if (job.status === 'done') {
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
this.loadList();
|
this.getList();
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
this.pendingJob = null;
|
this.pendingJob = null;
|
||||||
}, CREATE_MODAL_AUTO_CLOSE_MS);
|
}, 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
|
// Optimistic UI update: pull the rows out immediately rather than
|
||||||
// waiting on a full reload, so the grid never looks stale even if
|
// 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.dumps = this.dumps.filter((dumpFile) => !filenames.includes(dumpFile.filename));
|
||||||
this.selection = {};
|
this.selection = {};
|
||||||
|
|
||||||
return Promise.all(filenames.map((filename) => this.aeonDumpManagerApiService.remove(filename)))
|
return Promise.all(filenames.map((filename) => this.aeonDumpManagerApiService.remove(filename)))
|
||||||
.then(() => this.loadList())
|
.then(() => this.getList())
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
this.createNotificationError({
|
this.createNotificationError({
|
||||||
message: this.$tc('aeon-dump-manager.list.deleteFailed', 0, { error: error.message }),
|
message: this.$tc('aeon-dump-manager.list.deleteFailed', 0, { error: error.message }),
|
||||||
});
|
});
|
||||||
// A delete failed after the optimistic removal — reload to
|
// A delete failed after the optimistic removal — reload to
|
||||||
// show the real state rather than leave a wrong guess on screen.
|
// show the real state rather than leave a wrong guess on screen.
|
||||||
return this.loadList();
|
return this.getList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
"columnFilename": "Name",
|
"columnFilename": "Name",
|
||||||
"columnDatetime": "Erstellt am",
|
"columnDatetime": "Erstellt am",
|
||||||
"columnSize": "Größe",
|
"columnSize": "Größe",
|
||||||
|
"filterFromLabel": "Von",
|
||||||
|
"filterFromPlaceholder": "Startdatum auswählen...",
|
||||||
|
"filterToLabel": "Bis",
|
||||||
|
"filterToPlaceholder": "Enddatum auswählen...",
|
||||||
"buttonCreate": "Dump erstellen",
|
"buttonCreate": "Dump erstellen",
|
||||||
"buttonDownload": "Herunterladen",
|
"buttonDownload": "Herunterladen",
|
||||||
"buttonDelete": "Löschen",
|
"buttonDelete": "Löschen",
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
"columnFilename": "Name",
|
"columnFilename": "Name",
|
||||||
"columnDatetime": "Created at",
|
"columnDatetime": "Created at",
|
||||||
"columnSize": "Size",
|
"columnSize": "Size",
|
||||||
|
"filterFromLabel": "From",
|
||||||
|
"filterFromPlaceholder": "Select start date...",
|
||||||
|
"filterToLabel": "To",
|
||||||
|
"filterToPlaceholder": "Select end date...",
|
||||||
"buttonCreate": "Create dump",
|
"buttonCreate": "Create dump",
|
||||||
"buttonDownload": "Download",
|
"buttonDownload": "Download",
|
||||||
"buttonDelete": "Delete",
|
"buttonDelete": "Delete",
|
||||||
|
|||||||
@@ -43,9 +43,12 @@ export default class DumpApiService extends ApiService {
|
|||||||
super(httpClient, loginService, apiEndpoint);
|
super(httpClient, loginService, apiEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
getList(): Promise<DumpList> {
|
getList(filter: { from?: string | null; to?: string | null } = {}): Promise<DumpList> {
|
||||||
return this.httpClient
|
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));
|
.then((response: unknown) => ApiService.handleResponse(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
monolog:
|
||||||
|
channels: ['aeon_dump_manager']
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -1,7 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
|
|
||||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
|
||||||
|
|
||||||
return function (RoutingConfigurator $routes): void {
|
|
||||||
$routes->import(__DIR__ . '/../../Controller/*Controller.php', 'attribute');
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
aeon_dump_manager_controllers:
|
||||||
|
resource: ../../Controller/*Controller.php
|
||||||
|
type: attribute
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?xml version="1.0" ?>
|
|
||||||
|
|
||||||
<container xmlns="http://symfony.com/schema/dic/services"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
|
||||||
|
|
||||||
<services>
|
|
||||||
<!-- Services -->
|
|
||||||
|
|
||||||
<service id="Symfony\Component\Process\ExecutableFinder"/>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_filename_parser" class="AeonDumpManager\Service\DumpFilenameParser"/>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_binary_locator" class="AeonDumpManager\Service\DumpBinaryLocator">
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<argument type="service" id="Symfony\Component\Process\ExecutableFinder"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_job_status_service" class="AeonDumpManager\Service\DumpJobStatusService">
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_lister" class="AeonDumpManager\Service\DumpLister">
|
|
||||||
<argument type="service" id="aeon_dump_manager.filesystem.private"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_filename_parser"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_service" class="AeonDumpManager\Service\DumpService">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.filesystem.private"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_binary_locator"/>
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_filename_parser"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Async create job -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.message_queue.create_dump_handler" class="AeonDumpManager\MessageQueue\Handler\CreateDumpHandler">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<tag name="messenger.message_handler"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Retention -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.scheduled_task.purge_dumps_task" class="AeonDumpManager\ScheduledTask\PurgeDumpsTask">
|
|
||||||
<tag name="shopware.scheduled.task"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.scheduled_task.purge_dumps_task_handler" class="AeonDumpManager\ScheduledTask\PurgeDumpsTaskHandler">
|
|
||||||
<argument type="service" id="scheduled_task.repository"/>
|
|
||||||
<argument type="service" id="logger"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<tag name="messenger.message_handler" handles="AeonDumpManager\ScheduledTask\PurgeDumpsTask"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Console commands -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_list" class="AeonDumpManager\Command\DumpListCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_create" class="AeonDumpManager\Command\DumpCreateCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_remove" class="AeonDumpManager\Command\DumpRemoveCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Admin API controller -->
|
|
||||||
|
|
||||||
<service id="AeonDumpManager\Controller\DumpController" public="true">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<argument type="service" id="messenger.default_bus"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
</services>
|
|
||||||
</container>
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
services:
|
||||||
|
Symfony\Component\Process\ExecutableFinder: ~
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_filename_parser:
|
||||||
|
class: AeonDumpManager\Service\DumpFilenameParser
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_binary_locator:
|
||||||
|
class: AeonDumpManager\Service\DumpBinaryLocator
|
||||||
|
arguments:
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
- '@Symfony\Component\Process\ExecutableFinder'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_job_status_service:
|
||||||
|
class: AeonDumpManager\Service\DumpJobStatusService
|
||||||
|
arguments:
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_lister:
|
||||||
|
class: AeonDumpManager\Service\DumpLister
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.filesystem.private'
|
||||||
|
- '@aeon_dump_manager.dump_filename_parser'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_service:
|
||||||
|
class: AeonDumpManager\Service\DumpService
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
- '@aeon_dump_manager.filesystem.private'
|
||||||
|
- '@aeon_dump_manager.dump_binary_locator'
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
- '@aeon_dump_manager.dump_filename_parser'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
|
||||||
|
# Async create job
|
||||||
|
aeon_dump_manager.message_queue.create_dump_handler:
|
||||||
|
class: AeonDumpManager\MessageQueue\Handler\CreateDumpHandler
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
tags:
|
||||||
|
- { name: messenger.message_handler }
|
||||||
|
|
||||||
|
# Retention
|
||||||
|
aeon_dump_manager.scheduled_task.purge_dumps_task:
|
||||||
|
class: AeonDumpManager\ScheduledTask\PurgeDumpsTask
|
||||||
|
tags:
|
||||||
|
- { name: shopware.scheduled.task }
|
||||||
|
|
||||||
|
aeon_dump_manager.scheduled_task.purge_dumps_task_handler:
|
||||||
|
class: AeonDumpManager\ScheduledTask\PurgeDumpsTaskHandler
|
||||||
|
arguments:
|
||||||
|
- '@scheduled_task.repository'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
tags:
|
||||||
|
- { name: messenger.message_handler, handles: AeonDumpManager\ScheduledTask\PurgeDumpsTask }
|
||||||
|
|
||||||
|
# Console commands
|
||||||
|
aeon_dump_manager.command.dump_list:
|
||||||
|
class: AeonDumpManager\Command\DumpListCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
aeon_dump_manager.command.dump_create:
|
||||||
|
class: AeonDumpManager\Command\DumpCreateCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
aeon_dump_manager.command.dump_remove:
|
||||||
|
class: AeonDumpManager\Command\DumpRemoveCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
# Admin API controller
|
||||||
|
AeonDumpManager\Controller\DumpController:
|
||||||
|
public: true
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@messenger.default_bus'
|
||||||
@@ -18,7 +18,7 @@ class DumpLister
|
|||||||
/**
|
/**
|
||||||
* @return DumpFile[] newest first
|
* @return DumpFile[] newest first
|
||||||
*/
|
*/
|
||||||
public function list(): array
|
public function list(?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array
|
||||||
{
|
{
|
||||||
$dumps = [];
|
$dumps = [];
|
||||||
|
|
||||||
@@ -33,6 +33,14 @@ class DumpLister
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($from !== null && $datetime < $from) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($to !== null && $datetime > $to) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$dumps[] = new DumpFile($filename, $datetime, $item->fileSize());
|
$dumps[] = new DumpFile($filename, $datetime, $item->fileSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use AeonDumpManager\Service\Exception\DumpNotFoundException;
|
|||||||
use AeonDumpManager\Struct\DumpFile;
|
use AeonDumpManager\Struct\DumpFile;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use League\Flysystem\FilesystemOperator;
|
use League\Flysystem\FilesystemOperator;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
||||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
@@ -24,6 +25,7 @@ class DumpService
|
|||||||
private readonly Connection $connection,
|
private readonly Connection $connection,
|
||||||
private readonly SystemConfigService $systemConfigService,
|
private readonly SystemConfigService $systemConfigService,
|
||||||
private readonly DumpFilenameParser $filenameParser,
|
private readonly DumpFilenameParser $filenameParser,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@ class DumpService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete($path);
|
$this->aeonDumpManagerFilesystemPrivate->delete($path);
|
||||||
|
$this->logger->info('Dump deleted.', ['filename' => $filename]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,6 +103,7 @@ class DumpService
|
|||||||
|
|
||||||
foreach ($excess as $dumpFile) {
|
foreach ($excess as $dumpFile) {
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
||||||
|
$this->logger->info('Dump removed: maxDumps exceeded.', ['filename' => $dumpFile->filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +112,7 @@ class DumpService
|
|||||||
foreach ($this->dumpLister->list() as $dumpFile) {
|
foreach ($this->dumpLister->list() as $dumpFile) {
|
||||||
if ($dumpFile->datetime < $threshold) {
|
if ($dumpFile->datetime < $threshold) {
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
||||||
|
$this->logger->info('Dump removed: older than retention.', ['filename' => $dumpFile->filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +148,7 @@ class DumpService
|
|||||||
|
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
@unlink($tempPath);
|
@unlink($tempPath);
|
||||||
|
$this->logger->error('Dump process failed.', ['exitCode' => $process->getExitCode()]);
|
||||||
|
|
||||||
throw new ProcessFailedException($process);
|
throw new ProcessFailedException($process);
|
||||||
}
|
}
|
||||||
@@ -153,6 +159,8 @@ class DumpService
|
|||||||
fclose($stream);
|
fclose($stream);
|
||||||
@unlink($tempPath);
|
@unlink($tempPath);
|
||||||
|
|
||||||
|
$this->logger->info('Dump created.', ['filename' => $filename, 'sizeBytes' => $sizeBytes]);
|
||||||
|
|
||||||
return new DumpFile($filename, $dateTime, $sizeBytes);
|
return new DumpFile($filename, $dateTime, $sizeBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace AeonDumpManager\Tests\Service;
|
namespace AeonDumpManager\Tests\Service;
|
||||||
|
|
||||||
use AeonDumpManager\Service\DumpFilenameParser;
|
use AeonDumpManager\Service\DumpFilenameParser;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DumpFilenameParserTest extends TestCase
|
class DumpFilenameParserTest extends TestCase
|
||||||
@@ -29,9 +30,7 @@ class DumpFilenameParserTest extends TestCase
|
|||||||
self::assertEquals($dateTime, $this->parser->parse($filename));
|
self::assertEquals($dateTime, $this->parser->parse($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('invalidFilenameProvider')]
|
||||||
* @dataProvider invalidFilenameProvider
|
|
||||||
*/
|
|
||||||
public function testParseRejectsInvalidFilenames(string $filename): void
|
public function testParseRejectsInvalidFilenames(string $filename): void
|
||||||
{
|
{
|
||||||
self::assertNull($this->parser->parse($filename));
|
self::assertNull($this->parser->parse($filename));
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
namespace AeonDumpManager\Tests\Service;
|
namespace AeonDumpManager\Tests\Service;
|
||||||
|
|
||||||
use AeonDumpManager\Service\MySqlVariant;
|
use AeonDumpManager\Service\MySqlVariant;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MySqlVariantTest extends TestCase
|
class MySqlVariantTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('versionProvider')]
|
||||||
* @dataProvider versionProvider
|
|
||||||
*/
|
|
||||||
public function testIsMariaDb(string $version, bool $expected): void
|
public function testIsMariaDb(string $version, bool $expected): void
|
||||||
{
|
{
|
||||||
self::assertSame($expected, MySqlVariant::isMariaDb($version));
|
self::assertSame($expected, MySqlVariant::isMariaDb($version));
|
||||||
|
|||||||
Reference in new issue
Block a user