From b05a3f26b3adff9936a0ef8b806a7d9a57b72a6d Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Mon, 22 May 2023 12:27:33 +0200 Subject: [PATCH] Fix review points, rebuild solution --- __tests__/setup-dotnet.test.ts | 2 +- dist/index.js | 18 ++++++------------ src/installer.ts | 14 ++++---------- src/setup-dotnet.ts | 4 ++-- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 9e4b8ca..2a32d63 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -59,7 +59,7 @@ describe('setup-dotnet tests', () => { const expectedDebugMessage = 'No version found, trying to find version from global.json'; - const expectedInfoMessage = `A global.json wasn't found in the root directory. No .NET version will be installed.`; + const expectedInfoMessage = `The global.json wasn't found in the root directory. No .NET version will be installed.`; await setup.run(); diff --git a/dist/index.js b/dist/index.js index 90e197b..088b68f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -242,11 +242,8 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const os_1 = __importDefault(__nccwpck_require__(2037)); const semver_1 = __importDefault(__nccwpck_require__(5911)); const utils_1 = __nccwpck_require__(918); -var DotnetInstallerLimits; -(function (DotnetInstallerLimits) { - DotnetInstallerLimits[DotnetInstallerLimits["QualityInputMinimalMajorTag"] = 6] = "QualityInputMinimalMajorTag"; - DotnetInstallerLimits[DotnetInstallerLimits["LatestPatchSyntaxMinimalMajorTag"] = 5] = "LatestPatchSyntaxMinimalMajorTag"; -})(DotnetInstallerLimits || (DotnetInstallerLimits = {})); +const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6; +const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5; class DotnetVersionResolver { constructor(version) { this.inputVersion = version.trim(); @@ -272,8 +269,7 @@ class DotnetVersionResolver { var _b, _c; const majorTag = (_c = (_b = this.inputVersion.match(/^(?\d+)\.\d+\.\d{1}x{2}$/)) === null || _b === void 0 ? void 0 : _b.groups) === null || _c === void 0 ? void 0 : _c.majorTag; if (majorTag && - parseInt(majorTag) < - DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag) { + parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG) { throw new Error(`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`); } return majorTag ? true : false; @@ -300,9 +296,7 @@ class DotnetVersionResolver { this.resolvedArgument.value = 'LTS'; } this.resolvedArgument.qualityFlag = - parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag - ? true - : false; + parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; }); } createDotNetVersion() { @@ -556,7 +550,7 @@ function run() { versions.push(getVersionFromGlobalJson(globalJsonPath)); } else { - core.info(`A global.json wasn't found in the root directory. No .NET version will be installed.`); + core.info(`The global.json wasn't found in the root directory. No .NET version will be installed.`); } } if (versions.length) { @@ -613,7 +607,7 @@ function outputInstalledVersion(installedVersions, globalJsonFileInput) { return; } if (globalJsonFileInput) { - const versionToOutput = installedVersions.at(-1); + const versionToOutput = installedVersions.at(-1); // .NET SDK version parsed from the global.json file is installed last core.setOutput('dotnet-version', versionToOutput); return; } diff --git a/src/installer.ts b/src/installer.ts index f86dfa0..a993be8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -16,11 +16,8 @@ export interface DotnetVersion { qualityFlag: boolean; } -enum DotnetInstallerLimits { - QualityInputMinimalMajorTag = 6, - LatestPatchSyntaxMinimalMajorTag = 5 -} - +const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6; +const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5; export class DotnetVersionResolver { private inputVersion: string; private resolvedArgument: DotnetVersion; @@ -53,8 +50,7 @@ export class DotnetVersionResolver { )?.groups?.majorTag; if ( majorTag && - parseInt(majorTag) < - DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag + parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG ) { throw new Error( `The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.` @@ -82,9 +78,7 @@ export class DotnetVersionResolver { this.resolvedArgument.value = 'LTS'; } this.resolvedArgument.qualityFlag = - parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag - ? true - : false; + parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; } public async createDotNetVersion(): Promise { diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index cf26f14..58de8ef 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -48,7 +48,7 @@ export async function run() { versions.push(getVersionFromGlobalJson(globalJsonPath)); } else { core.info( - `A global.json wasn't found in the root directory. No .NET version will be installed.` + `The global.json wasn't found in the root directory. No .NET version will be installed.` ); } } @@ -121,7 +121,7 @@ function outputInstalledVersion( } if (globalJsonFileInput) { - const versionToOutput = installedVersions.at(-1); + const versionToOutput = installedVersions.at(-1); // .NET SDK version parsed from the global.json file is installed last core.setOutput('dotnet-version', versionToOutput); return; }