Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions install-universal.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash
# Universal web installer for WriteCommit tool
# Usage: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-universal.sh | bash
# Or with arch override: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-universal.sh | bash -s -- --arch linux-arm64
# Usage: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-universal.sh | bash
# Or with arch override: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-universal.sh | bash -s -- --arch linux-arm64

set -e

# Configuration
REPO="PatrickRuddiman/Toolkit"
TOOL_NAME="WriteCommit"
REPO="PatrickRuddiman/WriteCommit"
# Binary name inside the archive
BINARY_NAME="WriteCommit"
# Asset prefix is lowercase
TOOL_ASSET="writecommit"
INSTALL_DIR="$HOME/.local/bin"

# Parse command line arguments
Expand Down Expand Up @@ -70,7 +73,7 @@ else
*)
echo "❌ Unsupported OS: $OS"
echo "This script is for Linux and macOS only. For Windows, use:"
echo "iex (irm https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-web.ps1)"
echo "iex (irm https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-web.ps1)"
exit 1
;;
esac
Expand All @@ -91,13 +94,17 @@ fi
echo "📦 Latest version: $VERSION"

# Construct download URL
ASSET_NAME="${TOOL_NAME}-${VERSION}-${RUNTIME}.tar.gz"
ASSET_NAME="${TOOL_ASSET}-${RUNTIME}-${VERSION}.tar.gz"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$ASSET_NAME"

echo "⬇️ Downloading $ASSET_NAME..."

# Create temporary directory
# Create temporary directory and ensure cleanup
TEMP_DIR=$(mktemp -d)
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT
cd "$TEMP_DIR"

# Download the release
Expand All @@ -121,32 +128,32 @@ if [ ! -d "$INSTALL_DIR" ]; then
fi

# Install the binary
echo "📥 Installing $TOOL_NAME to $INSTALL_DIR..."
cp "$TOOL_NAME" "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/$TOOL_NAME"
echo "📥 Installing $BINARY_NAME to $INSTALL_DIR..."
cp "$BINARY_NAME" "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/$BINARY_NAME"

# Cleanup
cd - > /dev/null
rm -rf "$TEMP_DIR"
Copy link

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit removal of the temporary directory is redundant since a cleanup trap is already in place. Removing this duplicate call will simplify the script.

Suggested change
rm -rf "$TEMP_DIR"

Copilot uses AI. Check for mistakes.

echo "✅ $TOOL_NAME $VERSION ($RUNTIME) installed successfully!"
echo "✅ $BINARY_NAME $VERSION ($RUNTIME) installed successfully!"
echo ""
echo "📝 Note: Make sure $INSTALL_DIR is in your PATH."
echo " Add this line to your ~/.bashrc or ~/.zshrc:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
echo ""
echo "🚀 Example usage:"
echo " git add ."
echo " $TOOL_NAME"
echo " $TOOL_NAME --dry-run"
echo " $TOOL_NAME --verbose"
echo " $BINARY_NAME"
echo " $BINARY_NAME --dry-run"
echo " $BINARY_NAME --verbose"

# Check if binary is in PATH
if command -v "$TOOL_NAME" >/dev/null 2>&1; then
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
echo ""
echo "🎉 $TOOL_NAME is ready to use!"
echo "🎉 $BINARY_NAME is ready to use!"
else
echo ""
echo "⚠️ $TOOL_NAME is not in your PATH. Restart your shell or run:"
echo "⚠️ $BINARY_NAME is not in your PATH. Restart your shell or run:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
fi
4 changes: 2 additions & 2 deletions install-web.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Web installer for WriteCommit tool (Windows)
# Usage: iex (irm https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-web.ps1)
# Usage: iex (irm https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-web.ps1)

