Skip to content

Commit 546838c

Browse files
committed
feat: add initialization script and improve maintenance process
- Added `init.sh` script for environment setup, including PHP, Composer, NVM, and Node.js configuration. - Simplified Composer installation logic by removing redundant lines in `update-stufis.sh`. - Enhanced project development environment setup with automated dependency installation.
1 parent 81facb7 commit 546838c

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

init.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
set -e
3+
4+
readonly PHP_VERSION="8.4"
5+
readonly NODE_VERSION="22"
6+
readonly COMPOSER_PHAR="composer.phar"
7+
readonly NVM_DIR="$HOME/.nvm"
8+
9+
cd "$(dirname "$0")"
10+
11+
# Helper to run the specific PHP version
12+
php_run() {
13+
"php$PHP_VERSION" "$@"
14+
}
15+
16+
install_composer() {
17+
if [[ ! -f "$COMPOSER_PHAR" ]]; then
18+
echo "Installing Composer using PHP $PHP_VERSION..."
19+
php_run -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
20+
php_run composer-setup.php
21+
php_run -r "unlink('composer-setup.php');"
22+
fi
23+
}
24+
25+
setup_nvm() {
26+
touch "$HOME/.profile"
27+
if [[ ! -d "$NVM_DIR" ]]; then
28+
echo "Installing NVM..."
29+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
30+
fi
31+
32+
export NVM_DIR
33+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
34+
35+
nvm install "$NODE_VERSION"
36+
nvm use "$NODE_VERSION"
37+
}
38+
39+
install_dependencies() {
40+
echo "Installing project dependencies..."
41+
php_run "$COMPOSER_PHAR" install
42+
npm ci
43+
}
44+
45+
install_composer
46+
setup_nvm
47+
install_dependencies

update-stufis.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ cd "$(dirname "$0")"
1111
alias php="php8.4"
1212
alias composer="php composer.phar"
1313

14-
if [ ! -f "composer.phar" ]; then
15-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
16-
php composer-setup.php
17-
php -r "unlink('composer-setup.php');"
18-
fi
19-
20-
21-
2214
# puts StuFis in Maintenance Mode
2315
php artisan down --with-secret
2416

0 commit comments

Comments
 (0)