summaryrefslogtreecommitdiff
path: root/Collect-Command-Line.ps1
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-09 21:30:49 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-09 21:30:49 +0800
commit6b9268d2d88c81c18f2cc21e343d321989dad99c (patch)
tree051a3e1ca1c49a8e67a4da2c59fec576fc9e6ec5 /Collect-Command-Line.ps1
parent3f8e818b58127a2fad66ed67032344f553632c38 (diff)
Set up project structure and CLI integration
Diffstat (limited to 'Collect-Command-Line.ps1')
-rw-r--r--Collect-Command-Line.ps161
1 files changed, 61 insertions, 0 deletions
diff --git a/Collect-Command-Line.ps1 b/Collect-Command-Line.ps1
new file mode 100644
index 0000000..d8705a2
--- /dev/null
+++ b/Collect-Command-Line.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"
+ }
+}