Skip to content

Commit 22ecd1c

Browse files
committed
fixes for JSONVault search path
1 parent 6b613fd commit 22ecd1c

File tree

8 files changed

+42
-4969
lines changed

8 files changed

+42
-4969
lines changed

packages/cli/bundle-stats.html

Lines changed: 0 additions & 4949 deletions
This file was deleted.

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/cli",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "SmythOS SRE Command Line Interface",
55
"keywords": [
66
"smythos",

packages/cli/rollup.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ const zeroDepConfig = {
206206
keepNames: true, // Keep all names
207207
}),
208208
// Bundle size visualization
209-
visualizer({
210-
filename: './bundle-stats.html',
211-
open: true, // automatically opens in browser
212-
gzipSize: true,
213-
brotliSize: true,
214-
template: 'treemap', // treemap, sunburst, or network
215-
title: 'CLI Bundle Size Report',
216-
}),
209+
// visualizer({
210+
// filename: './bundle-stats.html',
211+
// open: true, // automatically opens in browser
212+
// gzipSize: true,
213+
// brotliSize: true,
214+
// template: 'treemap', // treemap, sunburst, or network
215+
// title: 'CLI Bundle Size Report',
216+
// }),
217217
// No terser plugin - no compression at all
218218
],
219219
};

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sre",
3-
"version": "1.6.11",
3+
"version": "1.6.12",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/core/src/helpers/Sysconfig.helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ export function findSmythPath(_path: string = '', callback?: (smythDir: string,
8383
export function findValidResourcePath(listOfLocations: string[], callback?: (dir: string, success?: boolean, nextDir?: string) => void) {
8484
let found = '';
8585
for (let location of listOfLocations) {
86-
found = findSmythPath(location, (dir, success, nextDir) => {
86+
findSmythPath(location, (dir, success, nextDir) => {
8787
callback?.(dir, success, nextDir);
8888
if (success) {
8989
found = dir;
9090
}
9191
});
92+
if (found) return found;
9293
}
9394
return found;
9495
}

packages/core/src/helpers/TemplateString.helper.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,26 @@ export class TemplateStringHelper {
227227
// });
228228
// }
229229
}
230+
/**
231+
* A helper function that takes an object and a property string and returns the value of the property
232+
* @param obj the object to get the property from
233+
* @param propertyString the property string to get the value from
234+
* @returns the value of the property
235+
*/
236+
export function JSONExpression(obj, propertyString) {
237+
const properties = propertyString.split(/\.|\[|\]\.|\]\[|\]/).filter(Boolean);
238+
let currentProperty = obj;
239+
240+
for (let property of properties) {
241+
if (currentProperty === undefined || currentProperty === null) {
242+
return undefined;
243+
}
244+
245+
currentProperty = currentProperty[property];
246+
}
247+
248+
return currentProperty;
249+
}
230250

231251
/**
232252
* a helper function that takes a string and escape it

packages/core/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import fs from 'fs';
1111
import * as readlineSync from 'readline-sync';
1212
import { VaultConnector } from '../VaultConnector';
1313

14-
const console = Logger('JSONFileVault');
14+
const logger = Logger('JSONFileVault');
1515

1616
export type JSONFileVaultConfig = {
1717
file?: string;
@@ -44,19 +44,19 @@ export class JSONFileVault extends VaultConnector {
4444
if (_vaultFile && fs.existsSync(_vaultFile)) {
4545
return _vaultFile;
4646
}
47-
console.warn('Vault file not found in:', _vaultFile);
47+
logger.warn('Vault file not found in:', _vaultFile);
4848

4949
let found = '';
5050

5151
const relativeSearchLocations = ['vault.json', 'vault/vault.json', '.sre/vault.json'];
5252
found = findValidResourcePath(relativeSearchLocations, (dir, success, nextDir) => {
5353
if (!success) {
54-
console.warn('Vault file not found in:', nextDir);
54+
logger.warn('Vault file not found in:', nextDir);
5555
}
5656
});
5757

5858
if (found) {
59-
console.warn('Using alternative vault file found in : ', found);
59+
logger.warn('Using alternative vault file found in : ', found);
6060
return found;
6161
}
6262

@@ -75,7 +75,7 @@ export class JSONFileVault extends VaultConnector {
7575
hideEchoBack: true,
7676
mask: '*',
7777
});
78-
console.info('Master key entered');
78+
logger.info('Master key entered');
7979
return masterKey;
8080
}
8181

@@ -96,7 +96,7 @@ export class JSONFileVault extends VaultConnector {
9696
return value.replace(envVarPattern, (match, envVarName) => {
9797
const envValue = process.env[envVarName];
9898
if (envValue === undefined) {
99-
console.warn(`Environment variable ${envVarName} not found, keeping original value: ${match}`);
99+
logger.warn(`Environment variable ${envVarName} not found, keeping original value: ${match}`);
100100
return match;
101101
}
102102
return envValue;
@@ -175,8 +175,8 @@ export class JSONFileVault extends VaultConnector {
175175
this.vaultData = JSON.parse(fs.readFileSync(vaultFile).toString());
176176
}
177177
} catch (e) {
178-
console.error('Error parsing vault file:', e);
179-
console.error('!!! Vault features might not work properly !!!');
178+
logger.error('Error parsing vault file:', e);
179+
logger.error('!!! Vault features might not work properly !!!');
180180
this.vaultData = {};
181181
}
182182

@@ -197,6 +197,7 @@ export class JSONFileVault extends VaultConnector {
197197
}
198198

199199
private initFileWatcher() {
200+
if (!this.vaultFile || !fs.existsSync(this.vaultFile)) return;
200201
this.watcher = chokidar.watch(this.vaultFile, {
201202
persistent: false, // Don't keep the process running
202203
ignoreInitial: true,

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sdk",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "SRE SDK",
55
"keywords": [
66
"smythos",

0 commit comments

Comments
 (0)