@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.
@@ -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
- // Load base env-config.yaml
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
 
@@ -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 base ports from env-config when available so *_PUBLIC_PORT is always base + devId*100
237
- * (e.g. KEYCLOAK_PUBLIC_PORT = 8082 + 600 = 8682 for dev 6, not 8080 + 600 from overrides)
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} [baseVars] - Base vars from env-config (used for *_PUBLIC_PORT calculation when present)
242
+ * @param {Object} [schemaBaseVars] - Schema-only env-config vars (lib/schema/env-config.yaml) for *_PUBLIC_PORT
243
243
  */
244
- function calculateDockerPublicPorts(result, devIdNum, baseVars = {}) {
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 base port from env-config when available so PUBLIC_PORT is canonical (e.g. 8082 not 8080)
253
- const basePort = baseVars[key];
254
- const sourceVal = basePort !== undefined && basePort !== null ? basePort : value;
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
- calculateDockerPublicPorts(result, devIdNum, baseVars);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aifabrix/builder",
3
- "version": "2.33.4",
3
+ "version": "2.33.5",
4
4
  "description": "AI Fabrix Local Fabric & Deployment SDK",
5
5
  "main": "lib/index.js",
6
6
  "bin": {