rb-homer 1.6.8 → 1.6.12
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 +4 -2
- package/src/synchronize.js +37 -0
- package/src/synchronizeREX2.js +148 -0
- package/templates/rex2/config.js +4 -0
- package/templates/snippets/html.json +14 -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\/|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
|
@@ -315,7 +315,7 @@ interface vm {
|
|
|
315
315
|
interface rbPromise {
|
|
316
316
|
then(callback:(data) => void):this;
|
|
317
317
|
catch(callback:(e) => void):this;
|
|
318
|
-
finally(callback?: () => void | undefined | null):this;
|
|
318
|
+
finally(callback?: (() => void) | undefined | null):this;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
interface config{
|
|
@@ -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;
|
package/src/synchronize.js
CHANGED
|
@@ -105,6 +105,29 @@ function findResourcesInComponent(controllerContent, configContent, allHTMLConte
|
|
|
105
105
|
return resourcesUsed;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
function checkForRbClass(controllerContent){
|
|
109
|
+
var rbClassComponents = [];
|
|
110
|
+
var match = null;
|
|
111
|
+
|
|
112
|
+
//Find rbClass components
|
|
113
|
+
|
|
114
|
+
var re = /\/[a-zA-Z]+RbClassController/ig;
|
|
115
|
+
|
|
116
|
+
while ((match = re.exec(controllerContent)) !== null) {
|
|
117
|
+
|
|
118
|
+
if (rbClassComponents.indexOf(match[0]) === -1 && match[0].indexOf("{") === -1) {
|
|
119
|
+
|
|
120
|
+
var matchitem = match[0].split("/")[1];
|
|
121
|
+
|
|
122
|
+
matchitem = matchitem.replace("Controller", "");
|
|
123
|
+
|
|
124
|
+
rbClassComponents.push(matchitem);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return rbClassComponents;
|
|
129
|
+
}
|
|
130
|
+
|
|
108
131
|
function findLookupComponents(content) {
|
|
109
132
|
var lookupComponents = [];
|
|
110
133
|
|
|
@@ -386,6 +409,20 @@ exports.sync = function (folderToZip, rbConfigMod) {
|
|
|
386
409
|
allTsContent += viewModels[i].contentTS;
|
|
387
410
|
}
|
|
388
411
|
}
|
|
412
|
+
|
|
413
|
+
var rbClasses = checkForRbClass(allTsContent);
|
|
414
|
+
if (rbClasses.length > 0) {
|
|
415
|
+
for (x = 0; x < rbClasses.length; x++) {
|
|
416
|
+
lookupComponents.push(rbClasses[x]);
|
|
417
|
+
}
|
|
418
|
+
if (lookupComponents.length > 0) {
|
|
419
|
+
configModule.lookupComponents = lookupComponents;
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
delete configModule.lookupComponents;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
389
426
|
var componentResources = findResourcesInComponent(allTsContent, configTSContent, allHTMLContent);
|
|
390
427
|
|
|
391
428
|
if (componentResources && componentResources.length > 0) {
|
|
@@ -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
|
+
}
|
|
@@ -313,5 +313,19 @@
|
|
|
313
313
|
"<rb-timeline datasource=\"${1:vm.datasource}\" id=\"${2:id}\" subject=\"${3:title}\" description=\"${4:description}\" icon=\"${5:icon}\" created=\"${6:createdDate}\" created-by=\"${7:createdBy}\" created-by-userid=\"${8:createdByUserId}\" inspect-doc=\"${9:docid}\"\n template=\"${10:inlineTemplate}\" icon-set=\"${11:vm.icons}\" delete=\"${12:vm.delete}\" load-more=\"${13:vm.loadMore}\" on-open=\"${14:vm.onOpen}\" save=\"${15:vm.save}\" close=\"${16:vm.close}\" on-done=\"${17:vm.onDone}\" done=\"${18:itemCompleted}\" new-item=\"${19:vm.newitem}\" subtitle=\"${20:description}\">\n\t<rb-timeline-add>\n\t\t$BLOCK_COMMENT_START template for adding a new timeline item $BLOCK_COMMENT_END\n\t\t<rb-input type=\"text\" ng-model=\"vm.newitem.title\"></rb-input>\n\t</rb-timeline-add> \n\n\t<rb-timeline-item>\n\t\t$BLOCK_COMMENT_START template for editing an existing item. use 'dataItem' in this block to access each item in the vm.datasource $BLOCK_COMMENT_END\n\t\t<rb-input type=\"text\" ng-model=\"dataItem.title\"></rb-input>\n\t</rb-timeline-item>\n</rb-timeline>"
|
|
314
314
|
],
|
|
315
315
|
"description": "Add a timeline to your component"
|
|
316
|
+
},
|
|
317
|
+
"rb_044":{
|
|
318
|
+
"prefix": "rb-input: multiselect(standard)",
|
|
319
|
+
"body": [
|
|
320
|
+
"<rb-input \n\t type=\"multiselect\" \n\t model=\"${1:vm.currency}\" \n\t label=\"{{'${2:Currency}' | translate}}\" \n\t rb-fieldname=\"${3:currency}\" \n\t k-data-source=\"${4:vm.currencies}\" \n\t value=\"${5:currency}\" \n\t text=\"${6:currencyDomainDescription}\" \n\t description=\"${7:vm.currencyDescr}\" \n\t k-on-change=\"${8:vm.currencySelected()}\" auto-close=\"${9:false}\" value-primitive=\"${10:true}\" k-on-deselect=\"${11:vm.currencyDeSelected()}\" placeholder=\"${12:vm.currencyPlaceholder}\">\n</rb-input>"
|
|
321
|
+
],
|
|
322
|
+
"description": "Mulstiselect using k-data-source."
|
|
323
|
+
},
|
|
324
|
+
"rb_045":{
|
|
325
|
+
"prefix": "rb-input: multiselect(apiresource)",
|
|
326
|
+
"body": [
|
|
327
|
+
"<rb-input \n\t type=\"multiselect\" \n\t model=\"${1:vm.currency}\" \n\t label=\"{{'${2:Currency}' | translate}}\" \n\t rb-fieldname=\"${3:currency}\" \n\t apiresource=\"${4:base/currencies/?$top=80}\" \n\t value=\"${5:currency}\" \n\t text=\"${6:currencyDomainDescription}\" \n\t description=\"${7:vm.currencyDescr}\" \n\t k-on-change=\"${8:vm.currencySelected()}\" auto-close=\"${9:false}\" value-primitive=\"${10:true}\" k-on-deselect=\"${11:vm.currencyDeSelected()}\" placeholder=\"${12:vm.currencyPlaceholder}\">\n</rb-input>"
|
|
328
|
+
],
|
|
329
|
+
"description": "Multiselect using apiresource."
|
|
316
330
|
}
|
|
317
331
|
}
|