Skip to content
This repository was archived by the owner on May 27, 2022. It is now read-only.

Commit 97bbf78

Browse files
authored
Monorepo - Multipack (#10)
1 parent c682904 commit 97bbf78

23 files changed

+239
-85
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
55
/.php-cs-fixer.php export-ignore
6+
/config.subsplit-publish.json export-ignore
67
/Makefile export-ignore
78
/infection.json.dist export-ignore
89
/phpunit.xml.dist export-ignore

.github/workflows/integrate.yaml

+18-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,19 @@ jobs:
1313
runs-on: "ubuntu-latest"
1414

1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
php-version:
1819
- "8.0"
20+
subdir:
21+
- "./"
22+
- "./src/Core/"
23+
- "./src/Gzip/"
24+
- "./src/V1Encrypt/"
25+
26+
defaults:
27+
run:
28+
working-directory: "${{ matrix.subdir }}"
1929

2030
steps:
2131
- name: "Checkout"
@@ -29,29 +39,34 @@ jobs:
2939
tools: composer-normalize, composer-require-checker, composer-unused
3040

3141
- name: "Get composer cache directory"
42+
if: ${{ matrix.subdir == './' }}
3243
id: composercache
3344
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3445

3546
- name: "Cache dependencies"
47+
if: ${{ matrix.subdir == './' }}
3648
uses: actions/cache@v2
3749
with:
3850
path: ${{ steps.composercache.outputs.dir }}
3951
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
4052
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
4153

42-
- name: "Install dependencies"
43-
run: "composer update --no-interaction --no-progress"
44-
4554
- name: "Validate composer.json"
4655
run: "composer validate --strict"
4756

4857
- name: "Normalize composer.json"
4958
run: "composer-normalize --dry-run"
5059

60+
- name: "Install dependencies"
61+
if: ${{ matrix.subdir == './' }}
62+
run: "composer update --no-interaction --no-progress"
63+
5164
- name: "Check composer.json explicit dependencies"
65+
if: ${{ matrix.subdir == './' }}
5266
run: "composer-require-checker"
5367

5468
- name: "Check composer.json unused dependencies"
69+
if: ${{ matrix.subdir == './' }}
5570
run: "composer-unused --excludePackage=php"
5671

5772
tests:
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Sub-Split Publishing"
2+
on:
3+
create:
4+
tags:
5+
- '*'
6+
delete:
7+
tags:
8+
- '*'
9+
10+
jobs:
11+
publish_subsplits:
12+
runs-on: ubuntu-latest
13+
name: "Publish package sub-splits"
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: '0'
18+
persist-credentials: 'false'
19+
- uses: frankdejonge/use-github-token@1.0.1
20+
with:
21+
authentication: 'Slamdunk:${{ secrets.PERSONAL_ACCESS_TOKEN }}'
22+
user_name: 'Filippo Tessarotto'
23+
user_email: 'zoeslam@gmail.com'
24+
- name: "Cache splitsh-lite"
25+
id: splitsh-cache
26+
uses: actions/cache@v2
27+
with:
28+
path: './.splitsh'
29+
key: '${{ runner.os }}-splitsh'
30+
- uses: frankdejonge/use-subsplit-publish@1.0.0-beta.3
31+
with:
32+
source-branch: '2.x'
33+
config-path: './config.subsplit-publish.json'
34+
splitsh-path: './.splitsh/splitsh-lite'
35+
splitsh-version: 'v1.0.1'

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ $ composer require slam/flysystem-compress-and-encrypt-proxy
2020
## Usage
2121

2222
```php
23-
24-
use SlamCompressAndEncryptProxy\GzipAdapter;
25-
use SlamCompressAndEncryptProxy\EncryptAdapter;
23+
use SlamCompressAndEncryptProxy\Gzip\GzipProxyAdapter;
24+
use SlamCompressAndEncryptProxy\V1Encrypt\V1EncryptProxyAdapter;
2625
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
2726

2827
// Create a strong key and save it somewhere
@@ -31,7 +30,7 @@ $key = EncryptAdapter::generateKey();
3130
// Create the final FilesystemAdapter, for example Aws S3
3231
$remoteAdapter = new AwsS3V3Adapter(/* ... */);
3332

34-
$adapter = new GzipAdapter(new EncryptAdapter(
33+
$adapter = new GzipProxyAdapter(new V1EncryptProxyAdapter(
3534
$remoteAdapter,
3635
$key
3736
));
@@ -64,7 +63,7 @@ space required.
6463

6564
GZip's `zlib.deflate` and `zlib.inflate` compression filters are used.
6665

67-
You can opt-out compression by using just the `EncryptAdapter`.
66+
You can opt-out compression by using just the `V1EncryptProxyAdapter`.
6867

6968
## Encryption
7069

config.subsplit-publish.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"sub-splits": [
3+
{
4+
"name": "core",
5+
"directory": "src/Core",
6+
"target": "git@github.com:Slamdunk/flysystem-core-proxy.git"
7+
},
8+
{
9+
"name": "gzip",
10+
"directory": "src/Gzip",
11+
"target": "git@github.com:Slamdunk/flysystem-gzip-proxy.git"
12+
},
13+
{
14+
"name": "v1encrypt",
15+
"directory": "src/V1Encrypt",
16+
"target": "git@github.com:Slamdunk/flysystem-v1encrypt-proxy.git"
17+
}
18+
]
19+
}

psalm-baseline.xml

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<files psalm-version="4.12.0@e42bc4a23f67acba28a23bb09c348e2ff38a1d87">
3-
<file src="src/EncryptStreamFilter.php">
4-
<MissingConstructor occurrences="2">
5-
<code>$key</code>
3+
<file src="src/Gzip/GzipStreamFilter.php">
4+
<MissingConstructor occurrences="3">
5+
<code>$filename</code>
6+
<code>$id</code>
67
<code>$mode</code>
78
</MissingConstructor>
89
<UndefinedThisPropertyFetch occurrences="2">
910
<code>$this-&gt;stream</code>
1011
<code>$this-&gt;stream</code>
1112
</UndefinedThisPropertyFetch>
13+
<UnusedFunctionCall occurrences="1">
14+
<code>hash_update</code>
15+
</UnusedFunctionCall>
1216
</file>
13-
<file src="src/GzipStreamFilter.php">
14-
<MissingConstructor occurrences="3">
15-
<code>$filename</code>
16-
<code>$id</code>
17+
<file src="src/V1Encrypt/V1EncryptStreamFilter.php">
18+
<MissingConstructor occurrences="2">
19+
<code>$key</code>
1720
<code>$mode</code>
1821
</MissingConstructor>
1922
<UndefinedThisPropertyFetch occurrences="2">
2023
<code>$this-&gt;stream</code>
2124
<code>$this-&gt;stream</code>
2225
</UndefinedThisPropertyFetch>
23-
<UnusedFunctionCall occurrences="1">
24-
<code>hash_update</code>
25-
</UnusedFunctionCall>
2626
</file>
27-
<file src="test/AbstractProxyAdapterTest.php">
27+
<file src="test/CompressAndEncryptAdapterTest.php">
28+
<PropertyNotSetInConstructor occurrences="4">
29+
<code>$remoteMock</code>
30+
<code>CompressAndEncryptAdapterTest</code>
31+
<code>CompressAndEncryptAdapterTest</code>
32+
<code>CompressAndEncryptAdapterTest</code>
33+
</PropertyNotSetInConstructor>
34+
</file>
35+
<file src="test/Core/AbstractProxyAdapterTest.php">
2836
<InternalClass occurrences="1">
2937
<code>AbstractProxyAdapter</code>
3038
</InternalClass>
@@ -36,24 +44,7 @@
3644
<code>AbstractProxyAdapterTest</code>
3745
</PropertyNotSetInConstructor>
3846
</file>
39-
<file src="test/CompressAndEncryptAdapterTest.php">
40-
<PropertyNotSetInConstructor occurrences="4">
41-
<code>$remoteMock</code>
42-
<code>CompressAndEncryptAdapterTest</code>
43-
<code>CompressAndEncryptAdapterTest</code>
44-
<code>CompressAndEncryptAdapterTest</code>
45-
</PropertyNotSetInConstructor>
46-
</file>
47-
<file src="test/EncryptStreamFilterTest.php">
48-
<PropertyNotSetInConstructor occurrences="2">
49-
<code>EncryptStreamFilterTest</code>
50-
<code>EncryptStreamFilterTest</code>
51-
</PropertyNotSetInConstructor>
52-
<UnusedFunctionCall occurrences="1">
53-
<code>stream_get_contents</code>
54-
</UnusedFunctionCall>
55-
</file>
56-
<file src="test/GzipStreamFilterTest.php">
47+
<file src="test/Gzip/GzipStreamFilterTest.php">
5748
<PropertyNotSetInConstructor occurrences="2">
5849
<code>GzipStreamFilterTest</code>
5950
<code>GzipStreamFilterTest</code>
@@ -65,4 +56,13 @@
6556
<code>stream_get_contents</code>
6657
</UnusedFunctionCall>
6758
</file>
59+
<file src="test/V1Encrypt/V1EncryptStreamFilterTest.php">
60+
<PropertyNotSetInConstructor occurrences="2">
61+
<code>V1EncryptStreamFilterTest</code>
62+
<code>V1EncryptStreamFilterTest</code>
63+
</PropertyNotSetInConstructor>
64+
<UnusedFunctionCall occurrences="1">
65+
<code>stream_get_contents</code>
66+
</UnusedFunctionCall>
67+
</file>
6868
</files>

src/AbstractProxyAdapter.php renamed to src/Core/AbstractProxyAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace SlamCompressAndEncryptProxy;
5+
namespace SlamCompressAndEncryptProxy\Core;
66

77
use League\Flysystem\Config;
88
use League\Flysystem\FileAttributes;

src/Core/composer.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "slam/flysystem-core-proxy",
3+
"type": "library",
4+
"description": "FlySystem core classes for proxy adapters",
5+
"homepage": "https://github.com/slamdunk/flysystem-compress-and-encrypt-proxy",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Filippo Tessarotto",
10+
"email": "zoeslam@gmail.com",
11+
"role": "Developer"
12+
}
13+
],
14+
"require": {
15+
"php": ">=8.0",
16+
"league/flysystem": "^2.3.1"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"SlamCompressAndEncryptProxy\\Core\\": ""
21+
}
22+
}
23+
}

src/GzipAdapter.php renamed to src/Gzip/GzipProxyAdapter.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace SlamCompressAndEncryptProxy;
5+
namespace SlamCompressAndEncryptProxy\Gzip;
66

77
use League\Flysystem\Config;
88
use League\Flysystem\FilesystemAdapter;
9+
use SlamCompressAndEncryptProxy\Core\AbstractProxyAdapter;
910

10-
final class GzipAdapter extends AbstractProxyAdapter
11+
final class GzipProxyAdapter extends AbstractProxyAdapter
1112
{
1213
public function __construct(
1314
FilesystemAdapter $remoteAdapter

src/GzipStreamFilter.php renamed to src/Gzip/GzipStreamFilter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace SlamCompressAndEncryptProxy;
5+
namespace SlamCompressAndEncryptProxy\Gzip;
66

77
use php_user_filter;
88
use RuntimeException;

src/Gzip/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Sub-split for Gzip compression
2+
3+
```bash
4+
composer require slam/flysystem-gzip-proxy
5+
```

src/Gzip/composer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "slam/flysystem-gzip-proxy",
3+
"type": "library",
4+
"description": "FlySystem adapter to Gzip content before sending it to the real adapter",
5+
"homepage": "https://github.com/slamdunk/flysystem-compress-and-encrypt-proxy",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Filippo Tessarotto",
10+
"email": "zoeslam@gmail.com",
11+
"role": "Developer"
12+
}
13+
],
14+
"require": {
15+
"php": ">=8.0",
16+
"ext-hash": "*",
17+
"league/flysystem": "^2.3.1",
18+
"slam/flysystem-core-proxy": "^0.3.0"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"SlamCompressAndEncryptProxy\\Gzip\\": ""
23+
}
24+
}
25+
}

src/V1Encrypt/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Sub-split for V1 Encryption
2+
3+
```bash
4+
composer require slam/flysystem-v1encrypt-proxy
5+
```

src/EncryptAdapter.php renamed to src/V1Encrypt/V1EncryptProxyAdapter.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
declare(strict_types=1);
44

5-
namespace SlamCompressAndEncryptProxy;
5+
namespace SlamCompressAndEncryptProxy\V1Encrypt;
66

77
use InvalidArgumentException;
88
use League\Flysystem\Config;
99
use League\Flysystem\FilesystemAdapter;
10+
use SlamCompressAndEncryptProxy\Core\AbstractProxyAdapter;
1011

11-
final class EncryptAdapter extends AbstractProxyAdapter
12+
final class V1EncryptProxyAdapter extends AbstractProxyAdapter
1213
{
1314
public function __construct(
1415
FilesystemAdapter $remoteAdapter,
@@ -23,7 +24,7 @@ public function __construct(
2324
));
2425
}
2526

26-
EncryptStreamFilter::register();
27+
V1EncryptStreamFilter::register();
2728

2829
parent::__construct($remoteAdapter);
2930
}
@@ -46,7 +47,7 @@ public static function getRemoteFileExtension(): string
4647
*/
4748
public function writeStream(string $path, $contents, Config $config): void
4849
{
49-
EncryptStreamFilter::appendEncryption($contents, $this->key);
50+
V1EncryptStreamFilter::appendEncryption($contents, $this->key);
5051

5152
$this->getRemoteAdapter()->writeStream($this->getRemotePath($path), $contents, $config);
5253
}
@@ -58,7 +59,7 @@ public function readStream(string $path)
5859
{
5960
$contents = $this->getRemoteAdapter()->readStream($this->getRemotePath($path));
6061

61-
EncryptStreamFilter::appendDecryption($contents, $this->key);
62+
V1EncryptStreamFilter::appendDecryption($contents, $this->key);
6263

6364
return $contents;
6465
}

src/EncryptStreamFilter.php renamed to src/V1Encrypt/V1EncryptStreamFilter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
namespace SlamCompressAndEncryptProxy;
5+
namespace SlamCompressAndEncryptProxy\V1Encrypt;
66

77
use php_user_filter;
88
use RuntimeException;
99

1010
/**
1111
* @internal
1212
*/
13-
final class EncryptStreamFilter extends php_user_filter
13+
final class V1EncryptStreamFilter extends php_user_filter
1414
{
1515
private const FILTERNAME_PREFIX = 'slamflysystemencryptor';
1616
private const MODE_ENCRYPT = '.encrypt';

0 commit comments

Comments
 (0)