diff --git a/scripts/install-brew-packages.sh b/scripts/install-brew-packages.sh index 0affd1d..3d175df 100755 --- a/scripts/install-brew-packages.sh +++ b/scripts/install-brew-packages.sh @@ -23,27 +23,28 @@ install_brew_packages() { found_packages="" # Read the package names from the file - while IFS= read -r brew_package; do + while IFS= read -r app_name; do # Skip lines that start with # - case "$brew_package" in + case "$app_name" in \#*) continue ;; esac # Check if package exists in brew repository and is not already installed on the system - if brew search "$brew_package" 2>/dev/null | grep -q "$brew_package"; then - if ! command -v "$brew_package" >/dev/null 2>&1; then - echo "Available: $brew_package" - found_packages="$found_packages $brew_package" + if brew info "$app_name" >/dev/null 2>&1; then + if ! command -v "$app_name" >/dev/null 2>&1; then + echo "Available: $app_name" + found_packages="$found_packages $app_name" else - echo "Already installed: $brew_package" + echo "Already installed: $app_name" fi else - not_found_packages="$not_found_packages $brew_package" - echo "Unavailable: $brew_package" + not_found_packages="$not_found_packages $app_name" + echo "Unavailable: $app_name" fi done <"$BREW_PACKAGE_FILE" - # Install available brew packages + echo + echo "Installing brew packages..." # shellcheck disable=SC2086 if ! brew install $found_packages; then exit 1 diff --git a/scripts/install-flatpak-packages.sh b/scripts/install-flatpak-packages.sh index ccfdef8..00999d6 100755 --- a/scripts/install-flatpak-packages.sh +++ b/scripts/install-flatpak-packages.sh @@ -26,16 +26,18 @@ install_flatpak_packages() { esac # Check if the package exists in the flatpak repository - if flatpak search --columns=application "$flatpak_package" 2> /dev/null | grep -q "^$flatpak_package\$"; then + if flatpak search --columns=application "$flatpak_package" 2>/dev/null | grep -q "^$flatpak_package\$"; then echo "Available: $flatpak_package" found_packages="$found_packages $flatpak_package" else not_found_packages="$not_found_packages $flatpak_package" echo "Unavailable: $flatpak_package" fi - done < "$FLATPAK_PACKAGE_FILE" + done <"$FLATPAK_PACKAGE_FILE" - # Install available flatpak packages + echo + echo "Installing available flatpak packages..." + # shellcheck disable=SC2086 if ! flatpak install -y --noninteractive $found_packages; then exit 1 fi diff --git a/scripts/install-node-packages.sh b/scripts/install-node-packages.sh new file mode 100755 index 0000000..0a80197 --- /dev/null +++ b/scripts/install-node-packages.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env sh + +NODE_PACKAGE_FILE=package-list-node + +validate_input() { + if [ ! -f "$NODE_PACKAGE_FILE" ]; then + echo "File not found: $NODE_PACKAGE_FILE" + exit 1 + fi + + if ! command -v node >/dev/null 2>&1; then + echo "node not installed" + exit 2 + fi +} + +install_node_packages() { + missing_packages="" + found_packages="" + + # Read the package names from the file + while IFS= read -r node_package; do + # Skip lines that start with # + case "$node_package" in + \#*) continue ;; + esac + + # Check if the package exists in the node repository + if npm info "$node_package" >/dev/null 2>&1; then + echo "Available: $node_package" + found_packages="$found_packages $node_package" + else + missing_packages="$missing_packages $node_package" + echo "Unavailable: $node_package" + fi + done <"$NODE_PACKAGE_FILE" + + echo + echo "Installing available npm packages..." + # shellcheck disable=SC2086 + if ! npm install -g $found_packages; then + exit 1 + fi +} + +print_summary() { + if [ -n "$2" ]; then + echo + echo "The following $1 packages were not found in npm repository:" | tee -a "$INSTALL_LOG_FILE" + echo "$2" | tee -a "$INSTALL_LOG_FILE" + fi +} + +main() { + validate_input + install_node_packages + print_summary "node" "$missing_packages" +} + +main "$@" diff --git a/scripts/install-os-packages.sh b/scripts/install-os-packages.sh index 261fe3d..5ea9666 100755 --- a/scripts/install-os-packages.sh +++ b/scripts/install-os-packages.sh @@ -9,7 +9,7 @@ setup() { OS_INSTALL_COMMAND="apt-get install -y" OS_PKG_CHECK_COMMAND="apt-cache show" apt_setup - elif [ -f /etc/rocky-release ] || [ -f /etc/almalinux-release ] || [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then # Rocky, Almalinux, + elif [ -f /etc/rocky-release ] || [ -f /etc/almalinux-release ] || [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then # Fedora, CentOS, Rocky, Almalinux OS_INSTALL_COMMAND="dnf install -y --allowerasing --skip-broken" OS_PKG_CHECK_COMMAND="dnf list available" dnf_setup @@ -81,7 +81,7 @@ dnf_setup() { } apt_setup() { - # We are Debian or Ubuntu + # Debian/Ubuntu [ -f /etc/os-release ] && . /etc/os-release sudo apt-get update && sudo apt-get upgrade -y diff --git a/scripts/install.sh b/scripts/install.sh index a276a92..4843c4c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -55,6 +55,7 @@ main() { pre_install ./install-os-packages.sh + ./install-node-package.sh # Skip flatpak & brew installations on FreeBSD if [ "$(uname -s)" != "FreeBSD" ]; then diff --git a/scripts/package-list-brew b/scripts/package-list-brew index c4b74f7..248a18b 100644 --- a/scripts/package-list-brew +++ b/scripts/package-list-brew @@ -1,26 +1,28 @@ # Lines that start with # are ignored -# TIP: Only add commandline apps that aren't available/updated on OS repos +# TIP: +# - Only add commandline apps that aren't available/updated on OS repos; cause brew isn't available on FreeBSD +# - Apps that are already installed skipped +# - Those that must be kept up-to-date (eg rclone); manually brew install them after the scipt completes + +basedpyright bats-core dnscrypt-proxy dockerfile-language-server fd gitleaks -go htop kondo lazydocker lua lua-language-server luajit -markdown-toc -markdownlint-cli +markdown-oxide marksman n neovim prettierd python-lsp-server python@3.12 -basedpyright rclone sccache shodan @@ -31,9 +33,6 @@ taplo tlrc tokei tree-sitter -typescript-language-server -vue-language-server -yaml-language-server yamlfmt yt-dlp zoxide diff --git a/scripts/package-list-node b/scripts/package-list-node new file mode 100644 index 0000000..5bd9245 --- /dev/null +++ b/scripts/package-list-node @@ -0,0 +1,13 @@ +@microsoft/compose-language-service +awk-language-server +bash-language-server +composerize +markdown-toc +markdownlint-cli +n +sql-language-server +typescript-language-server +vscode-css-languageservice +vscode-html-languageservice +vscode-json-languageservice +yaml-language-server diff --git a/scripts/package-list-os b/scripts/package-list-os index 0e09dd9..67ca8e8 100644 --- a/scripts/package-list-os +++ b/scripts/package-list-os @@ -1,5 +1,8 @@ # Lines that start with # are ignored +# TIP: +# - MacOS doesn't have OS installer + # Coding aspnetcore-runtime-8.0 build-essential @@ -22,7 +25,7 @@ lua54 luajit make node -nodejs-bash-language-server +nodejs npm podman python3