From 2b41209f2b76d4067867be466bdcfed478ff3f39 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 24 Jan 2026 04:41:19 +0800 Subject: Move setup scripts to scripts/setup directory --- .gitignore | 2 +- README.md | 7 ---- README_zh_CN.md | 7 ---- build.rs | 2 +- scripts/setup/linux/inst.sh | 88 ++++++++++++++++++++++++++++++++++++++++ scripts/setup/windows/inst.ps1 | 19 +++++++++ scripts/setup/windows/uninst.ps1 | 39 ++++++++++++++++++ setup/linux/inst.sh | 88 ---------------------------------------- setup/windows/inst.ps1 | 19 --------- setup/windows/uninst.ps1 | 39 ------------------ 10 files changed, 148 insertions(+), 162 deletions(-) create mode 100644 scripts/setup/linux/inst.sh create mode 100644 scripts/setup/windows/inst.ps1 create mode 100644 scripts/setup/windows/uninst.ps1 delete mode 100644 setup/linux/inst.sh delete mode 100644 setup/windows/inst.ps1 delete mode 100644 setup/windows/uninst.ps1 diff --git a/.gitignore b/.gitignore index 9cfca26..77d8158 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ # Generated from templates /src/data/compile_info.rs -/setup/windows/setup_jv_cli.iss +/scripts/setup/windows/setup_jv_cli.iss _*.rs # Generated by the build system diff --git a/README.md b/README.md index 3fbdf32..736ee62 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,3 @@

- -# Install (From Source Code) - -```bash -# Linux -curl -s https://raw.githubusercontent.com/JustEnoughVCS/CommandLine/main/setup/linux/inst.sh | bash -``` diff --git a/README_zh_CN.md b/README_zh_CN.md index 5fb207c..ed64bd1 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -15,10 +15,3 @@

- -# 安装 (从源码编译) - -```bash -# Linux -curl -s https://raw.githubusercontent.com/JustEnoughVCS/CommandLine/main/setup/linux/inst.sh | bash -``` diff --git a/build.rs b/build.rs index 8ee2245..ed427f0 100644 --- a/build.rs +++ b/build.rs @@ -10,7 +10,7 @@ const COMPILE_INFO_RS_TEMPLATE: &str = "./templates/compile_info.rs.template"; const COMPILE_INFO_RS: &str = "./src/data/compile_info.rs"; const SETUP_JV_CLI_ISS_TEMPLATE: &str = "./templates/setup_jv_cli.iss.template"; -const SETUP_JV_CLI_ISS: &str = "./setup/windows/setup_jv_cli.iss"; +const SETUP_JV_CLI_ISS: &str = "./scripts/setup/windows/setup_jv_cli.iss"; const REGISTRY_RS_TEMPLATE: &str = "./templates/_registry.rs.template"; const REGISTRY_RS: &str = "./src/systems/cmd/_registry.rs"; diff --git a/scripts/setup/linux/inst.sh b/scripts/setup/linux/inst.sh new file mode 100644 index 0000000..ec609fc --- /dev/null +++ b/scripts/setup/linux/inst.sh @@ -0,0 +1,88 @@ +# Check if required tools are installed +echo "Checking for required tools..." +if ! command -v cargo &> /dev/null; then + echo "Error: cargo is not installed. Please install Rust and Cargo first." + exit 1 +fi +if ! command -v git &> /dev/null; then + echo "Error: git is not installed. Please install git first." + exit 1 +fi + +# Set installation directory to current directory +echo "Installation directory set to current directory: $(pwd)" +install_dir="$(pwd)" + +# Clone or update repos +echo "Cloning or updating repositories..." +mkdir -p "$install_dir" +cd "$install_dir" + +# Function to clone or pull repository +clone_or_pull() { + local repo_url="$1" + local repo_name=$(basename "$repo_url") + + if [ -d "$repo_name" ]; then + echo "Repository $repo_name already exists, pulling latest changes..." + cd "$repo_name" + git pull origin main + cd .. + else + echo "Cloning $repo_name..." + git clone "$repo_url" + fi +} + +# Clone or update repositories +clone_or_pull https://github.com/JustEnoughVCS/CommandLine +clone_or_pull https://github.com/JustEnoughVCS/VersionControl + +# Setup VersionControl repo +echo "Setting up VersionControl..." +cd VersionControl +chmod +x setup.sh +./setup.sh + +# Build CLI +echo "Building CLI..." +cd ../CommandLine +chmod +x deploy.sh +./scripts/dev/deploy.sh + +# Configure shell to include CLI in PATH +echo "Now adding JustEnoughVCS CLI to your environment. Please select your target shell:" +echo "1) ~/.zshrc (Zsh)" +echo "2) ~/.bashrc (Bash)" +echo "3) ~/.config/fish/config.fish (Fish)" +echo "4) Skip shell configuration" +echo -n "Enter your choice (1-4): " +read choice + +case $choice in + 1) + config_file="$HOME/.zshrc" + ;; + 2) + config_file="$HOME/.bashrc" + ;; + 3) + config_file="$HOME/.config/fish/config.fish" + ;; + 4) + echo "Skipping shell configuration." + echo "Installation completed! You can manually add the CLI to your PATH later." + exit 0 + ;; + *) + echo "Invalid choice. Skipping shell configuration." + exit 0 + ;; +esac + +cli_path="$(pwd)/export/jv_cli.sh" +echo "# JustEnoughVCS CLI" >> "$config_file" +echo "source \"$cli_path\"" >> "$config_file" +echo "CLI has been added to $config_file" +echo "Please restart your shell or run: source $config_file" +echo "Installation completed successfully!" diff --git a/scripts/setup/windows/inst.ps1 b/scripts/setup/windows/inst.ps1 new file mode 100644 index 0000000..4cb4772 --- /dev/null +++ b/scripts/setup/windows/inst.ps1 @@ -0,0 +1,19 @@ +# Execute uninstall script, attempt to remove leftover PROFILE entries +. ".\uninst.ps1" + +# Calculate directories +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$parentDir = Split-Path -Parent $scriptDir + +# Write configuration to PROFILE +Add-Content -Path $PROFILE -Value "# JustEnoughVCS - Begin #" +Add-Content -Path $PROFILE -Value ". `"$parentDir\jv_cli.ps1`"" +Add-Content -Path $PROFILE -Value "# JustEnoughVCS - End #" + +# Check dependencies, if OpenSSL is not found, show a prompt +try { + $null = Get-Command openssl -ErrorAction Stop +} catch { + $wshell = New-Object -ComObject Wscript.Shell + $wshell.Popup("OpenSSL was not found on your computer. JustEnoughVCS key generation depends on OpenSSL.", 0, "JustEnoughVCS Installation", 0x0 + 0x30) +} diff --git a/scripts/setup/windows/uninst.ps1 b/scripts/setup/windows/uninst.ps1 new file mode 100644 index 0000000..d5c898d --- /dev/null +++ b/scripts/setup/windows/uninst.ps1 @@ -0,0 +1,39 @@ +$profileContent = Get-Content $PROFILE -ErrorAction SilentlyContinue +if ($profileContent) { + $startMarker = "# JustEnoughVCS - Begin #" + $endMarker = "# JustEnoughVCS - End #" + $newContent = @() + $insideBlock = $false + $foundStart = $false + + foreach ($line in $profileContent) { + if ($line.Trim() -eq $startMarker) { + $insideBlock = $true + $foundStart = $true + continue + } + if ($line.Trim() -eq $endMarker) { + $insideBlock = $false + continue + } + if (-not $insideBlock) { + $newContent += $line + } + } + + if ($foundStart -and $insideBlock) { + $newContent = @() + $insideBlock = $false + foreach ($line in $profileContent) { + if ($line.Trim() -eq $startMarker) { + $insideBlock = $true + continue + } + if (-not $insideBlock) { + $newContent += $line + } + } + } + + $newContent | Set-Content $PROFILE +} diff --git a/setup/linux/inst.sh b/setup/linux/inst.sh deleted file mode 100644 index 519121b..0000000 --- a/setup/linux/inst.sh +++ /dev/null @@ -1,88 +0,0 @@ -# Check if required tools are installed -echo "Checking for required tools..." -if ! command -v cargo &> /dev/null; then - echo "Error: cargo is not installed. Please install Rust and Cargo first." - exit 1 -fi -if ! command -v git &> /dev/null; then - echo "Error: git is not installed. Please install git first." - exit 1 -fi - -# Set installation directory to current directory -echo "Installation directory set to current directory: $(pwd)" -install_dir="$(pwd)" - -# Clone or update repos -echo "Cloning or updating repositories..." -mkdir -p "$install_dir" -cd "$install_dir" - -# Function to clone or pull repository -clone_or_pull() { - local repo_url="$1" - local repo_name=$(basename "$repo_url") - - if [ -d "$repo_name" ]; then - echo "Repository $repo_name already exists, pulling latest changes..." - cd "$repo_name" - git pull origin main - cd .. - else - echo "Cloning $repo_name..." - git clone "$repo_url" - fi -} - -# Clone or update repositories -clone_or_pull https://github.com/JustEnoughVCS/CommandLine -clone_or_pull https://github.com/JustEnoughVCS/VersionControl - -# Setup VersionControl repo -echo "Setting up VersionControl..." -cd VersionControl -chmod +x setup.sh -./setup.sh - -# Build CLI -echo "Building CLI..." -cd ../CommandLine -chmod +x deploy.sh -./deploy.sh - -# Configure shell to include CLI in PATH -echo "Now adding JustEnoughVCS CLI to your environment. Please select your target shell:" -echo "1) ~/.zshrc (Zsh)" -echo "2) ~/.bashrc (Bash)" -echo "3) ~/.config/fish/config.fish (Fish)" -echo "4) Skip shell configuration" -echo -n "Enter your choice (1-4): " -read choice - -case $choice in - 1) - config_file="$HOME/.zshrc" - ;; - 2) - config_file="$HOME/.bashrc" - ;; - 3) - config_file="$HOME/.config/fish/config.fish" - ;; - 4) - echo "Skipping shell configuration." - echo "Installation completed! You can manually add the CLI to your PATH later." - exit 0 - ;; - *) - echo "Invalid choice. Skipping shell configuration." - exit 0 - ;; -esac - -cli_path="$(pwd)/export/jv_cli.sh" -echo "# JustEnoughVCS CLI" >> "$config_file" -echo "source \"$cli_path\"" >> "$config_file" -echo "CLI has been added to $config_file" -echo "Please restart your shell or run: source $config_file" -echo "Installation completed successfully!" diff --git a/setup/windows/inst.ps1 b/setup/windows/inst.ps1 deleted file mode 100644 index 4cb4772..0000000 --- a/setup/windows/inst.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Execute uninstall script, attempt to remove leftover PROFILE entries -. ".\uninst.ps1" - -# Calculate directories -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$parentDir = Split-Path -Parent $scriptDir - -# Write configuration to PROFILE -Add-Content -Path $PROFILE -Value "# JustEnoughVCS - Begin #" -Add-Content -Path $PROFILE -Value ". `"$parentDir\jv_cli.ps1`"" -Add-Content -Path $PROFILE -Value "# JustEnoughVCS - End #" - -# Check dependencies, if OpenSSL is not found, show a prompt -try { - $null = Get-Command openssl -ErrorAction Stop -} catch { - $wshell = New-Object -ComObject Wscript.Shell - $wshell.Popup("OpenSSL was not found on your computer. JustEnoughVCS key generation depends on OpenSSL.", 0, "JustEnoughVCS Installation", 0x0 + 0x30) -} diff --git a/setup/windows/uninst.ps1 b/setup/windows/uninst.ps1 deleted file mode 100644 index d5c898d..0000000 --- a/setup/windows/uninst.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -$profileContent = Get-Content $PROFILE -ErrorAction SilentlyContinue -if ($profileContent) { - $startMarker = "# JustEnoughVCS - Begin #" - $endMarker = "# JustEnoughVCS - End #" - $newContent = @() - $insideBlock = $false - $foundStart = $false - - foreach ($line in $profileContent) { - if ($line.Trim() -eq $startMarker) { - $insideBlock = $true - $foundStart = $true - continue - } - if ($line.Trim() -eq $endMarker) { - $insideBlock = $false - continue - } - if (-not $insideBlock) { - $newContent += $line - } - } - - if ($foundStart -and $insideBlock) { - $newContent = @() - $insideBlock = $false - foreach ($line in $profileContent) { - if ($line.Trim() -eq $startMarker) { - $insideBlock = $true - continue - } - if (-not $insideBlock) { - $newContent += $line - } - } - } - - $newContent | Set-Content $PROFILE -} -- cgit