Skip to content

Commit 5cf3999

Browse files
committed
ci(dependency): Add composer dependency analyser configuration
- Introduce a new PHP file for Composer dependency analysis. - Add configuration for paths to scan and exclude. - Specify error handling for certain extensions and packages. - Update composer.json to include the new dependency and related scripts.
1 parent 284b46c commit 5cf3999

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

composer-dependency-analyser.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2024-2025 guanguans<ityaozm@gmail.com>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/guanguans/laravel-api-response
12+
*/
13+
14+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
15+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
16+
17+
return (new Configuration)
18+
->addPathsToScan(
19+
[
20+
__DIR__.'/config',
21+
__DIR__.'/src',
22+
],
23+
false
24+
)
25+
->addPathsToExclude([
26+
__DIR__.'/tests',
27+
__DIR__.'/src/Support/Rectors',
28+
])
29+
// ->ignoreErrorsOnExtensions(
30+
// [
31+
// 'ext-mbstring',
32+
// ],
33+
// [ErrorType::SHADOW_DEPENDENCY]
34+
// )
35+
->ignoreErrorsOnPackages(
36+
[
37+
'symfony/http-foundation',
38+
'symfony/http-kernel',
39+
'symfony/var-dumper',
40+
],
41+
[ErrorType::SHADOW_DEPENDENCY]
42+
)
43+
->ignoreErrorsOnPackages(
44+
[
45+
'guanguans/ai-commit',
46+
],
47+
[ErrorType::DEV_DEPENDENCY_IN_PROD]
48+
);

