mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(install-script): Install packages using npm
- Use npm to install packages - Move packages from brew to npm where available - fix: use `brew info` to search exact package names - chore: better comments
This commit is contained in:
@@ -23,27 +23,28 @@ install_brew_packages() {
|
|||||||
found_packages=""
|
found_packages=""
|
||||||
|
|
||||||
# Read the package names from the file
|
# 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 #
|
# Skip lines that start with #
|
||||||
case "$brew_package" in
|
case "$app_name" in
|
||||||
\#*) continue ;;
|
\#*) continue ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Check if package exists in brew repository and is not already installed on the system
|
# 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 brew info "$app_name" >/dev/null 2>&1; then
|
||||||
if ! command -v "$brew_package" >/dev/null 2>&1; then
|
if ! command -v "$app_name" >/dev/null 2>&1; then
|
||||||
echo "Available: $brew_package"
|
echo "Available: $app_name"
|
||||||
found_packages="$found_packages $brew_package"
|
found_packages="$found_packages $app_name"
|
||||||
else
|
else
|
||||||
echo "Already installed: $brew_package"
|
echo "Already installed: $app_name"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
not_found_packages="$not_found_packages $brew_package"
|
not_found_packages="$not_found_packages $app_name"
|
||||||
echo "Unavailable: $brew_package"
|
echo "Unavailable: $app_name"
|
||||||
fi
|
fi
|
||||||
done <"$BREW_PACKAGE_FILE"
|
done <"$BREW_PACKAGE_FILE"
|
||||||
|
|
||||||
# Install available brew packages
|
echo
|
||||||
|
echo "Installing brew packages..."
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if ! brew install $found_packages; then
|
if ! brew install $found_packages; then
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ install_flatpak_packages() {
|
|||||||
fi
|
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
|
if ! flatpak install -y --noninteractive $found_packages; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
60
scripts/install-node-packages.sh
Executable file
60
scripts/install-node-packages.sh
Executable file
@@ -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 "$@"
|
||||||
@@ -9,7 +9,7 @@ setup() {
|
|||||||
OS_INSTALL_COMMAND="apt-get install -y"
|
OS_INSTALL_COMMAND="apt-get install -y"
|
||||||
OS_PKG_CHECK_COMMAND="apt-cache show"
|
OS_PKG_CHECK_COMMAND="apt-cache show"
|
||||||
apt_setup
|
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_INSTALL_COMMAND="dnf install -y --allowerasing --skip-broken"
|
||||||
OS_PKG_CHECK_COMMAND="dnf list available"
|
OS_PKG_CHECK_COMMAND="dnf list available"
|
||||||
dnf_setup
|
dnf_setup
|
||||||
@@ -81,7 +81,7 @@ dnf_setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apt_setup() {
|
apt_setup() {
|
||||||
# We are Debian or Ubuntu
|
# Debian/Ubuntu
|
||||||
[ -f /etc/os-release ] && . /etc/os-release
|
[ -f /etc/os-release ] && . /etc/os-release
|
||||||
|
|
||||||
sudo apt-get update && sudo apt-get upgrade -y
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ main() {
|
|||||||
pre_install
|
pre_install
|
||||||
|
|
||||||
./install-os-packages.sh
|
./install-os-packages.sh
|
||||||
|
./install-node-package.sh
|
||||||
|
|
||||||
# Skip flatpak & brew installations on FreeBSD
|
# Skip flatpak & brew installations on FreeBSD
|
||||||
if [ "$(uname -s)" != "FreeBSD" ]; then
|
if [ "$(uname -s)" != "FreeBSD" ]; then
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
# Lines that start with # are ignored
|
# 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
|
bats-core
|
||||||
dnscrypt-proxy
|
dnscrypt-proxy
|
||||||
dockerfile-language-server
|
dockerfile-language-server
|
||||||
fd
|
fd
|
||||||
gitleaks
|
gitleaks
|
||||||
go
|
|
||||||
htop
|
htop
|
||||||
kondo
|
kondo
|
||||||
lazydocker
|
lazydocker
|
||||||
lua
|
lua
|
||||||
lua-language-server
|
lua-language-server
|
||||||
luajit
|
luajit
|
||||||
markdown-toc
|
markdown-oxide
|
||||||
markdownlint-cli
|
|
||||||
marksman
|
marksman
|
||||||
n
|
n
|
||||||
neovim
|
neovim
|
||||||
prettierd
|
prettierd
|
||||||
python-lsp-server
|
python-lsp-server
|
||||||
python@3.12
|
python@3.12
|
||||||
basedpyright
|
|
||||||
rclone
|
rclone
|
||||||
sccache
|
sccache
|
||||||
shodan
|
shodan
|
||||||
@@ -31,9 +33,6 @@ taplo
|
|||||||
tlrc
|
tlrc
|
||||||
tokei
|
tokei
|
||||||
tree-sitter
|
tree-sitter
|
||||||
typescript-language-server
|
|
||||||
vue-language-server
|
|
||||||
yaml-language-server
|
|
||||||
yamlfmt
|
yamlfmt
|
||||||
yt-dlp
|
yt-dlp
|
||||||
zoxide
|
zoxide
|
||||||
|
|||||||
13
scripts/package-list-node
Normal file
13
scripts/package-list-node
Normal file
@@ -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
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# Lines that start with # are ignored
|
# Lines that start with # are ignored
|
||||||
|
|
||||||
|
# TIP:
|
||||||
|
# - MacOS doesn't have OS installer
|
||||||
|
|
||||||
# Coding
|
# Coding
|
||||||
aspnetcore-runtime-8.0
|
aspnetcore-runtime-8.0
|
||||||
build-essential
|
build-essential
|
||||||
@@ -22,7 +25,7 @@ lua54
|
|||||||
luajit
|
luajit
|
||||||
make
|
make
|
||||||
node
|
node
|
||||||
nodejs-bash-language-server
|
nodejs
|
||||||
npm
|
npm
|
||||||
podman
|
podman
|
||||||
python3
|
python3
|
||||||
|
|||||||
Reference in New Issue
Block a user