param(
[string]$InstallDir = "$env:LOCALAPPDATA\Programs\WriteCommit",
Expand All @@ -9,7 +9,7 @@ param(
$ErrorActionPreference = "Stop"

# Configuration
$Repo = "PatrickRuddiman/Toolkit"
$Repo = "PatrickRuddiman/WriteCommit"
$ToolName = "writecommit"
$Platform = "windows"
$Arch = "x64"
Expand Down
53 changes: 32 additions & 21 deletions install-web.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash
# Web installer for WriteCommit tool (Linux/macOS)
# Usage: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-web.sh | bash
# Usage: curl -sSL https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-web.sh | bash

set -e

# Configuration
REPO="PatrickRuddiman/Toolkit"
TOOL_NAME="WriteCommit"
REPO="PatrickRuddiman/WriteCommit"
# Name of the binary within the archive
BINARY_NAME="WriteCommit"
# Prefix for assets
TOOL_ASSET="writecommit"
INSTALL_DIR="$HOME/.local/share/WriteCommit"
BIN_DIR="$HOME/.local/bin"
VERSION="latest"
Expand Down Expand Up @@ -44,7 +47,7 @@ case $OS in
*)
echo "❌ Unsupported OS: $OS"
echo "This script is for Linux and macOS only. For Windows, use the PowerShell installer:"
echo "iex (irm https://raw.githubusercontent.com/PatrickRuddiman/Toolkit/main/Tools/Write-Commit/install-web.ps1)"
echo "iex (irm https://raw.githubusercontent.com/PatrickRuddiman/WriteCommit/main/install-web.ps1)"
exit 1
;;
esac
Expand Down Expand Up @@ -81,13 +84,17 @@ fi
echo "📦 Version: $VERSION"

# Construct download URL with correct naming pattern
ASSET_NAME="${TOOL_NAME}-${PLATFORM}-${ARCH_TAG}-${VERSION}.tar.gz"
ASSET_NAME="${TOOL_ASSET}-${PLATFORM}-${ARCH_TAG}-${VERSION}.tar.gz"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$ASSET_NAME"

echo "⬇️ Downloading $ASSET_NAME from $DOWNLOAD_URL..."

# Create temporary directory
# Create temporary directory and ensure cleanup
TEMP_DIR=$(mktemp -d)
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT
cd "$TEMP_DIR"

# Download the release
Expand Down Expand Up @@ -120,10 +127,10 @@ fi

# Create a wrapper script in the bin directory
echo "📥 Creating wrapper script in $BIN_DIR..."
WRAPPER_PATH="$BIN_DIR/$TOOL_NAME"
WRAPPER_PATH="$BIN_DIR/$BINARY_NAME"
cat > "$WRAPPER_PATH" << EOF
#!/bin/bash
exec "$INSTALL_DIR/$TOOL_NAME" "\$@"
exec "$INSTALL_DIR/$BINARY_NAME" "\$@"
EOF
chmod +x "$WRAPPER_PATH"

Expand All @@ -138,9 +145,11 @@ update_shell_config() {

if [ -f "$config_file" ]; then
if ! grep -q "$BIN_DIR" "$config_file"; then
echo "" >> "$config_file"
echo "# Added by WriteCommit installer" >> "$config_file"
echo "$path_entry" >> "$config_file"
{
echo ""
echo "# Added by WriteCommit installer"
echo "$path_entry"
} >> "$config_file"
echo "✅ Updated $config_file"
return 0
else
Expand Down Expand Up @@ -170,9 +179,11 @@ if command -v fish >/dev/null 2>&1 || [ "$SHELL" = "/usr/bin/fish" ]; then
if [ -f "$FISH_CONFIG" ]; then
if ! grep -q "$BIN_DIR" "$FISH_CONFIG"; then
mkdir -p "$(dirname "$FISH_CONFIG")"
echo "" >> "$FISH_CONFIG"
echo "# Added by WriteCommit installer" >> "$FISH_CONFIG"
echo "fish_add_path $BIN_DIR" >> "$FISH_CONFIG"
{
echo ""
echo "# Added by WriteCommit installer"
echo "fish_add_path $BIN_DIR"
} >> "$FISH_CONFIG"
echo "✅ Updated $FISH_CONFIG"
PATH_UPDATED=true
else
Expand All @@ -188,21 +199,21 @@ if [ "$PATH_UPDATED" = false ]; then
fi

echo ""
echo "✅ WriteCommit $VERSION installed successfully!"
echo "✅ $BINARY_NAME $VERSION installed successfully!"
echo ""
echo "📂 Installation directory: $INSTALL_DIR"
echo "🚀 Example usage:"
echo " git add ."
echo " WriteCommit"
echo " WriteCommit --dry-run"
echo " WriteCommit --verbose"
echo " $BINARY_NAME"
echo " $BINARY_NAME --dry-run"
echo " $BINARY_NAME --verbose"

# Check if binary is in PATH
if command -v WriteCommit >/dev/null 2>&1; then
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
echo ""
echo "🎉 WriteCommit is ready to use!"
echo "🎉 $BINARY_NAME is ready to use!"
else
echo ""
echo "⚠️ You need to restart your terminal or run the following command to use WriteCommit in this session:"
echo "⚠️ You need to restart your terminal or run the following command to use $BINARY_NAME in this session:"
echo " export PATH=\"$BIN_DIR:\$PATH\""
fi
9 changes: 2 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ runtime="linux-x64"
exeName="WriteCommit"

echo "Publishing WriteCommit for $runtime..."
dotnet publish WriteCommit.csproj --configuration Release --runtime $runtime --self-contained true --output "publish/$runtime"

if [ $? -eq 0 ]; then
if dotnet publish WriteCommit.csproj --configuration Release --runtime "$runtime" --self-contained true --output "publish/$runtime"; then
echo "Publish successful!"

# Create a directory in user's local bin if it doesn't exist
Expand All @@ -23,10 +21,7 @@ if [ $? -eq 0 ]; then
targetPath="$localBin/$exeName"

echo "Installing WriteCommit to $targetPath..."
cp "$sourcePath" "$targetPath"
chmod +x "$targetPath"

if [ $? -eq 0 ]; then
if cp "$sourcePath" "$targetPath" && chmod +x "$targetPath"; then
echo "✅ WriteCommit installed successfully!"

echo "Note: Make sure $localBin is in your PATH."
Expand Down