@ejfdelgado/ejflab-back 1.16.8 → 1.17.0
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/package.json
CHANGED
@@ -2,6 +2,7 @@ import { FlowChartExec } from "@ejfdelgado/ejflab-common/src/flowchart/FlowChart
|
|
2
2
|
import { GenericProcessor } from "./GenericProcessor.mjs";
|
3
3
|
import fs from "fs";
|
4
4
|
import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
|
5
|
+
import { MyTuples } from "@ejfdelgado/ejflab-common/src/MyTuples.js";
|
5
6
|
import { Buffer } from 'buffer';
|
6
7
|
|
7
8
|
const WORKSPACE = process.env.WORKSPACE;
|
@@ -24,6 +25,24 @@ export class LoadFlowChartProcessor extends GenericProcessor {
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
28
|
+
overwriteProcessorEnvVariables(dataObject) {
|
29
|
+
//console.log(JSON.stringify(dataObject, null, 4));
|
30
|
+
const tuples = MyTuples.getTuples(dataObject);
|
31
|
+
//console.log(JSON.stringify(tuples, null, 4));
|
32
|
+
const keys = Object.keys(tuples);
|
33
|
+
for (let i = 0; i < keys.length; i++) {
|
34
|
+
const key = keys[i];
|
35
|
+
const currentValue = tuples[key];
|
36
|
+
if (typeof currentValue == "string") {
|
37
|
+
const envKey = key.replace(".", "_").toUpperCase();
|
38
|
+
if (envKey in process.env) {
|
39
|
+
SimpleObj.recreate(dataObject, key, process.env[envKey]);
|
40
|
+
}
|
41
|
+
console.log(`${envKey}=${SimpleObj.getValue(dataObject, key)}`);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
27
46
|
async execute(args) {
|
28
47
|
let {
|
29
48
|
names,
|
@@ -59,7 +78,12 @@ export class LoadFlowChartProcessor extends GenericProcessor {
|
|
59
78
|
const keysData = Object.keys(dataPath);
|
60
79
|
for (let i = 0; i < keysData.length; i++) {
|
61
80
|
const keyData = keysData[i];
|
62
|
-
const
|
81
|
+
const fileName = dataPath[keyData];
|
82
|
+
const dataObject = JSON.parse(fs.readFileSync(fileName, 'utf8'));
|
83
|
+
// Here we can intercept the data model and overwrite given env variables
|
84
|
+
if (fileName.endsWith("processors.json")) {
|
85
|
+
this.overwriteProcessorEnvVariables(dataObject);
|
86
|
+
}
|
63
87
|
if (keyData.length == 0) {
|
64
88
|
Object.assign(data, dataObject);
|
65
89
|
} else {
|