@aifabrix/builder 2.33.3 → 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,11 +233,15 @@ function applyLocalPortAdjustment(result, devIdNum) {
233
233
 
234
234
  /**
235
235
  * Calculate public ports for docker context
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
+ *
236
239
  * @function calculateDockerPublicPorts
237
- * @param {Object} result - Environment variable map
240
+ * @param {Object} result - Environment variable map (merged base + overrides)
238
241
  * @param {number} devIdNum - Developer ID number
242
+ * @param {Object} [schemaBaseVars] - Schema-only env-config vars (lib/schema/env-config.yaml) for *_PUBLIC_PORT
239
243
  */
240
- function calculateDockerPublicPorts(result, devIdNum) {
244
+ function calculateDockerPublicPorts(result, devIdNum, schemaBaseVars = {}) {
241
245
  if (devIdNum <= 0) {
242
246
  return;
243
247
  }
@@ -245,13 +249,14 @@ function calculateDockerPublicPorts(result, devIdNum) {
245
249
  // Match any variable ending with _PORT (e.g., MISO_PORT, KEYCLOAK_PORT, DB_PORT)
246
250
  if (/_PORT$/.test(key) && !/_PUBLIC_PORT$/.test(key)) {
247
251
  const publicPortKey = key.replace(/_PORT$/, '_PUBLIC_PORT');
248
- // Always recalculate public port based on base port, even if manually set
249
- // This ensures developer-id offset is always applied correctly
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;
250
255
  let portVal;
251
- if (typeof value === 'string') {
252
- portVal = parseInt(value, 10);
253
- } else if (typeof value === 'number') {
254
- portVal = value;
256
+ if (typeof sourceVal === 'string') {
257
+ portVal = parseInt(sourceVal, 10);
258
+ } else if (typeof sourceVal === 'number') {
259
+ portVal = sourceVal;
255
260
  } else {
256
261
  continue;
257
262
  }
@@ -289,7 +294,9 @@ async function buildEnvVarMap(context, osModule = null, developerId = null) {
289
294
  applyLocalPortAdjustment(result, devIdNum);
290
295
  } else if (context === 'docker') {
291
296
  const devIdNum = await getDeveloperIdNumber(developerId);
292
- calculateDockerPublicPorts(result, devIdNum);
297
+ const schemaCfg = loadSchemaEnvConfig();
298
+ const schemaBaseVars = (schemaCfg && schemaCfg.environments && schemaCfg.environments[context]) ? schemaCfg.environments[context] : {};
299
+ calculateDockerPublicPorts(result, devIdNum, schemaBaseVars);
293
300
  }
294
301
 
295
302
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aifabrix/builder",
3
- "version": "2.33.3",
3
+ "version": "2.33.5",
4
4
  "description": "AI Fabrix Local Fabric & Deployment SDK",
5
5
  "main": "lib/index.js",
6
6
  "bin": {