From 38b49fb7178824be5cb7b9acd01eb2627e719a0b Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 18 May 2023 12:39:22 +0200 Subject: [PATCH] Fix informational and debug messages --- __tests__/installer.test.ts | 4 ++-- __tests__/setup-dotnet.test.ts | 6 +++--- dist/index.js | 12 ++++++------ src/installer.ts | 6 +++--- src/setup-dotnet.ts | 8 +++----- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 808d34a..c9f815e 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -119,7 +119,7 @@ describe('installer tests', () => { await dotnetInstaller.installDotnet(); expect(warningSpy).toHaveBeenCalledWith( - `'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.` + `The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.` ); }); @@ -145,7 +145,7 @@ describe('installer tests', () => { await dotnetInstaller.installDotnet(); expect(warningSpy).toHaveBeenCalledWith( - `'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.` + `The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.` ); }); diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 45043a1..9e4b8ca 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 = `global.json wasn't found in the root directory. No .NET version will be installed.`; + const expectedInfoMessage = `A global.json wasn't found in the root directory. No .NET version will be installed.`; await setup.run(); @@ -73,7 +73,7 @@ describe('setup-dotnet tests', () => { inputs['dotnet-version'] = ['6.0']; inputs['dotnet-quality'] = 'fictitiousQuality'; - const expectedErrorMessage = `${inputs['dotnet-quality']} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`; + const expectedErrorMessage = `Value '${inputs['dotnet-quality']}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`; await setup.run(); expect(setFailedSpy).toHaveBeenCalledWith(expectedErrorMessage); @@ -160,7 +160,7 @@ describe('setup-dotnet tests', () => { it(`shouldn't call setOutput() if actions didn't install .NET`, async () => { inputs['dotnet-version'] = []; - const warningMessage = `No .NET version was installed. The 'dotnet-version' output will not be set.`; + const warningMessage = `The 'dotnet-version' output will not be set.`; addToPathSpy.mockImplementation(() => {}); diff --git a/dist/index.js b/dist/index.js index 649f940..90e197b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -255,7 +255,7 @@ class DotnetVersionResolver { resolveVersionInput() { return __awaiter(this, void 0, void 0, function* () { if (!semver_1.default.validRange(this.inputVersion) && !this.isLatestPatchSyntax()) { - throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx`); + throw new Error(`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx`); } if (semver_1.default.valid(this.inputVersion)) { this.createVersionArgument(); @@ -274,7 +274,7 @@ class DotnetVersionResolver { if (majorTag && parseInt(majorTag) < DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag) { - throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`); + 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; } @@ -371,7 +371,7 @@ class DotnetCoreInstaller { scriptArguments.push(option, this.quality); } else { - core.warning(`'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`); + core.warning(`The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`); } } installDotnet() { @@ -556,13 +556,13 @@ function run() { versions.push(getVersionFromGlobalJson(globalJsonPath)); } else { - core.info(`global.json wasn't found in the root directory. No .NET version will be installed.`); + core.info(`A global.json wasn't found in the root directory. No .NET version will be installed.`); } } if (versions.length) { const quality = core.getInput('dotnet-quality'); if (quality && !qualityOptions.includes(quality)) { - throw new Error(`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`); + throw new Error(`Value '${quality}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`); } let dotnetInstaller; const uniqueVersions = new Set(versions); @@ -605,7 +605,7 @@ function getVersionFromGlobalJson(globalJsonPath) { } function outputInstalledVersion(installedVersions, globalJsonFileInput) { if (!installedVersions.length) { - core.info(`No .NET version was installed. The 'dotnet-version' output will not be set.`); + core.info(`The 'dotnet-version' output will not be set.`); return; } if (installedVersions.includes(null)) { diff --git a/src/installer.ts b/src/installer.ts index 18aef22..f86dfa0 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -33,7 +33,7 @@ export class DotnetVersionResolver { private async resolveVersionInput(): Promise { if (!semver.validRange(this.inputVersion) && !this.isLatestPatchSyntax()) { throw new Error( - `'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx` + `The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx` ); } if (semver.valid(this.inputVersion)) { @@ -57,7 +57,7 @@ export class DotnetVersionResolver { DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag ) { throw new Error( - `'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.` + `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; @@ -192,7 +192,7 @@ export class DotnetCoreInstaller { scriptArguments.push(option, this.quality); } else { core.warning( - `'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.` + `The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.` ); } } diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index e7e7726..cf26f14 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( - `global.json wasn't found in the root directory. No .NET version will be installed.` + `A global.json wasn't found in the root directory. No .NET version will be installed.` ); } } @@ -58,7 +58,7 @@ export async function run() { if (quality && !qualityOptions.includes(quality)) { throw new Error( - `${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.` + `Value '${quality}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.` ); } @@ -109,9 +109,7 @@ function outputInstalledVersion( globalJsonFileInput: string ): void { if (!installedVersions.length) { - core.info( - `No .NET version was installed. The 'dotnet-version' output will not be set.` - ); + core.info(`The 'dotnet-version' output will not be set.`); return; }