From 75f7578d784a4e209da4b29a80d27940197d8945 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 9 Jan 2026 23:58:47 +0800 Subject: Rename build scripts to Pre-Build --- Collect-Command-Line.ps1 | 61 ------------------------------------------------ Collect-Command-Line.sh | 53 ----------------------------------------- Pre-Build.ps1 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ Pre-Build.sh | 53 +++++++++++++++++++++++++++++++++++++++++ Run-Desktop.ps1 | 2 +- Run-Desktop.sh | 2 +- Run-WrapperExample.ps1 | 2 +- Run-WrapperExample.sh | 2 +- 8 files changed, 118 insertions(+), 118 deletions(-) delete mode 100644 Collect-Command-Line.ps1 delete mode 100644 Collect-Command-Line.sh create mode 100644 Pre-Build.ps1 create mode 100644 Pre-Build.sh diff --git a/Collect-Command-Line.ps1 b/Collect-Command-Line.ps1 deleted file mode 100644 index d8705a2..0000000 --- a/Collect-Command-Line.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -# Set current working directory to the script's directory -Set-Location -Path $PSScriptRoot - -# Define the path to the target CLI executable -$cliPath = ".\.Temp\Debug\JustEnoughVCS.exe" - -# Check if the target CLI file already exists -if (-not (Test-Path $cliPath)) { - # If the file does not exist, define the relative path to the command-line project directory - $commandLineDir = ".\..\CommandLine" - - # Check if the command-line project directory exists - if (-not (Test-Path $commandLineDir)) { - # If the directory does not exist, output an error and exit the script - Write-Error "Error: $commandLineDir Not Found!" - exit 1 - } - - # Define the path to the pre-built CLI executable - $jvExePath = "$commandLineDir\.temp\deploy\bin\jv.exe" - - # Check if the pre-built CLI file exists - if (Test-Path $jvExePath) { - # If the pre-built file exists, ensure the target directory exists - $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force - # Copy the pre-built file to the target location - Copy-Item -Path $jvExePath -Destination $cliPath -Force - # Output a completion notification - Write-Host "CLI copied to $cliPath" - } - else { - # If the pre-built file does not exist, define the path to the deployment script - $deployScriptPath = "$commandLineDir\deploy.ps1" - - # Check if the deployment script exists - if (-not (Test-Path $deployScriptPath)) { - # If the deployment script does not exist, output an error and exit - Write-Error "Error: $deployScriptPath Not Found!" - exit 1 - } - - # Output a notification that building is starting - Write-Host "Building CLI from deploy.ps1..." - # Execute the deployment script to build the CLI - & $deployScriptPath - - # Check if the CLI file is generated after building - if (-not (Test-Path $jvExePath)) { - # If the file still does not exist after building, output an error and exit - Write-Error "Error: $jvExePath Not Found after deployment!" - exit 1 - } - - # Ensure the target directory exists - $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force - # Copy the newly built file to the target location - Copy-Item -Path $jvExePath -Destination $cliPath -Force - # Output a notification that building and copying are complete - Write-Host "CLI built and copied to $cliPath" - } -} diff --git a/Collect-Command-Line.sh b/Collect-Command-Line.sh deleted file mode 100644 index 61545b7..0000000 --- a/Collect-Command-Line.sh +++ /dev/null @@ -1,53 +0,0 @@ -# Get the absolute path of the directory where the current script is located -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# Switch to the script's directory, exit if it fails -cd "$SCRIPT_DIR" || exit 1 - -# Define the target path for the CLI tool -cliPath=".Temp/Debug/JustEnoughVCS" - -# Check if the CLI already exists at the target path -if [ ! -f "$cliPath" ]; then - # Check if the CommandLine directory exists in the parent directory - if [ -d "./../CommandLine/" ]; then - # Check if a built CLI executable already exists - if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then - # Create the target directory (if it doesn't exist) - mkdir -p "$(dirname "$cliPath")" - # Copy the CLI executable to the target path - cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath" - # Add execute permission - chmod +x "$cliPath" - echo "CLI copied to $cliPath" - else - # Check if a deployment script exists - if [ -f "./../CommandLine/deploy.sh" ]; then - echo "Building CLI from deploy.sh..." - # Enter the CommandLine directory and execute the deployment script - (cd "./../CommandLine" && ./deploy.sh) - # Check if the CLI executable was generated after deployment - if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then - # Create the target directory (if it doesn't exist) - mkdir -p "$(dirname "$cliPath")" - # Copy the newly built CLI executable - cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath" - # Add execute permission - chmod +x "$cliPath" - echo "CLI built and copied to $cliPath" - else - # CLI executable still not found after deployment, error and exit - echo "Error: ./../CommandLine/.temp/deploy/bin/jv Not Found after deployment!" - exit 1 - fi - else - # Deployment script not found, error and exit - echo "Error: ./../CommandLine/deploy.sh Not Found!" - exit 1 - fi - fi - else - # CommandLine directory not found, error and exit - echo "Error: ./../CommandLine/ Not Found!" - exit 1 - fi -fi diff --git a/Pre-Build.ps1 b/Pre-Build.ps1 new file mode 100644 index 0000000..d8705a2 --- /dev/null +++ b/Pre-Build.ps1 @@ -0,0 +1,61 @@ +# Set current working directory to the script's directory +Set-Location -Path $PSScriptRoot + +# Define the path to the target CLI executable +$cliPath = ".\.Temp\Debug\JustEnoughVCS.exe" + +# Check if the target CLI file already exists +if (-not (Test-Path $cliPath)) { + # If the file does not exist, define the relative path to the command-line project directory + $commandLineDir = ".\..\CommandLine" + + # Check if the command-line project directory exists + if (-not (Test-Path $commandLineDir)) { + # If the directory does not exist, output an error and exit the script + Write-Error "Error: $commandLineDir Not Found!" + exit 1 + } + + # Define the path to the pre-built CLI executable + $jvExePath = "$commandLineDir\.temp\deploy\bin\jv.exe" + + # Check if the pre-built CLI file exists + if (Test-Path $jvExePath) { + # If the pre-built file exists, ensure the target directory exists + $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force + # Copy the pre-built file to the target location + Copy-Item -Path $jvExePath -Destination $cliPath -Force + # Output a completion notification + Write-Host "CLI copied to $cliPath" + } + else { + # If the pre-built file does not exist, define the path to the deployment script + $deployScriptPath = "$commandLineDir\deploy.ps1" + + # Check if the deployment script exists + if (-not (Test-Path $deployScriptPath)) { + # If the deployment script does not exist, output an error and exit + Write-Error "Error: $deployScriptPath Not Found!" + exit 1 + } + + # Output a notification that building is starting + Write-Host "Building CLI from deploy.ps1..." + # Execute the deployment script to build the CLI + & $deployScriptPath + + # Check if the CLI file is generated after building + if (-not (Test-Path $jvExePath)) { + # If the file still does not exist after building, output an error and exit + Write-Error "Error: $jvExePath Not Found after deployment!" + exit 1 + } + + # Ensure the target directory exists + $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force + # Copy the newly built file to the target location + Copy-Item -Path $jvExePath -Destination $cliPath -Force + # Output a notification that building and copying are complete + Write-Host "CLI built and copied to $cliPath" + } +} diff --git a/Pre-Build.sh b/Pre-Build.sh new file mode 100644 index 0000000..61545b7 --- /dev/null +++ b/Pre-Build.sh @@ -0,0 +1,53 @@ +# Get the absolute path of the directory where the current script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Switch to the script's directory, exit if it fails +cd "$SCRIPT_DIR" || exit 1 + +# Define the target path for the CLI tool +cliPath=".Temp/Debug/JustEnoughVCS" + +# Check if the CLI already exists at the target path +if [ ! -f "$cliPath" ]; then + # Check if the CommandLine directory exists in the parent directory + if [ -d "./../CommandLine/" ]; then + # Check if a built CLI executable already exists + if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then + # Create the target directory (if it doesn't exist) + mkdir -p "$(dirname "$cliPath")" + # Copy the CLI executable to the target path + cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath" + # Add execute permission + chmod +x "$cliPath" + echo "CLI copied to $cliPath" + else + # Check if a deployment script exists + if [ -f "./../CommandLine/deploy.sh" ]; then + echo "Building CLI from deploy.sh..." + # Enter the CommandLine directory and execute the deployment script + (cd "./../CommandLine" && ./deploy.sh) + # Check if the CLI executable was generated after deployment + if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then + # Create the target directory (if it doesn't exist) + mkdir -p "$(dirname "$cliPath")" + # Copy the newly built CLI executable + cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath" + # Add execute permission + chmod +x "$cliPath" + echo "CLI built and copied to $cliPath" + else + # CLI executable still not found after deployment, error and exit + echo "Error: ./../CommandLine/.temp/deploy/bin/jv Not Found after deployment!" + exit 1 + fi + else + # Deployment script not found, error and exit + echo "Error: ./../CommandLine/deploy.sh Not Found!" + exit 1 + fi + fi + else + # CommandLine directory not found, error and exit + echo "Error: ./../CommandLine/ Not Found!" + exit 1 + fi +fi diff --git a/Run-Desktop.ps1 b/Run-Desktop.ps1 index 4cd542d..58f802a 100644 --- a/Run-Desktop.ps1 +++ b/Run-Desktop.ps1 @@ -1,4 +1,4 @@ -& ".\Collect-Command-Line.ps1" +& ".\Pre-Build.ps1" if ($LASTEXITCODE -eq 0) { dotnet run --project .\JVDesktop diff --git a/Run-Desktop.sh b/Run-Desktop.sh index 21a21f0..1ce299b 100644 --- a/Run-Desktop.sh +++ b/Run-Desktop.sh @@ -1,5 +1,5 @@ #!/bin/bash -./Collect-Command-Line.sh +./Pre-Build.sh if [ $? -eq 0 ]; then dotnet run --project ./JVDesktop diff --git a/Run-WrapperExample.ps1 b/Run-WrapperExample.ps1 index b2fda22..d976c19 100644 --- a/Run-WrapperExample.ps1 +++ b/Run-WrapperExample.ps1 @@ -1,4 +1,4 @@ -& ".\Collect-Command-Line.ps1" +& ".\Pre-Build.ps1" if ($LASTEXITCODE -eq 0) { Clear-Host diff --git a/Run-WrapperExample.sh b/Run-WrapperExample.sh index c51bbdb..42e633f 100644 --- a/Run-WrapperExample.sh +++ b/Run-WrapperExample.sh @@ -1,5 +1,5 @@ #!/bin/bash -./Collect-Command-Line.sh +./Pre-Build.sh if [ $? -eq 0 ]; then clear -- cgit