fix: partager le même commit entre recette et production
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Dashboard Recette - Gestion des Applications</title>
|
||||
<title>Dashboard - Gestion des Applications</title>
|
||||
</head>
|
||||
<body class="bg-dark-900 text-white">
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"test": "node --test test/*.test.mjs",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ChevronDown,
|
||||
} from 'lucide-react';
|
||||
import { getAvailableStacks, createApp, getGiteaRepos } from '../utils/api';
|
||||
import { APP_DOMAIN_SUFFIX, ENVIRONMENT_LABEL_LOWER } from '../utils/environment';
|
||||
|
||||
const STEPS = [
|
||||
{ id: 1, title: 'Informations', icon: FileText },
|
||||
@@ -180,7 +181,7 @@ export default function AddAppModal({ isOpen, onClose, onSuccess }) {
|
||||
Ajouter une application
|
||||
</h2>
|
||||
<p className="text-sm text-gray-400 mt-0.5">
|
||||
Déployez une nouvelle application sur le serveur de recette
|
||||
Déployez une nouvelle application sur le serveur de {ENVIRONMENT_LABEL_LOWER}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@@ -271,7 +272,7 @@ export default function AddAppModal({ isOpen, onClose, onSuccess }) {
|
||||
}`}
|
||||
/>
|
||||
<span className="px-3 py-2.5 bg-dark-600 border border-dark-500 border-l-0 rounded-r-lg text-gray-400 text-sm whitespace-nowrap">
|
||||
.recette.santinova-soft.org
|
||||
.{APP_DOMAIN_SUFFIX}
|
||||
</span>
|
||||
</div>
|
||||
{errors.subdomain && (
|
||||
@@ -280,7 +281,7 @@ export default function AddAppModal({ isOpen, onClose, onSuccess }) {
|
||||
{formData.subdomain && !errors.subdomain && (
|
||||
<p className="text-gray-500 text-xs mt-1 flex items-center gap-1">
|
||||
<Globe className="w-3 h-3" />
|
||||
URL: https://{formData.subdomain}.recette.santinova-soft.org
|
||||
URL: https://{formData.subdomain}.{APP_DOMAIN_SUFFIX}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
@@ -545,7 +546,7 @@ export default function AddAppModal({ isOpen, onClose, onSuccess }) {
|
||||
L'application est en cours de déploiement. Suivez la progression dans l'onglet Déploiements.
|
||||
</p>
|
||||
<p className="text-gray-500 mt-2 text-xs">
|
||||
URL: https://{formData.subdomain}.recette.santinova-soft.org
|
||||
URL: https://{formData.subdomain}.{APP_DOMAIN_SUFFIX}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
@@ -573,7 +574,7 @@ export default function AddAppModal({ isOpen, onClose, onSuccess }) {
|
||||
<div className="flex justify-between items-center px-4 py-3">
|
||||
<span className="text-gray-400 text-sm">URL</span>
|
||||
<span className="text-primary-400 text-sm">
|
||||
https://{formData.subdomain}.recette.santinova-soft.org
|
||||
https://{formData.subdomain}.{APP_DOMAIN_SUFFIX}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center px-4 py-3">
|
||||
|
||||
@@ -12,6 +12,7 @@ import { LayoutList, TerminalSquare, ShieldCheck,
|
||||
Activity,
|
||||
BookOpen,
|
||||
} from 'lucide-react';
|
||||
import { ENVIRONMENT_LABEL } from '../utils/environment';
|
||||
const navItems = [
|
||||
{ id: 'dashboard', label: 'Tableau de bord', icon: LayoutDashboard },
|
||||
{ id: 'apps', label: 'Applications', icon: Box },
|
||||
@@ -40,7 +41,7 @@ export default function Sidebar({
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="text-lg font-bold text-white">Dashboard</h1>
|
||||
<p className="text-xs text-gray-500">Recette</p>
|
||||
<p className="text-xs text-gray-500">{ENVIRONMENT_LABEL}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { getApps, getSystemInfo } from '../utils/api';
|
||||
import StatusBadge from '../components/StatusBadge';
|
||||
import { sortAppsWithInfraFirst } from '../utils/appSorting';
|
||||
import { ENVIRONMENT_LABEL, GITEA_HOST, GITEA_URL, SERVER_PUBLIC_IP } from '../utils/environment';
|
||||
|
||||
function StatCard({ icon: Icon, label, value, color, subtext }) {
|
||||
return (
|
||||
@@ -101,7 +102,7 @@ export default function DashboardPage({ apps }) {
|
||||
<div className="flex items-center justify-between py-2 border-b border-dark-700">
|
||||
<span className="text-sm text-gray-400">Serveur</span>
|
||||
<span className="text-sm text-gray-200">
|
||||
78.138.58.109 (Recette)
|
||||
{SERVER_PUBLIC_IP} ({ENVIRONMENT_LABEL})
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between py-2 border-b border-dark-700">
|
||||
@@ -114,12 +115,12 @@ export default function DashboardPage({ apps }) {
|
||||
<div className="flex items-center justify-between py-2 border-b border-dark-700">
|
||||
<span className="text-sm text-gray-400">Gitea</span>
|
||||
<a
|
||||
href="https://git.recette.santinova-soft.org"
|
||||
href={GITEA_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-primary-400 hover:text-primary-300"
|
||||
>
|
||||
git.recette.santinova-soft.org
|
||||
{GITEA_HOST}
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex items-center justify-between py-2 border-b border-dark-700">
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
ShieldCheck,
|
||||
} from 'lucide-react';
|
||||
import { approveGiteaTokenRotation, getGiteaRepos, getGiteaCommits, getGiteaTokenRotation, getGiteaWorkflowRuns, getGiteaWorkflowSummary, prepareGiteaTokenRotation } from '../utils/api';
|
||||
import { GITEA_HOST, GITEA_URL } from '../utils/environment';
|
||||
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return 'N/A';
|
||||
@@ -137,12 +138,12 @@ export default function GiteaPage() {
|
||||
<p className="text-gray-400 mt-1">
|
||||
Explorez les dépôts sur{' '}
|
||||
<a
|
||||
href="https://git.recette.santinova-soft.org"
|
||||
href={GITEA_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-primary-400 hover:text-primary-300"
|
||||
>
|
||||
git.recette.santinova-soft.org
|
||||
{GITEA_HOST}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Lock, User, AlertCircle, Server } from 'lucide-react';
|
||||
import { login } from '../utils/api';
|
||||
import { ENVIRONMENT_LABEL, ENVIRONMENT_LABEL_LOWER } from '../utils/environment';
|
||||
|
||||
export default function LoginPage({ onLogin }) {
|
||||
const [username, setUsername] = useState('');
|
||||
@@ -34,7 +35,7 @@ export default function LoginPage({ onLogin }) {
|
||||
<div className="inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-primary-600 mb-4">
|
||||
<Server className="w-8 h-8 text-white" />
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold text-white">Dashboard Recette</h1>
|
||||
<h1 className="text-2xl font-bold text-white">Dashboard {ENVIRONMENT_LABEL}</h1>
|
||||
<p className="text-gray-400 mt-2">Gestion des applications</p>
|
||||
</div>
|
||||
|
||||
@@ -130,7 +131,7 @@ export default function LoginPage({ onLogin }) {
|
||||
</div>
|
||||
|
||||
<p className="text-center text-gray-600 text-sm mt-6">
|
||||
Santinova Soft — Serveur de recette
|
||||
Santinova Soft — Serveur de {ENVIRONMENT_LABEL_LOWER}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { Terminal, Wifi, WifiOff, X, Plus, ChevronDown } from 'lucide-react';
|
||||
import { DEFAULT_SSH_PRESET, ENVIRONMENT_LABEL, SERVER_PUBLIC_IP } from '../utils/environment';
|
||||
|
||||
// Serveurs SSH prédéfinis
|
||||
const PRESET_SERVERS = [
|
||||
@@ -30,8 +31,8 @@ export default function TerminalPage() {
|
||||
|
||||
// Formulaire de connexion
|
||||
const [form, setForm] = useState({
|
||||
preset: 'recette',
|
||||
host: '78.138.58.109',
|
||||
preset: DEFAULT_SSH_PRESET,
|
||||
host: SERVER_PUBLIC_IP,
|
||||
port: 22,
|
||||
username: 'root',
|
||||
password: '',
|
||||
@@ -116,7 +117,7 @@ export default function TerminalPage() {
|
||||
fitAddonRef.current = fitAddon;
|
||||
|
||||
term.writeln('\x1b[1;34m╔══════════════════════════════════════════════════╗\x1b[0m');
|
||||
term.writeln('\x1b[1;34m║ Terminal SSH — Dashboard Recette Santinova ║\x1b[0m');
|
||||
term.writeln(`\x1b[1;34m║ Terminal SSH — Dashboard ${ENVIRONMENT_LABEL} Santinova ║\x1b[0m`);
|
||||
term.writeln('\x1b[1;34m╚══════════════════════════════════════════════════╝\x1b[0m');
|
||||
term.writeln('');
|
||||
term.writeln('\x1b[90mSélectionnez un serveur et connectez-vous pour démarrer.\x1b[0m');
|
||||
|
||||
39
src/frontend/src/utils/environment.js
Normal file
39
src/frontend/src/utils/environment.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Identité de l'environnement courant, déterminée par le domaine public.
|
||||
* Le même artefact frontend peut ainsi être construit et exécuté en recette
|
||||
* comme en production sans branche ni modification de code spécifique.
|
||||
*/
|
||||
export function getEnvironmentConfig(hostname) {
|
||||
const normalizedHostname = hostname.toLowerCase();
|
||||
const isRecette =
|
||||
normalizedHostname.includes('recette') ||
|
||||
normalizedHostname === 'localhost' ||
|
||||
normalizedHostname === '127.0.0.1';
|
||||
|
||||
return {
|
||||
isRecette,
|
||||
label: isRecette ? 'Recette' : 'Production',
|
||||
labelLower: isRecette ? 'recette' : 'production',
|
||||
serverPublicIp: isRecette ? '78.138.58.109' : '180.149.196.138',
|
||||
giteaUrl: isRecette
|
||||
? 'https://git.recette.santinova-soft.org'
|
||||
: 'https://git.santinova-soft.org',
|
||||
appDomainSuffix: isRecette
|
||||
? 'recette.santinova-soft.org'
|
||||
: 'santinova-soft.org',
|
||||
defaultSshPreset: isRecette ? 'recette' : 'production',
|
||||
};
|
||||
}
|
||||
|
||||
const currentHostname = typeof window === 'undefined' ? 'localhost' : window.location.hostname;
|
||||
const environment = getEnvironmentConfig(currentHostname);
|
||||
|
||||
export const IS_RECETTE = environment.isRecette;
|
||||
export const ENVIRONMENT_LABEL = environment.label;
|
||||
export const ENVIRONMENT_LABEL_LOWER = environment.labelLower;
|
||||
export const SERVER_PUBLIC_IP = environment.serverPublicIp;
|
||||
export const GITEA_URL = environment.giteaUrl;
|
||||
export const GITEA_HOST = new URL(GITEA_URL).hostname;
|
||||
export const APP_DOMAIN_SUFFIX = environment.appDomainSuffix;
|
||||
export const DEFAULT_SSH_PRESET = environment.defaultSshPreset;
|
||||
|
||||
27
src/frontend/test/environment.test.mjs
Normal file
27
src/frontend/test/environment.test.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { getEnvironmentConfig } from '../src/utils/environment.js';
|
||||
|
||||
test('détecte le dashboard de recette depuis son domaine public', () => {
|
||||
const config = getEnvironmentConfig('dashboard.recette.santinova-soft.org');
|
||||
assert.equal(config.isRecette, true);
|
||||
assert.equal(config.label, 'Recette');
|
||||
assert.equal(config.serverPublicIp, '78.138.58.109');
|
||||
assert.equal(config.giteaUrl, 'https://git.recette.santinova-soft.org');
|
||||
assert.equal(config.appDomainSuffix, 'recette.santinova-soft.org');
|
||||
});
|
||||
|
||||
test('détecte le dashboard de production depuis son domaine public', () => {
|
||||
const config = getEnvironmentConfig('dashboard.santinova-soft.org');
|
||||
assert.equal(config.isRecette, false);
|
||||
assert.equal(config.label, 'Production');
|
||||
assert.equal(config.serverPublicIp, '180.149.196.138');
|
||||
assert.equal(config.giteaUrl, 'https://git.santinova-soft.org');
|
||||
assert.equal(config.appDomainSuffix, 'santinova-soft.org');
|
||||
});
|
||||
|
||||
test('utilise la recette pour le développement local', () => {
|
||||
assert.equal(getEnvironmentConfig('localhost').isRecette, true);
|
||||
assert.equal(getEnvironmentConfig('127.0.0.1').isRecette, true);
|
||||
});
|
||||
Reference in New Issue
Block a user