1
1
import fs , { PathLike } from 'fs' ;
2
- import semver from 'semver' ;
3
2
import parseJsonFile from '../json' ;
4
3
import { Tool , ToolExecutionType } from '../tools' ;
5
4
import { Logger } from '../logging' ;
6
5
import { CURRENT_STABLE , INSTALLABLE_VERSIONS , InstallablePhpVersionType , isInstallableVersion } from './php' ;
7
6
import { ComposerJson } from './composer' ;
8
7
import { ConfigurationFromFile , isAdditionalChecksConfiguration , isAnyComposerDependencySet , isAnyPhpVersionType , isConfigurationContainingJobExclusions , isExplicitChecksConfiguration , isLatestPhpVersionType , isLowestPhpVersionType , JobDefinitionFromFile , JobFromFile , JobToExcludeFromFile } from './input' ;
8
+ import { satisfies } from "../semver" ;
9
9
10
10
export const OPERATING_SYSTEM = 'ubuntu-latest' ;
11
11
export const ACTION = 'laminas/laminas-continuous-integration-action@v1' ;
@@ -16,19 +16,29 @@ export enum ComposerDependencySet {
16
16
LATEST = 'latest' ,
17
17
}
18
18
19
- function gatherVersions ( composerJson : ComposerJson ) : InstallablePhpVersionType [ ] {
19
+ function gatherVersions ( composerJson : ComposerJson , logger : Logger ) : InstallablePhpVersionType [ ] {
20
20
if ( JSON . stringify ( composerJson ) === '{}' ) {
21
+ logger . debug ( 'The composer.json file is either empty or does not exist.' ) ;
21
22
return [ ] ;
22
23
}
23
24
24
25
const composerPhpVersion : string = ( composerJson . require ?. php ?? '' ) . replace ( / , \s / , ' ' ) ;
25
26
26
27
if ( composerPhpVersion === '' ) {
28
+ logger . debug ( '`composer.json` does not contain any PHP requirement.' ) ;
27
29
return [ ] ;
28
30
}
29
31
30
32
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
+ } ) ;
32
42
}
33
43
34
44
function gatherExtensions ( composerJson : ComposerJson ) : Set < string > {
@@ -418,12 +428,13 @@ export default function createConfig(
418
428
requirements : Requirements ,
419
429
composerJsonFileName : PathLike ,
420
430
composerLockJsonFileName : PathLike ,
421
- continousIntegrationConfigurationJsonFileName : PathLike
431
+ continousIntegrationConfigurationJsonFileName : PathLike ,
432
+ logger : Logger
422
433
) : Config {
423
434
const composerJson : ComposerJson = parseJsonFile ( composerJsonFileName ) as ComposerJson ;
424
435
const configurationFromFile : ConfigurationFromFile =
425
436
parseJsonFile ( continousIntegrationConfigurationJsonFileName ) as ConfigurationFromFile ;
426
- const phpVersionsSupportedByProject : InstallablePhpVersionType [ ] = gatherVersions ( composerJson ) ;
437
+ const phpVersionsSupportedByProject : InstallablePhpVersionType [ ] = gatherVersions ( composerJson , logger ) ;
427
438
let phpExtensions : Set < string > = gatherExtensions ( composerJson ) ;
428
439
let stablePHPVersion : InstallablePhpVersionType = CURRENT_STABLE ;
429
440
0 commit comments