diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-24 03:56:35 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-24 04:31:03 +0800 |
| commit | 4c77a05993d40c42ebe78c1d3a72f8049f360982 (patch) | |
| tree | 81df02103be28bc88c0ff89f1857852255bdb32c | |
| parent | b32a021c2d5075303f5987e702c9df83e7c365e7 (diff) | |
Move deployment scripts to scripts/dev directory
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | scripts/dev/.gitignore | 1 | ||||
| -rw-r--r-- | scripts/dev/deploy.ps1 (renamed from deploy.ps1) | 11 | ||||
| -rw-r--r--[-rwxr-xr-x] | scripts/dev/deploy.sh (renamed from deploy.sh) | 2 | ||||
| -rw-r--r-- | scripts/dev/dev_deploy.ps1 (renamed from dev_deploy.ps1) | 11 | ||||
| -rw-r--r-- | scripts/dev/dev_deploy.sh (renamed from dev_deploy.sh) | 2 | ||||
| -rw-r--r-- | scripts/dev/hide_ignored_file.ps1 (renamed from scripts/hide_ignored_file.ps1) | 28 | ||||
| -rw-r--r-- | scripts/make_lnk.ps1 | 24 | ||||
| -rw-r--r-- | scripts/make_lnk.sh | 22 |
9 files changed, 96 insertions, 11 deletions
@@ -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/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/deploy.ps1 b/scripts/dev/deploy.ps1 index cf2eef3..bc00cad 100644 --- a/deploy.ps1 +++ b/scripts/dev/deploy.ps1 @@ -3,7 +3,16 @@ # Set location to script directory $scriptPath = $MyInvocation.MyCommand.Path $scriptDir = Split-Path $scriptPath -Parent -Set-Location $scriptDir + +# 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 diff --git a/deploy.sh b/scripts/dev/deploy.sh index c2403cf..429ea0a 100755..100644 --- a/deploy.sh +++ b/scripts/dev/deploy.sh @@ -3,7 +3,7 @@ # Require : Cargo (Rust) # Change to the directory where the script is located -cd "$(dirname "$0")" || exit 1 +cd "$(dirname "$0")/../../" || exit 1 # Check if core library exists coreLibPath="../VersionControl/" diff --git a/dev_deploy.ps1 b/scripts/dev/dev_deploy.ps1 index 8e9bff0..8e3a8e9 100644 --- a/dev_deploy.ps1 +++ b/scripts/dev/dev_deploy.ps1 @@ -3,7 +3,16 @@ # Set location to script directory $scriptPath = $MyInvocation.MyCommand.Path $scriptDir = Split-Path $scriptPath -Parent -Set-Location $scriptDir + +# 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') diff --git a/dev_deploy.sh b/scripts/dev/dev_deploy.sh index 1ae9ebf..6127645 100644 --- a/dev_deploy.sh +++ b/scripts/dev/dev_deploy.sh @@ -3,7 +3,7 @@ # Require : Cargo (Rust) # Change to the directory where the script is located -cd "$(dirname "$0")" || exit 1 +cd "$(dirname "$0")/../../" || exit 1 # Build if FORCE_BUILD=$(date +%M) cargo build --workspace; then diff --git a/scripts/hide_ignored_file.ps1 b/scripts/dev/hide_ignored_file.ps1 index 27355c2..0ab2632 100644 --- a/scripts/hide_ignored_file.ps1 +++ b/scripts/dev/hide_ignored_file.ps1 @@ -1,27 +1,41 @@ -# Hide all dotfiles and git-ignored files before build -# Set working directory to parent of script's directory -Set-Location -Path (Join-Path $PSScriptRoot "..") +# 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 "..\..") -# 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) { + if ($ignoredPath -notmatch '\.lnk$' -and (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 |
