Skip to content

Commit

Permalink
add - doc|bkp - Added local changelogs
Browse files Browse the repository at this point in the history
---

We've added local changelogs to the Nitrocid resources so that we can no
longer rely on Internet connectivity to fetch the changelogs.

In the "changes" command, you can use the -online switch to use the old
behavior.

  - Backportable for 0.1.1
  - Backportable for 0.1.0

---

Type: add
Breaking: False
Doc Required: True
Backport Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 6, 2025
1 parent b8e4da1 commit c704123
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
21 changes: 21 additions & 0 deletions public/Nitrocid/Kernel/Starting/KernelStageActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
using Nitrocid.ConsoleBase.Writers.MiscWriters;
using Nitrocid.Network.Types.RPC;

#if SPECIFIERREL
using Nitrocid.Files.Paths;
using Nitrocid.Files.Operations;
using Nitrocid.Files.Operations.Querying;
using Terminaux.Inputs.Styles;
using Terminaux.Inputs.Styles.Infobox;
#endif

namespace Nitrocid.Kernel.Starting
{
internal static class KernelStageActions
Expand Down Expand Up @@ -75,6 +83,19 @@ internal static void Stage02KernelUpdates()
{
if (UpdateManager.CheckUpdateStart)
UpdateManager.CheckKernelUpdates();
#if SPECIFIERREL
string upgradedPath = PathsManagement.TempPath + "/.upgraded";
if (!Checking.FileExists(upgradedPath) || Reading.ReadContents(upgradedPath)[0] != KernelMain.Version?.ToString())
{
Writing.WriteContentsText(upgradedPath, KernelMain.Version?.ToString() ?? "0.0.0.0");
SplashManager.BeginSplashOut(SplashManager.CurrentSplashContext);
string changes = UpdateManager.FetchCurrentChangelogsFromResources();
InfoBoxButtonsColor.WriteInfoBoxButtons([
new InputChoiceInfo(Translate.DoTranslation("Acknowledged"), Translate.DoTranslation("Acknowledged")),
], changes);
SplashManager.EndSplashOut(SplashManager.CurrentSplashContext);
}
#endif
}

internal static void Stage03HardwareProbe()
Expand Down
9 changes: 9 additions & 0 deletions public/Nitrocid/Kernel/Updates/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Nitrocid.Misc.Splash;
using Nitrocid.Languages;
using Nitrocid.Kernel.Exceptions;
using Nitrocid.Misc.Reflection.Internal;

#if SPECIFIERREL
using Nitrocid.Files.Paths;
Expand Down Expand Up @@ -216,5 +217,13 @@ public static string GetVersionChangelogs()
return changes;
}

internal static string FetchCurrentChangelogsFromResources()
{
// Get the changelogs from resource
bool exists = ResourcesManager.DataExists("changes.chg", ResourcesType.Misc, out string? contents);
if (!exists)
return "";
return contents ?? "";
}
}
}
9 changes: 9 additions & 0 deletions public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
</ItemGroup>
<!-- KS Manifest End -->

<!-- KS Release Changelogs -->
<ItemGroup>
<EmbeddedResource Include="..\..\tools\changes.chg">
<LogicalName>Nitrocid.Resources.changes.chg</LogicalName>
<Visible>false</Visible>
</EmbeddedResource>
</ItemGroup>
<!-- KS Release Changelogs -->

<!-- KS Package Files -->
<ItemGroup>
<None Include="OfficialAppIcon-NitrocidKS-512.png" Pack="true" PackagePath="\" />
Expand Down
4 changes: 3 additions & 1 deletion public/Nitrocid/Shell/Shells/UESH/Commands/Changes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Terminaux.Writer.ConsoleWriters;
using Nitrocid.Kernel.Updates;
using Nitrocid.Shell.ShellBase.Commands;
using Nitrocid.Shell.ShellBase.Switches;

namespace Nitrocid.Shell.Shells.UESH.Commands
{
Expand All @@ -34,7 +35,8 @@ class ChangesCommand : BaseCommand, ICommand

public override int Execute(CommandParameters parameters, ref string variableValue)
{
string changes = UpdateManager.GetVersionChangelogs();
bool online = SwitchManager.ContainsSwitch(parameters.SwitchesList, "-online");
string changes = online ? UpdateManager.GetVersionChangelogs() : UpdateManager.FetchCurrentChangelogsFromResources();
TextWriterColor.Write(changes);
return 0;
}
Expand Down
8 changes: 7 additions & 1 deletion public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo

new CommandInfo("changes", /* Localizable */ "What's new in this version of Nitrocid?",
[
new CommandArgumentInfo()
new CommandArgumentInfo(new[]
{
new SwitchInfo("online", /* Localizable */ "Fetch the changelogs from the internet instead of locally", new SwitchOptions()

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized

Check warning on line 149 in public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs

View workflow job for this annotation

GitHub Actions / build

This string, "Fetch the changelogs from the internet instead of locally", is unlocalized
{
AcceptsValues = false
}),
})
], new ChangesCommand()),

new CommandInfo("chattr", /* Localizable */ "Changes attribute of a file",
Expand Down

0 comments on commit c704123

Please sign in to comment.