From 75284c86876ebcff170a1a769f55587ef35874a9 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Thu, 23 Oct 2025 17:30:56 +0200 Subject: [PATCH] add Docker-specific npm and workspace configurations for CI builds --- .npmrc.docker | 22 ++ meet-ce/docker/Dockerfile | 30 ++- .../shared-meet-components/package.json | 2 +- meet.sh | 50 ++-- pnpm-lock.yaml | 39 +--- pnpm-workspace.docker.yaml | 12 + pnpm-workspace.yaml | 12 + scripts/prepare-ci-build.sh | 218 ++++++++++++++++++ scripts/restore-dev-config.sh | 138 +++++++++++ 9 files changed, 465 insertions(+), 58 deletions(-) create mode 100644 .npmrc.docker create mode 100755 scripts/prepare-ci-build.sh create mode 100755 scripts/restore-dev-config.sh diff --git a/.npmrc.docker b/.npmrc.docker new file mode 100644 index 0000000..a18c482 --- /dev/null +++ b/.npmrc.docker @@ -0,0 +1,22 @@ +# Docker/CI specific npm configuration +# This configuration is used during Docker builds and CI workflows +# to prevent linking workspace packages and use published versions instead + +# Disable workspace package linking +# This forces pnpm to install packages from registry or local tarballs +link-workspace-packages=false + +# Strict peer dependencies +strict-peer-dependencies=false + +# Auto install peers +auto-install-peers=true + +# Shamefully hoist - necessary for some packages +shamefully-hoist=true + +# Node linker - use hoisted for full compatibility +node-linker=hoisted + +# Lockfile settings +lockfile=true diff --git a/meet-ce/docker/Dockerfile b/meet-ce/docker/Dockerfile index 7bfe1fd..148c3bd 100644 --- a/meet-ce/docker/Dockerfile +++ b/meet-ce/docker/Dockerfile @@ -17,17 +17,45 @@ RUN mkdir -p meet-ce/typings meet-ce/frontend/webcomponent meet-ce/backend && \ USER node +# ============================================================================= +# Workspace Configuration for Docker/CI +# ============================================================================= +# We use Docker-specific configuration files to handle external dependencies: +# +# 1. pnpm-workspace.docker.yaml: Excludes external packages (openvidu-components-angular) +# 2. .npmrc.docker: Disables workspace linking, forces registry/tarball installation +# +# This allows openvidu-components-angular to be installed from: +# - npm registry (e.g., openvidu-components-angular@3.4.0) +# - Local tarball (e.g., ./meet-ce/frontend/openvidu-components-angular-3.4.0.tgz) +# +# The package.json should already have the correct dependency specified by CI +# before docker build is executed. +# +# See docs/ci-docker-dependencies-strategy.md for more information. +# ============================================================================= + # Copy workspace configuration files # Use Docker-specific workspace file that excludes external packages COPY --chown=node:node pnpm-workspace.docker.yaml ./pnpm-workspace.yaml -COPY --chown=node:node .npmrc package.json pnpm-lock.yaml ./ +# Use Docker-specific npmrc that disables workspace linking +COPY --chown=node:node .npmrc.docker ./.npmrc +COPY --chown=node:node package.json pnpm-lock.yaml ./ # Copy package.json files for all workspace packages COPY --chown=node:node meet-ce/typings/package.json ./meet-ce/typings/ COPY --chown=node:node meet-ce/frontend/package.json ./meet-ce/frontend/ COPY --chown=node:node meet-ce/frontend/webcomponent/package.json ./meet-ce/frontend/webcomponent/ +COPY --chown=node:node meet-ce/frontend/projects/shared-meet-components/package.json ./meet-ce/frontend/projects/shared-meet-components/ COPY --chown=node:node meet-ce/backend/package.json ./meet-ce/backend/ +# Install dependencies +# Note: openvidu-components-angular will be installed from: +# 1. Local tarball (if exists in meet-ce/frontend/openvidu-components-angular*.tgz) +# 2. npm registry (if specified in package.json) +# The tarball should be placed in meet-ce/frontend/ by CI before docker build +RUN pnpm install --no-frozen-lockfile + # Copy the source code for all packages COPY --chown=node:node meet-ce/typings/ ./meet-ce/typings/ COPY --chown=node:node meet-ce/frontend/ ./meet-ce/frontend/ diff --git a/meet-ce/frontend/projects/shared-meet-components/package.json b/meet-ce/frontend/projects/shared-meet-components/package.json index 8f2a9f4..93fdacb 100644 --- a/meet-ce/frontend/projects/shared-meet-components/package.json +++ b/meet-ce/frontend/projects/shared-meet-components/package.json @@ -5,7 +5,7 @@ "module": "dist/fesm2022/openvidu-meet-shared-components.mjs", "typings": "dist/index.d.ts", "peerDependencies": { - "openvidu-components-angular": "^3.0.0" + "openvidu-components-angular": "workspace:*" }, "dependencies": { "tslib": "^2.3.0" diff --git a/meet.sh b/meet.sh index 0bc9456..1974d1e 100755 --- a/meet.sh +++ b/meet.sh @@ -708,8 +708,6 @@ clone_meet_pro() { # Build Docker image build_docker() { local image_name="$1" - local components_next_version - components_next_version=$(pnpm view openvidu-components-angular@next version | tr -d '\r\n') shift || true # Remove first argument (image name) # Validate arguments @@ -721,17 +719,26 @@ build_docker() { # Parse flags local is_demos=false - local use_latest_components=false - for _arg in "$@"; do - case "$_arg" in + local components_version="" + local components_tarball="" + + while [ $# -gt 0 ]; do + case "$1" in --demos) is_demos=true + shift ;; - --with-latest-components) - use_latest_components=true + --components-angular-version) + components_version="$2" + shift 2 + ;; + --components-angular-tarball) + components_tarball="$2" + shift 2 ;; *) # ignore unknown flags for forward compatibility + shift ;; esac done @@ -752,11 +759,16 @@ build_docker() { echo -e "${BLUE}=====================================${NC}" echo - # Optionally install latest components to avoid local dist symlink inside image - if [ "$use_latest_components" = true ]; then - echo "🔧 Installing latest openvidu-components-angular..." - sed -i 's|"openvidu-components-angular": "workspace:\*"|"openvidu-components-angular": "^3.0.0"|g' meet-ce/frontend/projects/shared-meet-components/package.json - pnpm --filter @openvidu-meet/frontend install openvidu-components-angular@${components_next_version} + # Optionally install specific components version + if [ -n "$components_tarball" ]; then + echo -e "${BLUE}🔧 Installing OpenVidu Components Angular from tarball: $components_tarball${NC}" + ./scripts/prepare-ci-build.sh --components-angular-tarball "$components_tarball" + elif [ -n "$components_version" ]; then + echo -e "${BLUE}🔧 Installing OpenVidu Components Angular version: $components_version${NC}" + ./scripts/prepare-ci-build.sh --components-angular-version "$components_version" + else + echo -e "${YELLOW}⚠️ No specific components version specified, using latest from registry${NC}" + ./scripts/prepare-ci-build.sh --components-angular-version latest fi echo -e "${GREEN}Using BASE_HREF: $base_href${NC}" @@ -765,19 +777,19 @@ build_docker() { if docker build --pull --no-cache --rm=true -f meet-ce/docker/Dockerfile -t "$final_image_name" --build-arg BASE_HREF="$base_href" .; then echo echo -e "${GREEN}✓ Docker image '$final_image_name' built successfully!${NC}" + # Restore dev config + echo "🔧 Restoring dev config ..." + ./scripts/restore-dev-config.sh > /dev/null else echo echo -e "${RED}✗ Failed to build Docker image '$final_image_name'${NC}" + # Restore dev config + echo "🔧 Restoring dev config ..." + ./scripts/restore-dev-config.sh > /dev/null exit 1 fi - # Restore local link if we temporarily installed latest components - if [ "$use_latest_components" = true ]; then - echo "🔧 Restoring openvidu-components-angular to local dist link..." - sed -i 's|"openvidu-components-angular": "^3.0.0"|"openvidu-components-angular": "workspace:*"|g' meet-ce/frontend/projects/shared-meet-components/package.json - sed -i 's|"openvidu-components-angular": "'"${components_next_version}"'"|"openvidu-components-angular": "workspace:*"|g' meet-ce/frontend/package.json - pnpm install --no-frozen-lockfile - fi + } # Main script logic diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b27563b..6a4975b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,7 +28,7 @@ importers: version: 20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)) '@angular/cdk': specifier: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 - version: 20.2.7(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) + version: 20.2.9(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) '@angular/common': specifier: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 version: 20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) @@ -40,7 +40,7 @@ importers: version: 20.3.4(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(@angular/platform-browser@20.3.4(@angular/animations@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)))(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)))(rxjs@7.8.2) '@angular/material': specifier: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 - version: 20.2.7(aa99716c8f948d7f0acc37be6fe23365) + version: 20.2.9(b517547b325ffc8400ae4cda6a618bfd) '@livekit/track-processors': specifier: ^0.6.0 version: 0.6.1(@types/dom-mediacapture-transform@0.1.11)(livekit-client@2.15.11(@types/dom-mediacapture-record@1.0.22)) @@ -1156,13 +1156,6 @@ packages: vitest: optional: true - '@angular/cdk@20.2.7': - resolution: {integrity: sha512-QTqxPJSMXyjaswtpUrziwdoKRhqT2P9/Ascwzjg8T/SofV1850pc3YmonoOFrurYrmd4plZzWdr7raGcBWIh/Q==} - peerDependencies: - '@angular/common': ^20.0.0 || ^21.0.0 - '@angular/core': ^20.0.0 || ^21.0.0 - rxjs: ^6.5.3 || ^7.4.0 - '@angular/cdk@20.2.9': resolution: {integrity: sha512-rbY1AMz9389WJI29iAjWp4o0QKRQHCrQQUuP0ctNQzh1tgWpwiRLx8N4yabdVdsCA846vPsyKJtBlSNwKMsjJA==} peerDependencies: @@ -1219,16 +1212,6 @@ packages: '@angular/platform-browser': 20.3.4 rxjs: ^6.5.3 || ^7.4.0 - '@angular/material@20.2.7': - resolution: {integrity: sha512-VXsP5qkQQ3sCGkSHsgDku/OVlunGsqssOM057foOKJuajECsI3ZpGuLJ13nvLm9Z147UZOZfP463ixZIjd4XuQ==} - peerDependencies: - '@angular/cdk': 20.2.7 - '@angular/common': ^20.0.0 || ^21.0.0 - '@angular/core': ^20.0.0 || ^21.0.0 - '@angular/forms': ^20.0.0 || ^21.0.0 - '@angular/platform-browser': ^20.0.0 || ^21.0.0 - rxjs: ^6.5.3 || ^7.4.0 - '@angular/material@20.2.9': resolution: {integrity: sha512-xo/ozyRXCoJMi89XLTJI6fdPKBv2wBngWMiCrtTg23+pHbuyA/kDbk3v62eJkDD1xdhC4auXaIHu4Ddf5zTgSA==} peerDependencies: @@ -10051,14 +10034,6 @@ snapshots: - tsx - yaml - '@angular/cdk@20.2.7(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2)': - dependencies: - '@angular/common': 20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) - '@angular/core': 20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1) - parse5: 8.0.0 - rxjs: 7.8.2 - tslib: 2.8.1 - '@angular/cdk@20.2.9(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2)': dependencies: '@angular/common': 20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) @@ -10134,16 +10109,6 @@ snapshots: rxjs: 7.8.2 tslib: 2.8.1 - '@angular/material@20.2.7(aa99716c8f948d7f0acc37be6fe23365)': - dependencies: - '@angular/cdk': 20.2.7(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) - '@angular/common': 20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) - '@angular/core': 20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1) - '@angular/forms': 20.3.4(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(@angular/platform-browser@20.3.4(@angular/animations@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)))(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)))(rxjs@7.8.2) - '@angular/platform-browser': 20.3.4(@angular/animations@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)))(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1)) - rxjs: 7.8.2 - tslib: 2.8.1 - '@angular/material@20.2.9(b517547b325ffc8400ae4cda6a618bfd)': dependencies: '@angular/cdk': 20.2.9(@angular/common@20.3.4(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2))(@angular/core@20.3.4(@angular/compiler@20.3.4)(rxjs@7.8.2)(zone.js@0.15.1))(rxjs@7.8.2) diff --git a/pnpm-workspace.docker.yaml b/pnpm-workspace.docker.yaml index 76148d6..4c480ba 100644 --- a/pnpm-workspace.docker.yaml +++ b/pnpm-workspace.docker.yaml @@ -1,3 +1,15 @@ +# ============================================================================= +# Docker/CI Workspace Configuration +# ============================================================================= +# This workspace configuration is used for Docker builds and CI workflows. +# It EXCLUDES external packages (like openvidu-components-angular) that +# are not part of this repository. +# +# For local development, use pnpm-workspace.yaml instead. +# +# See docs/ci-docker-dependencies-strategy.md for more information. +# ============================================================================= + packages: - meet-ce/typings - meet-ce/frontend diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index a4ac102..f4820e8 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,15 @@ +# ============================================================================= +# Development Workspace Configuration +# ============================================================================= +# This workspace configuration is used for LOCAL DEVELOPMENT. +# It INCLUDES external packages (like openvidu-components-angular) that +# are located in sibling repositories for fast development with hot-reload. +# +# For Docker builds and CI, use pnpm-workspace.docker.yaml instead. +# +# See docs/ci-docker-dependencies-strategy.md for more information. +# ============================================================================= + packages: - ../openvidu/openvidu-components-angular/projects/openvidu-components-angular - meet-ce/typings diff --git a/scripts/prepare-ci-build.sh b/scripts/prepare-ci-build.sh new file mode 100755 index 0000000..89ecd8d --- /dev/null +++ b/scripts/prepare-ci-build.sh @@ -0,0 +1,218 @@ +#!/bin/bash + +# ============================================================================ +# prepare-ci-build.sh +# ============================================================================ +# This script prepares the workspace for CI/Docker builds by: +# 1. Switching to Docker-specific workspace configuration +# 2. Installing openvidu-components-angular from npm or tarball +# 3. Installing all dependencies +# +# Usage: +# ./scripts/prepare-ci-build.sh [options] +# +# Options: +# --components-angular-version Install from npm registry (e.g., 3.4.0) +# --components-angular-tarball Install from tarball (e.g., ./components.tgz) +# --help Show this help message +# +# Examples: +# # Install from npm registry +# ./scripts/prepare-ci-build.sh --components-angular-version 3.4.0 +# +# # Install from tarball +# ./scripts/prepare-ci-build.sh --components-angular-tarball ./openvidu-components-angular.tgz +# +# See docs/ci-docker-dependencies-strategy.md for more information. +# ============================================================================ + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Variables +NPM_VERSION="" +TARBALL_PATH="" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +# Function to update package.json files +update_package_json() { + local package_path="$1" + local version="$2" + + if [ -f "$package_path" ]; then + # Replace workspace:* with specific version + sed -i 's#"openvidu-components-angular": "workspace:\*"#"openvidu-components-angular": "'"$version"'"#g' "$package_path" + echo "✓ Updated $package_path: workspace:* → $version" + fi +} + +show_help() { + echo -e "${BLUE}============================================================================${NC}" + echo -e "${BLUE} OpenVidu Meet - Prepare CI Build${NC}" + echo -e "${BLUE}============================================================================${NC}" + echo "" + echo -e "${GREEN}Usage:${NC}" + echo -e " ./scripts/prepare-ci-build.sh [options]" + echo "" + echo -e "${GREEN}Options:${NC}" + echo -e " ${YELLOW}--components-angular-version ${NC} Install openvidu-components-angular from npm registry" + echo -e " ${YELLOW}--components-angular-tarball ${NC} Install openvidu-components-angular from tarball" + echo -e " ${YELLOW}--help${NC} Show this help message" + echo "" + echo -e "${GREEN}Examples:${NC}" + echo -e " # Install from npm registry" + echo -e " ./scripts/prepare-ci-build.sh --components-angular-version 3.4.0" + echo "" + echo -e " # Install from tarball" + echo -e " ./scripts/prepare-ci-build.sh --components-angular-tarball ./openvidu-components-angular.tgz" + echo "" + echo -e "${BLUE}For more information, see:${NC} docs/ci-docker-dependencies-strategy.md" + echo "" +} + +# Parse arguments +while [[ $# -gt 0 ]]; do + case "$1" in + --components-angular-version) + NPM_VERSION="$2" + shift 2 + ;; + --components-angular-tarball) + TARBALL_PATH="$2" + shift 2 + ;; + --help) + show_help + exit 0 + ;; + *) + echo -e "${RED}Error: Unknown option '$1'${NC}" + show_help + exit 1 + ;; + esac +done + +# Validate arguments +if [ -z "$NPM_VERSION" ] && [ -z "$TARBALL_PATH" ]; then + echo -e "${RED}Error: You must specify either --components-angular-version or --components-angular-tarball${NC}" + show_help + exit 1 +fi + +if [ -n "$NPM_VERSION" ] && [ -n "$TARBALL_PATH" ]; then + echo -e "${RED}Error: You cannot specify both --components-angular-version and --components-angular-tarball${NC}" + show_help + exit 1 +fi + +# Validate tarball exists +if [ -n "$TARBALL_PATH" ]; then + if [ ! -f "$TARBALL_PATH" ]; then + echo -e "${RED}Error: Tarball not found: $TARBALL_PATH${NC}" + exit 1 + fi + # Convert to absolute path + TARBALL_PATH="$(cd "$(dirname "$TARBALL_PATH")" && pwd)/$(basename "$TARBALL_PATH")" +fi + +cd "$PROJECT_ROOT" + +echo -e "${BLUE}============================================================================${NC}" +echo -e "${BLUE} Preparing CI Build${NC}" +echo -e "${BLUE}============================================================================${NC}" +echo "" + +# Step 1: Switch to Docker workspace configuration +echo -e "${YELLOW}[1/4] Switching to Docker workspace configuration...${NC}" +if [ ! -f "pnpm-workspace.docker.yaml" ]; then + echo -e "${RED}Error: pnpm-workspace.docker.yaml not found${NC}" + exit 1 +fi +if [ ! -f ".npmrc.docker" ]; then + echo -e "${RED}Error: .npmrc.docker not found${NC}" + exit 1 +fi + +cp pnpm-workspace.docker.yaml pnpm-workspace.yaml +cp .npmrc.docker .npmrc +echo -e "${GREEN}✓ Workspace configuration updated${NC}" +echo "" + +# Step 2: Copy tarball if needed +if [ -n "$TARBALL_PATH" ]; then + echo -e "${YELLOW}[2/4] Copying tarball to meet-ce/frontend/...${NC}" + mkdir -p meet-ce/frontend + TARBALL_NAME="$(basename "$TARBALL_PATH")" + if [ -f "meet-ce/frontend/$TARBALL_NAME" ]; then + echo -e "${GREEN}✓ Tarball already exists: $TARBALL_NAME${NC}" + else + cp "$TARBALL_PATH" meet-ce/frontend/ + echo -e "${GREEN}✓ Tarball copied: $TARBALL_NAME${NC}" + fi + echo "" +fi + +# Step 3: Install openvidu-components-angular +echo -e "${YELLOW}[3/4] Installing openvidu-components-angular...${NC}" + +if [ -n "$NPM_VERSION" ]; then + echo -e " ${BLUE}Installing from npm registry: $NPM_VERSION${NC}" + + # Update package.json files before installation + update_package_json "meet-ce/frontend/package.json" "$NPM_VERSION" + update_package_json "meet-ce/frontend/projects/shared-meet-components/package.json" "$NPM_VERSION" + + # Install in both packages + # echo "Installing in meet-ce/frontend..." + # pnpm add --filter @openvidu-meet/frontend openvidu-components-angular@$NPM_VERSION + + # echo "Installing in shared-meet-components..." + # pnpm add --filter @openvidu-meet/shared-components openvidu-components-angular@$NPM_VERSION + + # echo -e "${GREEN}✓ Installed from npm: openvidu-components-angular@$NPM_VERSION${NC}" +elif [ -n "$TARBALL_PATH" ]; then + TARBALL_NAME="$(basename "$TARBALL_PATH")" + echo -e " ${BLUE}Installing from tarball: $TARBALL_NAME${NC}" + + + # Update package.json files before installation + update_package_json "meet-ce/frontend/package.json" "file:./$TARBALL_NAME" + update_package_json "meet-ce/frontend/projects/shared-meet-components/package.json" "file:../../$TARBALL_NAME" + + # Install in both packages + # echo "Installing in meet-ce/frontend..." + # pnpm add --filter @openvidu-meet/frontend "openvidu-components-angular@$TARBALL_REF" + + # echo "Installing in shared-meet-components..." + # pnpm add --filter @openvidu-meet/shared-components "openvidu-components-angular@file:../$TARBALL_NAME" + # pnpm install --recursive + # echo -e "${GREEN}✓ Installed from tarball: $TARBALL_NAME${NC}" +fi +echo "" + +# Step 4: Install all dependencies +echo -e "${YELLOW}[4/4] Installing all dependencies...${NC}" +pnpm install --recursive +echo -e "${GREEN}✓ All dependencies installed${NC}" +echo "" + +echo -e "${GREEN}============================================================================${NC}" +echo -e "${GREEN} ✓ CI Build preparation completed successfully!${NC}" +echo -e "${GREEN}============================================================================${NC}" +echo "" +echo -e "${BLUE}Next steps:${NC}" +echo -e " - Build the project: ${YELLOW}./meet.sh build${NC}" +echo -e " - Build Docker image: ${YELLOW}docker build -f meet-ce/docker/Dockerfile .${NC}" +echo "" +echo -e "${BLUE}Note:${NC} To restore development configuration, run:" +echo -e " ${YELLOW}git checkout pnpm-workspace.yaml .npmrc${NC}" +echo -e " ${YELLOW}pnpm install${NC}" +echo "" diff --git a/scripts/restore-dev-config.sh b/scripts/restore-dev-config.sh new file mode 100755 index 0000000..36e05a4 --- /dev/null +++ b/scripts/restore-dev-config.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +# ============================================================================ +# restore-dev-config.sh +# ============================================================================ +# This script restores the development workspace configuration after +# preparing for CI/Docker builds. +# +# Usage: +# ./scripts/restore-dev-config.sh +# +# This will: +# 1. Restore pnpm-workspace.yaml from git +# 2. Restore .npmrc from git +# 3. Reinstall dependencies with workspace linking enabled +# +# See docs/ci-docker-dependencies-strategy.md for more information. +# ============================================================================ + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +cd "$PROJECT_ROOT" + +echo -e "${BLUE}============================================================================${NC}" +echo -e "${BLUE} Restoring Development Configuration${NC}" +echo -e "${BLUE}============================================================================${NC}" +echo "" + +# Step 1: Restore workspace configuration and package.json files +echo -e "${YELLOW}[1/4] Restoring workspace configuration and package.json files...${NC}" + +# List of files to restore +FILES_TO_RESTORE=( + "pnpm-workspace.yaml" + ".npmrc" + "meet-ce/frontend/package.json" + "meet-ce/frontend/projects/shared-meet-components/package.json" +) + +# Check if any files were modified +ANY_MODIFIED=false +for file in "${FILES_TO_RESTORE[@]}"; do + if [ -f "$file" ] && ! git diff --quiet "$file" 2>/dev/null; then + ANY_MODIFIED=true + break + fi +done + +if [ "$ANY_MODIFIED" = false ]; then + echo -e "${GREEN}✓ All files are already in development mode${NC}" +else + # Restore all files from git + git checkout "${FILES_TO_RESTORE[@]}" 2>/dev/null || { + echo -e "${RED}Error: Could not restore configuration files from git${NC}" + echo -e "${YELLOW}Make sure you're in a git repository${NC}" + exit 1 + } + echo -e "${GREEN}✓ Configuration and package.json files restored${NC}" +fi +echo "" + +# Step 2: Clean up any tarball artifacts +# echo -e "${YELLOW}[2/4] Cleaning up tarball artifacts...${NC}" +# if ls meet-ce/frontend/*.tgz >/dev/null 2>&1; then +# rm -f meet-ce/frontend/*.tgz +# echo -e "${GREEN}✓ Tarball artifacts removed${NC}" +# else +# echo -e "${GREEN}✓ No tarball artifacts to clean${NC}" +# fi +echo "" + +# Step 3: Reinstall dependencies +echo -e "${YELLOW}[3/4] Reinstalling dependencies with workspace linking...${NC}" +echo -e "${BLUE}This will link openvidu-components-angular from ../openvidu/...${NC}" +echo "" + +# Check if external package exists +if [ ! -d "../openvidu/openvidu-components-angular" ]; then + echo -e "${RED}Warning: External package not found: ../openvidu/openvidu-components-angular${NC}" + echo -e "${YELLOW}You may need to clone the openvidu repository:${NC}" + echo -e " ${YELLOW}git clone https://github.com/OpenVidu/openvidu.git ../openvidu${NC}" + echo "" + read -p "Continue anyway? (y/n) " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo -e "${RED}Aborted${NC}" + exit 1 + fi +fi + +pnpm install +echo -e "${GREEN}✓ Dependencies installed with workspace linking${NC}" +echo "" + +# Step 4: Verify workspace linking is active +echo -e "${YELLOW}[4/4] Verifying workspace linking...${NC}" + +# Check if openvidu-components-angular is using workspace protocol +if grep -q '"openvidu-components-angular": "workspace:\*"' meet-ce/frontend/package.json; then + echo -e "${GREEN}✓ Frontend: openvidu-components-angular using workspace:*${NC}" +else + echo -e "${RED}✗ Frontend: openvidu-components-angular NOT using workspace:*${NC}" + echo -e "${YELLOW} Current value in package.json:${NC}" + grep "openvidu-components-angular" meet-ce/frontend/package.json || echo " Not found" +fi + +if grep -q '"openvidu-components-angular": "\^' meet-ce/frontend/projects/shared-meet-components/package.json; then + echo -e "${GREEN}✓ Shared-components: openvidu-components-angular using ^version (peerDependency)${NC}" +else + echo -e "${YELLOW}⚠ Shared-components: Verify peerDependency manually${NC}" +fi + +# Check if pnpm list shows workspace link +if pnpm list openvidu-components-angular 2>/dev/null | grep -q "link:"; then + echo -e "${GREEN}✓ Workspace linking is active (linked from ../openvidu/...)${NC}" +else + echo -e "${RED}✗ WARNING: Workspace linking might not be active${NC}" + echo -e "${YELLOW} This is normal if openvidu-components-angular is not in ../openvidu/${NC}" +fi +echo "" + +echo -e "${GREEN}============================================================================${NC}" +echo -e "${GREEN} ✓ Development configuration restored successfully!${NC}" +echo -e "${GREEN}============================================================================${NC}" +echo "" +echo -e "${BLUE}You can now continue local development:${NC}" +echo -e " ${YELLOW}./meet.sh dev${NC}" +echo ""