Skip to content

Commit b02facd

Browse files
committed
init
0 parents  commit b02facd

35 files changed

+6094
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
env:
12+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
jobs:
15+
php-cs-fixer:
16+
name: PHP CS Fixer
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
tools: composer
26+
- run: composer install
27+
- run: composer cs
28+
phpstan:
29+
name: PHPStan
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
tools: composer
39+
- run: composer install
40+
- run: composer phpstan
41+
functional:
42+
name: Functional tests
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: ${{ matrix.php }}
51+
tools: composer
52+
- run: composer install
53+
- run: composer functional

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$header = <<<'HEADER'
6+
This file is part of the PMU project.
7+
8+
(c) Antoine Bluchet <[email protected]>
9+
10+
For the full copyright and license information, please view the LICENSE
11+
file that was distributed with this source code.
12+
HEADER;
13+
14+
$finder = PhpCsFixer\Finder::create()
15+
->in(__DIR__);
16+
17+
return (new PhpCsFixer\Config())
18+
->setRiskyAllowed(true)
19+
->setRules([
20+
'header_comment' => [
21+
'header' => $header,
22+
'location' => 'after_open',
23+
],
24+
'ordered_imports' => [
25+
'imports_order' => [
26+
'class',
27+
'function',
28+
'const',
29+
],
30+
'sort_algorithm' => 'alpha',
31+
],
32+
'no_unused_imports' => true,
33+
'declare_strict_types' => true,
34+
])->setFinder($finder);

LICENCE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT license
2+
3+
Copyright (c) 2015-present Antoine Bluchet
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 furnished
10+
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
21+
THE SOFTWARE.
22+

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# PMU
2+
3+
PMU is a Composer plugin for PHP Monorepository management.
4+
5+
## Configuration
6+
7+
```json5
8+
{
9+
"name": "test/monorepo",
10+
// Specify the projects that are part of your monorepository
11+
"extra": {
12+
"projects": [
13+
"test/a",
14+
"test/b",
15+
"test/c"
16+
],
17+
},
18+
// Add local path repositories for these projects
19+
"repositories": [
20+
{"type": "path", "url": "./packages/A", "symlink": true},
21+
{"type": "path", "url": "./packages/B", "symlink": true},
22+
{"type": "path", "url": "./packages/C", "symlink": true}
23+
],
24+
"require": {
25+
"test/a": "*@dev",
26+
"test/b": "*@dev",
27+
"test/c": "*@dev"
28+
},
29+
"config": {
30+
"allow-plugins": {
31+
"soyuka/pmu": true
32+
}
33+
}
34+
}
35+
```
36+
37+
Note that `repositories` are propagated to each project when running commands from the base `composer.json` file. An example is available in the `tests/monorepo` directory.
38+
39+
## Commands
40+
41+
### Run a command on a single project
42+
43+
```
44+
composer [project-name] [args]
45+
```
46+
47+
For example: `composer test/a install`.
48+
49+
### Run a command on every projects
50+
51+
```
52+
composer all install
53+
```
54+
55+
Runs `composer install` on every projects.
56+
57+
### Run a graph of dependencies
58+
59+
```
60+
composer graph [project-name]
61+
```
62+
63+
Example: `composer graph test/a` to see the dependencies for the `test/a` project.
64+
65+
### Checks dependencies
66+
67+
This script reads the code and detect `use` classes. It then checks that the dependencies are correctly mapped in the `require` or `require-dev` of each project.
68+
69+
```
70+
composer check-dependencies
71+
```
72+
73+
## TODO:
74+
75+
- handle `branch-alias`
76+
- bump versions of each project's dependencies
77+
- create and `affected` graph to be able to run tests on affected projects

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "soyuka/pmu",
3+
"description": "PHP Mono Repository Utility",
4+
"type": "composer-plugin",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"Pmu\\": "src/"
9+
}
10+
},
11+
"autoload-dev": {
12+
"psr-4": {
13+
"Pmu\\Tests\\Functional\\": "tests/functional/"
14+
}
15+
},
16+
"authors": [
17+
{
18+
"name": "soyuka",
19+
"email": "[email protected]"
20+
}
21+
],
22+
"require": {
23+
"composer-plugin-api": "^2.0"
24+
},
25+
"require-dev": {
26+
"composer/composer": "^2.7",
27+
"symfony/var-dumper": "^7.0",
28+
"phpstan/phpstan": "^1.10",
29+
"friendsofphp/php-cs-fixer": "^3.50",
30+
"phpunit/phpunit": "^11.0"
31+
},
32+
"extra": {
33+
"class": "Pmu\\Composer\\Plugin",
34+
"plugin-optional": true
35+
},
36+
"scripts": {
37+
"functional": "./vendor/bin/phpunit --bootstrap ./vendor/autoload.php tests/functional",
38+
"unit": "/vendor/bin/phpunit --bootstrap ./vendor/autoload.php tests/unit",
39+
"cs": "./vendor/bin/php-cs-fixer fix",
40+
"phpstan": "./vendor/bin/phpstan analyse"
41+
}
42+
}

0 commit comments

Comments
 (0)