rb-homer 1.6.9 → 1.6.13
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/index.js +82 -1
- package/package.json +1 -1
- package/src/rb.d.ts +3 -1
- package/src/synchronizeREX2.js +148 -0
- package/templates/rex2/build.js +0 -0
- package/templates/rex2/config.js +4 -0
- package/templates/rex2/readme.md +20 -0
package/index.js
CHANGED
|
@@ -12,7 +12,8 @@ const componentTypes = [
|
|
|
12
12
|
"-function",
|
|
13
13
|
"-widget",
|
|
14
14
|
"-VUE",
|
|
15
|
-
"-rbclass"
|
|
15
|
+
"-rbclass",
|
|
16
|
+
"-rex2"
|
|
16
17
|
];
|
|
17
18
|
|
|
18
19
|
// Read command line arguments
|
|
@@ -165,6 +166,78 @@ else if (validCommand(commands.first, "listen", "l") || validCommand(commands.fi
|
|
|
165
166
|
}).on('error', function () { });
|
|
166
167
|
}
|
|
167
168
|
}
|
|
169
|
+
else if (validCommand(commands.first, "rex2", "rex2")) {
|
|
170
|
+
login.tryLogin(rbConfig).then(listenAndSync);
|
|
171
|
+
|
|
172
|
+
function listenAndSync(rbConfigMod) {
|
|
173
|
+
|
|
174
|
+
var chokidar = require('chokidar');
|
|
175
|
+
var folderToWatch;
|
|
176
|
+
if (!commands.second || commands.second === "this") {
|
|
177
|
+
folderToWatch = process.cwd();
|
|
178
|
+
}
|
|
179
|
+
else if (commands.second && pathModule.isAbsolute(commands.second)) {
|
|
180
|
+
folderToWatch = commands.second;
|
|
181
|
+
if (folderToWatch.endsWith("/")) {
|
|
182
|
+
folderToWatch = folderToWatch.slice(0, -1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw "Please provide a valid path";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.log('\x1b[5m%s\x1b[0m', 'Listening to: ' + folderToWatch);
|
|
190
|
+
var lastTriggered = 0;
|
|
191
|
+
var walk = require("./src/walk.js");
|
|
192
|
+
|
|
193
|
+
chokidar.watch(folderToWatch, { ignored: /(^|[\/\\])\..|node_modules|\/min\/|\/Translation\/|\/rex-project\/|tsconfig.json|\.git|\.css|\.min|\.pot|\.svn/, disableGlobbing: true }).on('change', (path) => {
|
|
194
|
+
|
|
195
|
+
if (path.indexOf(folderToWatch) !== -1) {
|
|
196
|
+
//Return if in progress
|
|
197
|
+
var newTriggered = new Date().getTime();
|
|
198
|
+
if (newTriggered - lastTriggered < 5000) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
lastTriggered = new Date().getTime();
|
|
203
|
+
|
|
204
|
+
if (new Date().getTime() - rbConfigMod.access_tokenUpdatedTimeStamp > 28000000) {
|
|
205
|
+
login.tryLogin(rbConfigMod).then(syncWithValidAccessToken);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
syncWithValidAccessToken(rbConfigMod);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function syncWithValidAccessToken(rbConfigMod) {
|
|
212
|
+
var folderToZip = walk.walkUp(pathModule.dirname(path), "config.js");
|
|
213
|
+
if (!folderToZip) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!folderToZip.endsWith("/")) {
|
|
218
|
+
folderToZip += "/";
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
var synchronizer = require("./src/synchronizeREX2.js");
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
synchronizer.sync(folderToZip, rbConfigMod);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
notifier.notify({
|
|
227
|
+
'wait': true,
|
|
228
|
+
'title': 'Error :(',
|
|
229
|
+
'message': error.message || error,
|
|
230
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
231
|
+
});
|
|
232
|
+
console.log("Error :( " + error.message || error);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
}).on('error', function () { });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
168
241
|
else if (validCommand(commands.first, "vue", "vue")) {
|
|
169
242
|
login.tryLogin(rbConfig).then(syncVue);
|
|
170
243
|
|
|
@@ -343,6 +416,14 @@ function createTemplate(appNo, componentName, createWithinFolder, componenttype)
|
|
|
343
416
|
createPath = "";
|
|
344
417
|
}
|
|
345
418
|
|
|
419
|
+
if (componenttype === "rex2") {
|
|
420
|
+
var configContent = fs.readFileSync(createPath + "config.js", 'utf8');
|
|
421
|
+
configContent = configContent.replace("111111111", appNo);
|
|
422
|
+
configContent = configContent.replace("222222222", componentName);
|
|
423
|
+
fs.writeFileSync(createPath + "config.js", configContent, 'utf8');
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
346
427
|
//Update config.ts to include appNo and appName
|
|
347
428
|
var configContent = fs.readFileSync(createPath + "config.ts", 'utf8');
|
|
348
429
|
configContent = configContent.replace("111111111", appNo);
|
package/package.json
CHANGED
package/src/rb.d.ts
CHANGED
|
@@ -343,7 +343,9 @@ interface configDatasources{
|
|
|
343
343
|
interface configDataSourceProperties {
|
|
344
344
|
url:string,
|
|
345
345
|
/** true | false | "get" */
|
|
346
|
-
autoBind?:boolean | string
|
|
346
|
+
autoBind?:boolean | string,
|
|
347
|
+
minimumGetVersion?:number,
|
|
348
|
+
minimumPutVersion?:number
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
declare var toastr:toastr;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var exports = module.exports = {};
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
const notifier = require('node-notifier');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function uploadToFileServer(fileStream, fullDocid, authKey, compName) {
|
|
8
|
+
var BasicHttpBinding = require('wcf.js').BasicHttpBinding
|
|
9
|
+
, Proxy = require('wcf.js').Proxy
|
|
10
|
+
, binding = new BasicHttpBinding()
|
|
11
|
+
, proxy = new Proxy(binding, "https://Apps.Rambase.Net/Service.svc")
|
|
12
|
+
, message = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' +
|
|
13
|
+
'<s:Body>' +
|
|
14
|
+
'<UploadFile xmlns="http://tempuri.org/">' +
|
|
15
|
+
'<authKey>' + authKey + '</authKey>' +
|
|
16
|
+
'<fileStream>' + fileStream + '</fileStream>' +
|
|
17
|
+
'<fileName>' + compName + '.zip</fileName>' +
|
|
18
|
+
'<fullDocid>' + fullDocid + '</fullDocid>' +
|
|
19
|
+
'</UploadFile>' +
|
|
20
|
+
'</s:Body>' +
|
|
21
|
+
'</s:Envelope>'
|
|
22
|
+
|
|
23
|
+
proxy.send(message, "http://tempuri.org/IService1/UploadFile", function (response, ctx) {
|
|
24
|
+
|
|
25
|
+
var exceptionMessage;
|
|
26
|
+
var parseString = require('xml2js').parseString;
|
|
27
|
+
parseString(response, function (err, result) {
|
|
28
|
+
try {
|
|
29
|
+
exceptionMessage = result["s:Envelope"]["s:Body"][0]["UploadFileResponse"][0]["UploadFileResult"][0]["a:ExceptionMessage"][0];
|
|
30
|
+
} catch (error) {
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (exceptionMessage && exceptionMessage.indexOf("Url invalid") > -1) {
|
|
35
|
+
notifier.notify({
|
|
36
|
+
'wait': true,
|
|
37
|
+
'title': 'Error synching. ' + exceptionMessage,
|
|
38
|
+
'message': 'Make sure there exist a version 1 for your PID of: ' + fullDocid,
|
|
39
|
+
'sound': true,
|
|
40
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
41
|
+
});
|
|
42
|
+
console.log("Error syncing. Make sure there exist a version 1 for your PID of: " + fullDocid + " " + compName + ". " + exceptionMessage + " " + (new Date().toString()).split("GMT")[0]);
|
|
43
|
+
}
|
|
44
|
+
else if (exceptionMessage) {
|
|
45
|
+
notifier.notify({
|
|
46
|
+
'wait': true,
|
|
47
|
+
'title': 'Error synching. ' + exceptionMessage,
|
|
48
|
+
'message': fullDocid,
|
|
49
|
+
'sound': true,
|
|
50
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
51
|
+
});
|
|
52
|
+
console.log("Error syncing " + fullDocid + " " + compName + ". " + exceptionMessage + " " + (new Date().toString()).split("GMT")[0]);
|
|
53
|
+
}
|
|
54
|
+
else if (!response) {
|
|
55
|
+
notifier.notify({
|
|
56
|
+
'wait': true,
|
|
57
|
+
'title': 'Error synching',
|
|
58
|
+
'message': 'An error occured when uploading component: ' + fullDocid,
|
|
59
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
60
|
+
});
|
|
61
|
+
console.log("Error syncing " + fullDocid + " " + compName + " " + (new Date().toString()).split("GMT")[0]);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
notifier.notify({
|
|
65
|
+
'wait': true,
|
|
66
|
+
'title': 'Synced ok',
|
|
67
|
+
'message': 'Successfully synchronized component: ' + fullDocid + ' ' + compName,
|
|
68
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
69
|
+
});
|
|
70
|
+
console.log(compName + " synced ok " + (new Date().toString()).split("GMT")[0]);
|
|
71
|
+
if (global.sendUTF) { //notify rb client
|
|
72
|
+
global.sendUTF();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.sync = function (folderToZip, rbConfigMod) {
|
|
80
|
+
// Check for config file existence
|
|
81
|
+
if (!fs.existsSync(folderToZip + 'config.js')) {
|
|
82
|
+
throw "Missing config.js file";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//Check for mandatory properties in config file
|
|
86
|
+
|
|
87
|
+
var configJSFile = fs.readFileSync(folderToZip + 'config.js', 'utf8');
|
|
88
|
+
var configModule = eval(configJSFile);
|
|
89
|
+
|
|
90
|
+
if (!configModule.appName || !configModule.appNo) {
|
|
91
|
+
var pathModule = require('path');
|
|
92
|
+
var basePath = pathModule.basename(folderToZip);
|
|
93
|
+
var appNoFromBasePath = basePath.substring(0, 6);
|
|
94
|
+
var componentNameFromBasePath = basePath.substring(basePath.lastIndexOf(".") + 1, basePath.lastIndexOf("("));
|
|
95
|
+
componentNameFromBasePath = componentNameFromBasePath.trim();
|
|
96
|
+
|
|
97
|
+
if (isNaN(appNoFromBasePath) || basePath.indexOf("-") === -1 || basePath.indexOf(".") < 0 || componentNameFromBasePath.length < 3) {
|
|
98
|
+
throw ("Not able to get appNo and appName from the config file or from the current folder.");
|
|
99
|
+
}
|
|
100
|
+
configModule.appName = componentNameFromBasePath;
|
|
101
|
+
configModule.appNo = appNoFromBasePath;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
configModule.appNo = parseInt(configModule.appNo, 10);
|
|
105
|
+
|
|
106
|
+
if (isNaN(configModule.appNo)) {
|
|
107
|
+
throw "appNo must be of type number";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//Zip folder
|
|
111
|
+
var zipdir = require('zip-dir');
|
|
112
|
+
|
|
113
|
+
zipdir(folderToZip, {
|
|
114
|
+
filter: (path, stat) => !/\.zip|\.git|\.svn|\.vs|tsconfig.json|rex-project|\.vscode|node_modules/.test(path) //exclude this values in filepath
|
|
115
|
+
//each: path => console.log(path, "added!")
|
|
116
|
+
//saveTo: 'tempComponent.zip'
|
|
117
|
+
},
|
|
118
|
+
function (err, buffer) {
|
|
119
|
+
if (err) {
|
|
120
|
+
notifier.notify({
|
|
121
|
+
'wait': true,
|
|
122
|
+
'title': 'Zip error',
|
|
123
|
+
'message': 'Unable to zip folder. ' + err,
|
|
124
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
125
|
+
});
|
|
126
|
+
console.log('Unable to zip folder. ' + err);
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
else if (buffer) {
|
|
130
|
+
try {
|
|
131
|
+
// 6 Upload file
|
|
132
|
+
var pid = rbConfigMod.pid;
|
|
133
|
+
var fullDocid = "APP/" + configModule.appNo + ".1." + pid;
|
|
134
|
+
uploadToFileServer(buffer.toString('base64'), fullDocid, rbConfigMod.access_token, configModule.appName);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
notifier.notify({
|
|
137
|
+
'wait': true,
|
|
138
|
+
'title': 'Error synching',
|
|
139
|
+
'message': 'Are you on an unsecure network? ' + error,
|
|
140
|
+
'appName': "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe"
|
|
141
|
+
});
|
|
142
|
+
console.log('Error synching. Are you on an unsecure network? ' + error)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
**Listen and sync file changes**
|
|
2
|
+
|
|
3
|
+
rb rex2
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
**rex-project folder**
|
|
7
|
+
|
|
8
|
+
Here you can npm install the frontend framework and node_modules you want to use.
|
|
9
|
+
Files inside this folder will not be synced to RamBase.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**build.js**
|
|
13
|
+
|
|
14
|
+
This is the build file which will be synced to RamBase. The build file has to be a web component.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
**gitignore**
|
|
18
|
+
|
|
19
|
+
The node_modules folder will not be part of the commit.
|
|
20
|
+
|