Skip to content

Commit

Permalink
Fix review points, rebuild solution
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanZosimov committed May 22, 2023
1 parent 38b49fb commit b05a3f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion __tests__/setup-dotnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
18 changes: 6 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -272,8 +269,7 @@ class DotnetVersionResolver {
var _b, _c;
const majorTag = (_c = (_b = this.inputVersion.match(/^(?<majorTag>\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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 4 additions & 10 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.`
Expand Down Expand Up @@ -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<DotnetVersion> {
Expand Down
4 changes: 2 additions & 2 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b05a3f2

Please sign in to comment.