From 8300bee32d28597a675dadc3655f45b82e9c34bf Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 10 Apr 2025 19:18:37 +0000 Subject: [PATCH] Implement post-install --- linebridge | 2 +- packages/app/package.json | 3 +- packages/app/scripts/postinstall.sh | 74 +++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100755 packages/app/scripts/postinstall.sh diff --git a/linebridge b/linebridge index 6f8ed336..036c09dc 160000 --- a/linebridge +++ b/linebridge @@ -1 +1 @@ -Subproject commit 6f8ed3360dfcea053fe793a5689bca4f99720227 +Subproject commit 036c09dc1db86230f55fb38c9b7d29f8d00ec31c diff --git a/packages/app/package.json b/packages/app/package.json index 38a7ec14..e0d39494 100755 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -10,7 +10,8 @@ "dev": "vite", "build": "vite build", "preview": "vite preview", - "release": "node ./scripts/release.js" + "release": "node ./scripts/release.js", + "postinstall": "./scripts/postinstall.sh" }, "dependencies": { "@ant-design/icons": "^5.4.0", diff --git a/packages/app/scripts/postinstall.sh b/packages/app/scripts/postinstall.sh new file mode 100755 index 00000000..da2562e5 --- /dev/null +++ b/packages/app/scripts/postinstall.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Output colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +# Get the directory path where the script is located +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Get the project root directory path +PROJECT_ROOT="$( cd "$SCRIPT_DIR/../../.." && pwd )" + +echo -e "${YELLOW}=== Starting installation of dependencies in submodules ===${NC}" +echo -e "${YELLOW}Project directory: ${GREEN}$PROJECT_ROOT${NC}" + +# Check if git is installed +if ! command -v git &> /dev/null; then + echo -e "${RED}Error: git is not installed. Please install it first.${NC}" + exit 1 +fi + +# Check if npm is installed +if ! command -v npm &> /dev/null; then + echo -e "${RED}Error: npm is not installed. Please install it first.${NC}" + exit 1 +fi + +# Change to the project root directory +cd "$PROJECT_ROOT" + +# Get the list of submodules +SUBMODULES=$(git submodule --quiet foreach 'echo $path') + +# Check if there are submodules +if [ -z "$SUBMODULES" ]; then + echo -e "${YELLOW}No submodules found in this repository.${NC}" + exit 0 +fi + +# Initialize submodules if necessary +echo -e "${YELLOW}Initializing submodules...${NC}" +git submodule update --init --recursive + +# For each submodule, install dependencies +for submodule in $SUBMODULES; do + echo -e "${YELLOW}Installing dependencies in: ${GREEN}$submodule${NC}" + SUBMODULE_PATH="$PROJECT_ROOT/$submodule" + + # Check if package.json exists in the submodule directory + if [ -f "$SUBMODULE_PATH/package.json" ]; then + # Change to the submodule directory and run npm install + (cd "$SUBMODULE_PATH" && npm install) || { + echo -e "${RED}Error installing dependencies in $submodule${NC}" + } + echo -e "${GREEN}✓ Dependencies installed in $submodule${NC}" + else + # Check if install-dependencies.sh exists in the submodule directory + if [ -f "$SUBMODULE_PATH/install-dependencies.sh" ]; then + echo -e "${YELLOW}Running custom installation script in $submodule${NC}" + # Make sure the script has execution permissions + chmod +x "$SUBMODULE_PATH/install-dependencies.sh" + # Run the custom installation script + (cd "$SUBMODULE_PATH" && ./install-dependencies.sh) || { + echo -e "${RED}Error executing install-dependencies.sh in $submodule${NC}" + } + echo -e "${GREEN}✓ Custom installation script executed in $submodule${NC}" + else + echo -e "${YELLOW}⚠ Neither package.json nor install-dependencies.sh found in $submodule${NC}" + fi + fi +done + +echo -e "${GREEN}=== Installation of dependencies in submodules completed ===${NC}"