Skip to content

Commit

Permalink
Fix informational and debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanZosimov committed May 18, 2023
1 parent 3cf3e23 commit 38b49fb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
});

Expand All @@ -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.`
);
});

Expand Down
6 changes: 3 additions & 3 deletions __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 = `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();

Expand All @@ -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);
Expand Down Expand Up @@ -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(() => {});

Expand Down
12 changes: 6 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DotnetVersionResolver {
private async resolveVersionInput(): Promise<void> {
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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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.`
);
}
}
Expand Down
8 changes: 3 additions & 5 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(
`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.`
);
}
}
Expand All @@ -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.`
);
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 38b49fb

Please sign in to comment.