-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
executable file
·160 lines (134 loc) · 5.2 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env -S just --justfile
# Cross platform shebang:
shebang := if os() == 'windows' {
'pwsh.exe'
} else {
'/usr/bin/env bash'
}
set shell := ["/usr/bin/env", "bash" ,"-c"]
set windows-shell := ["pwsh.exe","-NoLogo", "-noprofile", "-c"]
newExe := "ncm"
originalExe := "ncm-rs"
configPath := "nvim-ncm"
dataPath := "nvim-ncm-data"
targetPath := "./target/release/"
releasePath := "./target/release/ncm"
installPath := "/.local/bin/"
lint:
cargo clippy
test:
cargo test
debug:
cargo build
release: test
cargo build --release
# --| Build ----------------------
# --|-----------------------------
build:
just _build-{{os()}}
# -| Linux
_build-linux: release
rm ./target/release/ncm || true
mv -f ./target/release/ncm-rs ./target/release/ncm || true
# --| Windows
_build-windows: release
if (test-path "{{releasePath}}.exe") { rm "{{releasePath}}.exe" };
mv '{{targetPath}}{{originalExe}}.exe' '{{targetPath}}{{newExe}}.exe'
# --| MacOS
_build-macos: release
# --| Install --------------------
# Install NCM --------------------
install:
just _install-{{os()}}
# --| Linux
_install-linux: build
cp ./target/release/ncm $HOME/.local/bin
# --| Windows
_install-windows: build
cp -force '{{releasePath}}.exe' ${HOME}/'{{installPath}}'
# --| MacOS
_install-macos: build
# --| Manual Cleanup -------------
# Revert all changes to system ---
reset:
just _reset-{{os()}}
# @formatter:off
# --| Linux
_reset-linux:
test -L ~/.cache/nvim && rm ~/.cache/nvim || true
test -L ~/.config/nvim && rm ~/.config/nvim || true
test -L ~/.local/share/nvim && rm ~/.local/share/nvim || true
mv "$HOME/.cache/nvim-ncm/main" "$HOME/.cache/nvim-ncm/nvim" && mv "$HOME/.cache/nvim-ncm/nvim" ~/.cache/ || true
mv "$HOME/.config/nvim-ncm/main" "$HOME/.config/nvim-ncm/nvim" && mv "$HOME/.config/nvim-ncm/nvim" ~/.config/ || true
mv "$HOME/.local/share/nvim-ncm/main" "$HOME/.local/share/nvim-ncm/nvim" && mv "$HOME/.local/share/nvim-ncm/nvim" ~/.local/share/ || true
rm -rf "$HOME/.cache/nvim-ncm" || true
rm -rf "$HOME/.config/nvim-ncm" || true
rm -rf "$HOME/.local/share/nvim-ncm" || true
rm -rf $HOME/.config/ncm-rs || true
/home/mosthated/_dev/languages/pwsh/file_sync/code_sync.ps1 /mnt/x/GitHub/instance-id/rust/ncm-rs
echo "Reset Complete! {{configPath}}"
# @formatter:on
_reset-windows:
just _refresh-code
just _run-reset
_refresh-code:
& C:\files\scripts\sync_code.ps1 Z:\code\rust\ncm-rs
# @formatter:off
# --| Windows
_run-reset:
#!{{shebang}}
try {
$useLocal = if($null -ne $env:USE_LOCAL_PATH) { echo "Using Local Path"; [bool]::Parse($env:USE_LOCAL_PATH); } else { $false }
$cfg = if(($null -ne $env:XDG_CONFIG_HOME) -and !($useLocal)) { $env:XDG_CONFIG_HOME } else { $env:LOCALAPPDATA }
$dataDir = if(($null -ne $env:XDG_DATA_HOME) -and !($useLocal)) { $env:XDG_DATA_HOME } else { $env:LOCALAPPDATA }
$cacheDir = if(($null -ne $env:XDG_CACHE_HOME) -and !($useLocal)) { $env:XDG_CACHE_HOME } else { $env:LOCALAPPDATA }
#
$nvimDir = "${cfg}/nvim"
$nvimData = "${dataDir}/nvim-data"
$nvimCache = "${cacheDir}/nvim"
echo "nvimDir: $nvimDir | nvimData: $nvimData | nvimCache: $nvimCache"
#
$nvCustomDataDir = if ($useLocal) { "nvim-ncm-data" } else { "nvim-ncm" }
$nvCustom = "${cfg}/nvim-ncm/main"
$nvCustomData = "${dataDir}/${nvCustomDataDir}/main"
$nvCustomCache = "${cacheDir}/${nvCustomDataDir}/main"
echo "nvCustom: $nvCustom | nvCustomData: $nvCustomData | nvCustomCache: $nvCustomCache"
#
if ((test-path "${nvimDir}") -and (Get-Item -Path "${nvimDir}" | Select-Object -ExpandProperty LinkType)) { rm "${nvimDir}" }
if ((test-path "${nvimData}") -and (Get-Item -Path "${nvimData}" | Select-Object -ExpandProperty LinkType)) { rm "${nvimData}" }
if ((test-path "${nvimCache}") -and (Get-Item -Path "${nvimCache}" | Select-Object -ExpandProperty LinkType)) { rm "${nvimCache}" }
#
function renameDir([string]$dir,[string]$newName) {
$newPath = $dir.Split("/")[-1]
$newDir = "${dir}/$newName"
if (!(test-path $newPath)){
rename-item -path $dir -newname $newName
}
}
# @formatter:on
if ((test-path "${nvCustom}") -and (!(test-path "${nvimDir}"))) {
renameDir "${nvCustom}" 'nvim'
mv "${cfg}/nvim-ncm/nvim" "${cfg}"
echo "Moved: ${nvCustom} to ${cfg}"
}
#
if ((test-path "${nvCustomData}") -and (!(test-path "${nvimData}"))) {
renameDir "${nvCustomData}" 'nvim-data'
mv "${dataDir}/${nvCustomDataDir}/nvim-data" "${dataDir}"
echo "Moved: ${nvCustomData} to ${nvimData}"
}
#
if ((test-path "${nvCustomCache}") -and (!(test-path "${nvimCache}"))) {
mv "${nvCustomCache}" "${nvimCache}" ;
renameDir ;
echo "Moved: ${nvCustomCache} to ${nvimCache}"
}
# @formatter:off
if (test-path "${cfg}/nvim-ncm") { rm "${cfg}/nvim-ncm" -force -recurse; }
if (test-path "${cfg}/ncm-rs") { rm "${cfg}/ncm-rs" -force -recurse; }
} catch { echo $_.Exception.Message; $_ > error.log }
# @formatter:on
# --| MacOS
_reset-macos:
# --| Reset To Default and Rebuild/Install NCM
reinstall: reset install