@aifabrix/builder 2.22.1 → 2.22.2
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.
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const path = require('path');
|
|
13
|
-
const os = require('os');
|
|
14
13
|
const chalk = require('chalk');
|
|
15
14
|
const logger = require('../utils/logger');
|
|
16
15
|
const { getAifabrixSecretsPath } = require('../config');
|
|
17
16
|
const { saveLocalSecret, saveSecret } = require('../utils/local-secrets');
|
|
17
|
+
const pathsUtil = require('../utils/paths');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Handle secrets set command action
|
|
@@ -61,7 +61,7 @@ async function handleSecretsSet(key, value, options) {
|
|
|
61
61
|
} else {
|
|
62
62
|
// Save to user secrets file
|
|
63
63
|
await saveLocalSecret(key, value);
|
|
64
|
-
const userSecretsPath = path.join(
|
|
64
|
+
const userSecretsPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.local.yaml');
|
|
65
65
|
logger.log(chalk.green(`✓ Secret '${key}' saved to user secrets file: ${userSecretsPath}`));
|
|
66
66
|
}
|
|
67
67
|
}
|
package/lib/commands/secure.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
const os = require('os');
|
|
15
14
|
const yaml = require('js-yaml');
|
|
16
15
|
const inquirer = require('inquirer');
|
|
17
16
|
const chalk = require('chalk');
|
|
@@ -19,6 +18,7 @@ const logger = require('../utils/logger');
|
|
|
19
18
|
const { setSecretsEncryptionKey, getSecretsEncryptionKey } = require('../config');
|
|
20
19
|
const { validateEncryptionKey } = require('../utils/secrets-encryption');
|
|
21
20
|
const { encryptYamlValues } = require('../utils/yaml-preserve');
|
|
21
|
+
const pathsUtil = require('../utils/paths');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Finds all secrets.local.yaml files to encrypt
|
|
@@ -32,7 +32,7 @@ async function findSecretsFiles() {
|
|
|
32
32
|
const files = [];
|
|
33
33
|
|
|
34
34
|
// User's secrets file
|
|
35
|
-
const userSecretsPath = path.join(
|
|
35
|
+
const userSecretsPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.local.yaml');
|
|
36
36
|
if (fs.existsSync(userSecretsPath)) {
|
|
37
37
|
files.push({ path: userSecretsPath, type: 'user' });
|
|
38
38
|
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
const os = require('os');
|
|
15
14
|
const dockerUtils = require('./docker');
|
|
16
15
|
const { getActualSecretsPath } = require('./secrets-path');
|
|
17
16
|
|
|
@@ -93,7 +92,8 @@ async function checkSecrets() {
|
|
|
93
92
|
return { status: 'missing', paths: pathsChecked };
|
|
94
93
|
} catch (error) {
|
|
95
94
|
// Fallback to default path if there's an error
|
|
96
|
-
const
|
|
95
|
+
const pathsUtil = require('./paths');
|
|
96
|
+
const defaultPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.yaml');
|
|
97
97
|
return {
|
|
98
98
|
status: fs.existsSync(defaultPath) ? 'ok' : 'missing',
|
|
99
99
|
paths: [defaultPath]
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const yaml = require('js-yaml');
|
|
14
|
-
const os = require('os');
|
|
15
14
|
const logger = require('../utils/logger');
|
|
15
|
+
const pathsUtil = require('./paths');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Saves a secret to ~/.aifabrix/secrets.local.yaml
|
|
19
|
+
* Uses paths.getAifabrixHome() to respect config.yaml aifabrix-home override
|
|
19
20
|
* Merges with existing secrets without overwriting other keys
|
|
20
21
|
*
|
|
21
22
|
* @async
|
|
@@ -37,7 +38,7 @@ async function saveLocalSecret(key, value) {
|
|
|
37
38
|
throw new Error('Secret value is required');
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
const secretsPath = path.join(
|
|
41
|
+
const secretsPath = path.join(pathsUtil.getAifabrixHome(), 'secrets.local.yaml');
|
|
41
42
|
const secretsDir = path.dirname(secretsPath);
|
|
42
43
|
|
|
43
44
|
// Create directory if needed
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
const os = require('os');
|
|
15
14
|
const yaml = require('js-yaml');
|
|
16
15
|
const config = require('../config');
|
|
17
16
|
const { makeApiCall, refreshDeviceToken: apiRefreshDeviceToken } = require('./api');
|
|
18
17
|
const logger = require('./logger');
|
|
18
|
+
const pathsUtil = require('./paths');
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
function getSecretsFilePath() {
|
|
21
|
+
return path.join(pathsUtil.getAifabrixHome(), 'secrets.local.yaml');
|
|
22
|
+
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Load client credentials from secrets.local.yaml
|
|
@@ -31,11 +33,12 @@ async function loadClientCredentials(appName) {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
try {
|
|
34
|
-
|
|
36
|
+
const secretsFile = getSecretsFilePath();
|
|
37
|
+
if (!fs.existsSync(secretsFile)) {
|
|
35
38
|
return null;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
const content = fs.readFileSync(
|
|
41
|
+
const content = fs.readFileSync(secretsFile, 'utf8');
|
|
39
42
|
const secrets = yaml.load(content) || {};
|
|
40
43
|
|
|
41
44
|
const clientIdKey = `${appName}-client-idKeyVault`;
|