node-red-contrib-config-files 0.1.0 → 0.2.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/CHANGELOG.md +17 -0
- package/HELP.md +30 -0
- package/LICENSE +21 -1
- package/README.md +14 -7
- package/install.js +1 -1
- package/package.json +5 -10
- package/subflow.json +165 -97
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.1] - 2026-01-31
|
|
4
|
+
### Changed
|
|
5
|
+
- If directory `configDir` doesn't exist or is not accessible: Instead of throwing a node error, a node warning is created. This warning may appear in the “Debug Messages” sidebar.
|
|
6
|
+
|
|
7
|
+
## [0.2.0] - 2026-01-30
|
|
8
|
+
### Added
|
|
9
|
+
- If directory `configDir` doesn't exist or is not accessible, a node error is throw. This error can be received with a `catch` node, for example.
|
|
10
|
+
- If no file was found with `configFileExt`, a node warning is created. This warning may appear in the “Debug Messages” sidebar.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- A filename extension can be specified for searching configuration files. In the previous version, a search pattern could be configured. The corresponding property has renamed to `configFileEx` (previously: `configFilePattern`).
|
|
14
|
+
- Dependency from `node-red-contrib-filesystem` has been removed. Only the Node.js core module [File System](https://nodejs.org/api/fs.html#file-system) (fs) is now used. This eliminates dependencies on third-party modules.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
nothing
|
package/HELP.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Read and merge configuration files (JSON).
|
|
2
|
+
|
|
3
|
+
### Inputs
|
|
4
|
+
|
|
5
|
+
Directory and filename extension used to search for configuration
|
|
6
|
+
files can be configured using the node properties and/or with the
|
|
7
|
+
input message.
|
|
8
|
+
|
|
9
|
+
: configDir (string) : Directory with config files. Absolute or relative path, default: `/config`. Input message `msg.configDir` overwrites the node property.
|
|
10
|
+
: configFileExt (string) : Filename extension for config files, default: `.json`. Input message `msg.configFileExt` overwrites the node property.
|
|
11
|
+
|
|
12
|
+
### Outputs
|
|
13
|
+
|
|
14
|
+
: payload (object) : Merged content from config files.
|
|
15
|
+
: configFiles [] : Paths to config files found, empty array if no files were found.
|
|
16
|
+
|
|
17
|
+
### Details
|
|
18
|
+
The node pproperty `defaultConfig` can be used to define configuration
|
|
19
|
+
values that are used when they are missing in the configuration files.
|
|
20
|
+
|
|
21
|
+
The `configDir` is searched non-recursively for configuration files using
|
|
22
|
+
the filename extension `configFilePattern`.
|
|
23
|
+
The files are sorted by their file names and merged in this order.
|
|
24
|
+
|
|
25
|
+
The content of the `defaultConfig` property and the configuration files
|
|
26
|
+
must by valid JSON.
|
|
27
|
+
|
|
28
|
+
### References
|
|
29
|
+
|
|
30
|
+
- [GitHub](https://github.com/schaeren/node-red-contrib-config-files) - source code
|
package/LICENSE
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# node-red-contrib-config-files
|
|
2
|
-
[Node-Red](https://nodered.org/) node for reading and merging configuration files with JSON content. The output returns
|
|
2
|
+
[Node-Red](https://nodered.org/) node for reading and merging configuration files with JSON content. The output returns
|
|
3
|
+
the resulting configuration object.
|
|
3
4
|
|
|
4
|
-
Directory and search
|
|
5
|
+
Directory and filename extension used to search for configuration files can be configured using the node properties and/or
|
|
6
|
+
with the input message.
|
|
5
7
|
|
|
6
|
-
The files are sorted by their file names and merged in this order. The `defaultConfig`
|
|
8
|
+
The files are sorted by their file names and merged in this order. The `defaultConfig` can be used to define configuration
|
|
9
|
+
values that are used when they are missing in the configuration files.
|
|
7
10
|
|
|
8
11
|
If no configuration files are found, the `defaultConfig` is returned.
|
|
9
12
|
|
|
10
13
|
The node status displays one of the following two messages:
|
|
11
|
-
- Found {count} config files in '{configDir}' with
|
|
12
|
-
- No config files found in '{configDir}' with
|
|
14
|
+
- Found {count} config files in '{configDir}' with extension '{configFileExt}'
|
|
15
|
+
- No config files found in '{configDir}' with extension '{configFileExt}' -> using default config
|
|
16
|
+
|
|
17
|
+
If directory `configDir` doesn't exist or is not accessible or if no file was found with `configFileExt`, a node warning
|
|
18
|
+
is created. This warning may appear in the “Debug Messages” sidebar.
|
|
13
19
|
|
|
14
20
|
## Internals
|
|
15
|
-
- This custom node
|
|
16
|
-
- It uses `node-red-contrib-filesystem : fs-list` to find the config files.
|
|
21
|
+
- This custom node was created from a subflow.
|
|
17
22
|
- It uses `lodash.merge()` to merge the `defaultConfig` with the contents of the files found.
|
|
23
|
+
- Some debug information is written by the node using `node.debug()`. To view these messages, set the logging level
|
|
24
|
+
in `settings.js` to at least `debug`.
|
package/install.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
4
|
module.exports = function(RED) {
|
|
5
|
-
const subflowFile = path.join(__dirname,"subflow.json");
|
|
5
|
+
const subflowFile = path.join(__dirname, "subflow.json");
|
|
6
6
|
const subflowContents = fs.readFileSync(subflowFile);
|
|
7
7
|
const subflowJSON = JSON.parse(subflowContents);
|
|
8
8
|
RED.nodes.registerSubflow(subflowJSON);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-config-files",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Read and merge configuration files (JSON).
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Read and merge configuration files (JSON).",
|
|
5
5
|
"main": "install.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -20,16 +20,11 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/schaeren/node-red-contrib-config-files"
|
|
22
22
|
},
|
|
23
|
-
"
|
|
23
|
+
"homepage": "https://github.com/schaeren/node-red-contrib-config-files",
|
|
24
|
+
"license": "MIT",
|
|
24
25
|
"node-red": {
|
|
25
26
|
"nodes": {
|
|
26
27
|
"config-files": "install.js"
|
|
27
|
-
}
|
|
28
|
-
"dependencies": [
|
|
29
|
-
"node-red-contrib-filesystem"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"node-red-contrib-filesystem": "*"
|
|
28
|
+
}
|
|
34
29
|
}
|
|
35
30
|
}
|
package/subflow.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "ec796389903c1d0f",
|
|
3
3
|
"type": "subflow",
|
|
4
4
|
"name": "config-files",
|
|
5
|
-
"info": "Read and merge configuration files (JSON). \
|
|
5
|
+
"info": "Read and merge configuration files (JSON). \n\n### Inputs\n\nDirectory and filename extension used to search for configuration \nfiles can be configured using the node properties and/or with the \ninput message.\n\n: configDir (string) : Directory with config files. Absolute or relative path, default: `/config`. Input message `msg.configDir` overwrites the node property.\n: configFileExt (string) : Filename extension for config files, default: `.json`. Input message `msg.configFileExt` overwrites the node property.\n\n### Outputs\n\n: payload (object) : Merged content from config files.\n: configFiles [] : Paths to config files found, empty array if no files were found.\n\n### Details\nThe node pproperty `defaultConfig` can be used to define configuration \nvalues that are used when they are missing in the configuration files.\n\nThe `configDir` is searched non-recursively for configuration files using \nthe filename extension `configFilePattern`.\nThe files are sorted by their file names and merged in this order. \n\nThe content of the `defaultConfig` property and the configuration files \nmust by valid JSON.\n\n### References\n\n- [GitHub](https://github.com/schaeren/node-red-contrib-config-files) - source code",
|
|
6
6
|
"category": "",
|
|
7
7
|
"in": [
|
|
8
8
|
{
|
|
@@ -17,16 +17,19 @@
|
|
|
17
17
|
],
|
|
18
18
|
"out": [
|
|
19
19
|
{
|
|
20
|
-
"x":
|
|
21
|
-
"y":
|
|
20
|
+
"x": 740,
|
|
21
|
+
"y": 400,
|
|
22
22
|
"wires": [
|
|
23
23
|
{
|
|
24
|
-
"id": "
|
|
24
|
+
"id": "86c429715975c781",
|
|
25
|
+
"port": 0
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "efa7ea24e8224b84",
|
|
25
29
|
"port": 0
|
|
26
30
|
}
|
|
27
31
|
]
|
|
28
|
-
}
|
|
29
|
-
],
|
|
32
|
+
} ],
|
|
30
33
|
"env": [
|
|
31
34
|
{
|
|
32
35
|
"name": "configDir",
|
|
@@ -34,9 +37,9 @@
|
|
|
34
37
|
"value": "/config"
|
|
35
38
|
},
|
|
36
39
|
{
|
|
37
|
-
"name": "
|
|
40
|
+
"name": "configFileExt",
|
|
38
41
|
"type": "str",
|
|
39
|
-
"value": "
|
|
42
|
+
"value": ".json"
|
|
40
43
|
},
|
|
41
44
|
{
|
|
42
45
|
"name": "defaultConfig",
|
|
@@ -47,17 +50,17 @@
|
|
|
47
50
|
"meta": {
|
|
48
51
|
"module": "node-red-contrib-config-files",
|
|
49
52
|
"type": "config-files",
|
|
50
|
-
"version": "0.1.0",
|
|
51
|
-
"author": "Peter Schären <peter.schaeren@gmail.com>",
|
|
52
53
|
"desc": "Read and merge configuration files (JSON).",
|
|
54
|
+
"version": "0.2.1",
|
|
55
|
+
"author": "Peter Schären <peter.schaeren@gmail.com>",
|
|
53
56
|
"keywords": "node-red,config-files,config,json",
|
|
54
|
-
"license": "
|
|
57
|
+
"license": "MIT"
|
|
55
58
|
},
|
|
56
59
|
"color": "#b0c2ba",
|
|
57
60
|
"icon": "node-red/parser-json.svg",
|
|
58
61
|
"status": {
|
|
59
|
-
"x":
|
|
60
|
-
"y":
|
|
62
|
+
"x": 740,
|
|
63
|
+
"y": 160,
|
|
61
64
|
"wires": [
|
|
62
65
|
{
|
|
63
66
|
"id": "73c98834cb90c714",
|
|
@@ -66,32 +69,10 @@
|
|
|
66
69
|
]
|
|
67
70
|
},
|
|
68
71
|
"flow": [
|
|
69
|
-
{
|
|
70
|
-
"id": "2b5d6f663d02b82f",
|
|
71
|
-
"type": "fs-list",
|
|
72
|
-
"z": "0d7c13f79e4a7aee",
|
|
73
|
-
"name": "Find config files",
|
|
74
|
-
"path": "configDir",
|
|
75
|
-
"pathType": "msg",
|
|
76
|
-
"pattern": "configFilePattern",
|
|
77
|
-
"patternType": "msg",
|
|
78
|
-
"filter": "files",
|
|
79
|
-
"recursive": false,
|
|
80
|
-
"follow": false,
|
|
81
|
-
"property": "payload",
|
|
82
|
-
"propertyType": "msg",
|
|
83
|
-
"x": 220,
|
|
84
|
-
"y": 80,
|
|
85
|
-
"wires": [
|
|
86
|
-
[
|
|
87
|
-
"73c98834cb90c714"
|
|
88
|
-
]
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
72
|
{
|
|
92
73
|
"id": "b46481b92cb28e07",
|
|
93
74
|
"type": "file in",
|
|
94
|
-
"z": "
|
|
75
|
+
"z": "ec796389903c1d0f",
|
|
95
76
|
"name": "read file",
|
|
96
77
|
"filename": "payload",
|
|
97
78
|
"filenameType": "msg",
|
|
@@ -101,7 +82,7 @@
|
|
|
101
82
|
"encoding": "utf8",
|
|
102
83
|
"allProps": false,
|
|
103
84
|
"x": 200,
|
|
104
|
-
"y":
|
|
85
|
+
"y": 280,
|
|
105
86
|
"wires": [
|
|
106
87
|
[
|
|
107
88
|
"f3c260d6c082e422"
|
|
@@ -111,7 +92,7 @@
|
|
|
111
92
|
{
|
|
112
93
|
"id": "bebafe14f9cc467b",
|
|
113
94
|
"type": "split",
|
|
114
|
-
"z": "
|
|
95
|
+
"z": "ec796389903c1d0f",
|
|
115
96
|
"name": "",
|
|
116
97
|
"splt": "\\n",
|
|
117
98
|
"spltType": "str",
|
|
@@ -120,35 +101,11 @@
|
|
|
120
101
|
"stream": false,
|
|
121
102
|
"addname": "",
|
|
122
103
|
"property": "payload",
|
|
123
|
-
"x":
|
|
124
|
-
"y":
|
|
125
|
-
"wires": [
|
|
126
|
-
[
|
|
127
|
-
"ef0d2e4ce8988133"
|
|
128
|
-
]
|
|
129
|
-
]
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"id": "ef0d2e4ce8988133",
|
|
133
|
-
"type": "function",
|
|
134
|
-
"z": "0d7c13f79e4a7aee",
|
|
135
|
-
"name": "make paths absolute",
|
|
136
|
-
"func": "const configDir = env.get('configDir');\nmsg.payload = path.join(configDir, msg.payload);\n\nreturn msg;\n",
|
|
137
|
-
"outputs": 1,
|
|
138
|
-
"timeout": 0,
|
|
139
|
-
"noerr": 0,
|
|
140
|
-
"initialize": "",
|
|
141
|
-
"finalize": "",
|
|
142
|
-
"libs": [
|
|
143
|
-
{
|
|
144
|
-
"var": "path",
|
|
145
|
-
"module": "path"
|
|
146
|
-
}
|
|
147
|
-
],
|
|
148
|
-
"x": 520,
|
|
149
|
-
"y": 160,
|
|
104
|
+
"x": 510,
|
|
105
|
+
"y": 240,
|
|
150
106
|
"wires": [
|
|
151
107
|
[
|
|
108
|
+
"7f1816d008fa2b70",
|
|
152
109
|
"b46481b92cb28e07"
|
|
153
110
|
]
|
|
154
111
|
]
|
|
@@ -156,23 +113,24 @@
|
|
|
156
113
|
{
|
|
157
114
|
"id": "f3c260d6c082e422",
|
|
158
115
|
"type": "json",
|
|
159
|
-
"z": "
|
|
160
|
-
"name": "to JS",
|
|
116
|
+
"z": "ec796389903c1d0f",
|
|
117
|
+
"name": "JSON to JS object",
|
|
161
118
|
"property": "payload",
|
|
162
119
|
"action": "obj",
|
|
163
120
|
"pretty": false,
|
|
164
|
-
"x":
|
|
165
|
-
"y":
|
|
121
|
+
"x": 230,
|
|
122
|
+
"y": 320,
|
|
166
123
|
"wires": [
|
|
167
124
|
[
|
|
168
|
-
"
|
|
125
|
+
"86c429715975c781",
|
|
126
|
+
"8639805af947d0c3"
|
|
169
127
|
]
|
|
170
128
|
]
|
|
171
129
|
},
|
|
172
130
|
{
|
|
173
131
|
"id": "e2a872db2d9086e6",
|
|
174
132
|
"type": "sort",
|
|
175
|
-
"z": "
|
|
133
|
+
"z": "ec796389903c1d0f",
|
|
176
134
|
"name": "",
|
|
177
135
|
"order": "ascending",
|
|
178
136
|
"as_num": false,
|
|
@@ -182,8 +140,8 @@
|
|
|
182
140
|
"msgKeyType": "elem",
|
|
183
141
|
"seqKey": "payload",
|
|
184
142
|
"seqKeyType": "msg",
|
|
185
|
-
"x":
|
|
186
|
-
"y":
|
|
143
|
+
"x": 370,
|
|
144
|
+
"y": 240,
|
|
187
145
|
"wires": [
|
|
188
146
|
[
|
|
189
147
|
"bebafe14f9cc467b"
|
|
@@ -191,11 +149,81 @@
|
|
|
191
149
|
]
|
|
192
150
|
},
|
|
193
151
|
{
|
|
194
|
-
"id": "
|
|
152
|
+
"id": "3c563aca59369641",
|
|
153
|
+
"type": "function",
|
|
154
|
+
"z": "ec796389903c1d0f",
|
|
155
|
+
"name": "get config dir and filename extension",
|
|
156
|
+
"func": "const configDir = msg.configDir ?? null;\nif (typeof configDir === 'string' && configDir.trim().length > 0) {\n msg.configDir = configDir;\n}\nelse {\n msg.configDir = env.get('configDir');\n}\n\nconst configFileExt = msg.configFileExt ?? null;\nif (typeof configFileExt === 'string' && configFileExt.trim().length > 0) {\n msg.configFileExt = configFileExt;\n}\nelse {\n msg.configFileExt = env.get('configFileExt');\n}\n\nmsg.topic = 'configFiles';\nreturn msg;",
|
|
157
|
+
"outputs": 1,
|
|
158
|
+
"timeout": 0,
|
|
159
|
+
"noerr": 0,
|
|
160
|
+
"initialize": "",
|
|
161
|
+
"finalize": "",
|
|
162
|
+
"libs": [],
|
|
163
|
+
"x": 290,
|
|
164
|
+
"y": 40,
|
|
165
|
+
"wires": [
|
|
166
|
+
[
|
|
167
|
+
"7883192ade1cf939"
|
|
168
|
+
]
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "73c98834cb90c714",
|
|
173
|
+
"type": "function",
|
|
174
|
+
"z": "ec796389903c1d0f",
|
|
175
|
+
"name": "node status",
|
|
176
|
+
"func": "const count = Array.isArray(msg.payload) ? msg.payload.length : 0;\n\nlet statusText = '';\nif (count > 0) {\n statusText = `Found ${count} config files in '${msg.configDir}' with extension '${msg.configFileExt}'`;\n}\nelse {\n statusText = `No config files found in '${msg.configDir}' with extension '${msg.configFileExt}' -> using default config`;\n}\nconst statusMsg = { payload: { fill: \"blue\", shape: \"ring\", text: statusText } };\n\nmsg.configFiles = msg.payload;\n\nreturn [msg, statusMsg];\n",
|
|
177
|
+
"outputs": 2,
|
|
178
|
+
"timeout": 0,
|
|
179
|
+
"noerr": 0,
|
|
180
|
+
"initialize": "",
|
|
181
|
+
"finalize": "",
|
|
182
|
+
"libs": [],
|
|
183
|
+
"x": 210,
|
|
184
|
+
"y": 160,
|
|
185
|
+
"wires": [
|
|
186
|
+
[
|
|
187
|
+
"6a7545e5271cd1fa"
|
|
188
|
+
],
|
|
189
|
+
[]
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"id": "7883192ade1cf939",
|
|
194
|
+
"type": "function",
|
|
195
|
+
"z": "ec796389903c1d0f",
|
|
196
|
+
"name": "find files",
|
|
197
|
+
"func": "const dir = msg.configDir;\nconst ext = msg.configFileExt\n\n// ---------------------------------------------------------------------------------------\n\nasync function findFiles(dir, ext) {\n try {\n // Check if directory exists and is accessible\n await fs.promises.access(dir);\n\n // Find files\n let filenames = await fs.promises.readdir(dir);\n filenames = filenames.filter(f => path.extname(f) === ext);\n\n // Prepend configDir to filenames\n const filepaths = filenames.map(f => path.join(dir, f));\n return filepaths ?? [];\n\n } catch (err) {\n node.warn(`Directory not found or not accessible: ${dir}`);\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------------------\n\nnode.debug(`Searching files in directory '${dir}' filename extension '${ext}' ...`);\n\nconst filepaths = await findFiles(dir, ext);\n\n// log\nif (filepaths.length > 0) {\n node.debug(`${filepaths.length} files found:`);\n for (let fp of filepaths) {\n node.debug(` ${fp}`);\n }\n}\nelse {\n node.warn(`No config files found in '${dir}' with extension '${ext}' -> using default config`);\n}\n\nmsg.payload = filepaths;\nreturn msg;\n",
|
|
198
|
+
"outputs": 1,
|
|
199
|
+
"timeout": 0,
|
|
200
|
+
"noerr": 0,
|
|
201
|
+
"initialize": "",
|
|
202
|
+
"finalize": "",
|
|
203
|
+
"libs": [
|
|
204
|
+
{
|
|
205
|
+
"var": "fs",
|
|
206
|
+
"module": "fs"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"var": "path",
|
|
210
|
+
"module": "path"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"x": 200,
|
|
214
|
+
"y": 120,
|
|
215
|
+
"wires": [
|
|
216
|
+
[
|
|
217
|
+
"73c98834cb90c714"
|
|
218
|
+
]
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"id": "86c429715975c781",
|
|
195
223
|
"type": "function",
|
|
196
|
-
"z": "
|
|
224
|
+
"z": "ec796389903c1d0f",
|
|
197
225
|
"name": "merge configs",
|
|
198
|
-
"func": "// const _t = global.get('libTracer');\n// _t.init(node, msg, flow.get('enableTracer')); \n\nlet config = flow.get('mergedConfig');\nconfig = lodash.merge(config, msg.payload);\n// _t.trace(node, msg, 'config', lodash.cloneDeep(config));\n\
|
|
226
|
+
"func": "// const _t = global.get('libTracer');\n// _t.init(node, msg, flow.get('enableTracer')); \n\nlet config = flow.get('mergedConfig');\n\nconfig = lodash.merge(config, msg.payload);\n// _t.trace(node, msg, 'config', lodash.cloneDeep(config));\n\n\n// Last config file read?\nif (msg.parts.index == msg.parts.count - 1) {\n msg.topic = 'config';\n msg.payload = config;\n delete msg.parts;\n delete msg.filename;\n\n node.debug(`Merged ALL configs:\\n ${JSON.stringify(msg.payload, null, 2)}`);\n return msg;\n}\n",
|
|
199
227
|
"outputs": 1,
|
|
200
228
|
"timeout": 0,
|
|
201
229
|
"noerr": 0,
|
|
@@ -208,51 +236,91 @@
|
|
|
208
236
|
}
|
|
209
237
|
],
|
|
210
238
|
"x": 220,
|
|
211
|
-
"y":
|
|
239
|
+
"y": 400,
|
|
212
240
|
"wires": [
|
|
213
241
|
[]
|
|
214
242
|
]
|
|
215
243
|
},
|
|
216
244
|
{
|
|
217
|
-
"id": "
|
|
245
|
+
"id": "7f1816d008fa2b70",
|
|
218
246
|
"type": "function",
|
|
219
|
-
"z": "
|
|
220
|
-
"name": "
|
|
221
|
-
"func": "
|
|
222
|
-
"outputs":
|
|
247
|
+
"z": "ec796389903c1d0f",
|
|
248
|
+
"name": "log",
|
|
249
|
+
"func": "node.debug(`Reading file '${msg.payload}' ...`)\nreturn msg;",
|
|
250
|
+
"outputs": 0,
|
|
223
251
|
"timeout": 0,
|
|
224
252
|
"noerr": 0,
|
|
225
253
|
"initialize": "",
|
|
226
254
|
"finalize": "",
|
|
227
255
|
"libs": [],
|
|
228
|
-
"x":
|
|
229
|
-
"y":
|
|
256
|
+
"x": 650,
|
|
257
|
+
"y": 240,
|
|
258
|
+
"wires": []
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"id": "8639805af947d0c3",
|
|
262
|
+
"type": "function",
|
|
263
|
+
"z": "ec796389903c1d0f",
|
|
264
|
+
"name": "log",
|
|
265
|
+
"func": "node.debug(`Config read from '${msg.filename}':\\n${JSON.stringify(msg.payload, null, 2)}`)\nreturn msg;",
|
|
266
|
+
"outputs": 0,
|
|
267
|
+
"timeout": 0,
|
|
268
|
+
"noerr": 0,
|
|
269
|
+
"initialize": "",
|
|
270
|
+
"finalize": "",
|
|
271
|
+
"libs": [],
|
|
272
|
+
"x": 650,
|
|
273
|
+
"y": 320,
|
|
274
|
+
"wires": []
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"id": "6a7545e5271cd1fa",
|
|
278
|
+
"type": "switch",
|
|
279
|
+
"z": "ec796389903c1d0f",
|
|
280
|
+
"name": "files found",
|
|
281
|
+
"property": "payload.length",
|
|
282
|
+
"propertyType": "msg",
|
|
283
|
+
"rules": [
|
|
284
|
+
{
|
|
285
|
+
"t": "gt",
|
|
286
|
+
"v": "0",
|
|
287
|
+
"vt": "str"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"t": "else"
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
"checkall": "true",
|
|
294
|
+
"repair": false,
|
|
295
|
+
"outputs": 2,
|
|
296
|
+
"x": 210,
|
|
297
|
+
"y": 240,
|
|
230
298
|
"wires": [
|
|
231
299
|
[
|
|
232
|
-
"
|
|
300
|
+
"e2a872db2d9086e6"
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
"efa7ea24e8224b84"
|
|
233
304
|
]
|
|
234
305
|
]
|
|
235
306
|
},
|
|
236
307
|
{
|
|
237
|
-
"id": "
|
|
308
|
+
"id": "efa7ea24e8224b84",
|
|
238
309
|
"type": "function",
|
|
239
|
-
"z": "
|
|
240
|
-
"name": "
|
|
241
|
-
"func": "const
|
|
242
|
-
"outputs":
|
|
310
|
+
"z": "ec796389903c1d0f",
|
|
311
|
+
"name": "defaultConfig",
|
|
312
|
+
"func": "const defaultConfig = env.get('defaultConfig') ?? {};\n\nmsg.payload = defaultConfig;\nreturn msg;\n",
|
|
313
|
+
"outputs": 1,
|
|
243
314
|
"timeout": 0,
|
|
244
315
|
"noerr": 0,
|
|
245
316
|
"initialize": "",
|
|
246
317
|
"finalize": "",
|
|
247
318
|
"libs": [],
|
|
248
|
-
"x":
|
|
249
|
-
"y":
|
|
319
|
+
"x": 570,
|
|
320
|
+
"y": 380,
|
|
250
321
|
"wires": [
|
|
251
|
-
[
|
|
252
|
-
"e2a872db2d9086e6"
|
|
253
|
-
],
|
|
254
322
|
[]
|
|
255
323
|
]
|
|
256
324
|
}
|
|
257
|
-
|
|
325
|
+
]
|
|
258
326
|
}
|