@@ -2,7 +2,7 @@ import * as core from '@actions/core';
22import * as tc from '@actions/tool-cache' ;
33import semver from 'semver' ;
44import fs from 'fs' ;
5- import { OutgoingHttpHeaders } from 'http' ;
5+ import { OutgoingHttpHeaders } from 'http' ;
66import path from 'path' ;
77import {
88 convertVersionToSemver ,
@@ -11,13 +11,13 @@ import {
1111 getGitHubHttpHeaders ,
1212 isVersionSatisfies
1313} from '../../util' ;
14- import { JavaBase } from '../base-installer' ;
14+ import { JavaBase } from '../base-installer' ;
1515import {
1616 JavaDownloadRelease ,
1717 JavaInstallerOptions ,
1818 JavaInstallerResults
1919} from '../base-models' ;
20- import { ISapMachineAllVersions , ISapMachineVersions } from './models' ;
20+ import { ISapMachineAllVersions , ISapMachineVersions } from './models' ;
2121
2222export class SapMachineDistribution extends JavaBase {
2323 constructor ( installerOptions : JavaInstallerOptions ) {
@@ -27,10 +27,12 @@ export class SapMachineDistribution extends JavaBase {
2727 protected async findPackageForDownload (
2828 version : string
2929 ) : Promise < JavaDownloadRelease > {
30- core . debug ( `Only stable versions: ${ this . stable } ` )
30+ core . debug ( `Only stable versions: ${ this . stable } ` ) ;
3131
3232 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+ ) ;
3436 }
3537
3638 const availableVersions = await this . getAvailableVersions ( ) ;
@@ -60,10 +62,15 @@ export class SapMachineDistribution extends JavaBase {
6062 const platform = this . getPlatformOption ( ) ;
6163 const arch = this . distributionArchitecture ( ) ;
6264
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+ ) ;
6468
6569 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+ ) ;
6774 }
6875
6976 if ( ! fetchedReleasesJson ) {
@@ -117,29 +124,42 @@ export class SapMachineDistribution extends JavaBase {
117124 this . architecture
118125 ) ;
119126
120- return { version : javaRelease . version , path : javaPath } ;
127+ return { version : javaRelease . version , path : javaPath } ;
121128 }
122129
123130 private parseVersions (
124131 platform : string ,
125132 arch : string ,
126- versions : ISapMachineAllVersions ,
133+ versions : ISapMachineAllVersions
127134 ) : ISapMachineVersions [ ] {
128135 const eligibleVersions : ISapMachineVersions [ ] = [ ] ;
129136
130137 for ( const [ , majorVersionMap ] of Object . entries ( versions ) ) {
131138 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+ ) ;
134146 if ( ! buildVersionWithoutPrefix . includes ( '.' ) ) {
135147 // 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+ ) ;
137152 }
138153 // replace + with . to convert to semver format if we have more than 3 version digits
139154 if ( buildVersionWithoutPrefix . split ( '.' ) . length > 3 ) {
140- buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace ( '+' , '.' ) ;
155+ buildVersionWithoutPrefix = buildVersionWithoutPrefix . replace (
156+ '+' ,
157+ '.'
158+ ) ;
141159 }
142- buildVersionWithoutPrefix = convertVersionToSemver ( buildVersionWithoutPrefix ) ;
160+ buildVersionWithoutPrefix = convertVersionToSemver (
161+ buildVersionWithoutPrefix
162+ ) ;
143163
144164 // ignore invalid version
145165 if ( ! semver . valid ( buildVersionWithoutPrefix ) ) {
@@ -148,23 +168,29 @@ export class SapMachineDistribution extends JavaBase {
148168 }
149169
150170 // skip earlyAccessVersions if stable version requested
151- if ( this . stable && buildVersionMap . ea === " true" ) {
171+ if ( this . stable && buildVersionMap . ea === ' true' ) {
152172 continue ;
153173 }
154174
155- for ( const [ edition , editionAssets ] of Object . entries ( buildVersionMap . assets ) ) {
175+ for ( const [ edition , editionAssets ] of Object . entries (
176+ buildVersionMap . assets
177+ ) ) {
156178 if ( this . packageType !== edition ) {
157179 continue ;
158180 }
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 } ` ;
161185 if ( platform === 'linux-musl' ) {
162- expectedArchAndPlatform = `linux-${ arch } -musl`
186+ expectedArchAndPlatform = `linux-${ arch } -musl` ;
163187 }
164188 if ( archAndPlatForm !== expectedArchAndPlatform ) {
165- continue
189+ continue ;
166190 }
167- for ( const [ contentType , contentTypeAssets ] of Object . entries ( archAssets ) ) {
191+ for ( const [ contentType , contentTypeAssets ] of Object . entries (
192+ archAssets
193+ ) ) {
168194 // skip if not tar.gz and zip files
169195 if ( contentType !== 'tar.gz' && contentType !== 'zip' ) {
170196 continue ;
@@ -175,7 +201,7 @@ export class SapMachineDistribution extends JavaBase {
175201 version : buildVersionWithoutPrefix ,
176202 checksum : contentTypeAssets . checksum ,
177203 downloadLink : contentTypeAssets . url ,
178- packageType : edition ,
204+ packageType : edition
179205 } ) ;
180206 }
181207 }
@@ -206,7 +232,7 @@ export class SapMachineDistribution extends JavaBase {
206232 case 'win32' :
207233 return 'windows' ;
208234 case 'darwin' :
209- return 'macos'
235+ return 'macos' ;
210236 case 'linux' :
211237 // figure out if alpine/musl
212238 if ( fs . existsSync ( '/etc/alpine-release' ) ) {
@@ -218,7 +244,10 @@ export class SapMachineDistribution extends JavaBase {
218244 }
219245 }
220246
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 > {
222251 try {
223252 core . debug (
224253 `Trying to fetch available SapMachine versions info from the primary url: ${ url } `
@@ -229,7 +258,8 @@ export class SapMachineDistribution extends JavaBase {
229258 return releases ;
230259 } catch ( err ) {
231260 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
233263 } `
234264 ) ;
235265 return null ;
0 commit comments