mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 00:26:07 +02:00
feat: update nuspec metadata and add PATH setup functionality for terminal access
This commit is contained in:
@@ -4,21 +4,21 @@
|
||||
<id>echohub</id>
|
||||
<version>__VERSION__</version>
|
||||
<title>EchoHub</title>
|
||||
<authors>Hue</authors>
|
||||
<owners>Hue</owners>
|
||||
<authors>HueByte</authors>
|
||||
<owners>HueByte</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<licenseUrl>https://github.com/HueByte/EchoHub/blob/master/LICENSE</licenseUrl>
|
||||
<projectUrl>https://github.com/HueByte/EchoHub</projectUrl>
|
||||
<projectSourceUrl>https://github.com/HueByte/EchoHub</projectSourceUrl>
|
||||
<docsUrl>https://huebyte.github.io/EchoHub</docsUrl>
|
||||
<bugTrackerUrl>https://github.com/HueByte/EchoHub/issues</bugTrackerUrl>
|
||||
<packageSourceUrl>https://github.com/HueByte/EchoHub/tree/master/packaging/choco</packageSourceUrl>
|
||||
<iconUrl>https://raw.githubusercontent.com/HueByte/EchoHub/master/assets/hue_icon.png</iconUrl>
|
||||
<licenseUrl>https://github.com/HueByteByte/EchoHub/blob/master/LICENSE</licenseUrl>
|
||||
<projectUrl>https://github.com/HueByteByte/EchoHub</projectUrl>
|
||||
<projectSourceUrl>https://github.com/HueByteByte/EchoHub</projectSourceUrl>
|
||||
<docsUrl>https://HueBytebyte.github.io/EchoHub</docsUrl>
|
||||
<bugTrackerUrl>https://github.com/HueByteByte/EchoHub/issues</bugTrackerUrl>
|
||||
<packageSourceUrl>https://github.com/HueByteByte/EchoHub/tree/master/packaging/choco</packageSourceUrl>
|
||||
<iconUrl>https://raw.githubusercontent.com/HueByteByte/EchoHub/master/assets/HueByte_icon.png</iconUrl>
|
||||
<description>EchoHub is a decentralized IRC-style chat application with a terminal user interface (TUI). Connect to any EchoHub server, join channels, and chat — all from your terminal. Features include SignalR real-time messaging, file sharing, custom themes, and IRC gateway compatibility.</description>
|
||||
<summary>Decentralized terminal chat client with IRC gateway support</summary>
|
||||
<tags>chat irc decentralized tui terminal signalr echohub</tags>
|
||||
<releaseNotes>https://huebyte.github.io/EchoHub/changelog/v__VERSION__.html</releaseNotes>
|
||||
<copyright>Copyright (c) 2026 Hue</copyright>
|
||||
<releaseNotes>https://HueBytebyte.github.io/EchoHub/changelog/v__VERSION__.html</releaseNotes>
|
||||
<copyright>Copyright (c) 2026 HueByte</copyright>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="tools\**" target="tools" />
|
||||
|
||||
+33
-9
@@ -130,6 +130,31 @@ download() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ── PATH setup ────────────────────────────────────────────────────────────
|
||||
|
||||
add_to_path() {
|
||||
dir="$1"
|
||||
export_line="export PATH=\"${dir}:\$PATH\" # Added by EchoHub"
|
||||
|
||||
added=0
|
||||
for profile in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.zshrc"; do
|
||||
if [ -f "$profile" ]; then
|
||||
if grep -q "$dir" "$profile" 2>/dev/null; then
|
||||
continue # Already present
|
||||
fi
|
||||
printf '\n%s\n' "$export_line" >> "$profile"
|
||||
echo " Added to PATH in $(basename "$profile")"
|
||||
added=1
|
||||
fi
|
||||
done
|
||||
|
||||
# If no profile existed, create .profile
|
||||
if [ "$added" -eq 0 ]; then
|
||||
printf '\n%s\n' "$export_line" >> "$HOME/.profile"
|
||||
echo " Added to PATH in .profile"
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Main ──────────────────────────────────────────────────────────────────
|
||||
|
||||
main() {
|
||||
@@ -181,18 +206,17 @@ main() {
|
||||
|
||||
echo ""
|
||||
|
||||
# Verify
|
||||
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
|
||||
# Ensure install directory is on PATH
|
||||
if ! command -v "$BINARY_NAME" >/dev/null 2>&1; then
|
||||
add_to_path "$install_dir"
|
||||
fi
|
||||
|
||||
echo "Installed successfully! Run 'echohub' to start."
|
||||
else
|
||||
echo "Installed to: ${install_dir}/${BINARY_NAME}"
|
||||
echo ""
|
||||
echo "WARNING: ${install_dir} is not in your PATH."
|
||||
echo "Add it to your shell profile:"
|
||||
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$install_dir"; then
|
||||
echo "NOTE: Restart your shell or run the following to use echohub now:"
|
||||
echo ""
|
||||
echo " echo 'export PATH=\"${install_dir}:\$PATH\"' >> ~/.bashrc"
|
||||
echo " # or for zsh:"
|
||||
echo " echo 'export PATH=\"${install_dir}:\$PATH\"' >> ~/.zshrc"
|
||||
echo " export PATH=\"${install_dir}:\$PATH\""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,9 @@ Log.Logger = new LoggerConfiguration()
|
||||
|
||||
Log.Information("EchoHub client starting");
|
||||
|
||||
// == Ensure echohub is on PATH for convenient terminal access ============
|
||||
PathSetup.EnsureOnPath();
|
||||
|
||||
// == Post-update detection: stale backup cleanup or flag for rollback menu ================
|
||||
if (UpdateBackupService.BackupExists())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
using Serilog;
|
||||
|
||||
namespace EchoHub.Client.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the application's directory is on the system PATH so users
|
||||
/// can run 'echohub' from any terminal session.
|
||||
/// </summary>
|
||||
public static class PathSetup
|
||||
{
|
||||
private const string PathMarker = "# Added by EchoHub";
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the app directory is on PATH; if not, adds it persistently.
|
||||
/// On Windows: modifies user-level PATH environment variable.
|
||||
/// On Linux/macOS: appends an export line to shell profile files.
|
||||
/// </summary>
|
||||
public static void EnsureOnPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
var appDir = AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
|
||||
if (IsOnPath(appDir))
|
||||
return;
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
AddToWindowsPath(appDir);
|
||||
else
|
||||
AddToUnixPath(appDir);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Debug(ex, "Could not add app directory to PATH");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsOnPath(string directory)
|
||||
{
|
||||
var pathVar = Environment.GetEnvironmentVariable("PATH") ?? "";
|
||||
var separator = OperatingSystem.IsWindows() ? ';' : ':';
|
||||
|
||||
return pathVar
|
||||
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Any(p => string.Equals(
|
||||
p.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar),
|
||||
directory,
|
||||
OperatingSystem.IsWindows()
|
||||
? StringComparison.OrdinalIgnoreCase
|
||||
: StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private static void AddToWindowsPath(string directory)
|
||||
{
|
||||
var userPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) ?? "";
|
||||
|
||||
// Double-check against user PATH specifically (process PATH includes system + user)
|
||||
if (userPath.Split(';', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Any(p => string.Equals(p.TrimEnd('\\', '/'), directory, StringComparison.OrdinalIgnoreCase)))
|
||||
return;
|
||||
|
||||
var newPath = string.IsNullOrEmpty(userPath) ? directory : userPath + ";" + directory;
|
||||
Environment.SetEnvironmentVariable("PATH", newPath, EnvironmentVariableTarget.User);
|
||||
Log.Information("Added {Directory} to user PATH", directory);
|
||||
}
|
||||
|
||||
private static void AddToUnixPath(string directory)
|
||||
{
|
||||
var exportLine = $"export PATH=\"{directory}:$PATH\" {PathMarker}";
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
|
||||
// Target the most common shell profiles
|
||||
string[] profiles = [
|
||||
Path.Combine(home, ".profile"),
|
||||
Path.Combine(home, ".bashrc"),
|
||||
Path.Combine(home, ".zshrc")
|
||||
];
|
||||
|
||||
var added = false;
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
if (!File.Exists(profile))
|
||||
continue;
|
||||
|
||||
var content = File.ReadAllText(profile);
|
||||
if (content.Contains(directory))
|
||||
continue; // Already present (manual or previous run)
|
||||
|
||||
File.AppendAllText(profile, $"\n{exportLine}\n");
|
||||
added = true;
|
||||
Log.Information("Added PATH export to {Profile}", profile);
|
||||
}
|
||||
|
||||
// If no profile existed, create .profile
|
||||
if (!added)
|
||||
{
|
||||
var fallback = Path.Combine(home, ".profile");
|
||||
File.AppendAllText(fallback, $"\n{exportLine}\n");
|
||||
Log.Information("Created PATH export in {Profile}", fallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user