From 36fa9877a93876f714083cf7deec26bbe66d0dbc Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 17 Mar 2021 12:38:57 +0300 Subject: [PATCH 1/5] try fixing 5.x issue --- dist/index.js | 16 +++++++++++----- src/installer.ts | 25 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index 15f8a3b..aadf381 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16876,7 +16876,13 @@ class DotNetVersionInfo { this.throwInvalidVersionFormat(); } let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); + let minor; + if (parts[1] === 'x') { + minor = parts[1]; + } + else { + minor = this.getVersionNumberOrThrow(parts[1]); + } this.fullversion = major + '.' + minor; } getVersionNumberOrThrow(input) { @@ -16894,7 +16900,7 @@ class DotNetVersionInfo { } } throwInvalidVersionFormat() { - throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; + throw new Error('Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'); } /** * If true exacatly one version should be resolved @@ -16997,7 +17003,7 @@ class DotnetCoreInstaller { } console.log(process.env['PATH']); if (resultCode != 0) { - throw `Failed to install dotnet ${resultCode}. ${output}`; + throw new Error(`Failed to install dotnet ${resultCode}. ${output}`); } }); } @@ -17025,7 +17031,7 @@ class DotnetCoreInstaller { // Sort for latest version releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); if (releasesInfo.length == 0) { - throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`; + throw new Error(`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`); } let release = releasesInfo[0]; return release['sdk']['version']; @@ -17046,7 +17052,7 @@ class DotnetCoreInstaller { return versionParts[0] == sdkParts[0]; }); if (releasesInfo.length === 0) { - throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; + throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`); } return releasesInfo[0]['releases.json']; }); diff --git a/src/installer.ts b/src/installer.ts index f0b48a2..12113e6 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -39,7 +39,12 @@ export class DotNetVersionInfo { } let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); + let minor; + if (parts[1] === 'x') { + minor = parts[1]; + } else { + minor = this.getVersionNumberOrThrow(parts[1]); + } this.fullversion = major + '.' + minor; } @@ -60,7 +65,9 @@ export class DotNetVersionInfo { } private throwInvalidVersionFormat() { - throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; + throw new Error( + 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*' + ); } /** @@ -187,7 +194,7 @@ export class DotnetCoreInstaller { console.log(process.env['PATH']); if (resultCode != 0) { - throw `Failed to install dotnet ${resultCode}. ${output}`; + throw new Error(`Failed to install dotnet ${resultCode}. ${output}`); } } @@ -236,7 +243,9 @@ export class DotnetCoreInstaller { ); if (releasesInfo.length == 0) { - throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`; + throw new Error( + `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.` + ); } let release = releasesInfo[0]; @@ -264,9 +273,11 @@ export class DotnetCoreInstaller { }); if (releasesInfo.length === 0) { - throw `Could not find info for version ${versionParts.join( - '.' - )} at ${DotNetCoreIndexUrl}`; + throw new Error( + `Could not find info for version ${versionParts.join( + '.' + )} at ${DotNetCoreIndexUrl}` + ); } return releasesInfo[0]['releases.json']; From 20afff9c90f1ba52c7fc7198759eba900832b4cf Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 17 Mar 2021 14:56:08 +0300 Subject: [PATCH 2/5] work on fixing test --- __tests__/versionutil.test.ts | 1 - dist/index.js | 12 +++--------- src/installer.ts | 11 +++-------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/__tests__/versionutil.test.ts b/__tests__/versionutil.test.ts index a238688..b816013 100644 --- a/__tests__/versionutil.test.ts +++ b/__tests__/versionutil.test.ts @@ -42,7 +42,6 @@ describe('version tests', () => { '.2.3', '.2.x', '1', - '2.x', '*.*.1', '*.1', '*.', diff --git a/dist/index.js b/dist/index.js index aadf381..9febcc2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16869,20 +16869,14 @@ class DotNetVersionInfo { return; } //Note: No support for previews when using generic - let parts = version.split('.'); + const parts = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor; - if (parts[1] === 'x') { - minor = parts[1]; - } - else { - minor = this.getVersionNumberOrThrow(parts[1]); - } + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } getVersionNumberOrThrow(input) { diff --git a/src/installer.ts b/src/installer.ts index 12113e6..0f3fc42 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -30,7 +30,7 @@ export class DotNetVersionInfo { } //Note: No support for previews when using generic - let parts: string[] = version.split('.'); + const parts: string[] = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); @@ -38,13 +38,8 @@ export class DotNetVersionInfo { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor; - if (parts[1] === 'x') { - minor = parts[1]; - } else { - minor = this.getVersionNumberOrThrow(parts[1]); - } + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } From 6930747f7f2406e54bf60cd86f4e425fb11b7b65 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 17 Mar 2021 14:58:04 +0300 Subject: [PATCH 3/5] create release --- dist/index.js | 4 +++- src/installer.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9febcc2..d80bc1e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16876,7 +16876,9 @@ class DotNetVersionInfo { this.throwInvalidVersionFormat(); } const major = this.getVersionNumberOrThrow(parts[0]); - const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); + const minor = ['x', '*'].includes(parts[1]) + ? parts[1] + : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } getVersionNumberOrThrow(input) { diff --git a/src/installer.ts b/src/installer.ts index 0f3fc42..d0bc4f4 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -39,7 +39,9 @@ export class DotNetVersionInfo { } const major = this.getVersionNumberOrThrow(parts[0]); - const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); + const minor = ['x', '*'].includes(parts[1]) + ? parts[1] + : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } From 083d63a2ff6892d228bfb580ea7c7a6e0995c2bf Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 10:18:52 +0300 Subject: [PATCH 4/5] add yesy cases --- __tests__/versionutil.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__tests__/versionutil.test.ts b/__tests__/versionutil.test.ts index b816013..1eb4697 100644 --- a/__tests__/versionutil.test.ts +++ b/__tests__/versionutil.test.ts @@ -13,6 +13,8 @@ describe('version tests', () => { ); each([ + ['3.x', '3.1'], + ['3.*', '3.1'], ['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0'] From 385512c5e5b7ecd4b4c3ad07e808b5a96c754f33 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 11:07:32 +0300 Subject: [PATCH 5/5] fix test --- __tests__/versionutil.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/versionutil.test.ts b/__tests__/versionutil.test.ts index 1eb4697..69681da 100644 --- a/__tests__/versionutil.test.ts +++ b/__tests__/versionutil.test.ts @@ -13,8 +13,8 @@ describe('version tests', () => { ); each([ - ['3.x', '3.1'], - ['3.*', '3.1'], + ['3.x', '3.x'], + ['3.*', '3.*'], ['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0']