@aifabrix/builder 2.22.0 → 2.22.1
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/secrets.js
CHANGED
|
@@ -338,7 +338,16 @@ async function generateEnvContent(appName, secretsPath, environment = 'local', f
|
|
|
338
338
|
const secretsPaths = await getActualSecretsPath(secretsPath, appName);
|
|
339
339
|
|
|
340
340
|
if (force) {
|
|
341
|
-
|
|
341
|
+
// Use the same path resolution logic as loadSecrets
|
|
342
|
+
// If explicit path provided, use it; otherwise use the path that loadUserSecrets() would use
|
|
343
|
+
let secretsFileForGeneration;
|
|
344
|
+
if (secretsPath) {
|
|
345
|
+
secretsFileForGeneration = resolveSecretsPath(secretsPath);
|
|
346
|
+
} else {
|
|
347
|
+
// Use the same path that loadUserSecrets() would use (now uses paths.getAifabrixHome())
|
|
348
|
+
secretsFileForGeneration = secretsPaths.userPath;
|
|
349
|
+
}
|
|
350
|
+
await generateMissingSecrets(template, secretsFileForGeneration);
|
|
342
351
|
}
|
|
343
352
|
|
|
344
353
|
const secrets = await loadSecrets(secretsPath, appName);
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
const yaml = require('js-yaml');
|
|
15
14
|
const os = require('os');
|
|
15
|
+
const yaml = require('js-yaml');
|
|
16
16
|
const crypto = require('crypto');
|
|
17
17
|
const logger = require('./logger');
|
|
18
|
+
const pathsUtil = require('./paths');
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Finds missing secret keys from template
|
|
@@ -123,11 +124,12 @@ function saveSecretsFile(resolvedPath, secrets) {
|
|
|
123
124
|
/**
|
|
124
125
|
* Generates missing secret keys in secrets file
|
|
125
126
|
* Scans env.template for kv:// references and adds missing keys with secure defaults
|
|
127
|
+
* Uses paths.getAifabrixHome() to respect config.yaml aifabrix-home override when path not provided
|
|
126
128
|
*
|
|
127
129
|
* @async
|
|
128
130
|
* @function generateMissingSecrets
|
|
129
131
|
* @param {string} envTemplate - Environment template content
|
|
130
|
-
* @param {string} secretsPath - Path to secrets file
|
|
132
|
+
* @param {string} [secretsPath] - Path to secrets file (optional)
|
|
131
133
|
* @returns {Promise<string[]>} Array of newly generated secret keys
|
|
132
134
|
* @throws {Error} If generation fails
|
|
133
135
|
*
|
|
@@ -136,7 +138,7 @@ function saveSecretsFile(resolvedPath, secrets) {
|
|
|
136
138
|
* // Returns: ['new-secret-key', 'another-secret']
|
|
137
139
|
*/
|
|
138
140
|
async function generateMissingSecrets(envTemplate, secretsPath) {
|
|
139
|
-
const resolvedPath = secretsPath || path.join(
|
|
141
|
+
const resolvedPath = secretsPath || path.join(pathsUtil.getAifabrixHome(), 'secrets.yaml');
|
|
140
142
|
const existingSecrets = loadExistingSecrets(resolvedPath);
|
|
141
143
|
const missingKeys = findMissingSecretKeys(envTemplate, existingSecrets);
|
|
142
144
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
14
|
const yaml = require('js-yaml');
|
|
15
|
-
const os = require('os');
|
|
16
15
|
const logger = require('./logger');
|
|
16
|
+
const pathsUtil = require('./paths');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Loads secrets from file with cascading lookup support
|
|
@@ -46,11 +46,12 @@ async function loadSecretsFromFile(filePath) {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Loads user secrets from ~/.aifabrix/secrets.local.yaml
|
|
49
|
+
* Uses paths.getAifabrixHome() to respect config.yaml aifabrix-home override
|
|
49
50
|
* @function loadUserSecrets
|
|
50
51
|
* @returns {Object} Loaded secrets object or empty object
|
|
51
52
|
*/
|
|
52
53
|
function loadUserSecrets() {
|
|
53
|
-
const userSecretsPath = path.join(
|
|
54
|
+
const userSecretsPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.local.yaml');
|
|
54
55
|
if (!fs.existsSync(userSecretsPath)) {
|
|
55
56
|
return {};
|
|
56
57
|
}
|
|
@@ -73,11 +74,12 @@ function loadUserSecrets() {
|
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Loads default secrets from ~/.aifabrix/secrets.yaml
|
|
77
|
+
* Uses paths.getAifabrixHome() to respect config.yaml aifabrix-home override
|
|
76
78
|
* @function loadDefaultSecrets
|
|
77
79
|
* @returns {Object} Loaded secrets object or empty object
|
|
78
80
|
*/
|
|
79
81
|
function loadDefaultSecrets() {
|
|
80
|
-
const defaultPath = path.join(
|
|
82
|
+
const defaultPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.yaml');
|
|
81
83
|
if (!fs.existsSync(defaultPath)) {
|
|
82
84
|
return {};
|
|
83
85
|
}
|