Skip to content

Commit

Permalink
Merge #3505 Enforce a few more spec version requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Jan 19, 2022
2 parents 0651323 + 61d824e commit aea9480
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ All notable changes to this project will be documented in this file.
- [Netkan] Sort Netkan warning lists (#3492 by: HebaruSan; reviewed: DasSkelett)
- [Netkan] Enforce spec version requirements for more install properties (#3494 by: HebaruSan; reviewed: techman83)
- [Build] Rename GH1866 test, fix invalid char test, fix equality assertion order (#3509 by: HebaruSan; reviewed: DasSkelett)
- [Netkan] Enforce a few more spec version requirements (#3505 by: HebaruSan; reviewed: DasSkelett)

## v1.30.4 (Hubble)

Expand Down
10 changes: 10 additions & 0 deletions Netkan/Validators/InstallValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public void Validate(Metadata metadata)
{
throw new Kraken("spec_version v1.2+ required for GameData with path");
}
if (metadata.SpecVersion < v1p14 && install_to.Equals("Scenarios"))
{
throw new Kraken("spec_version v1.14+ required to install to Scenarios");
}
if (metadata.SpecVersion < v1p25 && install_to.Equals("Missions"))
{
throw new Kraken("spec_version v1.25+ required to install to Missions");
}
if (metadata.SpecVersion < v1p29 && install_to.StartsWith("Ships/Script"))
{
throw new Kraken("spec_version v1.29+ required to install to Ships/Script");
Expand Down Expand Up @@ -83,9 +91,11 @@ public void Validate(Metadata metadata)
private static readonly ModuleVersion v1p4 = new ModuleVersion("v1.4");
private static readonly ModuleVersion v1p10 = new ModuleVersion("v1.10");
private static readonly ModuleVersion v1p12 = new ModuleVersion("v1.12");
private static readonly ModuleVersion v1p14 = new ModuleVersion("v1.14");
private static readonly ModuleVersion v1p16 = new ModuleVersion("v1.16");
private static readonly ModuleVersion v1p18 = new ModuleVersion("v1.18");
private static readonly ModuleVersion v1p24 = new ModuleVersion("v1.24");
private static readonly ModuleVersion v1p25 = new ModuleVersion("v1.25");
private static readonly ModuleVersion v1p29 = new ModuleVersion("v1.29");
private static readonly string[] pathProperties = {"find", "file", "install_to"};
}
Expand Down
5 changes: 5 additions & 0 deletions Netkan/Validators/LicensesValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public void Validate(Metadata metadata)
: new JArray() { json["license"] };
if (licenses != null)
{
if (metadata.SpecVersion < v1p8 && json["license"] is JArray)
{
throw new Kraken("spec_version v1.8+ required for license as array");
}
foreach (var lic in licenses)
{
if (metadata.SpecVersion < v1p2 && (string)lic == "WTFPL")
Expand Down Expand Up @@ -59,6 +63,7 @@ public void Validate(Metadata metadata)
RegexOptions.Compiled
);
private static readonly ModuleVersion v1p2 = new ModuleVersion("v1.2");
private static readonly ModuleVersion v1p8 = new ModuleVersion("v1.8");
private static readonly ModuleVersion v1p18 = new ModuleVersion("v1.18");
private static readonly ModuleVersion v1p30 = new ModuleVersion("v1.30");
}
Expand Down
5 changes: 5 additions & 0 deletions Netkan/Validators/RelationshipsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public void Validate(Metadata metadata)
{
if (json.ContainsKey(relName))
{
if (metadata.SpecVersion < v1p2 && relName.Equals("supports"))
{
throw new Kraken("spec_version v1.2+ required for 'supports'");
}
foreach (JObject rel in json[relName])
{
if (rel.ContainsKey("any_of"))
Expand Down Expand Up @@ -64,6 +68,7 @@ public void Validate(Metadata metadata)
"conflicts",
"supports"
};
private static readonly ModuleVersion v1p2 = new ModuleVersion("v1.2");
private static readonly ModuleVersion v1p26 = new ModuleVersion("v1.26");
private static readonly ModuleVersion v1p31 = new ModuleVersion("v1.31");
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/NetKAN/Validators/LicensesValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class LicensesValidatorTests
[Test,
TestCase("v1.2", @"""WTFPL"""),
TestCase("v1.18", @"""Unlicense"""),
TestCase("v1.4", @"[ ""GPL-3.0"", ""MIT"" ]"),
TestCase("v1.8", @"[ ""GPL-3.0"", ""MIT"" ]"),
]
public void Validate_GoodSpecVersionLicense_DoesNotThrow(string spec_version, string license)
{
Expand All @@ -22,6 +22,7 @@ public void Validate_GoodSpecVersionLicense_DoesNotThrow(string spec_version, st
TestCase("1", @"""WTFPL"""),
TestCase("v1.17", @"""Unlicense"""),
TestCase("v1.4", @"""NotARealLicense"""),
TestCase("v1.4", @"[ ""GPL-3.0"", ""MIT"" ]"),
TestCase("v1.4", @"[ ""GPL-3.0"", ""Unlicense"" ]"),
TestCase("v1.4", @"[ ""GPL-3.0"", ""NotARealLicense"" ]"),
]
Expand Down

0 comments on commit aea9480

Please sign in to comment.