Skip to content

Commit

Permalink
Update n to v10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yunohost-bot committed Nov 11, 2024
1 parent c409109 commit 94f4877
Showing 1 changed file with 49 additions and 29 deletions.
78 changes: 49 additions & 29 deletions helpers/vendor/n/n
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function n_grep() {
# Setup and state
#

VERSION="v10.0.0"
VERSION="v10.1.0"

N_PREFIX="${N_PREFIX-/usr/local}"
N_PREFIX=${N_PREFIX%/}
Expand Down Expand Up @@ -133,6 +133,7 @@ g_active_node=
g_target_node=

DOWNLOAD=false # set to opt-out of activate (install), and opt-in to download (run, exec)
CLEANUP=false # remove cached download after install
ARCH=
SHOW_VERBOSE_LOG="true"
OFFLINE=false
Expand Down Expand Up @@ -197,6 +198,10 @@ display_major_version() {
echo "${version}"
}

display_masked_url() {
echo "$1" | sed -r 's/(https?:\/\/[^:]+):([^@]+)@/\1:****@/'
}

#
# Synopsis: update_mirror_settings_for_version version
# e.g. <nightly/latest> means using download mirror and folder is nightly
Expand Down Expand Up @@ -257,7 +262,7 @@ function update_arch_settings_for_version() {
function is_lts_codename() {
# https://github.com/nodejs/Release/blob/master/CODENAMES.md
# e.g. argon, Boron
[[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od)$ ]]
[[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od|[Kk]rypton|[Ll]ithium)$ ]]
}

#
Expand Down Expand Up @@ -385,14 +390,16 @@ Commands:
n ls Output downloaded versions
n ls-remote [version] Output matching versions available for download
n uninstall Remove the installed Node.js
n download <version> Download Node.js <version> into cache
Options:
-V, --version Output version of n
-h, --help Display help information
-p, --preserve Preserve npm and npx during install of Node.js
-q, --quiet Disable curl output. Disable log messages processing "auto" and "engine" labels.
-d, --download Download if necessary, and don't make active
-d, --download Download if necessary. Used with run/exec/which.
--cleanup Remove cached version after install
-a, --arch Override system architecture
--offline Resolve target version against cached downloads instead of internet lookup
--all ls-remote displays all matches instead of last 20
Expand Down Expand Up @@ -753,6 +760,12 @@ activate() {
printf 'If "node --version" shows the old version then start a new shell, or reset the location hash with:\nhash -r (for bash, zsh, ash, dash, and ksh)\nrehash (for csh and tcsh)\n'
fi
fi

if [[ "$CLEANUP" == "true" ]]; then
log "cleanup" "removing cached $version"
remove_versions "$version"
fi

}

