feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -4,30 +4,45 @@ using Chronos.Core.Packaging;
|
||||
namespace Chronos.Tools.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// <c>pack-installer --setup Chronos.Setup.exe --product Chronos --version 1.2.3 --component Id=folder … --out file</c>:
|
||||
/// <c>pack-installer --setup Chronos.Setup.exe --product Chronos --version 1.2.3 --component Id=folder … --out file [--legacy]</c>:
|
||||
/// appends a TPK1 payload (BRIEF §18) to the setup program. Known component ids carry their display name, default
|
||||
/// selection, shortcuts and file types; unknown ids are packed as plain, preselected components. The Server
|
||||
/// installs only for all users: it is registered as a LocalSystem service, which must run from Program Files.
|
||||
/// selection, shortcuts and file types: <c>Chronos</c> (alias <c>Desktop</c>), the desktop app, preselected, and
|
||||
/// <c>Uploader</c>, not preselected; unknown ids are packed as plain, preselected components. A setup of one component
|
||||
/// preselects it, as the separate 1.0 Uploader setup the CI test stands in for did: a silent run without
|
||||
/// <c>/COMPONENTS</c> installs it. Chronos Server is no
|
||||
/// longer packed (it ships as a Docker image): <c>Server</c> is refused unless <c>--legacy</c>, which packs it as 1.0
|
||||
/// named it (not preselected, Start menu shortcut) for the CI test of a retained 1.0 Server, installable for the
|
||||
/// current user so that the test needs no administrator rights.
|
||||
/// </summary>
|
||||
internal sealed class PackInstallerCommand : ICommand
|
||||
{
|
||||
private sealed record KnownComponent(string DisplayName, bool DefaultSelected, string Program, bool Desktop, PayloadAssociation? Association, bool AllUsersOnly = false);
|
||||
/// <param name="DisplayName">The component's name when setup has no translation of it.</param>
|
||||
/// <param name="ShortcutName">The shortcut's file name, which links, pins and the sign-in entries follow: never renamed.</param>
|
||||
private sealed record KnownComponent(string DisplayName, string ShortcutName, bool DefaultSelected, string Program, bool Desktop, PayloadAssociation? Association);
|
||||
|
||||
/// <remarks>The file type's description is the English fallback; setup writes it in its own language (<c>Setup.FileType.*</c>).</remarks>
|
||||
private static readonly Dictionary<string, KnownComponent> Known = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["Chronos"] = new("Chronos", true, "Chronos.exe", Desktop: true,
|
||||
["Chronos"] = new("Chronos Desktop", "Chronos", true, "Chronos.exe", Desktop: true,
|
||||
new PayloadAssociation { Component = "Chronos", Extension = ".chronos", ProgId = "Chronos.Project", Description = "Chronos project", Target = "Chronos.exe" }),
|
||||
["Uploader"] = new("Chronos Uploader", true, "Chronos.Uploader.exe", Desktop: true, null),
|
||||
["Server"] = new("Chronos Server", false, "Chronos.Server.exe", Desktop: false, null, AllUsersOnly: true),
|
||||
["Uploader"] = new("Chronos Uploader", "Chronos Uploader", false, "Chronos.Uploader.exe", Desktop: true, null),
|
||||
};
|
||||
|
||||
/// <summary>The 1.0 Windows Server, packed only with <c>--legacy</c>.</summary>
|
||||
private static readonly KnownComponent LegacyServer = new("Chronos Server", "Chronos Server", false, "Chronos.Server.exe", Desktop: false, null);
|
||||
|
||||
private const string ServerId = "Server";
|
||||
|
||||
/// <summary><c>--component Desktop=…</c> packs the component <c>Chronos</c>, as <c>/COMPONENTS=Desktop</c> selects it.</summary>
|
||||
private const string DesktopAlias = "Desktop";
|
||||
|
||||
public string Name => "pack-installer";
|
||||
public string Summary => "--setup <exe> --product <name> --version <v> --component Id=dir … --out <file>";
|
||||
public string Summary => "--setup <exe> --product <name> --version <v> --component Id=dir … --out <file> [--legacy]";
|
||||
|
||||
public Task<int> RunAsync(string[] args)
|
||||
{
|
||||
var options = Parse(args);
|
||||
var legacy = args.Contains("--legacy", StringComparer.Ordinal);
|
||||
var options = Parse([.. args.Where(a => a != "--legacy")]);
|
||||
var setup = Required(options, "setup");
|
||||
var output = Required(options, "out");
|
||||
if (!File.Exists(setup)) throw new ToolException($"Setup program '{setup}' not found.");
|
||||
@@ -41,26 +56,37 @@ internal sealed class PackInstallerCommand : ICommand
|
||||
var eq = spec.IndexOf('=', StringComparison.Ordinal);
|
||||
if (eq <= 0 || eq == spec.Length - 1) throw new ToolException($"--component expects Id=folder, got '{spec}'.");
|
||||
var id = spec[..eq];
|
||||
if (id.Equals(DesktopAlias, StringComparison.OrdinalIgnoreCase)) id = "Chronos";
|
||||
var folder = spec[(eq + 1)..];
|
||||
if (!PayloadManifest.IdentifierRegex().IsMatch(id)) throw new ToolException($"Component id '{id}' must be letters and digits.");
|
||||
if (components.Any(c => c.Id.Equals(id, StringComparison.OrdinalIgnoreCase))) throw new ToolException($"Component '{id}' given twice.");
|
||||
if (!Directory.Exists(folder)) throw new ToolException($"Component folder '{folder}' not found.");
|
||||
|
||||
if (!Known.TryGetValue(id, out var known))
|
||||
KnownComponent? known;
|
||||
if (id.Equals(ServerId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!legacy) throw new ToolException("Chronos Server is no longer packed into the setup (it ships as a Docker image); --legacy packs a 1.0 Server for the migration test.");
|
||||
known = LegacyServer;
|
||||
id = ServerId;
|
||||
}
|
||||
else if (!Known.TryGetValue(id, out known))
|
||||
{
|
||||
components.Add(new PayloadComponentSource(id, id, true, folder));
|
||||
continue;
|
||||
}
|
||||
components.Add(new PayloadComponentSource(id, known.DisplayName, known.DefaultSelected, folder, known.AllUsersOnly));
|
||||
components.Add(new PayloadComponentSource(id, known.DisplayName, known.DefaultSelected, folder));
|
||||
if (!File.Exists(Path.Combine(folder, known.Program)))
|
||||
{
|
||||
Console.Error.WriteLine($"warning: {id} has no {known.Program}; no shortcut or file type registered.");
|
||||
continue;
|
||||
}
|
||||
shortcuts.Add(new PayloadShortcut { Component = id, Name = known.DisplayName, Target = known.Program, StartMenu = true, Desktop = known.Desktop });
|
||||
shortcuts.Add(new PayloadShortcut { Component = id, Name = known.ShortcutName, Target = known.Program, StartMenu = true, Desktop = known.Desktop });
|
||||
if (known.Association is { } association) associations.Add(association);
|
||||
}
|
||||
|
||||
// A single component is what the setup installs: preselected, or a silent run without /COMPONENTS would install nothing.
|
||||
if (components is [var only] && !only.DefaultSelected) components[0] = only with { DefaultSelected = true };
|
||||
|
||||
var source = new PayloadSource
|
||||
{
|
||||
Product = Required(options, "product"),
|
||||
|
||||
Reference in new issue
Block a user