forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request chocolatey#3001 from AdmiringWorm/readd-pack-valid…
…ations (chocolatey#3000) Create new rule service and read old validation messages
- Loading branch information
Showing
25 changed files
with
930 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/chocolatey/infrastructure.app/rules/EmptyOrInvalidUrlMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class EmptyOrInvalidUrlMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
var items = new[] | ||
{ | ||
"projectUrl", | ||
"projectSourceUrl", | ||
"docsUrl", | ||
"bugTrackerUrl", | ||
"mailingListUrl", | ||
"iconUrl", | ||
"licenseUrl" | ||
}; | ||
|
||
foreach (var item in items) | ||
{ | ||
if (has_element(reader, item)) | ||
{ | ||
var value = get_element_value(reader, item); | ||
|
||
if (string.IsNullOrWhiteSpace(value)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "The {0} element in the package nuspec file cannot be empty.".format_with(item)); | ||
} | ||
else if (!Uri.TryCreate(value, UriKind.Absolute, out _)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "'{0}' is not a valid URL for the {1} element in the package nuspec file.".format_with(value, item)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/chocolatey/infrastructure.app/rules/FrameWorkReferencesMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class FrameWorkReferencesMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (has_element(reader, "frameworkReferences")) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<frameworkReferences> elements are not supported in Chocolatey CLI."); | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/chocolatey/infrastructure.app/rules/IconMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class IconMetadataRule : IMetadataRule | ||
{ | ||
public IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (!(reader.GetIcon() is null)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<icon> elements are not supported in Chocolatey CLI, use <iconUrl> instead."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.