#
Expand Down Expand Up @@ -782,6 +795,8 @@ install() {
if [[ ! -e "$dir/n.lock" ]] ; then
if [[ "$DOWNLOAD" == "false" ]] ; then
activate "${g_mirror_folder_name}/${version}"
else
log downloaded "${g_mirror_folder_name}/${version} already in cache"
fi
exit
fi
Expand All @@ -790,18 +805,22 @@ install() {
abort "version unavailable offline"
fi

log installing "${g_mirror_folder_name}-v$version"
if [[ "$DOWNLOAD" == "false" ]]; then
log installing "${g_mirror_folder_name}-v$version"
else
log download "${g_mirror_folder_name}-v$version"
fi

local url="$(tarball_url "$version")"
is_ok "${url}" || abort "download preflight failed for '$version' (${url})"
is_ok "${url}" || abort "download preflight failed for '$version' ($(display_masked_url "${url}"))"

log mkdir "$dir"
mkdir -p "$dir" || abort "sudo required (or change ownership, or define N_PREFIX)"
touch "$dir/n.lock"

cd "${dir}" || abort "Failed to cd to ${dir}"

log fetch "$url"
log fetch "$(display_masked_url "${url}")"
do_get "${url}" | tar "$tarflag" --strip-components=1 --no-same-owner -f -
pipe_results=( "${PIPESTATUS[@]}" )
if [[ "${pipe_results[0]}" -ne 0 ]]; then
Expand Down Expand Up @@ -1135,6 +1154,8 @@ function get_nvmrc_version() {
verbose_log "found" "${filepath}"
local version
<"${filepath}" read -r version
# remove trailing comment, after #
version="$(echo "${version}" | sed 's/[[:space:]]*#.*//')"
verbose_log "read" "${version}"
# Translate from nvm aliases
case "${version}" in
Expand Down Expand Up @@ -1241,7 +1262,7 @@ display_remote_index() {
do_get_index "${index_url}" | tail -n +2 | cut -f 1,3,10
if [[ "${PIPESTATUS[0]}" -ne 0 ]]; then
# Reminder: abort will only exit subshell, but consistent error display
abort "failed to download version index (${index_url})"
abort "failed to download version index ($(display_masked_url "${index_url}"))"
fi
}

Expand Down Expand Up @@ -1494,8 +1515,8 @@ function show_diagnostics() {
printf "\n\nSETTINGS\n"

printf "\nn\n"
echo "node mirror: ${N_NODE_MIRROR}"
echo "node downloads mirror: ${N_NODE_DOWNLOAD_MIRROR}"
echo "node mirror: $(display_masked_url "${N_NODE_MIRROR}")"
echo "node downloads mirror: $(display_masked_url "${N_NODE_DOWNLOAD_MIRROR}")"
echo "install destination: ${N_PREFIX}"
[[ -n "${N_PREFIX}" ]] && echo "PATH: ${PATH}"
echo "ls-remote max matches: ${N_MAX_REMOTE_MATCHES}"
Expand Down Expand Up @@ -1668,6 +1689,7 @@ while [[ $# -ne 0 ]]; do
-h|--help|help) display_help; exit ;;
-q|--quiet) set_quiet ;;
-d|--download) DOWNLOAD="true" ;;
--cleanup) CLEANUP="true" ;;
--offline) OFFLINE="true" ;;
--insecure) set_insecure ;;
-p|--preserve) N_PRESERVE_NPM="true" N_PRESERVE_COREPACK="true" ;;
Expand Down Expand Up @@ -1704,24 +1726,22 @@ if test $# -eq 0; then
test -z "$(display_versions_paths)" && err_no_installed_print_help
menu_select_cache_versions
else
while test $# -ne 0; do
case "$1" in
bin|which) display_bin_path_for_version "$2"; exit ;;
run|as|use) shift; run_with_version "$@"; exit ;;
exec) shift; exec_with_version "$@"; exit ;;
doctor) show_diagnostics; exit ;;
rm|-) shift; remove_versions "$@"; exit ;;
prune) prune_cache; exit ;;
latest) install latest; exit ;;
stable) install stable; exit ;;
lts) install lts; exit ;;
ls|list) display_versions_paths; exit ;;
lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
uninstall) uninstall_installed; exit ;;
i|install) shift; install "$1"; exit ;;
N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
*) install "$1"; exit ;;
esac
shift
done
case "$1" in
bin|which) display_bin_path_for_version "$2"; exit ;;
run|as|use) shift; run_with_version "$@"; exit ;;
exec) shift; exec_with_version "$@"; exit ;;
doctor) show_diagnostics; exit ;;
rm|-) shift; remove_versions "$@"; exit ;;
prune) prune_cache; exit ;;
latest) install latest; exit ;;
stable) install stable; exit ;;
lts) install lts; exit ;;
ls|list) display_versions_paths; exit ;;
lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
uninstall) uninstall_installed; exit ;;
i|install) shift; install "$1"; exit ;;
download) shift; DOWNLOAD="true"; install "$1"; exit ;;
N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
*) install "$1"; exit ;;
esac
fi

0 comments on commit 94f4877

Please sign in to comment.