VSCodeTask
This commit is contained in:
parent
440b0d2290
commit
a473fd1af1
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@ -12,17 +12,10 @@
|
||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"D:/5-Other-Small/Proxmox/Day-Helper-2024-07-28",
|
||||
"Day-Helper-2024-07-28",
|
||||
"ddns.net",
|
||||
"dashkiosk,gitea,ha,immich,music,odoo,pihole,phares,pgadmin,quartz,slideshow,umbrel,vaultwarden",
|
||||
"C:/Program Files/Git/mingw64/bin/openssl.exe",
|
||||
"12345",
|
||||
"-----BEGIN CERTIFICATE",
|
||||
"END CERTIFICATE-----",
|
||||
"certutil -addstore",
|
||||
"Root"
|
||||
"M",
|
||||
"D:/5-Other-Small/Kanban-mestsa003/Other/UWM @ LEO",
|
||||
"-d",
|
||||
"D:/5-Other-Small/Kanban-mestsa003/Other/UWM @ LEO/.vscode/helper"
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "integratedTerminal",
|
||||
|
6
.vscode/mklink.md
vendored
6
.vscode/mklink.md
vendored
@ -18,9 +18,9 @@ mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.kanbn" "D:\5-Other-Small\Kanban
|
||||
del "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode"
|
||||
del "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-oss"
|
||||
del "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-insiders"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode" "C:\Users\phares\.vscode\extensions\ifx.type-script-helper-1.6.2"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-oss" "C:\Users\phares\.vscode-oss\extensions\ifx.type-script-helper-1.6.2"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-insiders" "C:\Users\phares\.vscode-insiders\extensions\ifx.type-script-helper-1.6.2"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode" "C:\Users\phares\.vscode\extensions\ifx.type-script-helper-1.6.3"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-oss" "C:\Users\phares\.vscode-oss\extensions\ifx.type-script-helper-1.6.3"
|
||||
mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-insiders" "C:\Users\phares\.vscode-insiders\extensions\ifx.type-script-helper-1.6.3"
|
||||
```
|
||||
|
||||
```bash Thu Jul 18 2024 13:47:40 GMT-0700 (Mountain Standard Time)
|
||||
|
@ -1,3 +1,4 @@
|
||||
using File_Folder_Helper.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
@ -9,11 +10,6 @@ namespace File_Folder_Helper.Day;
|
||||
internal static partial class Helper20240724
|
||||
{
|
||||
|
||||
private record NginxFileSystem(string Name,
|
||||
string Type,
|
||||
string MTime,
|
||||
float Size);
|
||||
|
||||
private record FileConnectorConfigurationSystem(string AlternateTargetFolder,
|
||||
string FileAgeThreshold,
|
||||
string[] SourceFileFilters,
|
||||
@ -95,7 +91,6 @@ internal static partial class Helper20240724
|
||||
NginxFileSystem[]? weekNginxFileSystemCollection;
|
||||
string[] days = GetValidDays(fileAgeThresholdDateTime);
|
||||
string[] weeks = GetValidWeeks(fileAgeThresholdDateTime);
|
||||
JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
foreach (string week in weeks)
|
||||
{
|
||||
checkWeek = string.Concat("http://", _StaticFileServer, '/', week);
|
||||
@ -104,7 +99,7 @@ internal static partial class Helper20240724
|
||||
if (!task.Result.IsSuccessStatusCode)
|
||||
continue;
|
||||
weekJson = _HttpClient.GetStringAsync(checkWeek).Result;
|
||||
weekNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(weekJson, propertyNameCaseInsensitiveJsonSerializerOptions);
|
||||
weekNginxFileSystemCollection = JsonSerializer.Deserialize(weekJson, NginxFileSystemCollectionSourceGenerationContext.Default.NginxFileSystemArray);
|
||||
if (weekNginxFileSystemCollection is null)
|
||||
continue;
|
||||
foreach (NginxFileSystem weekNginxFileSystem in weekNginxFileSystemCollection)
|
||||
@ -113,7 +108,7 @@ internal static partial class Helper20240724
|
||||
continue;
|
||||
dayUrl = string.Concat(checkWeek, '/', weekNginxFileSystem.Name);
|
||||
dayJson = _HttpClient.GetStringAsync(dayUrl).Result;
|
||||
dayNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(dayJson, propertyNameCaseInsensitiveJsonSerializerOptions);
|
||||
dayNginxFileSystemCollection = JsonSerializer.Deserialize(dayJson, NginxFileSystemCollectionSourceGenerationContext.Default.NginxFileSystemArray);
|
||||
if (dayNginxFileSystemCollection is null)
|
||||
continue;
|
||||
results.AddRange(GetDayNginxFileSystemCollection(fileAgeThresholdDateTime, week, weekNginxFileSystem.Name, dayUrl, dayNginxFileSystemCollection));
|
||||
|
@ -366,6 +366,28 @@ internal static partial class HelperMarkdown
|
||||
return (lines.ToList(), lineNumber);
|
||||
}
|
||||
|
||||
private static Dictionary<string, object> GetFromMatterYaml(ReadOnlyCollection<string> frontMatterYamlLines)
|
||||
{
|
||||
Dictionary<string, object> results = [];
|
||||
string[] segments;
|
||||
foreach (string line in frontMatterYamlLines.OrderBy(l => l))
|
||||
{
|
||||
segments = line.Split(": ");
|
||||
if (segments.Length != 2)
|
||||
{
|
||||
results.Clear();
|
||||
break;
|
||||
}
|
||||
if (segments[1] is "''" or "\"\"")
|
||||
results.Add(segments[0], string.Empty);
|
||||
else if (segments[1] == "[]")
|
||||
results.Add(segments[0], Array.Empty<string>());
|
||||
else
|
||||
results.Add(segments[0], segments[1].Trim());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<string, object> GetFromMatterYaml(List<string> lines, LineNumber lineNumber)
|
||||
{
|
||||
Dictionary<string, object> results = [];
|
||||
@ -373,12 +395,19 @@ internal static partial class HelperMarkdown
|
||||
IDeserializer deserializer = new DeserializerBuilder().Build();
|
||||
#pragma warning restore IL3050
|
||||
ReadOnlyCollection<string> frontMatterYamlLines = GetFromMatterYamlLines(lines, lineNumber);
|
||||
string frontMatterYaml = string.Join(Environment.NewLine, frontMatterYamlLines);
|
||||
Dictionary<string, object>? keyValuePairs = deserializer.Deserialize<Dictionary<string, object>>(frontMatterYaml);
|
||||
if (keyValuePairs is not null)
|
||||
if (!frontMatterYamlLines.Any(l => l.StartsWith(' ')))
|
||||
results = GetFromMatterYaml(frontMatterYamlLines);
|
||||
else
|
||||
{
|
||||
foreach (string key in keyValuePairs.Keys.OrderBy(l => l))
|
||||
results.Add(key, keyValuePairs[key]);
|
||||
string frontMatterYaml = string.Join(Environment.NewLine, frontMatterYamlLines);
|
||||
Dictionary<string, object>? keyValuePairs = deserializer.Deserialize<Dictionary<string, object>>(frontMatterYaml);
|
||||
if (keyValuePairs is null)
|
||||
results = GetFromMatterYaml(frontMatterYamlLines);
|
||||
else
|
||||
{
|
||||
foreach (string key in keyValuePairs.Keys.OrderBy(l => l))
|
||||
results.Add(key, keyValuePairs[key]);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
@ -1135,6 +1164,36 @@ internal static partial class HelperMarkdown
|
||||
return new(result?.MarkdownFile, result?.Lines, result?.MarkdownFile.H1, result is null ? null : Path.GetRelativePath(markdownFile.Directory, Path.GetFullPath(result.MarkdownFile.File)));
|
||||
}
|
||||
|
||||
private static List<string> GetTaskArgumentsForDayHelper20240623(Input input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.Destination))
|
||||
throw new NotSupportedException();
|
||||
List<string> results = [];
|
||||
string? vscodeDirectory = Path.GetDirectoryName(input.Destination);
|
||||
string? taskFile = vscodeDirectory is null ? null : Path.Combine(vscodeDirectory, "tasks.json");
|
||||
if (!string.IsNullOrEmpty(taskFile) && File.Exists(taskFile))
|
||||
{
|
||||
string json = File.ReadAllText(taskFile);
|
||||
VSCodeTasks? vsCodeTasks = JsonSerializer.Deserialize(json, VSCodeTasksSourceGenerationContext.Default.VSCodeTasks);
|
||||
if (vsCodeTasks is not null && vsCodeTasks.TaskCollection is not null)
|
||||
{
|
||||
foreach (VSCodeTask vsCodeTask in vsCodeTasks.TaskCollection)
|
||||
{
|
||||
if (vsCodeTask.Arguments is null || vsCodeTask.Arguments.Count < 4 || vsCodeTask.Arguments[3] != "Day-Helper-2024-06-23")
|
||||
continue;
|
||||
if (results.Count > 0)
|
||||
{
|
||||
results.Clear();
|
||||
break;
|
||||
}
|
||||
results.AddRange(vsCodeTask.Arguments.Skip(2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static void MarkdownWikiLinkVerification(AppSettings appSettings, ILogger<Worker> logger, List<string> args, CancellationToken cancellationToken)
|
||||
{
|
||||
int updated;
|
||||
@ -1179,7 +1238,12 @@ internal static partial class HelperMarkdown
|
||||
logger.LogInformation("{updated} Markdown file(s) were updated", updated);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(input.Destination))
|
||||
{
|
||||
SaveColumnToCards(input, relativeToCollection);
|
||||
List<string> taskArgumentsForDayHelper20240623 = GetTaskArgumentsForDayHelper20240623(input);
|
||||
if (taskArgumentsForDayHelper20240623.Count > 0)
|
||||
HelperDay.Select(appSettings, logger, taskArgumentsForDayHelper20240623, cancellationToken: CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
30
Models/NginxFileSystem.cs
Normal file
30
Models/NginxFileSystem.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
public record NginxFileSystem(string Name,
|
||||
string Type,
|
||||
string MTime,
|
||||
float Size)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, NginxFileSystemSourceGenerationContext.Default.NginxFileSystem);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(NginxFileSystem))]
|
||||
internal partial class NginxFileSystemSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(NginxFileSystem[]))]
|
||||
internal partial class NginxFileSystemCollectionSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
43
Models/VSCodeTasks.cs
Normal file
43
Models/VSCodeTasks.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
public record VSCodeTask([property: JsonPropertyName("label")] string? Label,
|
||||
[property: JsonPropertyName("command")] string? Command,
|
||||
[property: JsonPropertyName("type")] string? Type,
|
||||
[property: JsonPropertyName("args")] IReadOnlyList<string>? Arguments,
|
||||
[property: JsonPropertyName("script")] string? Script)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, VSCodeTaskSourceGenerationContext.Default.VSCodeTask);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, PropertyNameCaseInsensitive = true)]
|
||||
[JsonSerializable(typeof(VSCodeTask))]
|
||||
internal partial class VSCodeTaskSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
public record VSCodeTasks([property: JsonPropertyName("version")] string? Version,
|
||||
[property: JsonPropertyName("tasks")] VSCodeTask[]? TaskCollection)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, VSCodeTasksSourceGenerationContext.Default.VSCodeTasks);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, PropertyNameCaseInsensitive = true)]
|
||||
[JsonSerializable(typeof(VSCodeTasks))]
|
||||
internal partial class VSCodeTasksSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user