Skip to content

Commit b21b4fe

Browse files
committed
Ready to release
1 parent bcb8fe6 commit b21b4fe

File tree

6 files changed

+268
-94
lines changed

6 files changed

+268
-94
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package-lock.json

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
This node is a wrapper around the [rsyncwrapper](https://www.npmjs.com/package/rsyncwrapper) module, which is a wrapper around rsync.
44

5-
It requires that rsync is already installed. If using the Docker image for Node-Red, you can create your own image with rsync
6-
installed using the following dockerfile:
7-
8-
**
5+
It requires that rsync is already installed. If using the Docker image for Node-Red, you can create your own image with rsync installed using the following dockerfile:
96

107
FROM nodered/node-red-docker
118

package.json

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-rsync",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Node Red wrapper for rsync",
55
"main": "rsync-wrapper.js",
66
"scripts": {
@@ -22,7 +22,8 @@
2222
"homepage": "https://github.com/michaelblight/node-red-contrib-rsync#readme",
2323
"dependencies": {
2424
"rsyncwrapper": "^3.0.0"
25-
}, "node-red" : {
25+
},
26+
"node-red": {
2627
"nodes": {
2728
"rsync": "rsync-wrapper.js"
2829
}

rsync-wrapper.html

100644100755
Lines changed: 129 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
11
<script type="text/javascript">
22
RED.nodes.registerType('rsync', {
33
category: 'advanced',
4-
color: '#a6bbcf',
4+
color: '#9999ff',
55
defaults: {
66
name: { value: ""},
7-
source: { value: "" },
8-
destination: { value: "" },
7+
source: { value: "", validate: RED.validators.typedInput("sourceType") },
8+
sourceType: { value: "str" },
9+
destination: { value: "", validate: RED.validators.typedInput("destinationType") },
10+
destinationType: { value: "str" },
11+
exclude: { value: "", validate: RED.validators.typedInput("excludeType") },
12+
excludeType: { value: "str" },
13+
include: { value: "", validate: RED.validators.typedInput("includeType") },
14+
includeType: { value: "str" },
15+
dryrun: { value: "" },
916
verbose: { value: "" },
1017
recursive: { value: "" },
18+
options: { value: ""},
19+
extra: { value: "", validate: RED.validators.typedInput("extraType") },
20+
extraType: { value: "str" },
1121
},
1222
inputs: 1,
1323
outputs: 2,
1424
icon: "file.png",
1525
label: function() {
1626
return this.name || "rsync";
17-
}
27+
},
28+
oneditprepare: function() {
29+
hookup("source", this.sourceType)
30+
hookup("destination", this.destinationType)
31+
hookup("exclude", this.excludeType)
32+
hookup("include", this.includeType)
33+
hookup("extra", this.extraType)
34+
},
1835
});
36+
37+
function hookup(name, field) {
38+
var f = "#node-input-"+name;
39+
var ft = f+"Type";
40+
$(ft).val(field);
41+
$(f).typedInput({
42+
default: 'str',
43+
typeField: $(ft),
44+
types: ['msg', 'flow', 'global', 'str', 'jsonata'],
45+
});
46+
}
1947
</script>
2048

2149
<script type="text/x-red" data-template-name="rsync">
@@ -25,64 +53,130 @@
2553
</div>
2654
<div class="form-row">
2755
<label for="node-input-source"><i class="fa fa-file-text-o"></i> Source</label>
28-
<input type="text" id="node-input-source" placeholder="Source">
56+
<input type="text" id="node-input-source" style="width:70%">
57+
<input type="hidden" id="node-input-sourceType">
2958
</div>
3059
<div class="form-row">
3160
<label for="node-input-destination"><i class="fa fa-file-text-o"></i> Destination</label>
32-
<input type="text" id="node-input-destination" placeholder="Destination">
61+
<input type="text" id="node-input-destination" style="width:70%">
62+
<input type="hidden" id="node-input-destinationType">
63+
</div>
64+
<div class="form-row">
65+
<label for="node-input-exclude"><i class="fa fa-file-text-o"></i> Exclude</label>
66+
<input type="text" id="node-input-exclude" style="width:70%">
67+
<input type="hidden" id="node-input-excludeType">
68+
</div>
69+
<div class="form-row">
70+
<label for="node-input-include"><i class="fa fa-file-text-o"></i> Include</label>
71+
<input type="text" id="node-input-include" style="width:70%">
72+
<input type="hidden" id="node-input-includeType">
73+
</div>
74+
<div class="form-row">
75+
<label for="node-input-dryrun"><i class="fa fa-bug"></i> Dry run</label>
76+
<input type="checkbox" id="node-input-dryrun" style="display: inline-block; width: auto; vertical-align: top;">
3377
</div>
3478
<div class="form-row">
3579
<label for="node-input-verbose"><i class="fa fa-bug"></i> Verbose</label>
3680
<input type="checkbox" id="node-input-verbose" style="display: inline-block; width: auto; vertical-align: top;">
3781
</div>
3882
<div class="form-row">
39-
<label for="node-input-recursive"><i class="fa fa-bug"></i> Recursive</label>
83+
<label for="node-input-recursive"><i class="fa fa-arrow-down"></i> Recursive</label>
4084
<input type="checkbox" id="node-input-recursive" style="display: inline-block; width: auto; vertical-align: top;">
4185
</div>
86+
<div class="form-row">
87+
<label for="node-input-extra"><i class="fa fa-wrench"></i> Extra options</label>
88+
<input type="text" id="node-input-extra" style="width:70%">
89+
<input type="hidden" id="node-input-extraType">
90+
</div>
4291
</script>
4392

4493
<script type="text/x-red" data-help-name="rsync">
4594
<p>Uses rsyncwrapper to call rsync.</p>
46-
<p>The node can be configured with the source and destination, as well as the options below.</p>
95+
<p>
96+
The node can be configured with the source and destination, as well as the options below.
97+
</p>
4798
<p>When configured through the dialog, the source can only be a single folder or filename. However, when configured
4899
through msg, the source can also be an array of folders or filenames.</p>
49100

50101
<h3>Inputs</h3>
51-
<p>The following can be overridden by including them in the input msg</p>
52102
<dl class="message-properties">
53-
<dt>source
54-
<span class="property-type">string or array</span>
55-
</dt>
56-
<dd>The folder or filename to copy from. Can also be an array of folders and filenames.</dd>
57-
<dt>destination
58-
<span class="property-type">string</span>
59-
</dt>
60-
<dd>The folder or filename to copy to.</dd>
61-
<dt>verbose
62-
<span class="property-type">boolean</span>
63-
</dt>
64-
<dd>Include verbose flag on rsync command.</dd>
65-
<dt>recursive
66-
<span class="property-type">boolean</span>
67-
</dt>
68-
<dd>Recursively copy child folders.</dd>
103+
<dt>Source
104+
<span class="property-type">string or array</span>
105+
</dt>
106+
<dd>
107+
The folder or filename to copy from. Can also be an array of folders and filenames.
108+
If one or more contain "./", then "--relative" will be automatically added to the rsync.
109+
</dd>
110+
<dt>
111+
Destination
112+
<span class="property-type">string</span>
113+
</dt>
114+
<dt>
115+
Exclude
116+
<span class="property-type">string or array</span>
117+
</dt>
118+
<dd>One or more patterns to exclude.</dd>
119+
<dt>
120+
Include
121+
<span class="property-type">string or array</span>
122+
</dt>
123+
<dd>
124+
One or more patterns to include, overriding exclude. If "*" is excluded and you want to
125+
recurse sub-folders, add "*/" to (re)include sub-folders, along with the specific files
126+
you want to include. For example, exclude "*" and include ["*/", "*.sh"] to rsync all shell
127+
scripts in all sub-folders.
128+
</dd>
129+
<dt>Dry run
130+
<span class="property-type">boolean</span>
131+
</dt>
132+
<dd>
133+
Dry-run to show the files that would be copied without actually copying. Can be overridden
134+
with `msg.dryrun`.
135+
</dd>
136+
<dt>verbose
137+
<span class="property-type">boolean</span>
138+
</dt>
139+
<dd>
140+
Include verbose flag on rsync command. Can be overridden with `msg.verbose`.
141+
</dd>
142+
<dt>Recursive
143+
<span class="property-type">boolean</span>
144+
</dt>
145+
<dd>Recursively copy child folders. Can be overridden with `msg.recursive`.</dd>
146+
<dt>Extra options
147+
<span class="property-type">string or array</span>
148+
</dt>
149+
<dd>Include extra options on the rsync command line.</dd>
69150
</dl>
70151
<h3>Outputs</h3>
71152
<dl class="message-properties">
72153
The resulting message will be sent to the first output if successfully, or the second output upon failure. The message will contain
73154
all of the input properties, as well as the following as appropriate:
74155

75156
<dt>error
76-
<span class="property-type">string</span>
77-
</dt>
157+
<span class="property-type">string</span>
158+
</dt>
78159
<dt>stdout
79-
<span class="property-type">string</span>
80-
</dt>
160+
<span class="property-type">string</span>
161+
</dt>
81162
<dt>stderr
82-
<span class="property-type">string</span>
83-
</dt>
84-
<dt>cmd
85-
<span class="property-type">string</span>
86-
<dd>The command line as sent to rsync.</dd>
87-
</dt>
163+
<span class="property-type">string</span>
164+
</dt>
165+
<dt>cmd
166+
<span class="property-type">string</span>
167+
<dd>The command line as sent to rsync.</dd>
168+
</dt>
169+
</dl>
170+
<h3>Details</h3>
171+
<dl class="message-properties">
172+
To configure the inputs as arrays, use the JSONata format. For example, to add the following extra arguments to rsync:
173+
174+
```
175+
[
176+
'--prune-empty-dirs',
177+
'--times'
178+
]
179+
```
180+
181+
</dl>
88182
</script>

0 commit comments

Comments
 (0)