From 4c77a05993d40c42ebe78c1d3a72f8049f360982 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 24 Jan 2026 03:56:35 +0800 Subject: Move deployment scripts to scripts/dev directory --- .gitignore | 6 +++ deploy.ps1 | 69 ---------------------------------- deploy.sh | 57 ---------------------------- dev_deploy.ps1 | 19 ---------- dev_deploy.sh | 15 -------- scripts/dev/.gitignore | 1 + scripts/dev/deploy.ps1 | 78 +++++++++++++++++++++++++++++++++++++++ scripts/dev/deploy.sh | 57 ++++++++++++++++++++++++++++ scripts/dev/dev_deploy.ps1 | 28 ++++++++++++++ scripts/dev/dev_deploy.sh | 15 ++++++++ scripts/dev/hide_ignored_file.ps1 | 43 +++++++++++++++++++++ scripts/hide_ignored_file.ps1 | 29 --------------- scripts/make_lnk.ps1 | 24 ++++++++++++ scripts/make_lnk.sh | 22 +++++++++++ 14 files changed, 274 insertions(+), 189 deletions(-) delete mode 100644 deploy.ps1 delete mode 100755 deploy.sh delete mode 100644 dev_deploy.ps1 delete mode 100644 dev_deploy.sh create mode 100644 scripts/dev/.gitignore create mode 100644 scripts/dev/deploy.ps1 create mode 100644 scripts/dev/deploy.sh create mode 100644 scripts/dev/dev_deploy.ps1 create mode 100644 scripts/dev/dev_deploy.sh create mode 100644 scripts/dev/hide_ignored_file.ps1 delete mode 100644 scripts/hide_ignored_file.ps1 create mode 100644 scripts/make_lnk.ps1 create mode 100644 scripts/make_lnk.sh diff --git a/.gitignore b/.gitignore index 392d233..9cfca26 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,9 @@ _*.rs /src/cmds.rs /src/arguments.rs /src/renderers.rs + +# Symbolic links and shortcuts created by scripts +/deploy.lnk +/dev.lnk +/deploy +/dev diff --git a/deploy.ps1 b/deploy.ps1 deleted file mode 100644 index cf2eef3..0000000 --- a/deploy.ps1 +++ /dev/null @@ -1,69 +0,0 @@ -# Require : Cargo (Rust), ISCC (Inno Setup) - -# Set location to script directory -$scriptPath = $MyInvocation.MyCommand.Path -$scriptDir = Split-Path $scriptPath -Parent -Set-Location $scriptDir - -# Check for ISCC -$isccPath = Get-Command ISCC -ErrorAction SilentlyContinue -if (-not $isccPath) { - Write-Warning '"Inno Setup" not installed. (https://jrsoftware.org/isinfo.php)' - exit 1 -} - -# Check if core library exists -$coreLibPath = "..\VersionControl\" -if (-not (Test-Path $coreLibPath)) { - Write-Warning "Core library not found at $coreLibPath. Aborting build." - exit 1 -} - -# Test core library -Write-Host "Testing Core Library `".\..\VersionControl\Cargo.toml`"" -cargo test --manifest-path ..\VersionControl\Cargo.toml --workspace --quiet -if ($LASTEXITCODE -ne 0) { - Write-Warning "Core library tests failed. Aborting build." - exit 1 -} - -# Test workspace -Write-Host "Testing Command Line `".\Cargo.toml`"" -cargo test --workspace --quiet -if ($LASTEXITCODE -ne 0) { - Write-Warning "Workspace tests failed. Aborting build." - exit 1 -} - -# Check if main git worktree is clean -$gitStatus = git status --porcelain -if ($gitStatus) { - Write-Warning "Git worktree is not clean. Commit or stash changes before building." - exit 1 -} - -# Check if core library git worktree is clean -Push-Location $coreLibPath -$coreGitStatus = git status --porcelain -Pop-Location -if ($coreGitStatus) { - Write-Warning "Core library git worktree is not clean. Commit or stash changes before building." - exit 1 -} - -# Build -$env:FORCE_BUILD=$(Get-Date -Format 'mmss') -Write-Host "Building `".\Cargo.toml`"" -cargo build --workspace --release --quiet -if ($LASTEXITCODE -ne 0) { - # Build failed -} else { - # Build succeeded - # Export - Write-Host "Deploying `".\.cargo\config.toml`"" - if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release) { - Copy-Item -Path templates\compile_info.rs.template -Destination src\data\compile_info.rs -Force - Write-Host "Packing Installer `".\setup\windows\setup_jv_cli.iss`"" - ISCC /Q .\setup\windows\setup_jv_cli.iss - } -} diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index c2403cf..0000000 --- a/deploy.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Require : Cargo (Rust) - -# Change to the directory where the script is located -cd "$(dirname "$0")" || exit 1 - -# Check if core library exists -coreLibPath="../VersionControl/" -if [ ! -d "$coreLibPath" ]; then - echo "Core library not found at $coreLibPath. Aborting build." - exit 1 -fi - -# Test core library -echo "Testing Core Library \"../VersionControl/Cargo.toml\"" -cargo test --manifest-path ../VersionControl/Cargo.toml --workspace --quiet -if [ $? -ne 0 ]; then - echo "Core library tests failed. Aborting build." - exit 1 -fi - -# Test workspace -echo "Testing Command Line \"./Cargo.toml\"" -cargo test --workspace --quiet -if [ $? -ne 0 ]; then - echo "Workspace tests failed. Aborting build." - exit 1 -fi - -# Check if main git worktree is clean -git_status=$(git status --porcelain) -if [ -n "$git_status" ]; then - echo "Git worktree is not clean. Commit or stash changes before building." - exit 1 -fi - -# Check if core library git worktree is clean -pushd "$coreLibPath" > /dev/null -core_git_status=$(git status --porcelain) -popd > /dev/null -if [ -n "$core_git_status" ]; then - echo "Core library git worktree is not clean. Commit or stash changes before building." - exit 1 -fi - -# Build -echo "Building \"./Cargo.toml\"" -if FORCE_BUILD=$(date +%s) cargo build --workspace --release --quiet; then - # Build succeeded - # Export - echo "Deploying \"./.cargo/config.toml\"" - if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release; then - # Copy compile_info.rs.template to compile_info.rs after successful export - cp -f templates/compile_info.rs.template src/data/compile_info.rs - fi -fi diff --git a/dev_deploy.ps1 b/dev_deploy.ps1 deleted file mode 100644 index 8e9bff0..0000000 --- a/dev_deploy.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Require : Cargo (Rust) - -# Set location to script directory -$scriptPath = $MyInvocation.MyCommand.Path -$scriptDir = Split-Path $scriptPath -Parent -Set-Location $scriptDir - -# Build -$env:FORCE_BUILD=$(Get-Date -Format 'mm') -cargo build --workspace -if ($LASTEXITCODE -ne 0) { - # Build failed -} else { - # Build succeeded - # Export - if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter debug) { - Copy-Item -Path templates\compile_info.rs.template -Destination src\data\compile_info.rs -Force - } -} diff --git a/dev_deploy.sh b/dev_deploy.sh deleted file mode 100644 index 1ae9ebf..0000000 --- a/dev_deploy.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Require : Cargo (Rust) - -# Change to the directory where the script is located -cd "$(dirname "$0")" || exit 1 - -# Build -if FORCE_BUILD=$(date +%M) cargo build --workspace; then - # Export - if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter debug; then - # Copy compile_info.rs.template to compile_info.rs after successful export - cp -f templates/compile_info.rs src/data/compile_info.rs - fi -fi diff --git a/scripts/dev/.gitignore b/scripts/dev/.gitignore new file mode 100644 index 0000000..50b595b --- /dev/null +++ b/scripts/dev/.gitignore @@ -0,0 +1 @@ +/last_check diff --git a/scripts/dev/deploy.ps1 b/scripts/dev/deploy.ps1 new file mode 100644 index 0000000..bc00cad --- /dev/null +++ b/scripts/dev/deploy.ps1 @@ -0,0 +1,78 @@ +# Require : Cargo (Rust), ISCC (Inno Setup) + +# Set location to script directory +$scriptPath = $MyInvocation.MyCommand.Path +$scriptDir = Split-Path $scriptPath -Parent + +# Run script to hide ignored files +$hideScriptPath = Join-Path $scriptDir "hide_ignored_file.ps1" +if (Test-Path $hideScriptPath) { + & $hideScriptPath +} else { + Write-Warning "hide_ignored_file.ps1 not found at $hideScriptPath" +} + +Set-Location (Join-Path $scriptDir "..\..") + +# Check for ISCC +$isccPath = Get-Command ISCC -ErrorAction SilentlyContinue +if (-not $isccPath) { + Write-Warning '"Inno Setup" not installed. (https://jrsoftware.org/isinfo.php)' + exit 1 +} + +# Check if core library exists +$coreLibPath = "..\VersionControl\" +if (-not (Test-Path $coreLibPath)) { + Write-Warning "Core library not found at $coreLibPath. Aborting build." + exit 1 +} + +# Test core library +Write-Host "Testing Core Library `".\..\VersionControl\Cargo.toml`"" +cargo test --manifest-path ..\VersionControl\Cargo.toml --workspace --quiet +if ($LASTEXITCODE -ne 0) { + Write-Warning "Core library tests failed. Aborting build." + exit 1 +} + +# Test workspace +Write-Host "Testing Command Line `".\Cargo.toml`"" +cargo test --workspace --quiet +if ($LASTEXITCODE -ne 0) { + Write-Warning "Workspace tests failed. Aborting build." + exit 1 +} + +# Check if main git worktree is clean +$gitStatus = git status --porcelain +if ($gitStatus) { + Write-Warning "Git worktree is not clean. Commit or stash changes before building." + exit 1 +} + +# Check if core library git worktree is clean +Push-Location $coreLibPath +$coreGitStatus = git status --porcelain +Pop-Location +if ($coreGitStatus) { + Write-Warning "Core library git worktree is not clean. Commit or stash changes before building." + exit 1 +} + +# Build +$env:FORCE_BUILD=$(Get-Date -Format 'mmss') +Write-Host "Building `".\Cargo.toml`"" +cargo build --workspace --release --quiet +if ($LASTEXITCODE -ne 0) { + # Build failed +} else { + # Build succeeded + # Export + Write-Host "Deploying `".\.cargo\config.toml`"" + if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release) { + Copy-Item -Path templates\compile_info.rs.template -Destination src\data\compile_info.rs -Force + Write-Host "Packing Installer `".\setup\windows\setup_jv_cli.iss`"" + ISCC /Q .\setup\windows\setup_jv_cli.iss + } +} diff --git a/scripts/dev/deploy.sh b/scripts/dev/deploy.sh new file mode 100644 index 0000000..429ea0a --- /dev/null +++ b/scripts/dev/deploy.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Require : Cargo (Rust) + +# Change to the directory where the script is located +cd "$(dirname "$0")/../../" || exit 1 + +# Check if core library exists +coreLibPath="../VersionControl/" +if [ ! -d "$coreLibPath" ]; then + echo "Core library not found at $coreLibPath. Aborting build." + exit 1 +fi + +# Test core library +echo "Testing Core Library \"../VersionControl/Cargo.toml\"" +cargo test --manifest-path ../VersionControl/Cargo.toml --workspace --quiet +if [ $? -ne 0 ]; then + echo "Core library tests failed. Aborting build." + exit 1 +fi + +# Test workspace +echo "Testing Command Line \"./Cargo.toml\"" +cargo test --workspace --quiet +if [ $? -ne 0 ]; then + echo "Workspace tests failed. Aborting build." + exit 1 +fi + +# Check if main git worktree is clean +git_status=$(git status --porcelain) +if [ -n "$git_status" ]; then + echo "Git worktree is not clean. Commit or stash changes before building." + exit 1 +fi + +# Check if core library git worktree is clean +pushd "$coreLibPath" > /dev/null +core_git_status=$(git status --porcelain) +popd > /dev/null +if [ -n "$core_git_status" ]; then + echo "Core library git worktree is not clean. Commit or stash changes before building." + exit 1 +fi + +# Build +echo "Building \"./Cargo.toml\"" +if FORCE_BUILD=$(date +%s) cargo build --workspace --release --quiet; then + # Build succeeded + # Export + echo "Deploying \"./.cargo/config.toml\"" + if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release; then + # Copy compile_info.rs.template to compile_info.rs after successful export + cp -f templates/compile_info.rs.template src/data/compile_info.rs + fi +fi diff --git a/scripts/dev/dev_deploy.ps1 b/scripts/dev/dev_deploy.ps1 new file mode 100644 index 0000000..8e3a8e9 --- /dev/null +++ b/scripts/dev/dev_deploy.ps1 @@ -0,0 +1,28 @@ +# Require : Cargo (Rust) + +# Set location to script directory +$scriptPath = $MyInvocation.MyCommand.Path +$scriptDir = Split-Path $scriptPath -Parent + +# Run script to hide ignored files +$hideScriptPath = Join-Path $scriptDir "hide_ignored_file.ps1" +if (Test-Path $hideScriptPath) { + & $hideScriptPath +} else { + Write-Warning "hide_ignored_file.ps1 not found at $hideScriptPath" +} + +Set-Location (Join-Path $scriptDir "..\..") + +# Build +$env:FORCE_BUILD=$(Get-Date -Format 'mm') +cargo build --workspace +if ($LASTEXITCODE -ne 0) { + # Build failed +} else { + # Build succeeded + # Export + if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter debug) { + Copy-Item -Path templates\compile_info.rs.template -Destination src\data\compile_info.rs -Force + } +} diff --git a/scripts/dev/dev_deploy.sh b/scripts/dev/dev_deploy.sh new file mode 100644 index 0000000..6127645 --- /dev/null +++ b/scripts/dev/dev_deploy.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Require : Cargo (Rust) + +# Change to the directory where the script is located +cd "$(dirname "$0")/../../" || exit 1 + +# Build +if FORCE_BUILD=$(date +%M) cargo build --workspace; then + # Export + if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter debug; then + # Copy compile_info.rs.template to compile_info.rs after successful export + cp -f templates/compile_info.rs src/data/compile_info.rs + fi +fi diff --git a/scripts/dev/hide_ignored_file.ps1 b/scripts/dev/hide_ignored_file.ps1 new file mode 100644 index 0000000..0ab2632 --- /dev/null +++ b/scripts/dev/hide_ignored_file.ps1 @@ -0,0 +1,43 @@ +# Check `last_check` + +$lastCheckFile = Join-Path $PSScriptRoot "last_check" +$currentTime = Get-Date +$timeThreshold = 10 + +if (Test-Path $lastCheckFile) { + $lastCheckTime = Get-Content $lastCheckFile | Get-Date + $timeDiff = ($currentTime - $lastCheckTime).TotalMinutes + + if ($timeDiff -lt $timeThreshold) { + exit + } +} + +$currentTime.ToString() | Out-File -FilePath $lastCheckFile -Force + +# Hide Files + +Set-Location -Path (Join-Path $PSScriptRoot "..\..") + +Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object { + $_.FullName -notmatch '\\.temp\\' -and $_.FullName -notmatch '\\.git\\' +} | ForEach-Object { + attrib -h $_.FullName 2>&1 | Out-Null +} + +Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object { + $_.Name -match '^\..*' -and $_.FullName -notmatch '\\\.\.$' -and $_.FullName -notmatch '\\\.$' +} | ForEach-Object { + attrib +h $_.FullName 2>&1 | Out-Null +} + +if (Get-Command git -ErrorAction SilentlyContinue) { + git status --ignored --short | ForEach-Object { + if ($_ -match '^!!\s+(.+)$') { + $ignoredPath = $matches[1] + if ($ignoredPath -notmatch '\.lnk$' -and (Test-Path $ignoredPath)) { + attrib +h $ignoredPath 2>&1 | Out-Null + } + } + } +} diff --git a/scripts/hide_ignored_file.ps1 b/scripts/hide_ignored_file.ps1 deleted file mode 100644 index 27355c2..0000000 --- a/scripts/hide_ignored_file.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -# Hide all dotfiles and git-ignored files before build -# Set working directory to parent of script's directory -Set-Location -Path (Join-Path $PSScriptRoot "..") - -# First, unhide all files and directories in the current directory, but skip .temp and .git directories -Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object { - $_.FullName -notmatch '\\.temp\\' -and $_.FullName -notmatch '\\.git\\' -} | ForEach-Object { - attrib -h $_.FullName 2>&1 | Out-Null -} - -# Get all dotfiles and directories -Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object { - $_.Name -match '^\..*' -and $_.FullName -notmatch '\\\.\.$' -and $_.FullName -notmatch '\\\.$' -} | ForEach-Object { - attrib +h $_.FullName 2>&1 | Out-Null -} - -# Get git ignored files and hide them -if (Get-Command git -ErrorAction SilentlyContinue) { - git status --ignored --short | ForEach-Object { - if ($_ -match '^!!\s+(.+)$') { - $ignoredPath = $matches[1] - if (Test-Path $ignoredPath) { - attrib +h $ignoredPath 2>&1 | Out-Null - } - } - } -} diff --git a/scripts/make_lnk.ps1 b/scripts/make_lnk.ps1 new file mode 100644 index 0000000..67d7ec2 --- /dev/null +++ b/scripts/make_lnk.ps1 @@ -0,0 +1,24 @@ +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +Set-Location $scriptDir + +$deployPs1 = Join-Path $scriptDir "dev\deploy.ps1" +$devDeployPs1 = Join-Path $scriptDir "dev\dev_deploy.ps1" +$parentDir = Split-Path $scriptDir -Parent + +if (Test-Path $deployPs1) { + $linkPath = Join-Path $parentDir "deploy.lnk" + if (Test-Path $linkPath) { Remove-Item $linkPath -Force } + $WshShell = New-Object -ComObject WScript.Shell + $shortcut = $WshShell.CreateShortcut($linkPath) + $shortcut.TargetPath = $deployPs1 + $shortcut.Save() +} + +if (Test-Path $devDeployPs1) { + $linkPath = Join-Path $parentDir "dev.lnk" + if (Test-Path $linkPath) { Remove-Item $linkPath -Force } + $WshShell = New-Object -ComObject WScript.Shell + $shortcut = $WshShell.CreateShortcut($linkPath) + $shortcut.TargetPath = $devDeployPs1 + $shortcut.Save() +} diff --git a/scripts/make_lnk.sh b/scripts/make_lnk.sh new file mode 100644 index 0000000..3b52b97 --- /dev/null +++ b/scripts/make_lnk.sh @@ -0,0 +1,22 @@ +#!/bin/bash +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$(dirname "$0")" || exit 1 +deploy_sh="$script_dir/dev/deploy.sh" +dev_deploy_sh="$script_dir/dev/dev_deploy.sh" +parent_dir="$(dirname "$script_dir")" + +if [ -f "$deploy_sh" ]; then + link_path="$parent_dir/deploy" + if [ -e "$link_path" ]; then + rm -f "$link_path" + fi + ln -s "$deploy_sh" "$link_path" +fi + +if [ -f "$dev_deploy_sh" ]; then + link_path="$parent_dir/dev" + if [ -e "$link_path" ]; then + rm -f "$link_path" + fi + ln -s "$dev_deploy_sh" "$link_path" +fi -- cgit