-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTools-ReadmeBuilder.csx
More file actions
110 lines (78 loc) · 5.41 KB
/
Tools-ReadmeBuilder.csx
File metadata and controls
110 lines (78 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var searchDirectory = new DirectoryInfo(Environment.CurrentDirectory);
Console.Write(
$"Pointless Waymarks README.md -> Project Specific README_[project] running in {searchDirectory.FullName}");
var mainReadme = new FileInfo(Path.Combine(searchDirectory.FullName, "README-Fossil.md"));
if (mainReadme.Exists && File.Exists(Path.Combine(searchDirectory.FullName, "PiSlicedDayPhotos.sln")))
{
var gitMirrorInformation =
$"""
## This is a mirror of the [Pi Sliced Day Fossil Repository](https://chiselapp.com/user/cmiles/repository/pi-sliced-day-photos/index)
Information, posts about development and installers can be found on [Pointless Waymarks Software](https://software.pointlesswaymarks.com/) - [Pi Sliced-Day Photos and Timelapse Helper Page](https://software.pointlesswaymarks.com/Posts/Software/pi-sliced-day-photos-and-timelapse-helper/pi-sliced-day-photos-and-timelapse-helper.html)
This project uses the [Pointless Waymarks Tools](https://chiselapp.com/user/cmiles/repository/pointless-waymarks-tools/index) and a number of incredible packages that are genorously provided as open source/free software, see the list below!
Thanks to [Chisel](https://chiselapp.com/) for the generous hosting of Fossil repositories and [Fossil](https://fossil-scm.org/home/doc/trunk/www/index.wiki) for an amazing alternative to git and GitHub.
*This file is generated - do not edit this directly, changes will be overwritten.*
### Mirrored README.md from the [Pi Sliced Day Fossil Repository](https://chiselapp.com/user/cmiles/repository/pi-sliced-day-photos/index) follows below...
{await File.ReadAllTextAsync(mainReadme.FullName)}
""";
await File.WriteAllTextAsync(Path.Combine(searchDirectory.FullName, "README.md"), gitMirrorInformation);
Console.WriteLine("Found the main README-Fossil.md - prepended mirror message and wrote to README.md");
Console.WriteLine();
}
var subDirectories = searchDirectory.GetDirectories("*", SearchOption.AllDirectories)
.Where(d => !d.FullName.Contains(Path.DirectorySeparatorChar + "bin", StringComparison.OrdinalIgnoreCase) &&
!d.FullName.Contains(Path.DirectorySeparatorChar + "obj", StringComparison.OrdinalIgnoreCase) &&
!d.FullName.Contains(Path.DirectorySeparatorChar + "debug", StringComparison.OrdinalIgnoreCase) &&
!d.FullName.Contains(Path.DirectorySeparatorChar + "release", StringComparison.OrdinalIgnoreCase) &&
!d.FullName.Contains(Path.DirectorySeparatorChar + ".", StringComparison.OrdinalIgnoreCase))
.ToArray();
Console.WriteLine($"Scanning {subDirectories.Length} SubDirectories.");
foreach (var subDirectory in subDirectories)
try
{
Console.WriteLine(subDirectory.FullName);
var possibleReadme = new FileInfo(Path.Combine(subDirectory.FullName, "README.md"));
if (subDirectory.Name.Equals("PointlessWaymarksTools", StringComparison.OrdinalIgnoreCase))
{
var toolsMainReadme = Path.Combine(subDirectory.FullName, "README-Fossil.md");
if (File.Exists(toolsMainReadme))
{
var gitMirrorInformation =
$"""
## This is a mirror of the [Pointless Waymarks Tools Fossil Repository](https://chiselapp.com/user/cmiles/repository/pointless-waymarks-tools/index)
Thanks to [Chisel](https://chiselapp.com/) for the generous hosting of Fossil repositories and [Fossil](https://fossil-scm.org/home/doc/trunk/www/index.wiki) for an amazing alternative to git and GitHub.
*This file is generated by the Pointless Waymarks PublishReadmeHelper - do not edit this directly, changes will be overwritten.*
### Mirrored README.md from the [Pointless Waymarks Tools Fossil Repository](https://chiselapp.com/user/cmiles/repository/pointless-waymarks-tools/index) follows below...
{await File.ReadAllTextAsync(toolsMainReadme)}
""";
await File.WriteAllTextAsync(Path.Combine(subDirectory.FullName, "README.md"), gitMirrorInformation);
Console.WriteLine(
" Found the main README-Fossil.md - prepended mirror message and wrote to README.md");
Console.WriteLine();
}
continue;
}
if (!possibleReadme.Exists)
{
Console.WriteLine($" No README.md found");
continue;
}
var readmeName = string.Join("-", subDirectory.Name.Split(".")[1..]);
if (string.IsNullOrWhiteSpace(readmeName))
{
var possibleSolutionFile = subDirectory.EnumerateFiles("*.sln", SearchOption.TopDirectoryOnly).ToList();
readmeName = possibleSolutionFile.Any()
? possibleSolutionFile.First().Name.Split(".")[0]
: subDirectory.Name;
}
var targetReadme = new FileInfo(Path.Combine(subDirectory.FullName, $"README_{readmeName}.md"));
possibleReadme.CopyTo(targetReadme.FullName, true);
Console.WriteLine($" Copied {possibleReadme.FullName} to {targetReadme.FullName}");
}
catch (Exception e)
{
Console.WriteLine($"!!! Error - continuing...{Environment.NewLine}{e}");
}
finally
{
Console.WriteLine();
}