@@ -2,7 +2,7 @@ import * as core from '@actions/core';
2
2
import * as tc from '@actions/tool-cache' ;
3
3
import semver from 'semver' ;
4
4
import fs from 'fs' ;
5
- import { OutgoingHttpHeaders } from 'http' ;
5
+ import { OutgoingHttpHeaders } from 'http' ;
6
6
import path from 'path' ;
7
7
import {
8
8
convertVersionToSemver ,
@@ -11,13 +11,13 @@ import {
11
11
getGitHubHttpHeaders ,
12
12
isVersionSatisfies
13
13
} from '../../util' ;
14
- import { JavaBase } from '../base-installer' ;
14
+ import { JavaBase } from '../base-installer' ;
15
15
import {
16
16
JavaDownloadRelease ,
17
17
JavaInstallerOptions ,
18
18
JavaInstallerResults
19
19
} from '../base-models' ;
20
- import { ISapMachineAllVersions , ISapMachineVersions } from './models' ;
20
+ import { ISapMachineAllVersions , ISapMachineVersions } from './models' ;
21
21
22
22
export class SapMachineDistribution extends JavaBase {
23
23
constructor ( installerOptions : JavaInstallerOptions ) {
@@ -27,10 +27,12 @@ export class SapMachineDistribution extends JavaBase {
27
27
protected async findPackageForDownload (
28
28
version : string
29
29
) : Promise < JavaDownloadRelease > {
30
- core . debug ( `Only stable versions: ${ this . stable } ` )
30
+ core . debug ( `Only stable versions: ${ this . stable } ` ) ;
31
31
32
32
if ( ! [ 'jdk' , 'jre' ] . includes ( this . packageType ) ) {
33
- throw new Error ( 'SapMachine provides only the `jdk` and `jre` package type' ) ;
33
+ throw new Error (
34
+ 'SapMachine provides only the `jdk` and `jre` package type'
35
+ ) ;
34
36
}
35
37
36
38
const availableVersions = await this . getAvailableVersions ( ) ;
@@ -60,10 +62,15 @@ export class SapMachineDistribution extends JavaBase {
60
62
const platform = this . getPlatformOption ( ) ;
61
63
const arch = this . distributionArchitecture ( ) ;
62
64
63
- let fetchedReleasesJson = await this . fetchReleasesFromUrl ( 'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json' )
65
+ let fetchedReleasesJson = await this . fetchReleasesFromUrl (
66
+ 'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
67
+ ) ;
64
68
65
69
if ( ! fetchedReleasesJson ) {
66
- fetchedReleasesJson = await this . fetchReleasesFromUrl ( 'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages' , getGitHubHttpHeaders ( ) ) ;
70
+ fetchedReleasesJson = await this . fetchReleasesFromUrl (
71
+ 'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages' ,
72
+ getGitHubHttpHeaders ( )
73
+ ) ;
67
74
}
68
75
69
76
if ( ! fetchedReleasesJson ) {
@@ -117,29 +124,42 @@ export class SapMachineDistribution extends JavaBase {
117
124
this . architecture
118
125
) ;
119
126
120
- return { version : javaRelease . version , path : javaPath } ;
127
+ return { version : javaRelease . version , path : javaPath } ;
121
128
}
122
129
123
130
private parseVersions (
124
131
platform : string ,
125
132
arch : string ,
126
- versions : ISapMachineAllVersions ,
133
+ versions : ISapMachineAllVersions
127
134
) : ISapMachineVersions [ ] {
128
135
const eligibleVersions : ISapMachineVersions [ ] = [ ] ;
129
136
130
137
for ( const [ , majorVersionMap ] of Object . entries ( versions ) ) {
131
138
for ( const [ , jdkVersionMap ] of Object . entries ( majorVersionMap . updates ) ) {
132
- for ( const [ buildVersion , buildVersionMap ] of Object . entries ( jdkVersionMap ) ) {
133
- let buildVersionWithoutPrefix = buildVersion . replace ( 'sapmachine-' , '' ) ;
139
+ for ( const [ buildVersion , buildVersionMap ] of Object . entries (
140
+ jdkVersionMap
141
+ ) ) {
142
+ let buildVersionWithoutPrefix = buildVersion . replace (
143
+ 'sapmachine-' ,
144
+ ''
145
+ ) ;
134
146
if ( ! buildVersionWithoutPrefix . includes ( '.' ) ) {
135
147
// replace major version with major.minor.patch and keep the remaining build identifier after the + as is with regex
136
- buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace ( / ( \d + ) ( \+ .* ) ? / , '$1.0.0$2' ) ;
148
+ buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace (
149
+ / ( \d + ) ( \+ .* ) ? / ,
150
+ '$1.0.0$2'
151
+ ) ;
137
152
}
138
153
// replace + with . to convert to semver format if we have more than 3 version digits
139
154
if ( buildVersionWithoutPrefix . split ( '.' ) . length > 3 ) {
140
- buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace ( '+' , '.' ) ;
155
+ buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace (
156
+ '+' ,
157
+ '.'
158
+ ) ;
141
159
}
142
- buildVersionWithoutPrefix = convertVersionToSemver ( buildVersionWithoutPrefix ) ;
160
+ buildVersionWithoutPrefix = convertVersionToSemver (
161
+ buildVersionWithoutPrefix
162
+ ) ;
143
163
144
164
// ignore invalid version
145
165
if ( ! semver . valid ( buildVersionWithoutPrefix ) ) {
@@ -148,23 +168,29 @@ export class SapMachineDistribution extends JavaBase {
148
168
}
149
169
150
170
// skip earlyAccessVersions if stable version requested
151
- if ( this . stable && buildVersionMap . ea === " true" ) {
171
+ if ( this . stable && buildVersionMap . ea === ' true' ) {
152
172
continue ;
153
173
}
154
174
155
- for ( const [ edition , editionAssets ] of Object . entries ( buildVersionMap . assets ) ) {
175
+ for ( const [ edition , editionAssets ] of Object . entries (
176
+ buildVersionMap . assets
177
+ ) ) {
156
178
if ( this . packageType !== edition ) {
157
179
continue ;
158
180
}
159
- for ( const [ archAndPlatForm , archAssets ] of Object . entries ( editionAssets ) ) {
160
- let expectedArchAndPlatform = `${ platform } -${ arch } `
181
+ for ( const [ archAndPlatForm , archAssets ] of Object . entries (
182
+ editionAssets
183
+ ) ) {
184
+ let expectedArchAndPlatform = `${ platform } -${ arch } ` ;
161
185
if ( platform === 'linux-musl' ) {
162
- expectedArchAndPlatform = `linux-${ arch } -musl`
186
+ expectedArchAndPlatform = `linux-${ arch } -musl` ;
163
187
}
164
188
if ( archAndPlatForm !== expectedArchAndPlatform ) {
165
- continue
189
+ continue ;
166
190
}
167
- for ( const [ contentType , contentTypeAssets ] of Object . entries ( archAssets ) ) {
191
+ for ( const [ contentType , contentTypeAssets ] of Object . entries (
192
+ archAssets
193
+ ) ) {
168
194
// skip if not tar.gz and zip files
169
195
if ( contentType !== 'tar.gz' && contentType !== 'zip' ) {
170
196
continue ;
@@ -175,7 +201,7 @@ export class SapMachineDistribution extends JavaBase {
175
201
version : buildVersionWithoutPrefix ,
176
202
checksum : contentTypeAssets . checksum ,
177
203
downloadLink : contentTypeAssets . url ,
178
- packageType : edition ,
204
+ packageType : edition
179
205
} ) ;
180
206
}
181
207
}
@@ -206,7 +232,7 @@ export class SapMachineDistribution extends JavaBase {
206
232
case 'win32' :
207
233
return 'windows' ;
208
234
case 'darwin' :
209
- return 'macos'
235
+ return 'macos' ;
210
236
case 'linux' :
211
237
// figure out if alpine/musl
212
238
if ( fs . existsSync ( '/etc/alpine-release' ) ) {
@@ -218,7 +244,10 @@ export class SapMachineDistribution extends JavaBase {
218
244
}
219
245
}
220
246
221
- private async fetchReleasesFromUrl ( url : string , headers : OutgoingHttpHeaders = { } ) : Promise < ISapMachineAllVersions | null > {
247
+ private async fetchReleasesFromUrl (
248
+ url : string ,
249
+ headers : OutgoingHttpHeaders = { }
250
+ ) : Promise < ISapMachineAllVersions | null > {
222
251
try {
223
252
core . debug (
224
253
`Trying to fetch available SapMachine versions info from the primary url: ${ url } `
@@ -229,7 +258,8 @@ export class SapMachineDistribution extends JavaBase {
229
258
return releases ;
230
259
} catch ( err ) {
231
260
core . debug (
232
- `Fetching SapMachine versions info from the link: ${ url } ended up with the error: ${ ( err as Error ) . message
261
+ `Fetching SapMachine versions info from the link: ${ url } ended up with the error: ${
262
+ ( err as Error ) . message
233
263
} `
234
264
) ;
235
265
return null ;
0 commit comments