composer.json

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"phpstan/phpstan-webmozart-assert": "^2.0",
6565
"povils/phpmnd": "^3.5",
6666
"rector/rector": "^2.0",
67+
"shipmonk/composer-dependency-analyser": "^1.8",
6768
"shipmonk/phpstan-baseline-per-identifier": "^2.1",
6869
"spatie/pest-plugin-snapshots": "^1.1 || ^2.0",
6970
"spaze/phpstan-disallowed-calls": "^4.4",
@@ -117,6 +118,13 @@
117118
"forward-command": true,
118119
"target-directory": "vendor-bin"
119120
},
121+
"branch-alias": {
122+
"dev-main": "2.x-dev"
123+
},
124+
"composer-normalize": {
125+
"indent-size": 4,
126+
"indent-style": "space"
127+
},
120128
"hooks": {
121129
"post-merge": [
122130
"composer checks"
@@ -125,13 +133,6 @@
125133
"composer checks"
126134
]
127135
},
128-
"hyperf": {
129-
"plugin": {
130-
"sort-autoload": {
131-
"guanguans/ai-commit": -1
132-
}
133-
}
134-
},
135136
"laravel": {
136137
"aliases": {
137138
"ApiResponseFacade": "Guanguans\\LaravelApiResponse\\Facades\\ApiResponseFacade"
@@ -157,24 +158,28 @@
157158
"ai-commit-github-models": "@ai-commit --generator=github_models_cli",
158159
"ai-commit-github-models-no-verify": "@ai-commit-github-models --no-verify",
159160
"ai-commit-no-verify": "@ai-commit --no-verify",
160-
"benchmark": "@php ./vendor/bin/phpbench run --warmup=1 --retry-threshold=1 --iterations=3 --revs=5 --ansi -v",
161+
"benchmark": "@php ./vendor/bin/phpbench run --report=aggregate --ansi -v",
161162
"cghooks": "@php ./vendor/bin/cghooks --ansi -v",
163+
"cghooks-ignore": "[ ! -f \"./vendor/bin/cghooks\" ] && exit 0 || php ./vendor/bin/cghooks --ansi -v",
162164
"checks": [
163165
"@composer-normalize",
164166
"@composer-validate",
165-
"@composer-require-checker",
166-
"@composer-unused",
167167
"@yaml-lint",
168168
"@md-lint",
169169
"@facade-lint",
170170
"@style-lint",
171+
"@composer-dependency-analyser",
171172
"@phpmnd",
172173
"@test",
173174
"@phpstan",
174175
"@rector-dry-run"
175176
],
177+
"class-leak": "@php ./vendor/bin/class-leak --ansi -v",
178+
"class-leak-check": "@class-leak check ./config ./src --skip-suffix=Pipe --skip-path=Support/Traits --skip-type=\\Guanguans\\LaravelExceptionNotify\\Contracts\\Channel --skip-type=\\Guanguans\\LaravelExceptionNotify\\Contracts\\Collector --skip-type=Rector\\Rector\\AbstractRector",
179+
"composer-audit": "@composer audit --ansi -v",
176180
"composer-bin-all-update": "@composer bin all update --ansi -v",
177181
"composer-check-platform-reqs": "@composer check-platform-reqs --lock --ansi -v",
182+
"composer-dependency-analyser": "@php ./vendor/bin/composer-dependency-analyser --verbose",
178183
"composer-normalize": "@composer normalize --dry-run --diff --ansi -v",
179184
"composer-require-checker": "@php ./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json composer.json --ansi -v",
180185
"composer-require-checker-json": "@php ./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json composer.json --ansi -v --output=json | jq",
@@ -231,7 +236,9 @@
231236
"@putenv PHP83=/opt/homebrew/opt/php@8.3/bin/php",
232237
"@putenv PHP84=/opt/homebrew/opt/php@8.4/bin/php"
233238
],
234-
"rector": "@php ./vendor/bin/rector --clear-cache --ansi -v",
239+
"rector": "@php ./vendor/bin/rector --ansi -v",
240+
"rector-clear-cache": "@rector --clear-cache",
241+
"rector-clear-cache-dry-run": "@rector-clear-cache --dry-run",
235242
"rector-custom-rule": "@rector custom-rule",
236243
"rector-detect-node": "@rector detect-node --loop",
237244
"rector-dry-run": "@rector --dry-run",
@@ -246,6 +253,13 @@
246253
"release-minor-dry-run": "@release-minor --dry-run",
247254
"release-patch": "@release patch",
248255
"release-patch-dry-run": "@release-patch --dry-run",
256+
"sk": "@php ./vendor/bin/swiss-knife --ansi -v",
257+
"sk-check-commented-code": "@sk check-commented-code ./config ./src --line-limit=5",
258+
"sk-check-conflicts": "@sk check-conflicts ./config ./src",
259+
"sk-finalize-classes": "@sk finalize-classes ./config ./src",
260+
"sk-finalize-classes-dry-run": "@sk-finalize-classes --dry-run",
261+
"sk-find-multi-classes": "@sk find-multi-classes ./config ./src",
262+
"sk-namespace-to-psr-4": "@sk namespace-to-psr-4 ./src --namespace-root=Guanguans\\LaravelExceptionNotify\\",
249263
"style-fix": "@php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --show-progress=dots --diff --ansi -v",
250264
"style-lint": "@style-fix --diff --dry-run",
251265
"test": "@pest",
@@ -256,6 +270,8 @@
256270
"test-phpunit-coverage": "@test --coverage-html=./.build/phpunit/ --coverage-clover=clover.xml",
257271
"test-type-coverage": "@pest-type-coverage",
258272
"test-update-snapshots": "@pest-update-snapshots",
273+
"time-end": "@php -r 'date_default_timezone_set('\\''Asia/Shanghai'\\''); echo \"\\nTime: \".round(time() - (int) getenv('\\''START_TIME'\\'')).'\\'' seconds, Memory: '\\''.round(memory_get_peak_usage(true) / 1024 / 1024, 2).\" MB\\n\";'",
274+
"time-start": "@putenv START_TIME=$(date +%s);",
259275
"trufflehog": "trufflehog git https://github.com/guanguans/notify --only-verified",
260276
"yaml-lint": "@php ./vendor/bin/yaml-lint .github --ansi -v",
261277
"zh-fix": "@zh-lint --fix",

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
__DIR__.'/config',
5252
__DIR__.'/src',
5353
__DIR__.'/tests',
54+
...glob(__DIR__.'/{*,.*}.php', \GLOB_BRACE),
5455
__DIR__.'/composer-updater',
5556
])
5657
->withRootFiles()

vendor-bin/larastan/composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
{
2-
"require-dev": {
3-
"larastan/larastan": "^2.0"
4-
}
52
}

0 commit comments

Comments
 (0)