11import fs , { PathLike } from 'fs' ;
22import { Config } from './config/app' ;
3- import { ComposerJson } from './config/composer' ;
4- import parseJsonFile from './json' ;
53import { CONTAINER_DEFAULT_PHP_VERSION } from './config/php' ;
6-
7- export enum ToolExecutionType {
8- /**
9- * @description Executed on every supported PHP version with lowest & latest dependencies.
10- * In case, a lock-file is present, the minimum supported PHP version will also run with LOCKED
11- * dependencies.
12- */
13- MATRIX = 'matrix' ,
14-
15- /**
16- * @description Executed on the minimum PHP version with either LOCKED or LATEST dependencies.
17- */
18- STATIC = 'static' ,
19- }
20-
21- enum ToolType {
22- LINTER = 'linter' ,
23- CODE_CHECK = 'code_check' ,
24- }
4+ import { PHPUnitTool } from './tools/phpunit' ;
5+ import { InfectionTool } from './tools/infection' ;
6+ import { PhpCodeSnifferTool } from './tools/codesniffer' ;
7+ import { PsalmTool } from './tools/psalm' ;
8+ import { ComposerRequireCheckerTool } from './tools/composerRequireChecker' ;
9+ import { PhpBenchTool } from './tools/phpbench' ;
10+ import { CodeceptionTool } from './tools/codeception' ;
11+ import { PhpCsFixerTool } from './tools/phpCsFixer' ;
12+ import { PHPStanTool } from './tools/phpstan' ;
13+ import { ToolExecutionType } from './enum/toolExecutionType' ;
14+ import { ToolType } from './enum/toolType' ;
2515
2616export type Tool = {
2717 executionType : ToolExecutionType ,
@@ -36,16 +26,6 @@ export type ToolRunningContainerDefaultPhpVersion = Tool & {
3626 php : typeof CONTAINER_DEFAULT_PHP_VERSION ,
3727}
3828
39- function detectInfectionCommand ( ) : string {
40- const composerJson : ComposerJson = parseJsonFile ( 'composer.json' , true ) as ComposerJson ;
41-
42- if ( composerJson [ 'require-dev' ] ?. [ 'roave/infection-static-analysis-plugin' ] !== undefined ) {
43- return './vendor/bin/roave-infection-static-analysis-plugin' ;
44- }
45-
46- return './vendor/bin/infection' ;
47- }
48-
4929function backwardCompatibilityCheckTool ( config : Config ) : ToolRunningContainerDefaultPhpVersion | null {
5030 if ( ! config . backwardCompatibilityCheck ) {
5131 return null ;
@@ -95,72 +75,15 @@ export default function createTools(config: Config): Array<Tool> {
9575 filesToCheck : [ 'README.md' ] ,
9676 toolType : ToolType . LINTER ,
9777 } ,
98- {
99- executionType : ToolExecutionType . MATRIX ,
100- name : 'PHPUnit' ,
101- command : './vendor/bin/phpunit' ,
102- filesToCheck : [ 'phpunit.xml.dist' , 'phpunit.xml' ] ,
103- toolType : ToolType . CODE_CHECK ,
104- lintConfigCommand : 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd' ,
105- } ,
106- {
107- executionType : ToolExecutionType . STATIC ,
108- name : 'Infection' ,
109- command : detectInfectionCommand ( ) ,
110- filesToCheck : [ 'infection.json' , 'infection.json.dist' ] ,
111- toolType : ToolType . CODE_CHECK ,
112- } ,
113- {
114- executionType : ToolExecutionType . STATIC ,
115- name : 'PHPCodeSniffer' ,
116- command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr' ,
117- filesToCheck : [ 'phpcs.xml' , 'phpcs.xml.dist' ] ,
118- toolType : ToolType . CODE_CHECK ,
119- lintConfigCommand : 'xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd' ,
120- } ,
121- {
122- executionType : ToolExecutionType . STATIC ,
123- name : 'Psalm' ,
124- command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache' ,
125- filesToCheck : [ 'psalm.xml.dist' , 'psalm.xml' ] ,
126- toolType : ToolType . CODE_CHECK ,
127- lintConfigCommand : 'xmllint --schema vendor/vimeo/psalm/config.xsd' ,
128- } ,
129- {
130- executionType : ToolExecutionType . STATIC ,
131- name : 'Composer Require Checker' ,
132- command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json' ,
133- filesToCheck : [ 'composer-require-checker.json' ] ,
134- toolType : ToolType . CODE_CHECK ,
135- } ,
136- {
137- executionType : ToolExecutionType . STATIC ,
138- name : 'PHPBench' ,
139- command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate' ,
140- filesToCheck : [ 'phpbench.json' ] ,
141- toolType : ToolType . CODE_CHECK ,
142- } ,
143- {
144- executionType : ToolExecutionType . STATIC ,
145- name : 'Codeception' ,
146- command : './vendor/bin/codecept run' ,
147- filesToCheck : [ 'codeception.yml.dist' , 'codeception.yml' ] ,
148- toolType : ToolType . CODE_CHECK ,
149- } ,
150- {
151- executionType : ToolExecutionType . STATIC ,
152- name : 'PHP CS Fixer' ,
153- command : './vendor/bin/php-cs-fixer fix -v --diff --dry-run' ,
154- filesToCheck : [ '.php-cs-fixer.php' , '.php-cs-fixer.dist.php' ] ,
155- toolType : ToolType . CODE_CHECK ,
156- } ,
157- {
158- executionType : ToolExecutionType . STATIC ,
159- name : 'PHPStan' ,
160- command : './vendor/bin/phpstan analyse --error-format=github --ansi --no-progress' ,
161- filesToCheck : [ 'phpstan.neon' , 'phpstan.neon.dist' , 'phpstan.dist.neon' ] ,
162- toolType : ToolType . CODE_CHECK ,
163- } ,
78+ PHPUnitTool ,
79+ InfectionTool ,
80+ PhpCodeSnifferTool ,
81+ PsalmTool ,
82+ ComposerRequireCheckerTool ,
83+ PhpBenchTool ,
84+ CodeceptionTool ,
85+ PhpCsFixerTool ,
86+ PHPStanTool ,
16487 backwardCompatibilityCheckTool ( config ) ,
16588 ] . filter ( ( tool ) => tool !== null ) as Tool [ ] ;
16689
0 commit comments