How to use readFileAsync method in argos

Best JavaScript code snippet using argos

server.js

Source:server.js Github

copy

Full Screen

...63 var viewWidgets = ["VIEW", "GRAPHICS-WINDOW"];64 var widget = "";65 var zip;66 var gbccTeacherArray;67 fs.readFileAsync(nlogoFilename1, "utf8").then(function(data) {68 zip = new JSZip();69 zip.file(title, data);70 if (activityType === "legacyHubnet") {71 var sanitizedFileContents = data.toString();//removeUnimplementedPrimCalls(data.toString());72 array = sanitizedFileContents.split("\n");73 nlogoFile = "";74 arrayIndex = 0;75 var newWidget = false;76 var lastWidgetType = "";77 var label;78 var widgetList = [];79 for(i in array) {80 // buttons on the client need a client-procedure, to avoid a console error81 if (arrayIndex === 0 && array[i] === "@#$#@#$#@") { nlogoFile = nlogoFile + "\n\nto client-procedure\nend\n"; }82 nlogoFile += array[i] + "\n";83 if (arrayIndex === 1) { if (widgets.indexOf(array[i]) > -1) { numTeacherWidgets++; } }84 if (arrayIndex === 8) {85 if ((widgets.indexOf(array[i]) > -1) || (array[i]==="@#$#@#$#@")) {86 if ((array[i] != "VIEW") && (array[i]!="@#$#@#$#@")) { numStudentWidgets++; }87 switch (lastWidgetType) {88 case "BUTTON":89 widget = widget.substr(0,widget.lastIndexOf("NIL"))+"NIL\nNIL\nNIL\n"+widget.lastIndexOf("NIL")+"\n\n";90 widget = widget.replace("NIL","client-procedure");91 if (widget.split("NIL").length === 5) { widget = widget.replace("NIL\nNIL","NIL\nNIL\nNIL"); }92 break;93 case "MONITOR":94 widget = widget.substr(0,widget.indexOf("NIL"))+'""'+"\n0\n1\n11\n";95 //widget = widget.replace("NIL",label+"\n0");96 break;97 case "CHOOSER":98 var widgetLines = widget.split("\n");99 widgetLines[7] = widgetLines[7].replace(/\\"/g, "\"");100 widget = widgetLines.join("\n");101 break;102 case "VIEW":103 var widgetParts = widget.split("\n");104 secondView.push(parseInt(widgetParts[1]));105 secondView.push(parseInt(widgetParts[2]));106 secondView.push(parseInt(widgetParts[3]));107 secondView.push(parseInt(widgetParts[4]));108 widget = "";109 break;110 }111 if ((widget != "") && (viewWidgets.indexOf(lastWidgetType) === -1)) {112 widgetList.push(widget);113 widget = "";114 }115 lastWidgetType = array[i];116 label = array[(parseInt(i) + 5).toString()];117 }118 widget += array[i] + "\n"; 119 }120 if (array[i] === "@#$#@#$#@") { arrayIndex++; }121 }122 teacherWidgetRange = [0, numTeacherWidgets - 1];123 studentWidgetRange = (numStudentWidgets === 0) ? teacherWidgetRange : [numTeacherWidgets, numTeacherWidgets + numStudentWidgets - 1];124 loginWidgetRange = [(numTeacherWidgets + numStudentWidgets), (numTeacherWidgets + numStudentWidgets)];125 var oldNlogoFile = nlogoFile;126 array = oldNlogoFile.toString().split("\n");127 nlogoFile = "";128 arrayIndex = 0;129 for (i in array) {130 if (array[i] === "@#$#@#$#@") {131 arrayIndex++;132 if (arrayIndex === 2) {133 for (var j=0; j<widgetList.length; j++) {134 nlogoFile += widgetList[j] + "\n";135 }136 }137 }138 nlogoFile += array[i] + "\n";139 }140 } else {141 //console.log("uploading first file");142 array = data.toString().split("\n");143 gbccTeacherArray = array;144 arrayIndex = 0;145 for(i in array) {146 if (arrayIndex === 1) { if (widgets.indexOf(array[i]) > -1) { numTeacherWidgets++; } }147 if (array[i] === "@#$#@#$#@") { arrayIndex++; }148 }149 teacherWidgetRange = [0, numTeacherWidgets - 1];150 studentWidgetRange = teacherWidgetRange;151 loginWidgetRange = [numTeacherWidgets, numTeacherWidgets];152 nlogoFile = "";153 arrayIndex = 0;154 for (i in array) {155 if (array[i] === "@#$#@#$#@") {156 arrayIndex++;157 }158 nlogoFile += array[i] + "\n";159 }160 }161 }).then(function() {162 if (nlogoFilename2 === undefined) { nlogoFilename2 = nlogoFilename1; }; //secondView = 'false'; }163 fs.readFileAsync(nlogoFilename2, "utf8").then(function(data) {164 if (activityType === "gbccHierarchical") {165 zip.file(title+"-student", data);166 array = data.toString().split("\n");167 arrayIndex = 0;168 nlogoCode = "";169 widgetCode = "";170 var graphicsWindowPosition = 0;171 for(i in array) {172 if ((arrayIndex === 0) && (array[i] != "@#$#@#$#@")) {173 nlogoCode += array[i] + "\n"; 174 }175 if (arrayIndex === 1) { 176 if (widgets.indexOf(array[i]) > -1) { numStudentWidgets++; } 177 if (graphicsWindowPosition > 0 && graphicsWindowPosition < 6) {178 if (graphicsWindowPosition > 1) { secondView+= ", "; }179 secondView+= array[i];180 graphicsWindowPosition++;181 }182 if (graphicsWindowPosition === 5) {183 secondView+= "";184 graphicsWindowPosition = 6;185 } 186 if (graphicsWindowPosition === 6 && array[i].length === 0) {187 graphicsWindowPosition = 0;188 } 189 if (array[i] === "GRAPHICS-WINDOW") {190 graphicsWindowPosition = 1;191 secondView ="";192 }193 if ((array[i] != "@#$#@#$#@") && (graphicsWindowPosition === 0)) {194 widgetCode += array[i] + "\n";195 }196 }197 if (array[i] === "@#$#@#$#@") { arrayIndex++; }198 }199 studentWidgetRange = (numStudentWidgets === 0) ? teacherWidgetRange : [numTeacherWidgets, numTeacherWidgets + numStudentWidgets - 1];200 loginWidgetRange = [(numTeacherWidgets + numStudentWidgets), (numTeacherWidgets + numStudentWidgets)];201 nlogoFile = "";202 array = gbccTeacherArray;203 arrayIndex = 0;204 for (i in array) {205 if (array[i] === "@#$#@#$#@") {206 arrayIndex++;207 if (arrayIndex === 1) { //console.log(nlogoFile); 208 nlogoFile += nlogoCode; }209 if (arrayIndex === 2) { //console.log(nlogoFile);210 nlogoFile += widgetCode; }211 }212 nlogoFile += array[i] + "\n";213 }214 }215 }).then(function() {216 fs.readFileAsync("gbcc/config.json", "utf8").then(function(data) {217 var array = data.toString().split("\n");218 var configData = data;219 configFile = "";220 for(var i in array) {221 configFile += array[i] + "\n";222 if (array[i].includes("loginComponents")) { configFile += ' "componentRange": [' +loginWidgetRange + "]\n" }223 if (array[i].includes("teacherComponents")) { configFile += ' "componentRange": [' +teacherWidgetRange + "]\n" }224 if (array[i].includes("studentComponents")) { configFile += ' "componentRange": [' +studentWidgetRange + "]\n" }225 if (array[i].includes("galleryJs")) {226 configFile += (fields["allowTabs"]) ? ' "allowTabs": true, \n' : ' "allowTabs": false, \n';227 configFile += (fields["allowMultipleLayers"]) ? ' "allowMultipleLayers": true, \n' : ' "allowMultipleLayers": false, \n';228 configFile += (fields["allowMultipleSelections"]) ? ' "allowMultipleSelections": true, \n' : ' "allowMultipleSelections": false, \n';229 configFile += (fields["allowCanvasForeverButtons"]) ? ' "allowCanvasForeverButtons": true, \n' : ' "allowCanvasForeverButtons": false, \n';230 configFile += (fields["allowGalleryControls"]) ? ' "allowGalleryControls": true, \n' : ' "allowGalleryControls": false, \n';231 configFile += (fields["allowTeacherControls"]) ? ' "allowTeacherControls": true, \n' : ' "allowTeacherControls": false, \n';232 configFile += (fields["allowMirrorControl"]) ? ' "allowMirrorControl": true, \n' : ' "allowMirrorControl": false, \n';233 configFile += (fields["legacyHubnet"]) ? ' "legacyHubnet": true, \n' : ' "legacyHubnet": false, \n';234 configFile += ' "secondView": [' +secondView + ']\n';235 } 236 }237 }).then(function() {238 fs.readFileAsync("gbcc/index1.html", "utf8").then(function(data) {239 indexFile = "";240 var array = data.toString().split("\n");241 for (i in array) { indexFile += array[i] + "\n"; }242 //indexFile += "\ndocument.title = '"+title+"';\n</script>";243 indexFile += "\n<script type='text/nlogo' id='nlogo-code' data-filename='"+title+"'>";244 indexFile += nlogoFile;245 }).then(function() {246 fs.readFileAsync("gbcc/index3.html", "utf8").then(function(data) {247 var array = data.toString().split("\n");248 for (i in array) { indexFile += array[i] + "\n"; }249 }).then(function() {250 //console.log(configFile);251 zip.file("config.json", configFile);252 zip.file("index.html", indexFile);253 254 fs.readFileAsync("gbcc/app/gbcc/exportworld.js", "utf8").then(function(data) {255 zip.file("app/gbcc/exportworld.js", data);256 }).then(function() {257 fs.readFileAsync("gbcc/app/gbcc/font-awesome.min.css", "utf8").then(function(data) {258 zip.file("app/gbcc/font-awesome.min.css", data);259 }).then(function() {260 fs.readFileAsync("gbcc/app/gbcc/fontawesome-webfont.eot").then(function(data) {261 zip.file("app/gbcc/fontawesome-webfont.eot", data);262 }).then(function() {263 fs.readFileAsync("gbcc/app/gbcc/fontawesome-webfont.svg").then(function(data) {264 zip.file("app/gbcc/fontawesome-webfont.svg", data);265 }).then(function() {266 fs.readFileAsync("gbcc/app/gbcc/fontawesome-webfont.ttf").then(function(data) {267 zip.file("app/gbcc/fontawesome-webfont.ttf", data);268 }).then(function() {269 fs.readFileAsync("gbcc/app/gbcc/fontawesome-webfont.woff").then(function(data) {270 zip.file("app/gbcc/fontawesome-webfont.woff", data);271 }).then(function() {272 fs.readFileAsync("gbcc/app/gbcc/fontawesome-webfont.woff2").then(function(data) {273 zip.file("app/gbcc/fontawesome-webfont.woff2", data);274 }).then(function() {275 fs.readFileAsync("gbcc/app/gbcc/gbcc-client.js", "utf8").then(function(data) {276 zip.file("app/gbcc/gbcc-client.js", data);277 }).then(function() {278 fs.readFileAsync("gbcc/app/gbcc/gbcc-events.js", "utf8").then(function(data) {279 zip.file("app/gbcc/gbcc-events.js", data);280 }).then(function() {281 fs.readFileAsync("gbcc/app/gbcc/gbcc-export.js", "utf8").then(function(data) {282 zip.file("app/gbcc/gbcc-export.js", data);283 }).then(function() {284 fs.readFileAsync("gbcc/app/gbcc/gbcc-files.js", "utf8").then(function(data) {285 zip.file("app/gbcc/gbcc-files.js", data);286 }).then(function() {287 fs.readFileAsync("gbcc/app/gbcc/gbcc-gallery.js", "utf8").then(function(data) {288 zip.file("app/gbcc/gbcc-gallery.js", data);289 }).then(function() {290 fs.readFileAsync("gbcc/app/gbcc/gbcc-gallery.css", "utf8").then(function(data) {291 zip.file("app/gbcc/gbcc-gallery.css", data);292 }).then(function() {293 fs.readFileAsync("gbcc/app/gbcc/gbcc-interface.js", "utf8").then(function(data) {294 zip.file("app/gbcc/gbcc-interface.js", data);295 }).then(function() {296 fs.readFileAsync("gbcc/app/gbcc/graph.js", "utf8").then(function(data) {297 zip.file("app/gbcc/graph.js", data);298 }).then(function() {299 fs.readFileAsync("gbcc/app/gbcc/html2canvas.min.js", "utf8").then(function(data) {300 zip.file("app/gbcc/html2canvas.min.js", data);301 }).then(function() {302 fs.readFileAsync("gbcc/app/gbcc/gbcc-image.js", "utf8").then(function(data) {303 zip.file("app/gbcc/gbcc-image.js", data);304 }).then(function() {305 fs.readFileAsync("gbcc/app/gbcc/jquery.min.js", "utf8").then(function(data) {306 zip.file("app/gbcc/jquery.min.js", data);307 }).then(function() {308 fs.readFileAsync("gbcc/app/gbcc/maps.js", "utf8").then(function(data) {309 zip.file("app/gbcc/maps.js", data);310 }).then(function() {311 fs.readFileAsync("gbcc/app/gbcc/physics-api.js", "utf8").then(function(data) {312 zip.file("app/gbcc/physics-api.js", data);313 }).then(function() {314 fs.readFileAsync("gbcc/app/gbcc/physics-box2d.js", "utf8").then(function(data) {315 zip.file("app/gbcc/physics-box2d.js", data);316 }).then(function() {317 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a1.png").then(function(data) {318 zip.file("app/gbcc/physics-ui/a1.png", data);319 }).then(function() {320 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a2.png").then(function(data) {321 zip.file("app/gbcc/physics-ui/a2.png", data);322 }).then(function() {323 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a3.png").then(function(data) {324 zip.file("app/gbcc/physics-ui/a3.png", data);325 }).then(function() {326 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a4.png").then(function(data) {327 zip.file("app/gbcc/physics-ui/a4.png", data);328 }).then(function() {329 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a5.png").then(function(data) {330 zip.file("app/gbcc/physics-ui/a5.png", data);331 }).then(function() {332 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a6.png").then(function(data) {333 zip.file("app/gbcc/physics-ui/a6.png", data);334 }).then(function() {335 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a7.png").then(function(data) {336 zip.file("app/gbcc/physics-ui/a7.png", data);337 }).then(function() {338 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a8.png").then(function(data) {339 zip.file("app/gbcc/physics-ui/a8.png", data);340 }).then(function() {341 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a22.png").then(function(data) {342 zip.file("app/gbcc/physics-ui/a22.png", data);343 }).then(function() {344 fs.readFileAsync("gbcc/app/gbcc/physics-ui/a23.png").then(function(data) {345 zip.file("app/gbcc/physics-ui/a23.png", data);346 }).then(function() {347 fs.readFileAsync("gbcc/app/gbcc/physics.js", "utf8").then(function(data) {348 zip.file("app/gbcc/physics.js", data);349 }).then(function() {350 fs.readFileAsync("gbcc/app/gbcc/style.css", "utf8").then(function(data) {351 zip.file("app/gbcc/style.css", data);352 }).then(function() {353 fs.readFileAsync("gbcc/app/netlogoweb/alert.css", "utf8").then(function(data) {354 zip.file("app/netlogoweb/alert.css", data);355 }).then(function() {356 fs.readFileAsync("gbcc/app/netlogoweb/babybehaviorspace.js", "utf8").then(function(data) {357 zip.file("app/netlogoweb/babybehaviorspace.js", data);358 }).then(function() {359 fs.readFileAsync("gbcc/app/netlogoweb/button.js", "utf8").then(function(data) {360 zip.file("app/netlogoweb/button.js", data);361 }).then(function() {362 fs.readFileAsync("gbcc/app/netlogoweb/checkbox.js", "utf8").then(function(data) {363 zip.file("app/netlogoweb/checkbox.js", data);364 }).then(function() {365 fs.readFileAsync("gbcc/app/netlogoweb/chooser.js", "utf8").then(function(data) {366 zip.file("app/netlogoweb/chooser.js", data);367 }).then(function() {368 fs.readFileAsync("gbcc/app/netlogoweb/chosen.css", "utf8").then(function(data) {369 zip.file("app/netlogoweb/chosen.css", data);370 }).then(function() {371 fs.readFileAsync("gbcc/app/netlogoweb/chosen.jquery.js", "utf8").then(function(data) {372 zip.file("app/netlogoweb/chosen.jquery.js", data);373 }).then(function() {374 fs.readFileAsync("gbcc/app/netlogoweb/classes.css", "utf8").then(function(data) {375 zip.file("app/netlogoweb/classes.css", data);376 }).then(function() {377 fs.readFileAsync("gbcc/app/netlogoweb/code-container.js", "utf8").then(function(data) {378 zip.file("app/netlogoweb/code-container.js", data);379 }).then(function() {380 fs.readFileAsync("gbcc/app/netlogoweb/code-editor.js", "utf8").then(function(data) {381 zip.file("app/netlogoweb/code-editor.js", data);382 }).then(function() {383 fs.readFileAsync("gbcc/app/netlogoweb/codemirror-mode.js", "utf8").then(function(data) {384 zip.file("app/netlogoweb/codemirror-mode.js", data);385 }).then(function() {386 fs.readFileAsync("gbcc/app/netlogoweb/codemirror.css", "utf8").then(function(data) {387 zip.file("app/netlogoweb/codemirror.css", data);388 }).then(function() {389 fs.readFileAsync("gbcc/app/netlogoweb/codemirror.js", "utf8").then(function(data) {390 zip.file("app/netlogoweb/codemirror.js", data);391 }).then(function() {392 fs.readFileAsync("gbcc/app/netlogoweb/color-input.js", "utf8").then(function(data) {393 zip.file("app/netlogoweb/color-input.js", data);394 }).then(function() {395 fs.readFileAsync("gbcc/app/netlogoweb/colors.js", "utf8").then(function(data) {396 zip.file("app/netlogoweb/colors.js", data);397 }).then(function() {398 fs.readFileAsync("gbcc/app/netlogoweb/config-shims.js", "utf8").then(function(data) {399 zip.file("app/netlogoweb/config-shims.js", data);400 }).then(function() {401 fs.readFileAsync("gbcc/app/netlogoweb/console.js", "utf8").then(function(data) {402 zip.file("app/netlogoweb/console.js", data);403 }).then(function() {404 fs.readFileAsync("gbcc/app/netlogoweb/context-menu.js", "utf8").then(function(data) {405 zip.file("app/netlogoweb/context-menu.js", data);406 }).then(function() {407 fs.readFileAsync("gbcc/app/netlogoweb/default-shapes.js", "utf8").then(function(data) {408 zip.file("app/netlogoweb/default-shapes.js", data);409 }).then(function() {410 fs.readFileAsync("gbcc/app/netlogoweb/dialog.css", "utf8").then(function(data) {411 zip.file("app/netlogoweb/dialog.css", data);412 }).then(function() {413 fs.readFileAsync("gbcc/app/netlogoweb/dialog.js", "utf8").then(function(data) {414 zip.file("app/netlogoweb/dialog.js", data);415 }).then(function() {416 fs.readFileAsync("gbcc/app/netlogoweb/draggable.js", "utf8").then(function(data) {417 zip.file("app/netlogoweb/draggable.js", data);418 }).then(function() {419 fs.readFileAsync("gbcc/app/netlogoweb/draw-shape.js", "utf8").then(function(data) {420 zip.file("app/netlogoweb/draw-shape.js", data);421 }).then(function() {422 fs.readFileAsync("gbcc/app/netlogoweb/dropdown.js", "utf8").then(function(data) {423 zip.file("app/netlogoweb/dropdown.js", data);424 }).then(function() {425 fs.readFileAsync("gbcc/app/netlogoweb/edit-form.js", "utf8").then(function(data) {426 zip.file("app/netlogoweb/edit-form.js", data);427 }).then(function() {428 fs.readFileAsync("gbcc/app/netlogoweb/element-overrides.css", "utf8").then(function(data) {429 zip.file("app/netlogoweb/element-overrides.css", data);430 }).then(function() {431 fs.readFileAsync("gbcc/app/netlogoweb/event-traffic-control.js", "utf8").then(function(data) {432 zip.file("app/netlogoweb/event-traffic-control.js", data);433 }).then(function() {434 fs.readFileAsync("gbcc/app/netlogoweb/export-data.js", "utf8").then(function(data) {435 zip.file("app/netlogoweb/export-data.js", data);436 }).then(function() {437 fs.readFileAsync("gbcc/app/netlogoweb/exporting.js", "utf8").then(function(data) {438 zip.file("app/netlogoweb/exporting.js", data);439 }).then(function() {440 fs.readFileAsync("gbcc/app/netlogoweb/FileSaver.js", "utf8").then(function(data) {441 zip.file("app/netlogoweb/FileSaver.js", data);442 }).then(function() {443 fs.readFileAsync("gbcc/app/netlogoweb/font-size.js", "utf8").then(function(data) {444 zip.file("app/netlogoweb/font-size.js", data);445 }).then(function() {446 fs.readFileAsync("gbcc/app/netlogoweb/global-noisy-things.js", "utf8").then(function(data) {447 zip.file("app/netlogoweb/global-noisy-things.js", data);448 }).then(function() {449 fs.readFileAsync("gbcc/app/netlogoweb/handle-context-menu.js", "utf8").then(function(data) {450 zip.file("app/netlogoweb/handle-context-menu.js", data);451 }).then(function() {452 fs.readFileAsync("gbcc/app/netlogoweb/handle-widget-selection.js", "utf8").then(function(data) {453 zip.file("app/netlogoweb/handle-widget-selection.js", data);454 }).then(function() {455 fs.readFileAsync("gbcc/app/netlogoweb/help-dialog.js", "utf8").then(function(data) {456 zip.file("app/netlogoweb/help-dialog.js", data);457 }).then(function() {458 fs.readFileAsync("gbcc/app/netlogoweb/highcharts.js", "utf8").then(function(data) {459 zip.file("app/netlogoweb/highcharts.js", data);460 }).then(function() {461 fs.readFileAsync("gbcc/app/netlogoweb/highcharts(1).js", "utf8").then(function(data) {462 zip.file("app/netlogoweb/highcharts(1).js", data);463 }).then(function() {464 fs.readFileAsync("gbcc/app/netlogoweb/html-sanitizer-minified.js", "utf8").then(function(data) {465 zip.file("app/netlogoweb/html-sanitizer-minified.js", data);466 }).then(function() {467 fs.readFileAsync("gbcc/app/netlogoweb/info.js", "utf8").then(function(data) {468 zip.file("app/netlogoweb/info.js", data);469 }).then(function() {470 fs.readFileAsync("gbcc/app/netlogoweb/initialize-ui.js", "utf8").then(function(data) {471 zip.file("app/netlogoweb/initialize-ui.js", data);472 }).then(function() {473 fs.readFileAsync("gbcc/app/netlogoweb/input.js", "utf8").then(function(data) {474 zip.file("app/netlogoweb/input.js", data);475 }).then(function() {476 fs.readFileAsync("gbcc/app/netlogoweb/jquery.js", "utf8").then(function(data) {477 zip.file("app/netlogoweb/jquery.js", data);478 }).then(function() {479 fs.readFileAsync("gbcc/app/netlogoweb/jquery.min.js", "utf8").then(function(data) {480 zip.file("app/netlogoweb/jquery.min.js", data);481 }).then(function() {482 fs.readFileAsync("gbcc/app/netlogoweb/keywords.js", "utf8").then(function(data) {483 zip.file("app/netlogoweb/keywords.js", data);484 }).then(function() {485 fs.readFileAsync("gbcc/app/netlogoweb/label.js", "utf8").then(function(data) {486 zip.file("app/netlogoweb/label.js", data);487 }).then(function() {488 fs.readFileAsync("gbcc/app/netlogoweb/labeled-input.js", "utf8").then(function(data) {489 zip.file("app/netlogoweb/labeled-input.js", data);490 }).then(function() {491 fs.readFileAsync("gbcc/app/netlogoweb/link-drawer.js", "utf8").then(function(data) {492 zip.file("app/netlogoweb/link-drawer.js", data);493 }).then(function() {494 fs.readFileAsync("gbcc/app/netlogoweb/markdown.js", "utf8").then(function(data) {495 zip.file("app/netlogoweb/markdown.js", data);496 }).then(function() {497 fs.readFileAsync("gbcc/app/netlogoweb/models.js", "utf8").then(function(data) {498 zip.file("app/netlogoweb/models.js", data);499 }).then(function() {500 fs.readFileAsync("gbcc/app/netlogoweb/monitor.js", "utf8").then(function(data) {501 zip.file("app/netlogoweb/monitor.js", data);502 }).then(function() {503 fs.readFileAsync("gbcc/app/netlogoweb/mousetrap.js", "utf8").then(function(data) {504 zip.file("app/netlogoweb/mousetrap.js", data);505 }).then(function() {506 fs.readFileAsync("gbcc/app/netlogoweb/netlogo-engine.js", "utf8").then(function(data) {507 zip.file("app/netlogoweb/netlogo-engine.js", data);508 }).then(function() {509 fs.readFileAsync("gbcc/app/netlogoweb/netlogo-syntax.css", "utf8").then(function(data) {510 zip.file("app/netlogoweb/netlogo-syntax.css", data);511 }).then(function() {512 fs.readFileAsync("gbcc/app/netlogoweb/netlogoweb.css", "utf8").then(function(data) {513 zip.file("app/netlogoweb/netlogoweb.css", data);514 }).then(function() {515 fs.readFileAsync("gbcc/app/netlogoweb/new-model.js", "utf8").then(function(data) {516 zip.file("app/netlogoweb/new-model.js", data);517 }).then(function() {518 fs.readFileAsync("gbcc/app/netlogoweb/output.js", "utf8").then(function(data) {519 zip.file("app/netlogoweb/output.js", data);520 }).then(function() {521 fs.readFileAsync("gbcc/app/netlogoweb/plot.js", "utf8").then(function(data) {522 zip.file("app/netlogoweb/plot.js", data);523 }).then(function() {524 fs.readFileAsync("gbcc/app/netlogoweb/print-area.js", "utf8").then(function(data) {525 zip.file("app/netlogoweb/print-area.js", data);526 }).then(function() {527 fs.readFileAsync("gbcc/app/netlogoweb/ractive.js", "utf8").then(function(data) {528 zip.file("app/netlogoweb/ractive.js", data);529 }).then(function() {530 fs.readFileAsync("gbcc/app/netlogoweb/resizer.js", "utf8").then(function(data) {531 zip.file("app/netlogoweb/resizer.js", data);532 }).then(function() {533 fs.readFileAsync("gbcc/app/netlogoweb/search.js", "utf8").then(function(data) {534 zip.file("app/netlogoweb/search.js", data);535 }).then(function() {536 fs.readFileAsync("gbcc/app/netlogoweb/searchcursor.js", "utf8").then(function(data) {537 zip.file("app/netlogoweb/searchcursor.js", data);538 }).then(function() {539 fs.readFileAsync("gbcc/app/netlogoweb/session-lite.js", "utf8").then(function(data) {540 zip.file("app/netlogoweb/session-lite.js", data);541 }).then(function() {542 fs.readFileAsync("gbcc/app/netlogoweb/set-up-widgets.js", "utf8").then(function(data) {543 zip.file("app/netlogoweb/set-up-widgets.js", data);544 }).then(function() {545 fs.readFileAsync("gbcc/app/netlogoweb/simple.js", "utf8").then(function(data) {546 zip.file("app/netlogoweb/simple.js", data);547 }).then(function() {548 fs.readFileAsync("gbcc/app/netlogoweb/skeleton.js", "utf8").then(function(data) {549 zip.file("app/netlogoweb/skeleton.js", data);550 }).then(function() {551 fs.readFileAsync("gbcc/app/netlogoweb/slider.js", "utf8").then(function(data) {552 zip.file("app/netlogoweb/slider.js", data);553 }).then(function() {554 fs.readFileAsync("gbcc/app/netlogoweb/spacer.js", "utf8").then(function(data) {555 zip.file("app/netlogoweb/spacer.js", data);556 }).then(function() {557 fs.readFileAsync("gbcc/app/netlogoweb/spinner.css", "utf8").then(function(data) {558 zip.file("app/netlogoweb/spinner.css", data);559 }).then(function() {560 fs.readFileAsync("gbcc/app/netlogoweb/switch.js", "utf8").then(function(data) {561 zip.file("app/netlogoweb/switch.js", data);562 }).then(function() {563 fs.readFileAsync("gbcc/app/netlogoweb/theme.css", "utf8").then(function(data) {564 zip.file("app/netlogoweb/theme.css", data);565 }).then(function() {566 fs.readFileAsync("gbcc/app/netlogoweb/tick-counter.js", "utf8").then(function(data) {567 zip.file("app/netlogoweb/tick-counter.js", data);568 }).then(function() {569 fs.readFileAsync("gbcc/app/netlogoweb/title.js", "utf8").then(function(data) {570 zip.file("app/netlogoweb/title.js", data);571 }).then(function() {572 fs.readFileAsync("gbcc/app/netlogoweb/topbar.js", "utf8").then(function(data) {573 zip.file("app/netlogoweb/topbar.js", data);574 }).then(function() {575 fs.readFileAsync("gbcc/app/netlogoweb/tortoise-compiler.js", "utf8").then(function(data) {576 zip.file("app/netlogoweb/tortoise-compiler.js", data);577 }).then(function() {578 fs.readFileAsync("gbcc/app/netlogoweb/tortoise.css", "utf8").then(function(data) {579 zip.file("app/netlogoweb/tortoise.css", data);580 }).then(function() {581 fs.readFileAsync("gbcc/app/netlogoweb/tortoise.js", "utf8").then(function(data) {582 zip.file("app/netlogoweb/tortoise.js", data);583 }).then(function() {584 fs.readFileAsync("gbcc/app/netlogoweb/ui-editor.css", "utf8").then(function(data) {585 zip.file("app/netlogoweb/ui-editor.css", data);586 }).then(function() {587 fs.readFileAsync("gbcc/app/netlogoweb/variable.js", "utf8").then(function(data) {588 zip.file("app/netlogoweb/variable.js", data);589 }).then(function() {590 fs.readFileAsync("gbcc/app/netlogoweb/view-controller.js", "utf8").then(function(data) {591 zip.file("app/netlogoweb/view-controller.js", data);592 }).then(function() {593 fs.readFileAsync("gbcc/app/netlogoweb/view.js", "utf8").then(function(data) {594 zip.file("app/netlogoweb/view.js", data);595 }).then(function() {596 fs.readFileAsync("gbcc/app/netlogoweb/web.html", "utf8").then(function(data) {597 zip.file("app/netlogoweb/web.html", data);598 }).then(function() {599 fs.readFileAsync("gbcc/app/netlogoweb/widget-controller.js", "utf8").then(function(data) {600 zip.file("app/netlogoweb/widget-controller.js", data);601 }).then(function() {602 fs.readFileAsync("gbcc/app/netlogoweb/widget.js", "utf8").then(function(data) {603 zip.file("app/netlogoweb/widget.js", data);604 }).then(function() {605 fs.readFileAsync("gbcc/app/netlogoweb/widgets.css", "utf8").then(function(data) {606 zip.file("app/netlogoweb/widgets.css", data);607 }).then(function() {608 fs.readFileAsync("gbcc/geogebra-default.ggb").then(function(data) {609 zip.file("geogebra-default.ggb", data);610 }).then(function() {611 fs.readFileAsync("gbcc/ocean.png").then(function(data) {612 zip.file("ocean.png", data);613 }).then(function() {614 fs.readFileAsync("gbcc/package.json", "utf8").then(function(data) {615 zip.file("package.json", data);616 }).then(function() {617 fs.readFileAsync("gbcc/readme.md", "utf8").then(function(data) {618 zip.file("readme.md", data);619 }).then(function() {620 fs.readFileAsync("gbcc/server.js", "utf8").then(function(data) {621 zip.file("server.js", data);622 }).then(function() {623 fs.readFileAsync("gbcc/app/netlogoweb/async-user-dialog.js").then(function(data) {624 zip.file("app/netlogoweb/async-user-dialog.js", data);625 }).then(function() {626 fs.readFileAsync("gbcc/app/netlogoweb/jscolor.js", "utf8").then(function(data) {627 zip.file("app/netlogoweb/jscolor.js", data);628 }).then(function() {629 fs.readFileAsync("gbcc/app/netlogoweb/synchrodecoder.min.js", "utf8").then(function(data) {630 zip.file("app/netlogoweb/synchrodecoder.min.js", data);631 }).then(function() {632 fs.readFileAsync("gbcc/app/netlogoweb/localforage.min.js", "utf8").then(function(data) {633 zip.file("app/netlogoweb/localforage.min.js", data);634 }).then(function() {635 fs.readFileAsync("gbcc/app/gbcc/geogebra_defaults2d.xml", "utf8").then(function(data) {636 zip.file("app/gbcc/geogebra_defaults2d.xml", data);637 }).then(function() {638 fs.readFileAsync("gbcc/app/gbcc/geogebra_defaults3d.xml", "utf8").then(function(data) {639 zip.file("app/gbcc/geogebra_defaults3d.xml", data);640 }).then(function() {641 fs.readFileAsync("gbcc/app/gbcc/geogebra_javascript.js", "utf8").then(function(data) {642 zip.file("app/gbcc/geogebra_javascript.js", data);643 }).then(function() {644 fs.readFileAsync("gbcc/app/gbcc/geogebra_thumbnail.png").then(function(data) {645 zip.file("app/gbcc/geogebra_thumbnail.png ", data);646 }).then(function() {647 fs.readFileAsync("gbcc/app/netlogoweb/comment.js", "utf8").then(function(data) {648 zip.file("app/netlogoweb/comment.js", data);649 }).then(function() {650 fs.readFileAsync("gbcc/app/netlogoweb/show-hint.js", "utf8").then(function(data) {651 zip.file("app/netlogoweb/show-hint.js", data);652 }).then(function() {653 fs.readFileAsync("gbcc/app/netlogoweb/show-hint.css").then(function(data) {654 zip.file("app/netlogoweb/show-hint.css", data);655 }).then(function() {656 zip.generateNodeStream({type:'nodebuffer',streamFiles:true})657 .pipe(fs.createWriteStream(filename+'.zip'))658 .on('finish', function () {659 res.download(filename+'.zip', function() {660 var fullPath= __dirname + '/'+filename+'.zip';661 console.log(fullPath);662 fs.unlink(fullPath, function() {663 console.log(fullPath + " deleted");664 });665 });666 });667 }).catch(function(e) {...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...8 let parseMode = 'HTML';9 let replyMarkup;10 switch (messageType) {11 case 'start':12 templateText = await readFileAsync(__dirname + '/messages/start.mustache');13 text = Mustache.render(templateText);14 break;15 case 'help':16 templateText = await readFileAsync(__dirname + '/messages/help.mustache');17 text = Mustache.render(templateText, {18 message: 'Binance Staking Bot Help',19 });20 break;21 case 'list':22 templateText = await readFileAsync(__dirname + '/messages/list.mustache');23 text = Mustache.render(templateText, {24 assetsLocked: data.assetsLocked,25 assetsDefi: data.assetsDefi,26 assetsLockedSavings: data.assetsLockedSavings,27 });28 break;29 case 'settings':30 templateText = await readFileAsync(__dirname + '/messages/settings.mustache');31 text = Mustache.render(templateText, {32 ...data,33 });34 break;35 case 'subscribe':36 templateText = await readFileAsync(__dirname + '/messages/subscribe.mustache');37 text = Mustache.render(templateText, {38 ...data,39 found: data.assets.length > 0,40 notFound: data.notFoundAssets.length > 0,41 });42 break;43 case 'unsubscribe':44 templateText = await readFileAsync(__dirname + '/messages/unsubscribe.mustache');45 text = Mustache.render(templateText, {46 ...data,47 unsubscribedSomething: data.assets.length > 0,48 });49 break;50 case 'staking-project-available':51 templateText = await readFileAsync(__dirname + '/messages/project-available.mustache');52 text = Mustache.render(templateText, {53 asset: data.projects[0].asset,54 projects: data.projects,55 });56 break;57 case 'defi-project-available':58 templateText = await readFileAsync(__dirname + '/messages/defi-project-available.mustache');59 text = Mustache.render(templateText, {60 asset: data.projects[0].asset,61 projects: data.projects,62 });63 break;64 case 'locked-savings-project-available':65 templateText = await readFileAsync(__dirname + '/messages/locked-savings-project-available.mustache');66 text = Mustache.render(templateText, {67 asset: data.projects[0].asset,68 projects: data.projects,69 });70 break;71 case 'new-asset-available':72 templateText = await readFileAsync(__dirname + '/messages/new-asset.mustache');73 text = Mustache.render(templateText, {74 ...data.asset,75 });76 break;77 case 'new-defi-asset-available':78 templateText = await readFileAsync(__dirname + '/messages/new-defi-asset.mustache');79 text = Mustache.render(templateText, {80 ...data.asset,81 });82 break;83 case 'new-locked-savings-asset-available':84 templateText = await readFileAsync(__dirname + '/messages/new-locked-savings-asset-available.mustache');85 text = Mustache.render(templateText, {86 ...data.asset,87 });88 break;89 case 'new-activity-available':90 templateText = await readFileAsync(__dirname + '/messages/new-activity.mustache');91 text = Mustache.render(templateText, {92 ...data.item,93 });94 break;95 case 'subscribe-activities':96 templateText = await readFileAsync(__dirname + '/messages/subscribe-activities.mustache');97 text = Mustache.render(templateText, {98 hasPremium: data.hasPremium,99 });100 break;101 case 'unsubscribe-activities':102 templateText = await readFileAsync(__dirname + '/messages/unsubscribe-activities.mustache');103 text = Mustache.render(templateText);104 break;105 case 'get-premium':106 templateText = await readFileAsync(__dirname + '/messages/get-premium.mustache');107 text = Mustache.render(templateText, {108 ...data,109 });110 replyMarkup = {111 inline_keyboard: [112 [{113 text: 'SUBSCRIPTION 1 WEEK (2€)',114 callback_data: '1WEEK',115 }],116 [{117 text: 'SUBSCRIPTION 4 WEEKS (5€)',118 callback_data: '4WEEK',119 }],120 [{121 text: 'SUBSCRIPTION 1 YEAR (30€)',122 callback_data: '1YEAR',123 }]124 ]125 };126 break;127 case 'successful-payment':128 templateText = await readFileAsync(__dirname + '/messages/successful-payment.mustache');129 text = Mustache.render(templateText, {130 subscriptionEndDate: data.subscriptionEndDate,131 });132 break;133 case 'subscription-ended':134 templateText = await readFileAsync(__dirname + '/messages/subscription-ended.mustache');135 text = Mustache.render(templateText);136 break;137 case 'support':138 templateText = await readFileAsync(__dirname + '/messages/support.mustache');139 text = Mustache.render(templateText);140 break;141 case 'terms':142 templateText = await readFileAsync(__dirname + '/messages/terms-and-conditions.mustache');143 text = Mustache.render(templateText);144 break;145 case 'custom-message':146 text = data.message;147 break;148 default:149 templateText = await readFileAsync(__dirname + '/messages/help.mustache');150 text = Mustache.render(templateText, {151 message: data.message || 'Unknown command !',152 });153 }154 const url = `https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`;155 const response = await axios.get(url, {156 params: {157 chat_id: chatID,158 parse_mode: parseMode,159 text: text,160 disable_web_page_preview: 1,161 reply_markup: replyMarkup,162 }163 });...

Full Screen

Full Screen

migrator.js

Source:migrator.js Github

copy

Full Screen

2const MigrationError = require("./MigrationError");3const isDb = (db) => db && db.executeRaw && typeof db.executeRaw === "function";4const isReadFile = (fn) => fn && typeof fn === "function";5const run = (db, readFileAsync) => async (migration) => {6 const sql = await readFileAsync(migration, "utf-8");7 const queries = sql.split(";");8 const result = await Promise.all(9 queries.map(async (query) => await db.executeRaw(query))10 );11 return result;12};13const runAll = (db, readFileAsync) => async (migrations) => {14 const fn = (m) => withError(run(db, readFileAsync), m);15 const result = await Promise.all(migrations.map(async (m) => await fn(m)));16 const where = (item) => isError(item);17 if (contains(result, where)) {18 const errs = result.filter(isError);19 throw new MigrationError("Migration errors", errs);20 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const argosy = require('argosy')2const file = require('argosy-file')3const fs = argosy()4fs.pipe(file()).pipe(fs)5fs.on('error', err => console.error(err))6fs.call({7}, (err, data) => {8 if (err) {9 console.error(err)10 } else {11 console.log(data)12 }13})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyFile = require('argosy-file')3var test = argosy()4test.pipe(argosyFile({5})).pipe(test)6test.accept({cmd: 'readFileAsync'}, function (pattern, callback) {7 console.log('pattern', pattern)8 callback(null, pattern)9})10test.accept({cmd: 'writeFileAsync'}, function (pattern, callback) {11 console.log('pattern', pattern)12 callback(null, pattern)13})14test.accept({cmd: 'readDirAsync'}, function (pattern, callback) {15 console.log('pattern', pattern)16 callback(null, pattern)17})18test.accept({cmd: 'removeFileAsync'}, function (pattern, callback) {19 console.log('pattern', pattern)20 callback(null, pattern)21})22test.accept({cmd: 'removeDirAsync'}, function (pattern, callback) {23 console.log('pattern', pattern)24 callback(null, pattern)25})26test.accept({cmd: 'renameFileAsync'}, function (pattern, callback) {27 console.log('pattern', pattern)28 callback(null, pattern)29})30test.accept({cmd: 'renameDirAsync'}, function (pattern, callback) {31 console.log('pattern', pattern)32 callback(null, pattern)33})34test.accept({cmd: 'copyFileAsync'}, function (pattern, callback) {35 console.log('pattern', pattern)36 callback(null, pattern)37})38test.accept({cmd: 'copyDirAsync'}, function (pattern, callback) {39 console.log('pattern', pattern)40 callback(null, pattern)41})42test.accept({cmd: 'createDirAsync'}, function (pattern, callback) {43 console.log('pattern', pattern)44 callback(null, pattern)45})46test.accept({cmd: 'createFileAsync'}, function (pattern, callback) {47 console.log('pattern', pattern)48 callback(null, pattern)49})50var argosy = require('argosy')51var argosyFile = require('argosy-file')52var test = argosy()53test.pipe(argosyFile({54})).pipe(test)55test.accept({cmd: 'readFileAsync'}, function (pattern, callback) {56 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var file = require('argosy-file')3var fileService = file({ path: __dirname })4var argosyPattern = argosy()5argosyPattern.pipe(fileService).pipe(argosyPattern)6argosyPattern.accept({ role: 'file', cmd: 'readFile' }, function (msg, respond) {7 argosyPattern.act({ role: 'file', cmd: 'readFile', filename: 'test.txt' }, function (err, result) {8 if (err) {9 console.log(err)10 }11 console.log(result)12 })13})14var argosy = require('argosy')15var file = require('argosy-file')16var fileService = file({ path: __dirname })17var argosyPattern = argosy()18argosyPattern.pipe(fileService).pipe(argosyPattern)19argosyPattern.accept({ role: 'file', cmd: 'readFile' }, function (msg, respond) {20 argosyPattern.act({ role: 'file', cmd: 'readFile', filename: 'test.txt' }, function (err, result) {21 if (err) {22 console.log(err)23 }24 console.log(result)25 })26})27var argosy = require('argosy')28var file = require('argosy-file')29var fileService = file({ path: __dirname })30var argosyPattern = argosy()31argosyPattern.pipe(fileService).pipe(argosyPattern)32argosyPattern.accept({ role: 'file', cmd: 'readFile' }, function (msg, respond) {33 argosyPattern.act({ role: 'file', cmd: 'readFile', filename: 'test.txt' }, function (err, result) {34 if (err) {35 console.log(err)36 }37 console.log(result)38 })39})40var argosy = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1argosy.readFileAsync('./test.txt', function (err, data) {2 if (err) {3 throw err;4 }5 console.log(data);6});7var data = 'This is the content of the file';8argosy.writeFileAsync('./test.txt', data, function (err) {9 if (err) {10 throw err;11 }12 console.log('Saved!');13});14argosy.readFileAsync('./test.txt', function (err, data) {15 if (err) {16 throw err;17 }18 console.log(data);19});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful