-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·133 lines (118 loc) · 4.23 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
set -e
# Check OS type
OS_TYPE=$(uname)
#
# First, install system-level dependencies
#
if [[ "$OS_TYPE" == "Darwin" ]]; then
echo "MacOS Detected."
# Check if Homebrew is installed
echo "Checking if Homebrew is installed..."
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "Homebrew is already installed."
fi
# Check if git is installed
echo "Checking if git is installed..."
if ! command -v git &> /dev/null; then
echo "git is not installed. Installing git..."
brew install git
else
echo "git is already installed."
fi
# Check if just is installed
echo "Checking if just is installed..."
if ! command -v just &> /dev/null; then
echo "just is not installed. Installing just..."
brew install just
else
echo "just already installed."
fi
# Get the TN CLI repo
if [ -d ~/.tn/cli ]; then
echo "TN CLI directory already exists. Updating..."
cd ~/.tn/cli
git pull
else
echo "TN CLI directory does not exist. Cloning..."
git clone [email protected]:thinknimble/tn-cli.git ~/.tn/cli
fi
ZSH_COMPLETIONS="source ~/.tn/cli/completions/zsh-completions/tncli"
echo "Checking if ZSH_COMPLETIONS is added to ~/.zshrc..."
if ! grep -q "${ZSH_COMPLETIONS}" ~/.zshrc; then
echo "Adding ZSH_COMPLETIONS to ~/.zshrc..."
echo '' >> ~/.zshrc
echo '# Load ZSH Completions for TN CLI' >> ~/.zshrc
echo "${ZSH_COMPLETIONS}" >> ~/.zshrc
else
echo "tn-cli completions already added to ~/.zshrc."
fi
echo
echo -e "\033[32mSUCCESS!\033[0m"
echo "TN CLI Installation is complete."
echo "Please restart your terminal."
exit 0
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Check if it's Ubuntu
if grep -q "Ubuntu" /etc/os-release; then
echo "Ubuntu Detected"
else
echo "Linux Detected, but not Ubuntu - sorry, we don't support this OS yet."
exit 1
fi
# Check if git is installed
echo "Checking if git is installed..."
if ! command -v git &> /dev/null; then
echo "git is not installed. Installing git..."
sudo apt update
sudo apt install git
else
echo "git is already installed."
fi
# Check if just is installed
echo "Checking if just is installed..."
if ! command -v just &> /dev/null; then
echo "just is not installed. Installing just..."
wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
sudo apt update
sudo apt install just
else
echo "just already installed."
fi
# Get the TN CLI repo
if [ -d ~/.tn/cli ]; then
echo "TN CLI directory already exists. Updating..."
cd ~/.tn/cli
git pull
else
echo "TN CLI directory does not exist. Cloning..."
git clone [email protected]:thinknimble/tn-cli.git ~/.tn/cli
fi
# Add bash alias
BASH_ALIAS="alias tn='just -f ~/.tn/cli/justfile -d .'"
echo "Checking if BASH_ALIAS is added to ~/.bashrc..."
if ! grep -q "$BASH_ALIAS" ~/.bashrc; then
echo "Adding BASH_ALIAS to ~/.bashrc..."
echo '' >> ~/.bashrc
echo '# Load ZSH Completions for TN CLI' >> ~/.bashrc
echo "$BASH_ALIAS" >> ~/.bashrc
else
echo "tn-cli alias already added to ~/.bashrc."
fi
# Install completions for bash
mkdir -p ~/.local/share/bash-completion/completions
cp ~/.tn/cli/completions/bash-completions/tncli ~/.local/share/bash-completion/completions/tn
echo
echo -e "\033[32mSUCCESS!\033[0m"
echo "TN CLI Installation is complete!"
echo "Please restart your terminal."
exit 0
else
echo "Your OS is not recognized or not supported."
exit 1
fi