1+ #!/usr/bin/env node
2+
3+ const FLAVORS = [
4+ "alpine" ,
5+ "bullseye" ,
6+ ] ;
7+
8+ /**
9+ * @todo : load from https://github.com/FriendsOfShopware/shopware-static-data/pull/1
10+ */
11+ const PHP_VERSIONS = [
12+ "8.0" ,
13+ "8.1" ,
14+ "8.2" ,
15+ ] ;
16+
17+ const getTemplate = ( version ) => {
18+ const parts = version . match ( / v [ 0 . 9 ] * .\. ( [ 0 - 9 ] * ) \. .* / ) ;
19+ if ( parts . length < 2 ) {
20+ throw new Error ( "Unexpected version format: " + version ) ;
21+ }
22+
23+ const minor = parts [ 1 ] ;
24+ if ( parseInt ( minor ) <= 4 ) {
25+ return "https://github.com/shopware/production" ;
26+ }
27+
28+ return "https://github.com/shopware/platform" ;
29+ }
30+
31+ async function main ( ) {
32+ const response = await fetch ( "https://api.github.com/repos/shopware/platform/git/refs/tags" )
33+ const tags = await response . json ( ) ;
34+
35+ const versions = tags . map ( ( tag ) => {
36+ const version = tag . ref . replace ( "refs/tags/" , "" ) ;
37+ const parts = version . match ( / v [ 0 . 9 ] * .\. ( [ 0 - 9 ] * ) \. .* / ) ;
38+ if ( parts . length < 2 ) {
39+ return ;
40+ }
41+
42+ const minor = parts [ 1 ] ;
43+ // skip
44+ if ( parseInt ( minor ) <= 3 ) {
45+ return ;
46+ }
47+
48+ return version ;
49+ } ) . filter ( version => ! ! version ) ;
50+
51+ let matrix = versions . map ( ( version ) => {
52+ const template = getTemplate ( version ) ;
53+
54+ const matrix = [ ] ;
55+
56+ for ( let flavor in FLAVORS ) {
57+ for ( let phpVersion in PHP_VERSIONS ) {
58+ matrix . push ( {
59+ "shopware-version" : version ,
60+ "php-version" : phpVersion ,
61+ "flavour" : flavor ,
62+ "template" : template ,
63+ } )
64+ }
65+ }
66+
67+ return matrix ;
68+ } )
69+
70+ console . log ( JSON . stringify ( {
71+ include : matrix ,
72+ } ) ) ;
73+ }
74+
75+ main ( ) ;
0 commit comments