From 49052dbeecab0b728da6ebb976f0e19cc00f16e4 Mon Sep 17 00:00:00 2001 From: Ida Dittrich Date: Wed, 10 Sep 2025 11:52:36 +0200 Subject: [PATCH] updated env and yml files* --- .cursorignore | 2 + .env.dev | 34 +++++++++++++ .env.int | 33 +++++++++++++ .env.prod | 33 +++++++++++++ .github/workflows/poweron_nyla_int.yml | 66 +++++++++++++++++++++++++ .github/workflows/poweron_nyla_main.yml | 66 +++++++++++++++++++++++++ .gitignore | 10 ---- index.html | 2 +- package.json | 6 ++- src/App.tsx | 7 ++- src/pages/Home/Home.tsx | 3 -- 11 files changed, 246 insertions(+), 16 deletions(-) create mode 100644 .cursorignore create mode 100644 .env.dev create mode 100644 .env.int create mode 100644 .env.prod create mode 100644 .github/workflows/poweron_nyla_int.yml create mode 100644 .github/workflows/poweron_nyla_main.yml diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 0000000..b9c9db8 --- /dev/null +++ b/.cursorignore @@ -0,0 +1,2 @@ +!.env +!.env.* diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..89a972a --- /dev/null +++ b/.env.dev @@ -0,0 +1,34 @@ +# Development Environment Configuration +# Frontend Nyla - Development + +# API Configuration +VITE_API_BASE_URL="http://localhost:8000/" +VITE_API_TIMEOUT=10000 + +# Microsoft Entra ID Configuration +VITE_MICROSOFT_CLIENT_ID=24cd6c8a-b592-4905-a5ba-d5fa9f911154 +VITE_MICROSOFT_TENANT_ID=6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_CLIENT_SECRET=2iw8Q~jwqG1iacxHopBt5pstu6R45UC1gIQabcbD +VITE_ENTRA_AUTHORITY=https://login.microsoftonline.com/6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_REDIRECT_PATH=/auth/callback/ +VITE_ENTRA_REDIRECT_URI=http://localhost:8000/api/msft/auth/callback/ + +# Application Configuration +VITE_APP_NAME=PowerOn Nyla dev +VITE_APP_VERSION=0.0.0 +VITE_APP_ENVIRONMENT=development + +# Debug Configuration +VITE_DEBUG=true +VITE_LOG_LEVEL=debug +VITE_ENABLE_CONSOLE_LOGS=true + +# Feature Flags +VITE_ENABLE_ANALYTICS=false +VITE_ENABLE_ERROR_REPORTING=false +VITE_ENABLE_PERFORMANCE_MONITORING=false + +# Development Server +VITE_DEV_SERVER_PORT=5176 +VITE_DEV_SERVER_HOST=localhost +VITE_DEV_SERVER_HTTPS=false \ No newline at end of file diff --git a/.env.int b/.env.int new file mode 100644 index 0000000..32874bc --- /dev/null +++ b/.env.int @@ -0,0 +1,33 @@ +# Integration/Test Environment Configuration +# Frontend Nyla - Integration + +# API Configuration +VITE_API_BASE_URL=https://gateway-int.poweron-center.net +VITE_API_TIMEOUT=12000 + +# Microsoft Entra ID Configuration +VITE_MICROSOFT_CLIENT_ID=24cd6c8a-b592-4905-a5ba-d5fa9f911154 +VITE_MICROSOFT_TENANT_ID=6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_CLIENT_SECRET=2iw8Q~jwqG1iacxHopBt5pstu6R45UC1gIQabcbD +VITE_ENTRA_AUTHORITY=https://login.microsoftonline.com/6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_REDIRECT_PATH=/auth/callback/ +VITE_ENTRA_REDIRECT_URI=https://gateway-int.poweron-center.net/api/msft/auth/callback/ + +# Application Configuration +VITE_APP_NAME=Poweron Nyla int +VITE_APP_VERSION=0.0.0 +VITE_APP_ENVIRONMENT=integration + +# Debug Configuration +VITE_DEBUG=true +VITE_LOG_LEVEL=info +VITE_ENABLE_CONSOLE_LOGS=true + +# Feature Flags +VITE_ENABLE_ANALYTICS=true +VITE_ENABLE_ERROR_REPORTING=true +VITE_ENABLE_PERFORMANCE_MONITORING=true + +# Test Configuration +VITE_ENABLE_MOCK_DATA=false +VITE_ENABLE_TEST_MODE=true diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..0db5112 --- /dev/null +++ b/.env.prod @@ -0,0 +1,33 @@ +# Production Environment Configuration +# Frontend Nyla - Production + +# API Configuration +VITE_API_BASE_URL=https://gateway-prod.poweron-center.net +VITE_API_TIMEOUT=15000 + +# Microsoft Entra ID Configuration +VITE_MICROSOFT_CLIENT_ID=24cd6c8a-b592-4905-a5ba-d5fa9f911154 +VITE_MICROSOFT_TENANT_ID=6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_CLIENT_SECRET=2iw8Q~jwqG1iacxHopBt5pstu6R45UC1gIQabcbD +VITE_ENTRA_AUTHORITY=https://login.microsoftonline.com/6a51aaeb-2467-4186-9504-2a05aedc591f +VITE_ENTRA_REDIRECT_PATH=/auth/callback/ +VITE_ENTRA_REDIRECT_URI=https://gateway-prod.poweron-center.net/api/msft/auth/callback/ + +# Application Configuration +VITE_APP_NAME=PowerOn Nyla +VITE_APP_VERSION=0.0.0 +VITE_APP_ENVIRONMENT=production + +# Debug Configuration +VITE_DEBUG=false +VITE_LOG_LEVEL=error +VITE_ENABLE_CONSOLE_LOGS=false + +# Feature Flags +VITE_ENABLE_ANALYTICS=true +VITE_ENABLE_ERROR_REPORTING=true +VITE_ENABLE_PERFORMANCE_MONITORING=true + +# Security Configuration +VITE_ENABLE_HTTPS=true +VITE_ENABLE_CSP=true diff --git a/.github/workflows/poweron_nyla_int.yml b/.github/workflows/poweron_nyla_int.yml new file mode 100644 index 0000000..1dfb319 --- /dev/null +++ b/.github/workflows/poweron_nyla_int.yml @@ -0,0 +1,66 @@ +name: Deploy Nyla Frontend to Integration + +on: + push: + branches: + - int + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Copy integration environment file + run: | + cp .env.int .env + + - name: Install dependencies + run: | + npm ci + npm install express + + - name: Build React app for integration + run: npm run build:int + + - name: Prepare deployment package + run: | + # Create deployment package with build files and necessary configs + mkdir deploy + cp -r dist/* deploy/ + # Create a simple server.js for serving the app + echo "const express = require('express');" > deploy/server.js + echo "const path = require('path');" >> deploy/server.js + echo "const app = express();" >> deploy/server.js + echo "app.use(express.static(path.join(__dirname)));" >> deploy/server.js + echo "app.get('/*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); });" >> deploy/server.js + echo "const port = process.env.PORT || 8080;" >> deploy/server.js + echo "app.listen(port, () => console.log('Server running on port', port));" >> deploy/server.js + # Create a new package.json for deployment + echo '{ + "name": "frontend-int", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "node server.js" + }, + "dependencies": { + "express": "^4.18.2" + } + }' > deploy/package.json + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + with: + app-name: 'poweron-nyla-int' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_POWERON_NYLA_INT }} + package: ./deploy \ No newline at end of file diff --git a/.github/workflows/poweron_nyla_main.yml b/.github/workflows/poweron_nyla_main.yml new file mode 100644 index 0000000..e09cc75 --- /dev/null +++ b/.github/workflows/poweron_nyla_main.yml @@ -0,0 +1,66 @@ +name: Deploy Nyla Frontend to Production + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Copy production environment file + run: | + cp .env.prod .env + + - name: Install dependencies + run: | + npm ci + npm install express + + - name: Build React app for production + run: npm run build:prod + + - name: Prepare deployment package + run: | + # Create deployment package with build files and necessary configs + mkdir deploy + cp -r dist/* deploy/ + # Create a simple server.js for serving the app + echo "const express = require('express');" > deploy/server.js + echo "const path = require('path');" >> deploy/server.js + echo "const app = express();" >> deploy/server.js + echo "app.use(express.static(path.join(__dirname)));" >> deploy/server.js + echo "app.get('/*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); });" >> deploy/server.js + echo "const port = process.env.PORT || 8080;" >> deploy/server.js + echo "app.listen(port, () => console.log('Server running on port', port));" >> deploy/server.js + # Create a new package.json for deployment + echo '{ + "name": "frontend", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "node server.js" + }, + "dependencies": { + "express": "^4.18.2" + } + }' > deploy/package.json + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + with: + app-name: 'poweron-nyla' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_POWERON_NYLA }} + package: ./deploy diff --git a/.gitignore b/.gitignore index 7d8652d..a547bf3 100644 --- a/.gitignore +++ b/.gitignore @@ -22,13 +22,3 @@ dist-ssr *.njsproj *.sln *.sw? - -# Environment files -.env -.env.local -<<<<<<< Updated upstream -.env.*.local -======= -.env.*.local - ->>>>>>> Stashed changes diff --git a/index.html b/index.html index e4b78ea..409813a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite + React + TS + %VITE_APP_NAME%
diff --git a/package.json b/package.json index 2a9f14d..73c7e7e 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,12 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite --port 5176", + "dev": "vite --port 5176 --mode dev", + "dev:prod": "vite --port 5176 --mode prod", + "dev:int": "vite --port 5176 --mode int", "build": "tsc -b && vite build", + "build:prod": "tsc -b && vite build --mode prod", + "build:int": "tsc -b && vite build --mode int", "lint": "eslint .", "preview": "vite preview" }, diff --git a/src/App.tsx b/src/App.tsx index 1866622..2e65d5d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,8 +15,13 @@ import Home from './pages/Home/Home'; import './assets/styles/light.css'; function App() { - // Load saved theme preference on app mount + // Load saved theme preference and set app name on app mount useEffect(() => { + // Set app name globally + const appName = import.meta.env.VITE_APP_NAME || "PowerOn"; + document.title = appName; + + // Load saved theme preference const savedTheme = localStorage.getItem('theme'); const prefersDark = savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches); diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index 07f922c..8e256ee 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -9,9 +9,6 @@ import PageManager from '../../components/PageManager'; function Home () { - useEffect(()=> { - document.title = "PowerOn"; - }, []);