Compare commits

..

No commits in common. "4259d72e25d0d91502d7b39dbc6253a8e2c13bc7" and "2e4e4de3b40545707193845e18b18d0fb7cfb4e5" have entirely different histories.

3 changed files with 41 additions and 28 deletions

View File

@ -202,7 +202,7 @@ describe('getAvailableVersions', () => {
await expect( await expect(
distribution['findPackageForDownload'](jdkVersion) distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow( ).rejects.toThrow(
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".` `Couldn't find any satisfied version for the specified java-version: "${jdkVersion}".`
); );
} }
); );
@ -218,6 +218,7 @@ describe('getAvailableVersions', () => {
checkLatest: false checkLatest: false
}); });
mockPlatform(distribution, platform); mockPlatform(distribution, platform);
await expect( await expect(
distribution['findPackageForDownload'](jdkVersion) distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow('Dragonwell provides only the `jdk` package type'); ).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) { findPackageForDownload(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!this.stable) { if (!this.stable) {
throw new Error('Early access versions are not supported by Dragonwell'); throw new Error('Early access versions are not supported');
} }
if (this.packageType !== 'jdk') { if (this.packageType !== 'jdk') {
throw new Error('Dragonwell provides only the `jdk` package type'); throw new Error('Dragonwell provides only the `jdk` package type');
@ -102673,7 +102673,7 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
}; };
}); });
if (!matchedVersions.length) { if (!matchedVersions.length) {
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`); throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}".`);
} }
const resolvedVersion = matchedVersions[0]; const resolvedVersion = matchedVersions[0];
return resolvedVersion; return resolvedVersion;
@ -102688,9 +102688,9 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl(); fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl();
} }
if (!fetchedDragonwellJson) { 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); const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellJson);
if (core.isDebug()) { if (core.isDebug()) {
core.startGroup('Print information about available versions'); core.startGroup('Print information about available versions');
@ -102731,10 +102731,8 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
if (jdkVersion === 'latest') { if (jdkVersion === 'latest') {
continue; 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) { if (jdkVersion.split('.').length > 3) {
jdkVersion = util_1.convertVersionToSemver(jdkVersion); jdkVersion = this.transformToSemver(jdkVersion);
} }
for (const edition in archMap) { for (const edition in archMap) {
eligibleVersions.push({ eligibleVersions.push({
@ -102762,6 +102760,14 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
}); });
return sortedVersions.reverse(); 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() { getPlatformOption() {
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':
@ -102774,12 +102780,12 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json'; const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
try { try {
core.debug(`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`); core.debug(`Trying to fetch available versions info from the primary url: ${primaryUrl}`);
const fetchedDragonwellJson = (yield this.http.getJson(primaryUrl)).result; const fetchedDragonwellJson = (yield this.http.getJson(primaryUrl)).result;
return fetchedDragonwellJson; return fetchedDragonwellJson;
} }
catch (err) { catch (err) {
core.debug(`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`); core.debug(`Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`);
return null; return null;
} }
}); });
@ -102793,12 +102799,12 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`; const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
const headers = util_1.getGitHubHttpHeaders(); const headers = util_1.getGitHubHttpHeaders();
try { try {
core.debug(`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`); core.debug(`Trying to fetch available versions info from the backup url: ${backupUrl}`);
const fetchedDragonwellJson = (yield this.http.getJson(backupUrl, headers)).result; const fetchedDragonwellVersions = (yield this.http.getJson(backupUrl, headers)).result;
return fetchedDragonwellJson; return fetchedDragonwellVersions;
} }
catch (err) { catch (err) {
core.debug(`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`); core.debug(`Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`);
return null; return null;
} }
}); });

View File

@ -7,7 +7,6 @@ import path from 'path';
import {JavaBase} from '../base-installer'; import {JavaBase} from '../base-installer';
import { import {
convertVersionToSemver,
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders, getGitHubHttpHeaders,
@ -29,7 +28,7 @@ export class DragonwellDistribution extends JavaBase {
version: string version: string
): Promise<JavaDownloadRelease> { ): Promise<JavaDownloadRelease> {
if (!this.stable) { if (!this.stable) {
throw new Error('Early access versions are not supported by Dragonwell'); throw new Error('Early access versions are not supported');
} }
if (this.packageType !== 'jdk') { if (this.packageType !== 'jdk') {
@ -51,7 +50,7 @@ export class DragonwellDistribution extends JavaBase {
if (!matchedVersions.length) { if (!matchedVersions.length) {
throw new Error( throw new Error(
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".` `Couldn't find any satisfied version for the specified java-version: "${version}".`
); );
} }
@ -71,12 +70,12 @@ export class DragonwellDistribution extends JavaBase {
if (!fetchedDragonwellJson) { if (!fetchedDragonwellJson) {
throw new Error( 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( core.debug(
'Successfully fetched information about available Dragonwell versions' 'Successfully fetched information about available dragonwell versions'
); );
const availableVersions = this.parseVersions( const availableVersions = this.parseVersions(
@ -147,10 +146,8 @@ export class DragonwellDistribution extends JavaBase {
continue; 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) { if (jdkVersion.split('.').length > 3) {
jdkVersion = convertVersionToSemver(jdkVersion); jdkVersion = this.transformToSemver(jdkVersion);
} }
for (const edition in archMap) { for (const edition in archMap) {
@ -185,6 +182,15 @@ export class DragonwellDistribution extends JavaBase {
return sortedVersions.reverse(); 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 { private getPlatformOption(): string {
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':
@ -198,7 +204,7 @@ export class DragonwellDistribution extends JavaBase {
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json'; const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
try { try {
core.debug( core.debug(
`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}` `Trying to fetch available versions info from the primary url: ${primaryUrl}`
); );
const fetchedDragonwellJson = ( const fetchedDragonwellJson = (
await this.http.getJson<IDragonwellAllVersions>(primaryUrl) await this.http.getJson<IDragonwellAllVersions>(primaryUrl)
@ -206,7 +212,7 @@ export class DragonwellDistribution extends JavaBase {
return fetchedDragonwellJson; return fetchedDragonwellJson;
} catch (err) { } catch (err) {
core.debug( core.debug(
`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}` `Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
); );
return null; return null;
} }
@ -224,15 +230,15 @@ export class DragonwellDistribution extends JavaBase {
try { try {
core.debug( core.debug(
`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}` `Trying to fetch available versions info from the backup url: ${backupUrl}`
); );
const fetchedDragonwellJson = ( const fetchedDragonwellVersions = (
await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers) await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers)
).result; ).result;
return fetchedDragonwellJson; return fetchedDragonwellVersions;
} catch (err) { } catch (err) {
core.debug( core.debug(
`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}` `Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`
); );
return null; return null;
} }