Skip to content

Commit 0d8c47a

Browse files
committed
feat: support night branch for install script.
Signed-off-by: ayamir <[email protected]>
1 parent 2c9e3c7 commit 0d8c47a

File tree

2 files changed

+47
-58
lines changed

2 files changed

+47
-58
lines changed

scripts/install.ps1

+24-28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Set-StrictMode -Version 3.0
88
$ErrorActionPreference = "Stop" # Exit when command fails
99

1010
# global-scope vars
11+
$REQUIRED_NVIM_VERSION_NIGHTLY = [version]'0.10'
1112
$REQUIRED_NVIM_VERSION = [version]'0.9.0'
1213
$REQUIRED_NVIM_VERSION_LEGACY = [version]'0.8.0'
1314
$USE_SSH = $True
@@ -20,7 +21,9 @@ $installer_pkg_matrix = @{ "NodeJS" = "npm"; "Python" = "pip"; "Ruby" = "gem" }
2021
# env vars
2122
$env:XDG_CONFIG_HOME ??= $env:LOCALAPPDATA
2223
$env:CCPACK_MGR ??= 'unknown'
24+
$env:CCLONE_BRANCH_NIGHTLY ??= '0.10'
2325
$env:CCLONE_BRANCH ??= 'main'
26+
$env:CCLONE_BRANCH_LEGACY ??= '0.8'
2427
$env:CCLONE_ATTR ??= 'undef'
2528
$env:CCDEST_DIR ??= "$env:XDG_CONFIG_HOME\nvim"
2629
$env:CCBACKUP_DIR = "$env:CCDEST_DIR" + "_backup-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmss")
@@ -282,6 +285,25 @@ function check_nvim_version ([Parameter(Mandatory = $True)][ValidateNotNullOrEmp
282285
return ($nvim_version -ge $RequiredVersionMin)
283286
}
284287

288+
function clone_by_https_or_ssh ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$CloneUrl) {
289+
if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_NIGHTLY)) {
290+
safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_NIGHTLY" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" }
291+
} elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) {
292+
safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" }
293+
} elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) {
294+
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)."
295+
info -Msg "Automatically redirecting you to the latest compatible version..."
296+
safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_LEGACY" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" }
297+
} else {
298+
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)."
299+
_abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @"
300+
You have a legacy Neovim distribution installed.
301+
Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least.
302+
303+
"@
304+
}
305+
}
306+
285307
function ring_bell {
286308
[System.Console]::beep()
287309
}
@@ -353,35 +375,9 @@ You must install Git before installing this Nvim config. See:
353375
info -Msg "Fetching in progress..."
354376

355377
if ($USE_SSH) {
356-
if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) {
357-
safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" '[email protected]:ayamir/nvimdots.git' "$env:CCDEST_DIR" }
358-
} elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) {
359-
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)."
360-
info -Msg "Automatically redirecting you to the latest compatible version..."
361-
safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" '[email protected]:ayamir/nvimdots.git' "$env:CCDEST_DIR" }
362-
} else {
363-
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)."
364-
_abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @"
365-
You have a legacy Neovim distribution installed.
366-
Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least.
367-
368-
"@
369-
}
378+
clone_by_https_or_ssh '[email protected]:ayamir/nvimdots.git'
370379
} else {
371-
if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) {
372-
safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" }
373-
} elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) {
374-
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)."
375-
info -Msg "Automatically redirecting you to the latest compatible version..."
376-
safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" }
377-
} else {
378-
warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)."
379-
_abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @"
380-
You have a legacy Neovim distribution installed.
381-
Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least.
382-
383-
"@
384-
}
380+
clone_by_https_or_ssh 'https://github.com/ayamir/nvimdots.git'
385381
}
386382

387383
safe_execute -WithCmd { Set-Location -Path "$env:CCDEST_DIR" }

scripts/install.sh

+23-30
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set -u
1010
DEST_DIR="${HOME}/.config/nvim"
1111
BACKUP_DIR="${DEST_DIR}_backup-$(date +%Y%m%dT%H%M%S)"
1212
CLONE_ATTR=("--progress")
13+
REQUIRED_NVIM_VERSION_NIGHTLY=0.10
1314
REQUIRED_NVIM_VERSION=0.9.0
1415
REQUIRED_NVIM_VERSION_LEGACY=0.8.0
1516
USE_SSH=1
@@ -169,6 +170,26 @@ check_nvim_version() {
169170
fi
170171
}
171172

173+
clone_by_https_or_ssh() {
174+
if check_nvim_version "${REQUIRED_NVIM_VERSION_NIGHTLY}"; then
175+
execute "git" "clone" "-b" "0.10" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}"
176+
elif check_nvim_version "${REQUIRED_NVIM_VERSION}" then
177+
execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}"
178+
elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then
179+
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})."
180+
info "Automatically redirecting you to the latest compatible version..."
181+
execute "git" "clone" "-b" "0.8" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}"
182+
else
183+
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})."
184+
abort "$(
185+
cat <<EOABORT
186+
You have a legacy Neovim distribution installed.
187+
Please make sure you have nvim v${REQUIRED_NVIM_VERSION_LEGACY} installed at the very least.
188+
EOABORT
189+
)"
190+
fi
191+
}
192+
172193
# Check if both `INTERACTIVE` and `NONINTERACTIVE` are set
173194
# Always use single-quoted strings with `exp` expressions
174195
# shellcheck disable=SC2016
@@ -252,37 +273,9 @@ fi
252273

253274
info "Fetching in progress..."
254275
if [[ "${USE_SSH}" -eq "1" ]]; then
255-
if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then
256-
execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "[email protected]:ayamir/nvimdots.git" "${DEST_DIR}"
257-
elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then
258-
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})."
259-
info "Automatically redirecting you to the latest compatible version..."
260-
execute "git" "clone" "-b" "0.8" "${CLONE_ATTR[@]}" "[email protected]:ayamir/nvimdots.git" "${DEST_DIR}"
261-
else
262-
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})."
263-
abort "$(
264-
cat <<EOABORT
265-
You have a legacy Neovim distribution installed.
266-
Please make sure you have nvim v${REQUIRED_NVIM_VERSION_LEGACY} installed at the very least.
267-
EOABORT
268-
)"
269-
fi
276+
clone_by_https_or_ssh "[email protected]:ayamir/nvimdots.git"
270277
else
271-
if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then
272-
execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "https://github.com/ayamir/nvimdots.git" "${DEST_DIR}"
273-
elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then
274-
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})."
275-
info "Automatically redirecting you to the latest compatible version..."
276-
execute "git" "clone" "-b" "0.8" "${CLONE_ATTR[@]}" "https://github.com/ayamir/nvimdots.git" "${DEST_DIR}"
277-
else
278-
warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})."
279-
abort "$(
280-
cat <<EOABORT
281-
You have a legacy Neovim distribution installed.
282-
Please make sure you have nvim v${REQUIRED_NVIM_VERSION_LEGACY} installed at the very least.
283-
EOABORT
284-
)"
285-
fi
278+
clone_by_https_or_ssh "https://github.com/ayamir/nvimdots.git"
286279
fi
287280

288281
cd "${DEST_DIR}" || return

0 commit comments

Comments
 (0)