-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
44 lines (32 loc) · 1.19 KB
/
install.sh
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
#!/bin/bash
set -e
REPO_URL="https://github.com/S1D007/redowl-cli"
INSTALL_DIR="$HOME/.redowl"
BIN_DIR="$HOME/.local/bin"
APP_NAME="redowl"
check_npm_installed() {
if ! command -v npm &> /dev/null; then
echo "npm is not installed. Installing Node.js and npm using nvm..."
install_node_with_nvm
else
echo "npm is already installed."
fi
}
install_node_with_nvm() {
if ! command -v nvm &> /dev/null; then
echo "nvm is not installed. Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
nvm install 20
nvm use 20
echo "Node.js and npm installed successfully, if you dont want to use nvm, you can uninstall it by running 'rm -rf $NVM_DIR'"
}
check_npm_installed
cd $INSTALL_DIR
npm install
npm i -g yarn
(yarn unlink --global | true) && tsc && node scripts/copy-assets.js && yarn link --global
chmod +x $INSTALL_DIR/dist/index.js
echo "$APP_NAME installed successfully. You can run it using the command: $APP_NAME"