-
-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathupdate-deps.cs
More file actions
executable file
·49 lines (38 loc) · 2.45 KB
/
update-deps.cs
File metadata and controls
executable file
·49 lines (38 loc) · 2.45 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
#! /usr/bin/env dotnet
#:property Nullable=enable
#:property PublishAOT=false
#:package ArcaneLibs@1.0.0-preview.20251207*
using ArcaneLibs;
using ArcaneLibs.Extensions;
using System.Text.Json;
Console.WriteLine("==> Getting outputs...");
var outs = JsonSerializer.Deserialize<string[]>(Util.GetCommandOutputSync("nix", $"eval --json .#packages.x86_64-linux --apply builtins.attrNames", silent: true, stderr: false));
if (args.Length > 0) {
var filter = args[0];
outs = outs.Where(x => x.Contains(filter)).ToArray();
}
Console.WriteLine($"==> Updating dependencies for {outs.Length} projects...");
var ss = new SemaphoreSlim(1, 1);
var tasks = outs.Select(outp => Task.Run(async () => {
Console.WriteLine(ConsoleUtils.ColoredString($" ==> Updating {outp}...", 0x80, 0x80, 0xff));
Console.Write(ConsoleUtils.ColoredString($" ==> Getting project root directory... ", 0x80, 0xff, 0xff));
var rootDir = JsonSerializer.Deserialize<string>(Util.GetCommandOutputSync("nix", $"eval --json .#packages.x86_64-linux.{outp}.srcRoot", silent: true, stderr: false)).Split("/extra/admin-api/", 2)[1];
Console.WriteLine(ConsoleUtils.ColoredString($"{rootDir}", 0x80, 0xff, 0xff));
if (rootDir.Length <= 1) throw new Exception("Invalid project file count?");
var nugetDepsFilePath = Path.Combine(rootDir, "deps.json");
Console.WriteLine(ConsoleUtils.ColoredString($" ==> {nugetDepsFilePath} exists: {File.Exists(nugetDepsFilePath)}", 0x80, 0xff, 0xff));
if (!File.Exists(nugetDepsFilePath)) {
Console.WriteLine(ConsoleUtils.ColoredString($" ==> No NuGet deps file, skipping!", 0xff, 0x80, 0x80));
return;
}
var fname = $"./update-deps-{outp}";
Console.WriteLine(ConsoleUtils.ColoredString($" ==> Building fetch-deps script {fname}...", 0x80, 0xff, 0x80));
Util.RunCommandSync("nix", $"build .#{outp}.passthru.fetch-deps --out-link {fname}");
Console.WriteLine(ConsoleUtils.ColoredString($" ==> Running fetch-deps script, writing into {nugetDepsFilePath}...", 0x80, 0xff, 0x80));
Util.RunCommandSync(fname, nugetDepsFilePath);
var deps = JsonSerializer.Deserialize<object[]>(await File.ReadAllTextAsync(nugetDepsFilePath));
Console.WriteLine(ConsoleUtils.ColoredString($" ==> Locked {deps.Length} dependencies...", (byte)(deps.Length == 0 ? 0xff : 0x80), (byte)(deps.Length == 0 ? 0x80 : 0xff), 0x80));
// File.Delete(fname);
// await Task.Delay(250);
})).ToList();
await Task.WhenAll(tasks);