Skip to content

Commit 02a0e86

Browse files
committed
Initial commit
0 parents  commit 02a0e86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+5161
-0
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/bin export-ignore
2+
/tests export-ignore
3+
/.github export-ignore
4+
/.gitattributes export-ignore
5+
/.gitignore export-ignore
6+
/phpunit.xml export-ignore

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: terminal42
2+
ko_fi: terminal42

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push: ~
5+
pull_request: ~
6+
7+
permissions: read-all
8+
9+
jobs:
10+
ci:
11+
uses: 'terminal42/contao-build-tools/.github/workflows/build-tools.yml@main'
12+
13+
tests:
14+
name: Unit tests (PHP ${{ matrix.php }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
php: [ '8.1', '8.2', '8.3', '8.4' ]
20+
steps:
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: none
26+
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
30+
- name: Install the dependencies
31+
run: |
32+
composer install --no-interaction --no-progress --no-plugins
33+
34+
- name: Run phpunit
35+
run: composer unit

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.phpunit.cache
2+
/tests/Fixtures/**/var/restic
3+
/var
4+
/vendor

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 terminal42 gmbh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# terminal42/php-restic
2+
3+
> An opinionated PHP library that installs Restic and provides basic commands to work via PHP with it.
4+
> It is used for our own purposes and thus **not covered** by any API BC promises whatsoever.
5+
> Use at your own risk.
6+
7+
## License
8+
9+
This project is open-sourced under the [MIT License](LICENSE).

bin/bump-restic-version.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
require __DIR__.'/../vendor/autoload.php';
7+
8+
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\InputArgument;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Symfony\Component\Console\SingleCommandApplication;
13+
use Symfony\Component\Console\Style\SymfonyStyle;
14+
use Terminal42\Restic\Restic;
15+
16+
(new SingleCommandApplication())
17+
->setName('Bump restic version.')
18+
->addArgument('version', InputArgument::REQUIRED, 'The desired version.')
19+
->setCode(
20+
static function (InputInterface $input, OutputInterface $output): int {
21+
$io = new SymfonyStyle($input, $output);
22+
$version = $input->getArgument('version');
23+
24+
// Read the file
25+
$resticClassPath = __DIR__.'/../src/Restic.php';
26+
$content = file_get_contents($resticClassPath);
27+
$pattern = "/public?\\s*const\\s+RESTIC_VERSION\\s*=\\s*'[^']*';/";
28+
$replacement = "public const RESTIC_VERSION = '{$version}';";
29+
$updatedContent = preg_replace($pattern, $replacement, $content);
30+
file_put_contents($resticClassPath, $updatedContent);
31+
32+
if (Restic::RESTIC_VERSION !== $version) {
33+
$io->error('Version could not be updated in Restic class.');
34+
35+
return Command::FAILURE;
36+
}
37+
38+
Restic::updateShaSumFile();
39+
40+
return Command::SUCCESS;
41+
},
42+
)
43+
->run()
44+
;

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "terminal42/php-restic",
3+
"description": "An opinionated helper library for Restic",
4+
"type": "library",
5+
"require": {
6+
"php": "^8.1",
7+
"ext-zip": "*",
8+
"ext-bz2": "*",
9+
"symfony/filesystem": "^6.4 || ^7.0",
10+
"symfony/finder": "^6.4 || ^7.0",
11+
"symfony/http-client": "^6.4 || ^7.0",
12+
"symfony/process": "^6.4 || ^7.0"
13+
},
14+
"license": "MIT",
15+
"autoload": {
16+
"psr-4": {
17+
"Terminal42\\Restic\\": "src/"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"Terminal42\\Restic\\Test\\": "tests/"
23+
}
24+
},
25+
"authors": [
26+
{
27+
"name": "Yanick Witschi",
28+
"email": "[email protected]"
29+
}
30+
],
31+
"config": {
32+
"allow-plugins": {
33+
"terminal42/contao-build-tools": true
34+
}
35+
},
36+
"require-dev": {
37+
"phpunit/phpunit": "^11.5",
38+
"symfony/console": "^6.4 || ^7.0",
39+
"terminal42/contao-build-tools": "dev-main"
40+
}
41+
}

0 commit comments

Comments
 (0)