1
1
#!/usr/bin/env node
2
2
3
- const FLAVORS = [
3
+ const FLAVOURS = [
4
4
"alpine" ,
5
5
"bullseye" ,
6
6
] ;
@@ -10,19 +10,16 @@ const FLAVORS = [
10
10
*/
11
11
const HARDCODED_MATRIX = [
12
12
{
13
- "shopware-version" : "6.4" ,
14
- "php-version" : "8.1" ,
15
- "template" : "https://github.com/shopware/shopware" ,
13
+ "shopwareVersion" : "6.4" ,
14
+ "phpVersions" : [ "8.1" , "8.2" ] ,
16
15
} ,
17
16
{
18
- "shopware-version" : "6.5.x" ,
19
- "php-version" : "8.1" ,
20
- "template" : "https://github.com/shopware/shopware" ,
17
+ "shopwareVersion" : "6.5.x" ,
18
+ "phpVersions" : [ "8.1" , "8.2" , "8.3" ] ,
21
19
} ,
22
20
{
23
- "shopware-version" : "trunk" ,
24
- "php-version" : "8.2" ,
25
- "template" : "https://github.com/shopware/shopware" ,
21
+ "shopwareVersion" : "trunk" ,
22
+ "phpVersions" : [ "8.2" , "8.3" ] ,
26
23
} ,
27
24
] ;
28
25
@@ -50,16 +47,32 @@ const parseMinorVersion = (version) => {
50
47
}
51
48
52
49
const getTemplate = ( version ) => {
53
- const minor = parseMinorVersion ( version ) ;
50
+ try {
51
+ const minor = parseMinorVersion ( version ) ;
54
52
55
- // For everything below 6.5, we need the shopware/production template.
56
- if ( minor <= 4 ) {
57
- return "https://github.com/shopware/production" ;
53
+ // For everything below 6.5, we need the shopware/production template.
54
+ if ( minor <= 4 ) {
55
+ return "https://github.com/shopware/production" ;
56
+ }
57
+ } catch ( e ) {
58
+ // Ignore
58
59
}
59
60
60
61
return "https://github.com/shopware/shopware" ;
61
62
}
62
63
64
+ function addMatrixEntries ( matrix , shopwareVersion , phpVersion , isMain ) {
65
+ FLAVOURS . forEach ( ( flavour ) => {
66
+ matrix . push ( {
67
+ "shopware-version" : shopwareVersion ,
68
+ "php-version" : phpVersion ,
69
+ "flavour" : flavour ,
70
+ "template" : getTemplate ( shopwareVersion ) ,
71
+ "is-main" : isMain ,
72
+ } ) ;
73
+ } ) ;
74
+ }
75
+
63
76
async function main ( ) {
64
77
const minPHPVersion = await loadMinPHPVersion ( ) ;
65
78
@@ -84,22 +97,17 @@ async function main() {
84
97
85
98
}
86
99
87
- let matrix = [ ] ;
100
+ if ( Object . entries ( shopwareMinorVersions ) . length === 0 ) {
101
+ throw new Error ( "No shopwareMinorVersions entries generated." ) ;
102
+ }
88
103
89
- for ( const [ _ , line ] of Object . entries ( shopwareMinorVersions ) ) {
90
- const minPhpVersions = line . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
104
+ let matrix = [ ] ;
91
105
92
- if ( minPhpVersions . length === 0 ) {
93
- continue ;
94
- }
106
+ for ( const [ _ , entry ] of Object . entries ( shopwareMinorVersions ) ) {
107
+ const supportedPhpVersions = entry . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
95
108
96
- FLAVORS . forEach ( ( flavor ) => {
97
- matrix . push ( {
98
- "shopware-version" : 'v' + line . shopwareVersion ,
99
- "php-version" : minPhpVersions [ 0 ] ,
100
- "flavour" : flavor ,
101
- "template" : getTemplate ( line . shopwareVersion ) ,
102
- } ) ;
109
+ supportedPhpVersions . forEach ( ( phpVersion , i ) => {
110
+ addMatrixEntries ( matrix , 'v' + entry . shopwareVersion , phpVersion , i === supportedPhpVersions . length - 1 ) ;
103
111
} ) ;
104
112
}
105
113
@@ -108,10 +116,10 @@ async function main() {
108
116
}
109
117
110
118
HARDCODED_MATRIX . forEach ( ( entry ) => {
111
- FLAVORS . forEach ( ( flavor ) => {
112
- entry . flavour = flavor ;
119
+ const supportedPhpVersions = entry . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
113
120
114
- matrix . push ( entry ) ;
121
+ supportedPhpVersions . forEach ( ( phpVersion , i ) => {
122
+ addMatrixEntries ( matrix , entry . shopwareVersion , phpVersion , i === supportedPhpVersions . length - 1 ) ;
115
123
} ) ;
116
124
} ) ;
117
125
0 commit comments