|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +#Requires: coreutils + curl + findutils + grep + moreutils + rsync |
| 4 | +# bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/main/Linux/install_node_x86_64.sh") |
| 5 | + |
| 6 | +#--------------# |
| 7 | +if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null ; then |
| 8 | + ##Get Latest Tar |
| 9 | + echo -e "\n[+] Installing NodeJS\n" |
| 10 | + pushd "$(mktemp -d)" > /dev/null 2>&1 |
| 11 | + #curl -qfsSLJO "https://nodejs.org/dist/latest/$(curl -qfsSL "https://nodejs.org/dist/latest/" | grep -o 'href="[^"]*"' | sed 's/href="//' | grep 'linux-x64.tar.xz' | sed 's/"$//' | sort | tail -n 1)" |
| 12 | + curl -qfsSLJO "https://nodejs.org$(curl -qfsSL "https://nodejs.org/dist/latest/" | grep -o 'href="[^"]*"' | sed 's/href="//' | grep 'linux-x64.tar.xz' | sed 's/"$//' | sort | tail -n 1)" |
| 13 | + find . -type f -name '*.xz' -exec tar -xf {} \; && find . -type f -name '*.xz' -exec rm {} -rf \; |
| 14 | + cd "$(find . -maxdepth 1 -type d -exec basename {} \; | grep -Ev '^\.$' | xargs -I {} realpath {})" |
| 15 | + #Copy to /usr/* && /usr/local/* |
| 16 | + if ! command -v rsync > /dev/null 2>&1 ; then |
| 17 | + sudo curl -qfsSL "https://bin.ajam.dev/$(uname -m)/rsync" -o "/usr/local/bin/rsync" && sudo chmod +x "/usr/local/bin/rsync" |
| 18 | + fi |
| 19 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./bin/" "/usr/bin/" |
| 20 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./bin/" "/usr/local/bin/" |
| 21 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./include/" "/usr/include/" |
| 22 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./include/" "/usr/local/include/" |
| 23 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./lib/" "/usr/lib/" |
| 24 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./lib/" "/usr/local/lib/" |
| 25 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./share/" "/usr/share/" |
| 26 | + sudo rsync --archive --checksum --human-readable --progress --quiet "./share/" "/usr/local/share/" |
| 27 | + ##Get N: https://github.com/mklement0/n-install/ |
| 28 | + #curl -qfksSL "https://bit.ly/n-install" | bash -s -- -y latest |
| 29 | + #Check |
| 30 | + node --version && npm version ; popd > /dev/null 2>&1 |
| 31 | +else |
| 32 | + #Update NPM |
| 33 | + npm install --global --force "npm@latest" |
| 34 | + #Update Node: https://github.com/mklement0/n-install/ |
| 35 | + npm install --global --force "n@latest" |
| 36 | + sudo n latest -y |
| 37 | + #Check |
| 38 | + node --version && npm version ; popd > /dev/null 2>&1 |
| 39 | +fi |
| 40 | +##bun : https://bun.sh/docs/installation#installing |
| 41 | +echo -e "\n[+] Installing Bun" |
| 42 | +npm install --global --force "bun@latest" ; bun --version |
| 43 | +##pnpm : https://pnpm.io/installation#using-npm |
| 44 | +echo -e "\n[+] Installing pnpm" |
| 45 | +npm install --global --force "pnpm@latest" ; pnpm --version |
| 46 | +# Requires no node: npm install "@pnpm/exe" --global ; pnpm --version |
| 47 | +##Yarn : https://classic.yarnpkg.com/lang/en/docs/install |
| 48 | +echo -e "\n[+] Installing yarn" |
| 49 | +npm install --global --force "yarn@latest" ; yarn --version |
| 50 | +##END |
0 commit comments