@ews-admin/global-design-system 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,11 @@ export interface EnvConfig {
25
25
  * For local development, sensible defaults are provided but can be overridden
26
26
  * (e.g. to point BFF URL at a mock server).
27
27
  *
28
+ * When env is empty (build without VITE_ENV), the environment is derived from
29
+ * the current host instead of always assuming local, so a deployed build never
30
+ * links to http://local.*.medecine360local.com. A console warning names the
31
+ * derived environment so the misconfigured build stays visible.
32
+ *
28
33
  * @param env - The environment name (VITE_ENV value)
29
34
  * @param overrides - Optional URL overrides (e.g. for local mock servers)
30
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"env-config.d.ts","sourceRoot":"","sources":["../../src/utils/env-config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAuCD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,kBAAkB,GAC7B,SAAS,CASX"}
1
+ {"version":3,"file":"env-config.d.ts","sourceRoot":"","sources":["../../src/utils/env-config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA6DD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,kBAAkB,GAC7B,SAAS,CAeX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ews-admin/global-design-system",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "EWS Global Design System - Reusable components for EWS applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -56,6 +56,28 @@ function buildUrls(environment: Environment): Omit<EnvConfig, "env"> {
56
56
  };
57
57
  }
58
58
 
59
+ /**
60
+ * Derives the environment from the host the app is served from, for builds
61
+ * that did not set VITE_ENV. Hosts actually served (Traefik rules in
62
+ * infrastructure/medecine360-hetzner/deployment/docker-stack.*.yml):
63
+ * - local: localhost, 127.0.0.1, *.medecine360local.com (local.app., api., ...)
64
+ * - dev: dev.{app,login,dashboard,admin,api}.medecine360.com
65
+ * - qa: qa.{app,login,dashboard,admin,api}.medecine360.com
66
+ * - prod: medecine360.com, {login,dashboard,admin,api}.medecine360.com
67
+ * Any other host (or no window, e.g. SSR or tests) falls back to local.
68
+ */
69
+ function environmentFromHost(): Environment {
70
+ const hostname =
71
+ typeof window !== "undefined" ? window.location?.hostname?.toLowerCase() : undefined;
72
+ if (!hostname) return "local";
73
+ if (hostname === "medecine360.com" || hostname.endsWith(".medecine360.com")) {
74
+ if (hostname.startsWith("dev.")) return "dev";
75
+ if (hostname.startsWith("qa.")) return "qa";
76
+ return "prod";
77
+ }
78
+ return "local";
79
+ }
80
+
59
81
  /**
60
82
  * Creates an environment configuration with all derived URLs.
61
83
  *
@@ -65,6 +87,11 @@ function buildUrls(environment: Environment): Omit<EnvConfig, "env"> {
65
87
  * For local development, sensible defaults are provided but can be overridden
66
88
  * (e.g. to point BFF URL at a mock server).
67
89
  *
90
+ * When env is empty (build without VITE_ENV), the environment is derived from
91
+ * the current host instead of always assuming local, so a deployed build never
92
+ * links to http://local.*.medecine360local.com. A console warning names the
93
+ * derived environment so the misconfigured build stays visible.
94
+ *
68
95
  * @param env - The environment name (VITE_ENV value)
69
96
  * @param overrides - Optional URL overrides (e.g. for local mock servers)
70
97
  */
@@ -72,7 +99,13 @@ export function createEnvConfig(
72
99
  env: string,
73
100
  overrides?: EnvConfigOverrides,
74
101
  ): EnvConfig {
75
- const environment = (env || "local") as Environment;
102
+ let environment = env as Environment;
103
+ if (!environment) {
104
+ environment = environmentFromHost();
105
+ console.warn(
106
+ `[env-config] VITE_ENV is not set; using "${environment}" derived from the current host.`,
107
+ );
108
+ }
76
109
  const derived = buildUrls(environment);
77
110
 
78
111
  return {