@aifabrix/builder 2.33.4 → 2.33.5
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.
- package/lib/utils/env-config-loader.js +16 -5
- package/lib/utils/env-map.js +11 -9
- package/package.json +1 -1
|
@@ -75,6 +75,19 @@ function mergeEnvConfigs(baseConfig, userConfig) {
|
|
|
75
75
|
return merged;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Load schema-only env-config (no user merge). Used for *_PUBLIC_PORT calculation
|
|
80
|
+
* so public ports always use canonical base (e.g. KEYCLOAK_PUBLIC_PORT = 8082 + devId*100).
|
|
81
|
+
*
|
|
82
|
+
* @function loadSchemaEnvConfig
|
|
83
|
+
* @returns {Object} Parsed schema env-config (environments.docker / .local only)
|
|
84
|
+
*/
|
|
85
|
+
function loadSchemaEnvConfig() {
|
|
86
|
+
const envConfigPath = path.join(__dirname, '..', 'schema', 'env-config.yaml');
|
|
87
|
+
const content = fs.readFileSync(envConfigPath, 'utf8');
|
|
88
|
+
return yaml.load(content) || {};
|
|
89
|
+
}
|
|
90
|
+
|
|
78
91
|
/**
|
|
79
92
|
* Load env config YAML used for environment variable interpolation
|
|
80
93
|
* Loads base config from lib/schema/env-config.yaml and merges with user config if configured
|
|
@@ -84,10 +97,7 @@ function mergeEnvConfigs(baseConfig, userConfig) {
|
|
|
84
97
|
* @throws {Error} If base file cannot be read or parsed
|
|
85
98
|
*/
|
|
86
99
|
async function loadEnvConfig() {
|
|
87
|
-
|
|
88
|
-
const envConfigPath = path.join(__dirname, '..', 'schema', 'env-config.yaml');
|
|
89
|
-
const content = fs.readFileSync(envConfigPath, 'utf8');
|
|
90
|
-
const baseConfig = yaml.load(content) || {};
|
|
100
|
+
const baseConfig = loadSchemaEnvConfig();
|
|
91
101
|
|
|
92
102
|
// Load user env-config if configured
|
|
93
103
|
const userConfig = await loadUserEnvConfig();
|
|
@@ -97,6 +107,7 @@ async function loadEnvConfig() {
|
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
module.exports = {
|
|
100
|
-
loadEnvConfig
|
|
110
|
+
loadEnvConfig,
|
|
111
|
+
loadSchemaEnvConfig
|
|
101
112
|
};
|
|
102
113
|
|
package/lib/utils/env-map.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const yaml = require('js-yaml');
|
|
13
|
-
const { loadEnvConfig } = require('./env-config-loader');
|
|
13
|
+
const { loadEnvConfig, loadSchemaEnvConfig } = require('./env-config-loader');
|
|
14
14
|
const config = require('../core/config');
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -233,15 +233,15 @@ function applyLocalPortAdjustment(result, devIdNum) {
|
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* Calculate public ports for docker context
|
|
236
|
-
* Uses
|
|
237
|
-
* (e.g. KEYCLOAK_PUBLIC_PORT = 8082 + 600 = 8682 for dev 6,
|
|
236
|
+
* Uses schema env-config ports only so *_PUBLIC_PORT is always canonical base + devId*100
|
|
237
|
+
* (e.g. KEYCLOAK_PUBLIC_PORT = 8082 + 600 = 8682 for dev 6, even if user env-config or config overrides KEYCLOAK_PORT to 8080)
|
|
238
238
|
*
|
|
239
239
|
* @function calculateDockerPublicPorts
|
|
240
240
|
* @param {Object} result - Environment variable map (merged base + overrides)
|
|
241
241
|
* @param {number} devIdNum - Developer ID number
|
|
242
|
-
* @param {Object} [
|
|
242
|
+
* @param {Object} [schemaBaseVars] - Schema-only env-config vars (lib/schema/env-config.yaml) for *_PUBLIC_PORT
|
|
243
243
|
*/
|
|
244
|
-
function calculateDockerPublicPorts(result, devIdNum,
|
|
244
|
+
function calculateDockerPublicPorts(result, devIdNum, schemaBaseVars = {}) {
|
|
245
245
|
if (devIdNum <= 0) {
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
@@ -249,9 +249,9 @@ function calculateDockerPublicPorts(result, devIdNum, baseVars = {}) {
|
|
|
249
249
|
// Match any variable ending with _PORT (e.g., MISO_PORT, KEYCLOAK_PORT, DB_PORT)
|
|
250
250
|
if (/_PORT$/.test(key) && !/_PUBLIC_PORT$/.test(key)) {
|
|
251
251
|
const publicPortKey = key.replace(/_PORT$/, '_PUBLIC_PORT');
|
|
252
|
-
// Use
|
|
253
|
-
const
|
|
254
|
-
const sourceVal =
|
|
252
|
+
// Use schema port when available so PUBLIC_PORT is canonical (e.g. 8082), not overridden (e.g. 8080)
|
|
253
|
+
const schemaPort = schemaBaseVars[key];
|
|
254
|
+
const sourceVal = schemaPort !== undefined && schemaPort !== null ? schemaPort : value;
|
|
255
255
|
let portVal;
|
|
256
256
|
if (typeof sourceVal === 'string') {
|
|
257
257
|
portVal = parseInt(sourceVal, 10);
|
|
@@ -294,7 +294,9 @@ async function buildEnvVarMap(context, osModule = null, developerId = null) {
|
|
|
294
294
|
applyLocalPortAdjustment(result, devIdNum);
|
|
295
295
|
} else if (context === 'docker') {
|
|
296
296
|
const devIdNum = await getDeveloperIdNumber(developerId);
|
|
297
|
-
|
|
297
|
+
const schemaCfg = loadSchemaEnvConfig();
|
|
298
|
+
const schemaBaseVars = (schemaCfg && schemaCfg.environments && schemaCfg.environments[context]) ? schemaCfg.environments[context] : {};
|
|
299
|
+
calculateDockerPublicPorts(result, devIdNum, schemaBaseVars);
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
return result;
|