mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
Script -- output ports with no code files; replace !...Any with None
This commit is contained in:
@@ -10,6 +10,11 @@ public static class Extensions {
|
|||||||
src.Select(x => selector(x.Item1, x.Item2, x.Item3));
|
src.Select(x => selector(x.Item1, x.Item2, x.Item3));
|
||||||
public static IEnumerable<(T1, T2, int)> WithIndex<T1, T2>(this IEnumerable<(T1, T2)> src) => src.Select((x, index) => (x.Item1, x.Item2, index));
|
public static IEnumerable<(T1, T2, int)> WithIndex<T1, T2>(this IEnumerable<(T1, T2)> src) => src.Select((x, index) => (x.Item1, x.Item2, index));
|
||||||
|
|
||||||
|
public static bool None<T>(this IEnumerable<T> src, Func<T, bool>? predicate = null) =>
|
||||||
|
predicate is null ?
|
||||||
|
!src.Any() :
|
||||||
|
!src.Any(predicate);
|
||||||
|
|
||||||
public static bool IsNullOrWhitespace([NotNullWhen(false)] this string? s) => string.IsNullOrWhiteSpace(s);
|
public static bool IsNullOrWhitespace([NotNullWhen(false)] this string? s) => string.IsNullOrWhiteSpace(s);
|
||||||
|
|
||||||
[return: NotNullIfNotNull("path")]
|
[return: NotNullIfNotNull("path")]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ var actions = new (Action action, string description)[] {
|
|||||||
(multipleProjs, "Output multiple project files"),
|
(multipleProjs, "Output multiple project files"),
|
||||||
(checkProjects, "Check .csproj/.vbproj files for target framework, nullability etc."),
|
(checkProjects, "Check .csproj/.vbproj files for target framework, nullability etc."),
|
||||||
(checkExecutableProject, "Check that there is at least one executable project per port"),
|
(checkExecutableProject, "Check that there is at least one executable project per port"),
|
||||||
|
(noCodeFiles, "Output ports without any code files"),
|
||||||
(printPortInfo, "Print info about a single port"),
|
(printPortInfo, "Print info about a single port"),
|
||||||
|
|
||||||
(generateMissingSlns, "Generate solution files when missing"),
|
(generateMissingSlns, "Generate solution files when missing"),
|
||||||
@@ -87,7 +88,7 @@ void printInfos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void missingSln() {
|
void missingSln() {
|
||||||
var data = infos.Where(x => !x.Slns.Any()).ToArray();
|
var data = infos.Where(x => x.Slns.None()).ToArray();
|
||||||
foreach (var item in data) {
|
foreach (var item in data) {
|
||||||
WriteLine(item.LangPath);
|
WriteLine(item.LangPath);
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,7 @@ void missingSln() {
|
|||||||
void unexpectedSlnName() {
|
void unexpectedSlnName() {
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
foreach (var item in infos) {
|
foreach (var item in infos) {
|
||||||
if (!item.Slns.Any()) { continue; }
|
if (item.Slns.None()) { continue; }
|
||||||
|
|
||||||
var expectedSlnName = $"{item.GameName}.sln";
|
var expectedSlnName = $"{item.GameName}.sln";
|
||||||
if (item.Slns.Contains(Combine(item.LangPath, expectedSlnName), StringComparer.InvariantCultureIgnoreCase)) { continue; }
|
if (item.Slns.Contains(Combine(item.LangPath, expectedSlnName), StringComparer.InvariantCultureIgnoreCase)) { continue; }
|
||||||
@@ -125,7 +126,7 @@ void multipleSlns() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void missingProj() {
|
void missingProj() {
|
||||||
var data = infos.Where(x => !x.Projs.Any()).ToArray();
|
var data = infos.Where(x => x.Projs.None()).ToArray();
|
||||||
foreach (var item in data) {
|
foreach (var item in data) {
|
||||||
WriteLine(item.LangPath);
|
WriteLine(item.LangPath);
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,7 @@ void missingProj() {
|
|||||||
void unexpectedProjName() {
|
void unexpectedProjName() {
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
foreach (var item in infos) {
|
foreach (var item in infos) {
|
||||||
if (!item.Projs.Any()) { continue; }
|
if (item.Projs.None()) { continue; }
|
||||||
|
|
||||||
var expectedProjName = $"{item.GameName}.{item.ProjExt}";
|
var expectedProjName = $"{item.GameName}.{item.ProjExt}";
|
||||||
if (item.Projs.Contains(Combine(item.LangPath, expectedProjName))) { continue; }
|
if (item.Projs.Contains(Combine(item.LangPath, expectedProjName))) { continue; }
|
||||||
@@ -164,7 +165,7 @@ void multipleProjs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void generateMissingSlns() {
|
void generateMissingSlns() {
|
||||||
foreach (var item in infos.Where(x => !x.Slns.Any())) {
|
foreach (var item in infos.Where(x => x.Slns.None())) {
|
||||||
var result = RunProcess("dotnet", $"new sln -n {item.GameName} -o {item.LangPath}");
|
var result = RunProcess("dotnet", $"new sln -n {item.GameName} -o {item.LangPath}");
|
||||||
WriteLine(result);
|
WriteLine(result);
|
||||||
|
|
||||||
@@ -177,7 +178,7 @@ void generateMissingSlns() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void generateMissingProjs() {
|
void generateMissingProjs() {
|
||||||
foreach (var item in infos.Where(x => !x.Projs.Any())) {
|
foreach (var item in infos.Where(x => x.Projs.None())) {
|
||||||
// We can't use the dotnet command to create a new project using the built-in console template, because part of that template
|
// We can't use the dotnet command to create a new project using the built-in console template, because part of that template
|
||||||
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
|
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
|
||||||
// if there's already such a file, it might try to overwrite it.
|
// if there's already such a file, it might try to overwrite it.
|
||||||
@@ -284,6 +285,15 @@ void checkExecutableProject() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void noCodeFiles() {
|
||||||
|
var qry = infos
|
||||||
|
.Where(x => x.CodeFiles.None())
|
||||||
|
.OrderBy(x => x.Lang);
|
||||||
|
foreach (var item in qry) {
|
||||||
|
WriteLine(item.LangPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tryBuild() {
|
void tryBuild() {
|
||||||
// if has code files, try to build
|
// if has code files, try to build
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user