11import fs , { PathLike } from 'fs' ;
2- import semver from 'semver' ;
32import parseJsonFile from '../json' ;
43import { Tool , ToolExecutionType } from '../tools' ;
54import { Logger } from '../logging' ;
65import { CURRENT_STABLE , INSTALLABLE_VERSIONS , InstallablePhpVersionType , isInstallableVersion } from './php' ;
76import { ComposerJson } from './composer' ;
87import { ConfigurationFromFile , isAdditionalChecksConfiguration , isAnyComposerDependencySet , isAnyPhpVersionType , isConfigurationContainingJobExclusions , isExplicitChecksConfiguration , isLatestPhpVersionType , isLowestPhpVersionType , JobDefinitionFromFile , JobFromFile , JobToExcludeFromFile } from './input' ;
8+ import { satisfies } from "../semver" ;
99
1010export const OPERATING_SYSTEM = 'ubuntu-latest' ;
1111export const ACTION = 'laminas/laminas-continuous-integration-action@v1' ;
@@ -16,19 +16,29 @@ export enum ComposerDependencySet {
1616 LATEST = 'latest' ,
1717}
1818
19- function gatherVersions ( composerJson : ComposerJson ) : InstallablePhpVersionType [ ] {
19+ function gatherVersions ( composerJson : ComposerJson , logger : Logger ) : InstallablePhpVersionType [ ] {
2020 if ( JSON . stringify ( composerJson ) === '{}' ) {
21+ logger . debug ( 'The composer.json file is either empty or does not exist.' ) ;
2122 return [ ] ;
2223 }
2324
2425 const composerPhpVersion : string = ( composerJson . require ?. php ?? '' ) . replace ( / , \s / , ' ' ) ;
2526
2627 if ( composerPhpVersion === '' ) {
28+ logger . debug ( '`composer.json` does not contain any PHP requirement.' ) ;
2729 return [ ] ;
2830 }
2931
3032 return INSTALLABLE_VERSIONS
31- . filter ( ( version ) => semver . satisfies ( `${ version } .0` , composerPhpVersion ) ) ;
33+ . filter ( ( version ) => {
34+ if ( satisfies ( `${ version } .0` , composerPhpVersion ) ) {
35+ logger . debug ( `PHP ${ version } is supported by projects \`composer.json\`!` )
36+ return true ;
37+ }
38+
39+ logger . debug ( `PHP ${ version } is NOT supported by projects \`composer.json\`!` )
40+ return false ;
41+ } ) ;
3242}
3343
3444function gatherExtensions ( composerJson : ComposerJson ) : Set < string > {
@@ -418,12 +428,13 @@ export default function createConfig(
418428 requirements : Requirements ,
419429 composerJsonFileName : PathLike ,
420430 composerLockJsonFileName : PathLike ,
421- continousIntegrationConfigurationJsonFileName : PathLike
431+ continousIntegrationConfigurationJsonFileName : PathLike ,
432+ logger : Logger
422433) : Config {
423434 const composerJson : ComposerJson = parseJsonFile ( composerJsonFileName ) as ComposerJson ;
424435 const configurationFromFile : ConfigurationFromFile =
425436 parseJsonFile ( continousIntegrationConfigurationJsonFileName ) as ConfigurationFromFile ;
426- const phpVersionsSupportedByProject : InstallablePhpVersionType [ ] = gatherVersions ( composerJson ) ;
437+ const phpVersionsSupportedByProject : InstallablePhpVersionType [ ] = gatherVersions ( composerJson , logger ) ;
427438 let phpExtensions : Set < string > = gatherExtensions ( composerJson ) ;
428439 let stablePHPVersion : InstallablePhpVersionType = CURRENT_STABLE ;
429440
0 commit comments