| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 404e5db commit ddb82ce
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -227,22 +227,3 @@ describe('findPackageForDownload', () => { | |||
| 227 | 227 | ).rejects.toThrow(/Could not find satisfied version for semver */); | |
| 228 | 228 | }); | |
| 229 | 229 | }); | |
| 230 | - | ||
| 231 | - describe('convertVersionToSemver', () => { | ||
| 232 | - it.each([ | ||
| 233 | - [[12], '12'], | ||
| 234 | - [[12, 0], '12.0'], | ||
| 235 | - [[12, 0, 2], '12.0.2'], | ||
| 236 | - [[12, 0, 2, 1], '12.0.2+1'], | ||
| 237 | - [[12, 0, 2, 1, 3], '12.0.2+1'] | ||
| 238 | - ])('%s -> %s', (input: number[], expected: string) => { | ||
| 239 | - const distribution = new ZuluDistribution({ | ||
| 240 | - version: '18', | ||
| 241 | - architecture: 'x86', | ||
| 242 | - packageType: 'jdk', | ||
| 243 | - checkLatest: false | ||
| 244 | - }); | ||
| 245 | - const actual = distribution['convertVersionToSemver'](input); | ||
| 246 | - expect(actual).toBe(expected); | ||
| 247 | - }); | ||
| 248 | - }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,10 @@ | |||
| 1 | 1 | import * as cache from '@actions/cache'; | |
| 2 | 2 | import * as core from '@actions/core'; | |
| 3 | - import {isVersionSatisfies, isCacheFeatureAvailable} from '../src/util'; | ||
| 3 | + import { | ||
| 4 | + convertVersionToSemver, | ||
| 5 | + isVersionSatisfies, | ||
| 6 | + isCacheFeatureAvailable | ||
| 7 | + } from '../src/util'; | ||
| 4 | 8 | ||
| 5 | 9 | jest.mock('@actions/cache'); | |
| 6 | 10 | jest.mock('@actions/core'); | |
@@ -63,3 +67,16 @@ describe('isCacheFeatureAvailable', () => { | |||
| 63 | 67 | expect(isCacheFeatureAvailable()).toBe(true); | |
| 64 | 68 | }); | |
| 65 | 69 | }); | |
| 70 | + | ||
| 71 | + describe('convertVersionToSemver', () => { | ||
| 72 | + it.each([ | ||
| 73 | + ['12', '12'], | ||
| 74 | + ['12.0', '12.0'], | ||
| 75 | + ['12.0.2', '12.0.2'], | ||
| 76 | + ['12.0.2.1', '12.0.2+1'], | ||
| 77 | + ['12.0.2.1.0', '12.0.2+1.0'] | ||
| 78 | + ])('%s -> %s', (input: string, expected: string) => { | ||
| 79 | + const actual = convertVersionToSemver(input); | ||
| 80 | + expect(actual).toBe(expected); | ||
| 81 | + }); | ||
| 82 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68786,7 +68786,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||
| 68786 | 68786 | return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| 68787 | 68787 | }; | |
| 68788 | 68788 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 68789 | - exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 68789 | + exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 68790 | 68790 | const os_1 = __importDefault(__nccwpck_require__(2037)); | |
| 68791 | 68791 | const path_1 = __importDefault(__nccwpck_require__(1017)); | |
| 68792 | 68792 | const fs = __importStar(__nccwpck_require__(7147)); | |
@@ -68913,6 +68913,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent; | |||
| 68913 | 68913 | function avoidOldNotation(content) { | |
| 68914 | 68914 | return content.startsWith('1.') ? content.substring(2) : content; | |
| 68915 | 68915 | } | |
| 68916 | + function convertVersionToSemver(version) { | ||
| 68917 | + // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1) | ||
| 68918 | + const versionArray = Array.isArray(version) ? version : version.split('.'); | ||
| 68919 | + const mainVersion = versionArray.slice(0, 3).join('.'); | ||
| 68920 | + if (versionArray.length > 3) { | ||
| 68921 | + return `${mainVersion}+${versionArray.slice(3).join('.')}`; | ||
| 68922 | + } | ||
| 68923 | + return mainVersion; | ||
| 68924 | + } | ||
| 68925 | + exports.convertVersionToSemver = convertVersionToSemver; | ||
| 68916 | 68926 | ||
| 68917 | 68927 | ||
| 68918 | 68928 | /***/ }), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104209,7 +104209,7 @@ class CorrettoDistribution extends base_installer_1.JavaBase { | |||
| 104209 | 104209 | .filter(item => item.version == version) | |
| 104210 | 104210 | .map(item => { | |
| 104211 | 104211 | return { | |
| 104212 | - version: item.correttoVersion, | ||
| 104212 | + version: util_1.convertVersionToSemver(item.correttoVersion), | ||
| 104213 | 104213 | url: item.downloadLink | |
| 104214 | 104214 | }; | |
| 104215 | 104215 | }); | |
@@ -105310,9 +105310,9 @@ class ZuluDistribution extends base_installer_1.JavaBase { | |||
| 105310 | 105310 | const availableVersionsRaw = yield this.getAvailableVersions(); | |
| 105311 | 105311 | const availableVersions = availableVersionsRaw.map(item => { | |
| 105312 | 105312 | return { | |
| 105313 | - version: this.convertVersionToSemver(item.jdk_version), | ||
| 105313 | + version: util_1.convertVersionToSemver(item.jdk_version), | ||
| 105314 | 105314 | url: item.url, | |
| 105315 | - zuluVersion: this.convertVersionToSemver(item.zulu_version) | ||
| 105315 | + zuluVersion: util_1.convertVersionToSemver(item.zulu_version) | ||
| 105316 | 105316 | }; | |
| 105317 | 105317 | }); | |
| 105318 | 105318 | const satisfiedVersions = availableVersions | |
@@ -105419,15 +105419,6 @@ class ZuluDistribution extends base_installer_1.JavaBase { | |||
| 105419 | 105419 | return process.platform; | |
| 105420 | 105420 | } | |
| 105421 | 105421 | } | |
| 105422 | - // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] | ||
| 105423 | - convertVersionToSemver(version_array) { | ||
| 105424 | - const mainVersion = version_array.slice(0, 3).join('.'); | ||
| 105425 | - if (version_array.length > 3) { | ||
| 105426 | - // intentionally ignore more than 4 numbers because it is invalid semver | ||
| 105427 | - return `${mainVersion}+${version_array[3]}`; | ||
| 105428 | - } | ||
| 105429 | - return mainVersion; | ||
| 105430 | - } | ||
| 105431 | 105422 | } | |
| 105432 | 105423 | exports.ZuluDistribution = ZuluDistribution; | |
| 105433 | 105424 | ||
@@ -105843,7 +105834,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||
| 105843 | 105834 | return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| 105844 | 105835 | }; | |
| 105845 | 105836 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 105846 | - exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 105837 | + exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 105847 | 105838 | const os_1 = __importDefault(__nccwpck_require__(2037)); | |
| 105848 | 105839 | const path_1 = __importDefault(__nccwpck_require__(1017)); | |
| 105849 | 105840 | const fs = __importStar(__nccwpck_require__(7147)); | |
@@ -105970,6 +105961,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent; | |||
| 105970 | 105961 | function avoidOldNotation(content) { | |
| 105971 | 105962 | return content.startsWith('1.') ? content.substring(2) : content; | |
| 105972 | 105963 | } | |
| 105964 | + function convertVersionToSemver(version) { | ||
| 105965 | + // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1) | ||
| 105966 | + const versionArray = Array.isArray(version) ? version : version.split('.'); | ||
| 105967 | + const mainVersion = versionArray.slice(0, 3).join('.'); | ||
| 105968 | + if (versionArray.length > 3) { | ||
| 105969 | + return `${mainVersion}+${versionArray.slice(3).join('.')}`; | ||
| 105970 | + } | ||
| 105971 | + return mainVersion; | ||
| 105972 | + } | ||
| 105973 | + exports.convertVersionToSemver = convertVersionToSemver; | ||
| 105973 | 105974 | ||
| 105974 | 105975 | ||
| 105975 | 105976 | /***/ }), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,11 @@ import * as core from '@actions/core'; | |||
| 2 | 2 | import * as tc from '@actions/tool-cache'; | |
| 3 | 3 | import fs from 'fs'; | |
| 4 | 4 | import path from 'path'; | |
| 5 | - import {extractJdkFile, getDownloadArchiveExtension} from '../../util'; | ||
| 5 | + import { | ||
| 6 | + extractJdkFile, | ||
| 7 | + getDownloadArchiveExtension, | ||
| 8 | + convertVersionToSemver | ||
| 9 | + } from '../../util'; | ||
| 6 | 10 | import {JavaBase} from '../base-installer'; | |
| 7 | 11 | import { | |
| 8 | 12 | JavaDownloadRelease, | |
@@ -62,7 +66,7 @@ export class CorrettoDistribution extends JavaBase { | |||
| 62 | 66 | .filter(item => item.version == version) | |
| 63 | 67 | .map(item => { | |
| 64 | 68 | return { | |
| 65 | - version: item.correttoVersion, | ||
| 69 | + version: convertVersionToSemver(item.correttoVersion), | ||
| 66 | 70 | url: item.downloadLink | |
| 67 | 71 | } as JavaDownloadRelease; | |
| 68 | 72 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ import {IZuluVersions} from './models'; | |||
| 10 | 10 | import { | |
| 11 | 11 | extractJdkFile, | |
| 12 | 12 | getDownloadArchiveExtension, | |
| 13 | + convertVersionToSemver, | ||
| 13 | 14 | isVersionSatisfies | |
| 14 | 15 | } from '../../util'; | |
| 15 | 16 | import { | |
@@ -29,9 +30,9 @@ export class ZuluDistribution extends JavaBase { | |||
| 29 | 30 | const availableVersionsRaw = await this.getAvailableVersions(); | |
| 30 | 31 | const availableVersions = availableVersionsRaw.map(item => { | |
| 31 | 32 | return { | |
| 32 | - version: this.convertVersionToSemver(item.jdk_version), | ||
| 33 | + version: convertVersionToSemver(item.jdk_version), | ||
| 33 | 34 | url: item.url, | |
| 34 | - zuluVersion: this.convertVersionToSemver(item.zulu_version) | ||
| 35 | + zuluVersion: convertVersionToSemver(item.zulu_version) | ||
| 35 | 36 | }; | |
| 36 | 37 | }); | |
| 37 | 38 | ||
@@ -172,15 +173,4 @@ export class ZuluDistribution extends JavaBase { | |||
| 172 | 173 | return process.platform; | |
| 173 | 174 | } | |
| 174 | 175 | } | |
| 175 | - | ||
| 176 | - // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] | ||
| 177 | - private convertVersionToSemver(version_array: number[]) { | ||
| 178 | - const mainVersion = version_array.slice(0, 3).join('.'); | ||
| 179 | - if (version_array.length > 3) { | ||
| 180 | - // intentionally ignore more than 4 numbers because it is invalid semver | ||
| 181 | - return `${mainVersion}+${version_array[3]}`; | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - return mainVersion; | ||
| 185 | - } | ||
| 186 | 176 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,3 +151,13 @@ export function getVersionFromFileContent( | |||
| 151 | 151 | function avoidOldNotation(content: string): string { | |
| 152 | 152 | return content.startsWith('1.') ? content.substring(2) : content; | |
| 153 | 153 | } | |
| 154 | + | ||
| 155 | + export function convertVersionToSemver(version: number[] | string) { | ||
| 156 | + // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1) | ||
| 157 | + const versionArray = Array.isArray(version) ? version : version.split('.'); | ||
| 158 | + const mainVersion = versionArray.slice(0, 3).join('.'); | ||
| 159 | + if (versionArray.length > 3) { | ||
| 160 | + return `${mainVersion}+${versionArray.slice(3).join('.')}`; | ||
| 161 | + } | ||
| 162 | + return mainVersion; | ||
| 163 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments