From f0dde7dc8c36f13b1537a2d31ac8f21ecdb1fa86 Mon Sep 17 00:00:00 2001 From: Priyagupta108 Date: Tue, 17 Jun 2025 09:56:51 +0530 Subject: [PATCH] fix: prevent default installation of JetBrains pre-releases --- dist/setup/index.js | 17 ++++++++++++----- src/distributions/jetbrains/installer.ts | 23 ++++++++++++++++++----- src/distributions/jetbrains/models.ts | 3 ++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 08107f09..d82352d3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -129672,7 +129672,12 @@ class JetBrainsDistribution extends base_installer_1.JavaBase { // url is identical except page_index so print it once for debug core.debug(`Gathering available versions from '${rawUrl}'`); } - const paginationPage = (yield this.http.getJson(rawUrl, requestHeaders)).result; + const paginationPageResult = (yield this.http.getJson(rawUrl, requestHeaders)).result; + if (!paginationPageResult || paginationPageResult.length === 0) { + // break infinity loop because we have reached end of pagination + break; + } + const paginationPage = paginationPageResult.filter(version => this.stable ? !version.prerelease : version.prerelease == true); if (!paginationPage || paginationPage.length === 0) { // break infinity loop because we have reached end of pagination break; @@ -129680,9 +129685,11 @@ class JetBrainsDistribution extends base_installer_1.JavaBase { rawVersions.push(...paginationPage); page_index++; } - // Add versions not available from the API but are downloadable - const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; - rawVersions.push(...hidden.map(tag => ({ tag_name: tag, name: tag }))); + if (this.stable) { + // Add versions not available from the API but are downloadable + const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; + rawVersions.push(...hidden.map(tag => ({ tag_name: tag, name: tag, prerelease: false }))); + } const versions0 = rawVersions.map((v) => __awaiter(this, void 0, void 0, function* () { var _a; // Release tags look like one of these: @@ -129701,7 +129708,7 @@ class JetBrainsDistribution extends base_installer_1.JavaBase { .replace('-', ''); const vsplit = vstring.split('b'); let semver = vsplit[0]; - const build = +vsplit[1]; + const build = vsplit[1]; // Normalize semver if (!semver.includes('.') && !semver.includes('_')) semver = `${semver}.0.0`; diff --git a/src/distributions/jetbrains/installer.ts b/src/distributions/jetbrains/installer.ts index ed0b49fe..505e9212 100644 --- a/src/distributions/jetbrains/installer.ts +++ b/src/distributions/jetbrains/installer.ts @@ -113,9 +113,18 @@ export class JetBrainsDistribution extends JavaBase { core.debug(`Gathering available versions from '${rawUrl}'`); } - const paginationPage = ( + const paginationPageResult = ( await this.http.getJson(rawUrl, requestHeaders) ).result; + if (!paginationPageResult || paginationPageResult.length === 0) { + // break infinity loop because we have reached end of pagination + break; + } + + const paginationPage: IJetBrainsRawVersion[] = + paginationPageResult.filter(version => + this.stable ? !version.prerelease : version.prerelease == true + ); if (!paginationPage || paginationPage.length === 0) { // break infinity loop because we have reached end of pagination break; @@ -125,9 +134,13 @@ export class JetBrainsDistribution extends JavaBase { page_index++; } - // Add versions not available from the API but are downloadable - const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; - rawVersions.push(...hidden.map(tag => ({tag_name: tag, name: tag}))); + if (this.stable) { + // Add versions not available from the API but are downloadable + const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; + rawVersions.push( + ...hidden.map(tag => ({tag_name: tag, name: tag, prerelease: false})) + ); + } const versions0 = rawVersions.map(async v => { // Release tags look like one of these: @@ -148,7 +161,7 @@ export class JetBrainsDistribution extends JavaBase { const vsplit = vstring.split('b'); let semver = vsplit[0]; - const build = +vsplit[1]; + const build = vsplit[1]; // Normalize semver if (!semver.includes('.') && !semver.includes('_')) diff --git a/src/distributions/jetbrains/models.ts b/src/distributions/jetbrains/models.ts index 7daaea06..bad2ec68 100644 --- a/src/distributions/jetbrains/models.ts +++ b/src/distributions/jetbrains/models.ts @@ -3,11 +3,12 @@ export interface IJetBrainsRawVersion { tag_name: string; name: string; + prerelease: boolean; } export interface IJetBrainsVersion { tag_name: string; semver: string; - build: number; + build: string; url: string; }