@tbrandenburg/node-red-cli 0.2.9 β 0.2.11
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/README.md +25 -80
- package/package.json +1 -1
- package/src/docker-image.js +7 -0
package/README.md
CHANGED
|
@@ -19,13 +19,36 @@ node-red-cli flows.json calculate --set x=4 --set y=5 < /dev/null
|
|
|
19
19
|
This turns Node-RED from a visual automation tool into a reusable runtime
|
|
20
20
|
building block for scripts, services, pipelines, and developer tooling. π§©
|
|
21
21
|
|
|
22
|
+
## Install π¦
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @tbrandenburg/node-red-cli
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This installs the `node-red-cli` command globally, ready to use against any
|
|
29
|
+
Node-RED flow file (see [Usage](#usage-) below).
|
|
30
|
+
|
|
31
|
+
To build and run from a repo checkout instead (e.g. for contributing):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
make install
|
|
35
|
+
make test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`make install` also wires up a `pre-push` git hook that runs `make ci`
|
|
39
|
+
(format, lint, and tests) automatically before every push. To use
|
|
40
|
+
`node-red-cli` as a regular command from a repo checkout, install it
|
|
41
|
+
globally from the local source:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
make install-global
|
|
45
|
+
```
|
|
46
|
+
|
|
22
47
|
## Table of contents
|
|
23
48
|
|
|
24
49
|
- [The idea](#the-idea-)
|
|
25
50
|
- [Why node-red-cli?](#why-node-red-cli-)
|
|
26
|
-
- [Current state](#current-state-)
|
|
27
51
|
- [Project layout](#project-layout-)
|
|
28
|
-
- [Install](#install-)
|
|
29
52
|
- [Usage](#usage-)
|
|
30
53
|
- [Quick start](#quick-start)
|
|
31
54
|
- [Passing flow JSON inline](#passing-flow-json-inline)
|
|
@@ -34,8 +57,6 @@ building block for scripts, services, pipelines, and developer tooling. π§©
|
|
|
34
57
|
- [Host API](#host-api-)
|
|
35
58
|
- [Technical approach](#technical-approach-)
|
|
36
59
|
- [Preflight and limitations](#preflight-and-limitations-)
|
|
37
|
-
- [Roadmap](#roadmap-)
|
|
38
|
-
- [Status](#status-)
|
|
39
60
|
- [Contributing](#contributing-)
|
|
40
61
|
- [Security](#security-)
|
|
41
62
|
- [License](#license-)
|
|
@@ -77,25 +98,6 @@ no permanently deployed adapter structure. π«π§
|
|
|
77
98
|
- **Optional sandboxing:** `--docker` re-executes a call inside a disposable,
|
|
78
99
|
hardened container instead of the host process.
|
|
79
100
|
|
|
80
|
-
## Current state π§
|
|
81
|
-
|
|
82
|
-
This repository provides an early-stage CLI and host-side adapter for
|
|
83
|
-
Node-RED 5.0.4. The adapter invokes an existing `link in` node and captures
|
|
84
|
-
the response from a `link out` node in return mode as a Promise.
|
|
85
|
-
|
|
86
|
-
The included example flow (`test/fixtures/flows.json`) computes `x + y`:
|
|
87
|
-
|
|
88
|
-
```text
|
|
89
|
-
link in: calculate -> Function -> link out: return
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
The test suite (`test/e2e/flow.e2e.test.js`) verifies:
|
|
93
|
-
|
|
94
|
-
1. β
A successful call returning `{ payload: 9 }`.
|
|
95
|
-
2. β
Preflight validation rejecting an unknown target.
|
|
96
|
-
3. β
A timeout when a flow doesn't respond in time.
|
|
97
|
-
4. β
An unchanged SHA-256 hash of the flow file before and after the call.
|
|
98
|
-
|
|
99
101
|
## Project layout π
|
|
100
102
|
|
|
101
103
|
```text
|
|
@@ -107,31 +109,6 @@ test/e2e/ Full round trip through the example flow
|
|
|
107
109
|
test/fixtures/ Example Node-RED flow used as a test asset
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
## Install π¦
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
npm install -g @tbrandenburg/node-red-cli
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
This installs the `node-red-cli` command globally, ready to use against any
|
|
117
|
-
Node-RED flow file (see [Usage](#usage-) below).
|
|
118
|
-
|
|
119
|
-
To build and run from a repo checkout instead (e.g. for contributing):
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
make install
|
|
123
|
-
make test
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
`make install` also wires up a `pre-push` git hook that runs `make ci`
|
|
127
|
-
(format, lint, and tests) automatically before every push. To use
|
|
128
|
-
`node-red-cli` as a regular command from a repo checkout, install it
|
|
129
|
-
globally from the local source:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
make install-global
|
|
133
|
-
```
|
|
134
|
-
|
|
135
112
|
## Usage π
|
|
136
113
|
|
|
137
114
|
### Quick start
|
|
@@ -385,38 +362,6 @@ Before a call, `validateTarget(RED, targetId)` checks:
|
|
|
385
362
|
Validation does not prove that a flow terminates semantically or replies
|
|
386
363
|
exactly once. A runtime timeout remains necessary for that.
|
|
387
364
|
|
|
388
|
-
## Roadmap πΊοΈ
|
|
389
|
-
|
|
390
|
-
The long-term goal is a stable, official host API in Node-RED core:
|
|
391
|
-
|
|
392
|
-
```js
|
|
393
|
-
const result = await callNodeRedFlow({
|
|
394
|
-
target: "calculate",
|
|
395
|
-
msg,
|
|
396
|
-
timeout: 5000
|
|
397
|
-
});
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
Or as a runtime interface:
|
|
401
|
-
|
|
402
|
-
```js
|
|
403
|
-
const result = await RED.runtime.flows.call("calculate", msg, {
|
|
404
|
-
timeout: 5000
|
|
405
|
-
});
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
The research focuses on which parts of the existing `node.linkcall()`
|
|
409
|
-
implementation can be generalized, and what a small upstream API such as
|
|
410
|
-
`RED.nodes.callLink()` or `RED.runtime.flows.call()` could look like.
|
|
411
|
-
|
|
412
|
-
## Status π
|
|
413
|
-
|
|
414
|
-
**Early-stage CLI:** the approach works for the included Node-RED 5.0.4
|
|
415
|
-
example flow. The link-call internals used here are not stabilized as a
|
|
416
|
-
public Node-RED API. Production use therefore requires deliberate version
|
|
417
|
-
pinning, integration tests, and robust error handling for ambiguous or
|
|
418
|
-
non-terminating flows.
|
|
419
|
-
|
|
420
365
|
## Contributing π€
|
|
421
366
|
|
|
422
367
|
Contributions are welcome β see [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/package.json
CHANGED
package/src/docker-image.js
CHANGED
|
@@ -81,8 +81,15 @@ function derivedTag(image, version) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
function derivedDockerfile(image, version) {
|
|
84
|
+
// Switch to root before the global npm install: many community/base
|
|
85
|
+
// images set a non-root default USER (e.g. `node`), which lacks write
|
|
86
|
+
// access to the global npm prefix and would otherwise fail with EACCES.
|
|
87
|
+
// The derived image is left running as root - restoring the original
|
|
88
|
+
// image's default user would require inspecting the base image at build
|
|
89
|
+
// time, which is out of scope here.
|
|
84
90
|
return [
|
|
85
91
|
`FROM ${image}`,
|
|
92
|
+
"USER root",
|
|
86
93
|
`RUN npm install -g @tbrandenburg/node-red-cli@${version}`,
|
|
87
94
|
`ENTRYPOINT ["node", "${SANDBOX_ENTRY_PATH}"]`,
|
|
88
95
|
""
|