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=""
|
||||
|
||||
# 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
|
||||
|
||||
@@ -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
|
||||
|
||||
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_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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user