Compare commits

...

2 Commits

Author SHA1 Message Date
Ivan Zosimov
4259d72e25 chore: refactor code 2023-09-20 11:48:35 +02:00
Ivan Zosimov
3fd8616c89 chore: update wordings 2023-09-20 11:15:37 +02:00
3 changed files with 28 additions and 41 deletions

View File

@ -202,7 +202,7 @@ describe('getAvailableVersions', () => {
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow(
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}".`
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
);
}
);
@ -218,7 +218,6 @@ describe('getAvailableVersions', () => {
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow('Dragonwell provides only the `jdk` package type');

32
dist/setup/index.js vendored
View File

@ -102656,7 +102656,7 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
findPackageForDownload(version) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.stable) {
throw new Error('Early access versions are not supported');
throw new Error('Early access versions are not supported by Dragonwell');
}
if (this.packageType !== 'jdk') {
throw new Error('Dragonwell provides only the `jdk` package type');
@ -102673,7 +102673,7 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
};
});
if (!matchedVersions.length) {
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}".`);
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`);
}
const resolvedVersion = matchedVersions[0];
return resolvedVersion;
@ -102688,9 +102688,9 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl();
}
if (!fetchedDragonwellJson) {
throw new Error(`Couldn't fetch dragonwell versions information from both primary and backup urls`);
throw new Error(`Couldn't fetch Dragonwell versions information from both primary and backup urls`);
}
core.debug('Successfully fetched information about available dragonwell versions');
core.debug('Successfully fetched information about available Dragonwell versions');
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellJson);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
@ -102731,8 +102731,10 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
if (jdkVersion === 'latest') {
continue;
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
jdkVersion = util_1.convertVersionToSemver(jdkVersion);
}
for (const edition in archMap) {
eligibleVersions.push({
@ -102760,14 +102762,6 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
});
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
transformToSemver(version) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
}
getPlatformOption() {
switch (process.platform) {
case 'win32':
@ -102780,12 +102774,12 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
return __awaiter(this, void 0, void 0, function* () {
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
try {
core.debug(`Trying to fetch available versions info from the primary url: ${primaryUrl}`);
core.debug(`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`);
const fetchedDragonwellJson = (yield this.http.getJson(primaryUrl)).result;
return fetchedDragonwellJson;
}
catch (err) {
core.debug(`Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`);
core.debug(`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`);
return null;
}
});
@ -102799,12 +102793,12 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
const headers = util_1.getGitHubHttpHeaders();
try {
core.debug(`Trying to fetch available versions info from the backup url: ${backupUrl}`);
const fetchedDragonwellVersions = (yield this.http.getJson(backupUrl, headers)).result;
return fetchedDragonwellVersions;
core.debug(`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`);
const fetchedDragonwellJson = (yield this.http.getJson(backupUrl, headers)).result;
return fetchedDragonwellJson;
}
catch (err) {
core.debug(`Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`);
core.debug(`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`);
return null;
}
});

View File

@ -7,6 +7,7 @@ import path from 'path';
import {JavaBase} from '../base-installer';
import {
convertVersionToSemver,
extractJdkFile,
getDownloadArchiveExtension,
getGitHubHttpHeaders,
@ -28,7 +29,7 @@ export class DragonwellDistribution extends JavaBase {
version: string
): Promise<JavaDownloadRelease> {
if (!this.stable) {
throw new Error('Early access versions are not supported');
throw new Error('Early access versions are not supported by Dragonwell');
}
if (this.packageType !== 'jdk') {
@ -50,7 +51,7 @@ export class DragonwellDistribution extends JavaBase {
if (!matchedVersions.length) {
throw new Error(
`Couldn't find any satisfied version for the specified java-version: "${version}".`
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
);
}
@ -70,12 +71,12 @@ export class DragonwellDistribution extends JavaBase {
if (!fetchedDragonwellJson) {
throw new Error(
`Couldn't fetch dragonwell versions information from both primary and backup urls`
`Couldn't fetch Dragonwell versions information from both primary and backup urls`
);
}
core.debug(
'Successfully fetched information about available dragonwell versions'
'Successfully fetched information about available Dragonwell versions'
);
const availableVersions = this.parseVersions(
@ -146,8 +147,10 @@ export class DragonwellDistribution extends JavaBase {
continue;
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
jdkVersion = convertVersionToSemver(jdkVersion);
}
for (const edition in archMap) {
@ -182,15 +185,6 @@ export class DragonwellDistribution extends JavaBase {
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
private transformToSemver(version: string) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
}
private getPlatformOption(): string {
switch (process.platform) {
case 'win32':
@ -204,7 +198,7 @@ export class DragonwellDistribution extends JavaBase {
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
try {
core.debug(
`Trying to fetch available versions info from the primary url: ${primaryUrl}`
`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`
);
const fetchedDragonwellJson = (
await this.http.getJson<IDragonwellAllVersions>(primaryUrl)
@ -212,7 +206,7 @@ export class DragonwellDistribution extends JavaBase {
return fetchedDragonwellJson;
} catch (err) {
core.debug(
`Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
);
return null;
}
@ -230,15 +224,15 @@ export class DragonwellDistribution extends JavaBase {
try {
core.debug(
`Trying to fetch available versions info from the backup url: ${backupUrl}`
`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`
);
const fetchedDragonwellVersions = (
const fetchedDragonwellJson = (
await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers)
).result;
return fetchedDragonwellVersions;
return fetchedDragonwellJson;
} catch (err) {
core.debug(
`Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`
`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`
);
return null;
}