Skip to content

Commit f6ecae5

Browse files
feat!: stache content pipe (#56)
BREAKING CHANGE: The Content has been removed. Replace it with StacheData or an alternative implementation. Ensure your code does not rely on the removed pipe.
1 parent 9f49655 commit f6ecae5

File tree

21 files changed

+334
-188
lines changed

21 files changed

+334
-188
lines changed

composer.json

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
{
2-
"name": "itiden/statamic-backup",
3-
"description": "Backup your Statamic site",
4-
"license": "MIT",
5-
"authors": [
6-
{
7-
"name": "Neo Lejondahl",
8-
"role": "Developer"
9-
}
10-
],
11-
"require": {
12-
"ext-zip": "*",
13-
"statamic/cms": "^5.0.0",
14-
"pixelfear/composer-dist-plugin": "^0.1.6"
15-
},
16-
"require-dev": {
17-
"orchestra/testbench": "^9.0",
18-
"pestphp/pest": "^3.0",
19-
"pestphp/pest-plugin-laravel": "^3.0",
20-
"carthage-software/mago": "^0.11.0"
21-
},
22-
"autoload": {
23-
"psr-4": {
24-
"Itiden\\Backup\\": "src"
25-
}
26-
},
27-
"autoload-dev": {
28-
"psr-4": {
29-
"Itiden\\Backup\\Tests\\": "tests",
30-
"Workbench\\App\\": "workbench/app/",
31-
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
32-
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
33-
},
34-
"files": [
35-
"tests/Helpers.php"
36-
]
2+
"name": "itiden/statamic-backup",
3+
"description": "Backup your Statamic site",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Neo Lejondahl",
8+
"role": "Developer"
9+
}
10+
],
11+
"require": {
12+
"ext-zip": "*",
13+
"statamic/cms": "^5.0.0",
14+
"pixelfear/composer-dist-plugin": "^0.1.6"
15+
},
16+
"require-dev": {
17+
"orchestra/testbench": "^9.0",
18+
"pestphp/pest": "^3.0",
19+
"pestphp/pest-plugin-laravel": "^3.0",
20+
"carthage-software/mago": "^0.11.0"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Itiden\\Backup\\": "src"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Itiden\\Backup\\Tests\\": "tests",
30+
"Workbench\\App\\": "workbench/app/",
31+
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
32+
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
3733
},
38-
"scripts": {
39-
"post-autoload-dump": [
40-
"@clear",
41-
"@prepare"
42-
],
43-
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
44-
"prepare": "@php vendor/bin/testbench package:discover --ansi",
45-
"build": "@php vendor/bin/testbench workbench:build --ansi",
46-
"serve": [
47-
"Composer\\Config::disableProcessTimeout",
48-
"@build",
49-
"@php vendor/bin/testbench serve --ansi"
50-
],
51-
"lint": [
52-
"@php vendor/bin/mago lint"
53-
],
54-
"format": [
55-
"@php vendor/bin/mago format"
56-
],
57-
"test": [
58-
"XDEBUG_MODE=coverage vendor/bin/pest --coverage"
59-
],
60-
"qa": [
61-
"@format",
62-
"@lint",
63-
"@test"
64-
]
34+
"files": [
35+
"tests/Helpers.php"
36+
]
37+
},
38+
"scripts": {
39+
"post-autoload-dump": [
40+
"@clear",
41+
"@prepare"
42+
],
43+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
44+
"prepare": "@php vendor/bin/testbench package:discover --ansi",
45+
"build": "@php vendor/bin/testbench workbench:build --ansi",
46+
"serve": [
47+
"Composer\\Config::disableProcessTimeout",
48+
"@build",
49+
"@php vendor/bin/testbench serve --ansi"
50+
],
51+
"lint": [
52+
"@php vendor/bin/mago lint"
53+
],
54+
"format": [
55+
"@php vendor/bin/mago format"
56+
],
57+
"test": [
58+
"XDEBUG_MODE=coverage vendor/bin/pest --coverage"
59+
],
60+
"qa": [
61+
"@format",
62+
"@lint",
63+
"@test"
64+
]
65+
},
66+
"extra": {
67+
"statamic": {
68+
"name": "Backup",
69+
"description": "Backup your Statamic site"
6570
},
66-
"extra": {
67-
"statamic": {
68-
"name": "Backup",
69-
"description": "Backup your Statamic site"
70-
},
71-
"laravel": {
72-
"providers": [
73-
"Itiden\\Backup\\ServiceProvider"
74-
]
75-
},
76-
"download-dist": {
77-
"url": "https://github.com/itiden/statamic-backup/releases/download/{$version}/dist.tar.gz",
78-
"path": "resources/dist"
79-
}
71+
"laravel": {
72+
"providers": [
73+
"Itiden\\Backup\\ServiceProvider"
74+
]
8075
},
81-
"config": {
82-
"allow-plugins": {
83-
"pixelfear/composer-dist-plugin": true,
84-
"pestphp/pest-plugin": true,
85-
"carthage-software/mago": true
86-
}
76+
"download-dist": {
77+
"url": "https://github.com/itiden/statamic-backup/releases/download/{$version}/dist.tar.gz",
78+
"path": "resources/dist"
79+
}
80+
},
81+
"config": {
82+
"allow-plugins": {
83+
"pixelfear/composer-dist-plugin": true,
84+
"pestphp/pest-plugin": true,
85+
"carthage-software/mago": true
8786
}
88-
}
87+
}
88+
}

config/backup.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php
22

33
return [
4-
/**
5-
* The path to the content directory
6-
*
7-
* This is used by the default content backup driver
8-
*/
9-
'content_path' => storage_path('content'),
104

115
/**
126
* The backup destination options
@@ -70,8 +64,27 @@
7064
* All pipes are expected to be instances of Itiden\Backup\Abtracts\BackupPipe
7165
*/
7266
'pipeline' => [
73-
Itiden\Backup\Pipes\Content::class,
67+
Itiden\Backup\Pipes\StacheData::class,
7468
Itiden\Backup\Pipes\Assets::class,
7569
Itiden\Backup\Pipes\Users::class,
7670
],
71+
72+
/**
73+
* The stache stores that should be backed up by the StacheData pipe, by key
74+
*/
75+
'stache_stores' => [
76+
// stores configurations
77+
'asset-containers',
78+
'collections',
79+
'navigation',
80+
'taxonomies',
81+
// content stores
82+
'terms',
83+
'entries',
84+
'globals',
85+
'global-variables',
86+
'collection-trees',
87+
'nav-trees',
88+
'form-submissions',
89+
],
7790
];

docs/pages/pipeline.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ for example, maybe you don't want to backup your users, then just comment that o
1414

1515
```php
1616
'pipeline' => [
17-
Itiden\Backup\Pipes\Content::class,
17+
Itiden\Backup\Pipes\StacheData::class,
1818
Itiden\Backup\Pipes\Assets::class,
1919
// Itiden\Backup\Pipes\Users::class,
2020
],
@@ -68,7 +68,7 @@ use Itiden\Backup\Abstracts\BackupPipe;
6868
use Illuminate\Support\Facades\File;
6969
use Itiden\Backup\Support\Zipper;
7070

71-
final class Logs extends BackupPipe
71+
final readonly class Logs extends BackupPipe
7272
{
7373
/**
7474
* Get the key of the driver.
@@ -81,7 +81,7 @@ final class Logs extends BackupPipe
8181
/**
8282
* Run the restore process.
8383
*/
84-
public function restore(string $restoringFromPath, Closure $next): void
84+
public function restore(string $restoringFromPath, Closure $next): string
8585
{
8686
$path = $this->getDirectoryPath($restoringFromPath);
8787
// Implement the logic to restore data from the provided backup file at $path.
@@ -93,7 +93,7 @@ final class Logs extends BackupPipe
9393
/**
9494
* Run the backup process.
9595
*/
96-
public function backup(Zipper $zip, Closure $next): void
96+
public function backup(Zipper $zip, Closure $next): Zipper
9797
{
9898
if (!file_exists(storage_path('logs'))) {
9999
return $this->skip(
@@ -127,9 +127,9 @@ Finally, you can configure your backup to use the custom driver you've created.
127127
return [
128128
// ...
129129
'pipeline' => [
130-
Itiden\Backup\Drivers\Content::class,
131-
Itiden\Backup\Drivers\Assets::class,
132-
Itiden\Backup\Drivers\Users::class,
130+
Itiden\Backup\Pipes\StacheData::class,
131+
Itiden\Backup\Pipes\Assets::class,
132+
Itiden\Backup\Pipes\Users::class,
133133
App\Backup\Pipes\Logs::class,
134134
],
135135
// ...

phpunit.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<php>
1919
<env name="APP_ENV" value="testing"/>
2020
<env name="DB_CONNECTION" value="testing"/>
21+
<env name="CACHE_STORE" value="array"/>
22+
<env name="QUEUE_CONNECTION" value="sync"/>
2123
<env name="APP_ENV" value="testing"/>
2224
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
2325
</php>

src/Abstracts/BackupPipe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Closure;
88
use Itiden\Backup\Support\Zipper;
99

10-
abstract class BackupPipe
10+
abstract readonly class BackupPipe
1111
{
1212
/**
1313
* Get the key of the driver.

src/Pipes/Assets.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
namespace Itiden\Backup\Pipes;
66

77
use Closure;
8+
use Illuminate\Http\Request;
89
use Illuminate\Support\Facades\File;
910
use Itiden\Backup\Abstracts\BackupPipe;
1011
use Itiden\Backup\Support\Zipper;
1112
use Statamic\Assets\AssetContainer as Container;
1213
use Statamic\Facades\AssetContainer;
1314

14-
final class Assets extends BackupPipe
15+
final readonly class Assets extends BackupPipe
1516
{
1617
public static function getKey(): string
1718
{

src/Pipes/Content.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)