- Updated package.json to use electron@2.0.18 instead of electron-prebuilt@1.4.3 - Modified lib/jibo-cli.js to reference 'electron' instead of 'electron-prebuilt' - This fixes compatibility issues with the simulator on modern Linux systems - electron-prebuilt was deprecated and renamed to electron in 2016
10 lines
39 KiB
JavaScript
10 lines
39 KiB
JavaScript
/**
|
|
* jibo-cli - Command line interface, templates, simulator
|
|
* @version v3.0.7
|
|
* @license Copyright (c) 2017, Jibo, Inc. All rights reserved.
|
|
* All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA)
|
|
* distributed herewith. If you did not receive a copy of the EULA, you may view a
|
|
* copy at https://developers.jibo.com/license.
|
|
*/
|
|
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.jiboCli=t()}}(function(){return function t(e,o,n){function r(s,a){if(!o[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=o[s]={exports:{}};e[s][0].call(c.exports,function(t){var o=e[s][1][t];return r(o?o:t)},c,c.exports,t,e,o,n)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(t,e,o){"use strict";var n=t("commander"),r=t("../jibo-tools"),i=t("colors"),s=function(){function t(){this.tools=r.default,this.program=n,this.parse(),this.exec()}return t.prototype.parse=function(){this.program.parse(process.argv)},t.prototype.exec=function(){throw new Error("Invalid command setup")},t.prototype.fetchRobot=function(t,e){var o=this;this.tools.robots.getInfo(t,function(t,n){return t?o.error(t):void e(n)})},t.prototype.error=function(t){this.red(t),process.exit(1)},t.prototype.warn=function(t){console.log(i.yellow("\n"+t+"\n"))},t.prototype.success=function(t){t&&this.green(t),process.exit()},t.prototype.green=function(t){console.log(i.green("\n"+t+"\n"))},t.prototype.red=function(t){console.log(i.red("\n"+t+"\n"))},t.prototype.isRobotReachable=function(t,e,o){var n=this;this.getRobotInfo(t,function(t){e&&n.green(e.replace("%s",t.name)),n.tools.networks.isRobotReachable(t,function(e,r){return e?n.error(e):void(r===!1?n.error("Could not connect to "+t.name+". Make sure the robot is turned on."):o(t))})})},t.prototype.getRobotInfo=function(t,e){var o=this;"undefined"==typeof t?this.tools.robots.getDefault(function(t,n){return t?o.error(t):null===n?o.error(new Error("No default robot was set. Call 'jibo set-default-robot <robotName>' to set a default.")):void o.fetchRobot(n,e)}):this.fetchRobot(t,e)},t}();Object.defineProperty(o,"__esModule",{value:!0}),o.default=s},{"../jibo-tools":25,colors:void 0,commander:void 0}],2:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.tools.robots.add(process.argv[2],process.argv[3],function(e){return e?t.error(e):void t.success(process.argv[2]+" success added.")})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],3:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Fetching the buildroot version of %s.",function(e){t.tools.buildVersion(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],4:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,null,function(e){t.tools.debug(e,null,function(e){return t.warn(e)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],5:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --robot <n>","Target robot").parse(process.argv)},e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,"Attempting to delete a skill from %s. Press CTRL+C to cancel.",function(e){t.tools.validateSkillPath(t.program.args[0],function(o,n,r){return o?t.error(o):void t.tools.delSkill(e,r,function(e,o){return e?t.error(e):void t.success(o)})})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],6:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Fetching storage space info for %s.",function(e){t.tools.diskSpace(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],7:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Getting the volume of %s.",function(e){t.tools.volume.get(e,function(o,n){return o?t.error(o):void t.success(e.name+"'s volume is: "+n)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],8:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Indexing %s.",function(e){t.tools.index(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],9:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=t("path"),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.description("Creates a jibo skeleton project.").option("-t, --type [package-type]","The type of project: 'behavior-template', 'asset-pack-template'\nDefault is 'behavior-template'",/^(behavior-template|asset-pack-template)$/i,"behavior-template").parse(process.argv)},e.prototype.exec=function(){var t=this,e=this._resolveSkillPath(this.program.args[0]);this.green("Creating package: "+e);var o=e.split(i.sep),n=o.length>0?o[o.length-1]:e;this.tools.packageGenerator(this.program.type,e,n,"",function(e){return e?t.error(e):void t.green("Done")})},e.prototype._resolveSkillPath=function(t){return"string"==typeof t?i.resolve(process.cwd(),i.normalize(t)):process.cwd()},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=s},{"../command":1,path:void 0}],10:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Powering off %s.",function(e){t.tools.powerOff(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],11:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Rebooting %s.",function(e){t.tools.reboot(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],12:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.tools.robots.remove(process.argv[2],function(e){return e?t.error(e):void t.success(process.argv[2]+" success removed.")})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],13:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.tools.robots.list(function(e,o){return e?t.error(e):(0===o.length&&t.success("Your robot list is empty. To add a robot, run: \n\n jibo add-robot <robotName> <robotIpAddress>\n"),void t.tools.robots.getDefault(function(e,n){return e?t.error(e):(o.forEach(function(t){t.hasOwnProperty("network")&&delete t.network,t.name===n?t.name="* "+t.name:t.name=" "+t.name}),t.green("List of robots:"),t.printTable(o,{name:" "}),void t.success())}))})},e.prototype.printTable=function(t,e){function o(t){return"undefined"!=typeof e&&"undefined"!=typeof e[t]?e[t]:""}function n(t){var e;return e=t?Array(t+1).join(" "):""}var r,i,s,a={};if(0!==t.length){for(r in t[0])for(s=o(r)+r,a[r]=s.length,i=0;i<t.length;i++)t[i][r]&&t[i][r].length>a[r]&&(a[r]=t[i][r].length);var u=Array(6).join(" "),l="";for(r in t[0])s=o(r)+r,l+=s+n(a[r]-s.length)+u;for(console.log(l),i=0;i<t.length;i++){var c="";for(r in t[0])c+=t[i][r]+n(a[r]-t[i][r].length)+u;console.log(c)}console.log("")}},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],14:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --robot <n>","Target robot").option("-v, --verbose","Output more information during command execution").option("-n, --nosync","If set, skip syncing").parse(process.argv)},e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,"Attempting to run a skill on %s. Press CTRL+C to cancel.",function(e){t.tools.validateSkillPath(t.program.args[0],function(o,n,r){return o?t.error(o):void(t.program.nosync===!0?t._run(e,r):t.tools.sync.start(e,n,function(o,n){return o?t.error(o):(t.green(n),void t._run(e,r))}))})})},e.prototype._run=function(t,e){var o=this;this.green("Launching skill"),this.tools.run(t,e,function(t,e){return t?o.error(t):void o.success(e)})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],15:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.tools.robots.setDefault(process.argv[2],function(e){return e?t.error(e):void t.success(process.argv[2]+" is now the default robot.")})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],16:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --robot <n>","Target robot").parse(process.argv)},e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,"Setting the volume of %s.",function(e){t.tools.volume.set(e,process.argv[2],function(o,n){return o?t.error(o):void t.success(e.name+"'s volume was successfully set to: "+n)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],17:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("child_process"),i=t("../command"),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --remote <address> <n>","Run this as a remote simulation").parse(process.argv)},e.prototype.exec=function(){var t=this;this.tools.validateSkillPath(this.program.args[0],function(e,o,n){return e?t.error(e):void t.sim(o,n)})},e.prototype.sim=function(t,e){var o=this;r.exec("cd "+t,function(n){if(n)return o.error(n);o.green("Running skill named "+e+", located at "+t+". Press control+c to quit");var r=t+"/index.html";o.program.remote&&o.program.remote.length>0?o.tools.launcher.play(r,o.program.remote):o.tools.launcher.play(r)})},e}(i.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=s},{"../command":1,child_process:void 0}],18:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.exec=function(){var t=this;this.isRobotReachable(process.argv[2],"Attempting to stop skill running on %s.",function(e){t.tools.stop(e,function(e,o){return e?t.error(e):void t.success(o)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],19:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --robot <n>","Target robot").parse(process.argv)},e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,"Attempting to sync a skill to %s. Press CTRL+C to cancel.",function(e){t.tools.sync.start(e,t.program.args[0],function(o,n){if(o)return t.error(o);n&&t.green(n);var r="Skill synced success to '"+e.name+"'. To launch the skill run: 'jibo run'";t.success(r)})})},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"../command":1}],20:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("../command"),i=t("cli-spinner").Spinner,s=t("ws-without-native"),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.parse=function(){this.program.option("-r, --robot <robotName>","Target robot").option("-f, --filter <string>","Optional filter for updates").parse(process.argv)},e.prototype.exec=function(){var t=this;this.isRobotReachable(this.program.robot,"Attempting to update %s.",function(e){t._robotInfo=e,t._spinner=new i("checking for updates... %s"),t._spinner.start(),t.tools.updateRobot.get(t._robotInfo,t.program.filter,function(e,o){if(t._spinner.stop(!0),e||!o||!o.data){var n=e;return!o&&t.program.filter&&(n="Unrecognized update filter"),t.error(n)}if(o.data&&0===o.data.length)return void t.red("No updates found");t.green(o.msg);var r=t.tools.updateRobot.getOTASocketUrl(t._robotInfo);t._otaSocket=new s(r),t._otaSocket.onerror=function(){console.log("Error opening ota download socket")},t._otaSocket.on("message",t._downloadStatus.bind(t)),t._downloadedIDs=[],t._updateIDs=[];for(var i=o.data.length,a=0;a<i;++a){var u=o.data[a];u.downloaded&&t._downloadedIDs.push(u.id),t._updateIDs.push(u.id)}t._startNextDownload(function(e){return t._spinner.stop(!0),t._closeOTASocket(),e?t.error(e):(t._spinner.setSpinnerTitle("installing updates... %s"),t._spinner.start(),void t.tools.updateRobot.install(t._robotInfo,t._updateIDs,function(e,o){return t._spinner.stop(!0),e?t.error(e):void t.success(o)}))})})})},e.prototype._startNextDownload=function(t){var e=this;this._spinner.stop(!0);var o=null,n=this._updateIDs.length;if(n!==this._downloadedIDs.length)for(var r=0;r<n;r++)if(this._downloadedIDs.indexOf(this._updateIDs[r])===-1){o=this._updateIDs[r];break}return o?(this._spinner.start(),void this.tools.updateRobot.download(this._robotInfo,[o],function(o,n){return e._spinner.stop(!0),o?t(o):(e._downloadedIDs.push(n.id),e.green("Downloaded "+n.id),void e._startNextDownload(t))})):t()},e.prototype._closeOTASocket=function(){this._otaSocket&&(this._otaSocket.removeListener("message",this._downloadStatus),this._otaSocket.close(),this._otaSocket=null)},e.prototype._downloadStatus=function(t){try{t=JSON.parse(t)}catch(t){return this._spinner.stop(!0),this.red("error during download...status is not JSON")}var e=Math.round(t.received/t.length*100);this._spinner.setSpinnerTitle("downloading update ("+t.id+") "+e+"% %s")},e}(r.default);Object.defineProperty(o,"__esModule",{value:!0}),o.default=a},{"../command":1,"cli-spinner":void 0,"ws-without-native":void 0}],21:[function(t,e,o){"use strict";var n=t("./main"),r=t("./commands/add-robot"),i=t("./commands/build-version"),s=t("./commands/debug"),a=t("./commands/diskspace"),u=t("./commands/get-volume"),l=t("./commands/index"),c=t("./commands/init"),d=t("./commands/poweroff"),p=t("./commands/reboot"),f=t("./commands/remove-robot"),h=t("./commands/robot-list"),v=t("./commands/run"),m=t("./commands/del"),b=t("./commands/set-default-robot"),y=t("./commands/set-volume"),g=t("./commands/sim"),_=t("./commands/stop"),w=t("./commands/sync"),O=t("./commands/update-robot");Object.defineProperty(o,"__esModule",{value:!0}),o.default={main:n.default,addRobot:r.default,buildVersion:i.default,debug:s.default,diskspace:a.default,getVolume:u.default,index:l.default,init:c.default,poweroff:d.default,reboot:p.default,removeRobot:f.default,robotList:h.default,run:v.default,setDefaultRobot:b.default,setVolume:y.default,sim:g.default,stop:_.default,sync:w.default,del:m.default,updateRobot:O.default}},{"./commands/add-robot":2,"./commands/build-version":3,"./commands/debug":4,"./commands/del":5,"./commands/diskspace":6,"./commands/get-volume":7,"./commands/index":8,"./commands/init":9,"./commands/poweroff":10,"./commands/reboot":11,"./commands/remove-robot":12,"./commands/robot-list":13,"./commands/run":14,"./commands/set-default-robot":15,"./commands/set-volume":16,"./commands/sim":17,"./commands/stop":18,"./commands/sync":19,"./commands/update-robot":20,"./main":22}],22:[function(t,e,o){"use strict";var n=t("commander"),r=t("path"),i=t("compute-hamming"),s=t("colors"),a=function(){function e(t){this.knownSubCommands=[["init","[path] [--type]","Create a new project (skill|asset pack)."],["sim","[path] [--remote]","Launch a skill in the simulator."],["robot-list","","Display the list of robots this machine is connected to."],["add-robot","<robotName> <robotIpAddress>","Add a robot to my robot list."],["remove-robot","[robotName]","Remove a robot from my robot list."],["set-default-robot","[robotName]","Set the default robot to be used when a robot is not specified."],["update-robot","[--robot] [--filter]","Download and install available updates on a robot."],["sync","[skillPath] [--robot]","Sync a skill to a robot."],["run","[skillPath] [--robot] [--nosync] [--verbose]","Run a skill on a robot."],["delete","[skillPath] [--robot]","Delete a skill from a robot."],["debug","","[Deprecated.]"],["stop","[robotName]","Stop any skills currently running on a robot."],["diskspace","[robotName]","Display the amount of storage space on a robot."],["build-version","[robotName]","Display the buildroot version installed on a robot."],["set-volume","<volume> [--robot]","Set the volume of a robot."],["get-volume","[robotName]","Display the current volume of a robot."],["index","[robotName]","Index a robot. (Required after powering robot on.)"],["reboot","[robotName]","Restart a robot."],["poweroff","[robotName]","Power off a robot."],["help","[command]","Display help for the specified command."],["-h"],["--help"],["help"],["-V"],["--version"]],this.rootPath=r.dirname(t),this.parse(),this.validate()}return e.prototype.parse=function(){var e=t(r.join(this.rootPath,"package.json")),o=n.version(e.version);this.knownSubCommands.forEach(function(t){1!==t.length&&(o=o.command(t[0]+" "+t[1],t[2]))}),o.parse(process.argv)},e.prototype.yellow=function(t){console.log(s.yellow(t))},e.prototype.validate=function(){var t,e=this;if(this.knownSubCommands.forEach(function(e){process.argv[2]===e[0]&&(t=!0)}),!t){var o=[],n=Number.MAX_SAFE_INTEGER;this.knownSubCommands.forEach(function(t){var e=t[0],r=process.argv[2],s=0;e.length<r.length?(s=r.length-e.length,r=r.slice(0,e.length)):e.length>r.length&&(s=e.length-r.length,e=r.slice(0,r.length)),s+=i(e,r),s<n&&(n=s,o=[t[0]])}),this.yellow("jibo: '"+process.argv[2]+"' is not a jibo command. See 'jibo --help' for the list of commands."),this.yellow(""),0===o.length?this.yellow("Did you mean this?"):this.yellow("Did you mean one of these?"),o.forEach(function(t){e.yellow(" "+t)})}},e}();Object.defineProperty(o,"__esModule",{value:!0}),o.default=a},{colors:void 0,commander:void 0,"compute-hamming":void 0,path:void 0}],23:[function(t,e,o){"use strict";function n(){var t="electron",e=s.substr(s.indexOf(t)+t.length),o=r.dirname(i.sync("electron"));return o+e}var r=t("path"),i=t("resolve"),s=t("electron");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"electron":void 0,path:void 0,resolve:void 0}],24:[function(t,e,o){"use strict";function n(t,e){var o=i(__dirname);return r.join(o,t||"",e||"")}var r=t("path"),i=t("find-root");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"find-root":void 0,path:void 0}],25:[function(t,e,o){"use strict";var n=t("./package-generator/package-generator"),r=t("./launcher/launcher"),i=t("./robots/sync"),s=t("./robots/run"),a=t("./robots/delete"),u=t("./robots/debug"),l=t("./robots/stop"),c=t("./robots/robots"),d=t("./robots/networks"),p=t("./robots/disk-space"),f=t("./robots/build-version"),h=t("./robots/volume"),v=t("./robots/index"),m=t("./robots/reboot"),b=t("./robots/poweroff"),y=t("./robots/validate-skill-path"),g=t("./get-electron-path"),_=t("./get-tools-path"),w=t("./cli"),O=t("./robots/update-robot");Object.defineProperty(o,"__esModule",{value:!0}),o.default={cli:w.default,packageGenerator:n.default,launcher:r.default,sync:i.default,run:s.default,delSkill:a.default,debug:u.default,stop:l.default,robots:c.default,networks:d.default,diskSpace:p.default,buildVersion:f.default,volume:h.default,index:v.default,reboot:m.default,powerOff:b.default,validateSkillPath:y.default,getElectronPath:g.default,getToolsPath:_.default,updateRobot:O.default}},{"./cli":21,"./get-electron-path":23,"./get-tools-path":24,"./launcher/launcher":26,"./package-generator/package-generator":27,"./robots/build-version":28,"./robots/debug":30,"./robots/delete":31,"./robots/disk-space":33,"./robots/index":34,"./robots/networks":35,"./robots/poweroff":36,"./robots/reboot":37,"./robots/robots":38,"./robots/run":39,"./robots/stop":40,"./robots/sync":41,"./robots/update-robot":42,"./robots/validate-skill-path":43,"./robots/volume":44}],26:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("child_process"),i=t("../get-electron-path"),s=t("path"),a=t("events"),u=t("lodash"),l=t("../robots/sync"),c=t("jibo-sync"),d=t("../robots/run"),p=t("../get-tools-path"),f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.kill=function(){c.stop(),this.emit("exit")},e}(a.EventEmitter),h=function(e){function o(t){var o=e.call(this)||this;return o.host=t,o}return n(o,e),o.prototype.kill=function(){t("../robots/stop")({ip:this.host},function(){console.log("skill stopped")}),this.emit("exit")},o}(a.EventEmitter),v=function(t){function e(){var e=t.call(this)||this;return e.child=null,e}return n(e,t),e.prototype.onChildExit=function(){this.child.removeAllListeners(),this.child=null,this.emit("exit")},e.prototype.playOnRobot=function(t,e,o){var n=this;this.child=new f,this.child.on("exit",this.onChildExit.bind(this)),l.default.start({ip:t},e,function(e){console.log("Skill synced"),n.child=null,e?(console.log("UPLOAD ABORTED",e),n.emit("upload-error")):(n.child=new h(t),n.child.on("exit",n.onChildExit.bind(n)),d.default({ip:t},o,function(t){t?(console.error("launch error "+t),n.child=null,n.emit("play-error")):n.emit("playing")}))})},e.prototype.play=function(t,e,o){if(void 0===o&&(o="0123456789abcdefg"),!this.child){var n=p.default("simulator"),a=[s.resolve(n,"app.js"),"--path",t,"--token",o],l=e&&e.length>0;l&&a.push("--remote",e);var c={ELECTRON_INTERNAL_RUN_AS_NODE:"0",RUNMODE:l?"REMOTELY":"SIMULATOR",NODE_PATH:""},d=process.env;d.hasOwnProperty("NODE_PATH_SIM")&&(d.hasOwnProperty("NODE_PATH")?c.NODE_PATH=d.NODE_PATH+":"+d.NODE_PATH_SIM:c.NODE_PATH=d.NODE_PATH_SIM),this.child=r.spawn(i.default(),a,{cwd:n,env:u.assign({},process.env,c)}),this.emit("start"),this.child.on("error",function(t){console.log(t)}),this.child.on("exit",this.onChildExit.bind(this))}},e.prototype.stop=function(){this.child&&(console.log("STOP"),this.child.on("error",function(t){console.log(t)}),this.child.kill())},e}(a.EventEmitter);Object.defineProperty(o,"__esModule",{value:!0}),o.default=new v},{"../get-electron-path":23,"../get-tools-path":24,"../robots/run":39,"../robots/stop":40,"../robots/sync":41,child_process:void 0,events:void 0,"jibo-sync":void 0,lodash:void 0,path:void 0}],27:[function(t,e,o){"use strict";function n(t,e){var o;return o=/__(?:(package-name)|([pP]ackageName)|(package_name))__/g,t.replace(o,e)}function r(t,e){var o;return o=/__(?:(display-name))__/g,t.replace(o,e)}function i(t){return t=t.replace(/-+|_+/g," "),t=t.replace(/\s+/g," ").trim(),t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})}function s(t,e){var o;return o=/__(?:(skill-page-title))__/g,t.replace(o,i(e))}function a(t,e,o,i,a){var p,f,h,v,m,b,y,g,_,w=d.default("templates",t);try{u.statSync(w)}catch(e){a("Template type "+t+" does not exist")}for(null===o&&(o=l.basename(e)),u.makeTreeSync(e),m=c.readdirSyncRecursive(w),y=[],h=0,v=m.length;h<v;h++)p=m[h],_=l.resolve(w,p),b=_.replace(w,""),b=b.replace(/^\//,""),b=b.replace(/\.template$/,""),g=l.join(e,b),u.existsSync(g)||(u.isDirectorySync(_)?y.push(u.makeTreeSync(g)):u.isFileSync(_)?(u.makeTreeSync(l.dirname(g)),f=u.readFileSync(_),"package.json"===l.basename(_)?(f=n(f.toString(),o),f=r(f.toString(),i)):"index.html"===l.basename(_)?f=s(f.toString(),o):"launch.rule"===l.basename(_)&&(f=n(f.toString(),o)),y.push(u.writeFileSync(g,f))):y.push(void 0));a()}var u=t("fs-plus"),l=t("path"),c=t("wrench"),d=t("../get-tools-path");Object.defineProperty(o,"__esModule",{value:!0}),o.default=a},{"../get-tools-path":24,"fs-plus":void 0,path:void 0,wrench:void 0}],28:[function(t,e,o){"use strict";function n(t,e){r.getBuildVersion(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],29:[function(t,e,o){"use strict";var n=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},r=t("fs"),i=t("path"),s=t("events"),a=t("ensureDir"),u=t("osenv"),l=i.resolve(u.home(),".jibo/cli.json"),c=function(t){function e(){var e=t.call(this)||this;return e.settings={},e}return n(e,t),e.prototype.load=function(t){var e=this;r.readFile(l,"utf8",function(o,n){if(o)return e.settings={},void t(null);try{var r=JSON.parse(n);e.settings=r}catch(e){console.log("parse error"),console.log(e),t(e)}t(null)})},e.prototype.save=function(t){var e=this;a(i.dirname(l),null,function(){r.writeFile(l,JSON.stringify(e.settings,null," "),function(e){t(e)})})},e.prototype.get=function(){if(0===arguments.length)return this.settings;for(var t=this.settings,e=0;e<arguments.length;e++){if("undefined"==typeof t[arguments[e]])return;t=t[arguments[e]]}return t},e.prototype.set=function(t){if(0===arguments.length)throw new Error("No value was provided to Config.set()");1===arguments.length&&(this.settings=t);for(var e=this.settings,o=0;o<arguments.length-2;o++)console.log("path "+arguments[o]),("undefined"==typeof e[arguments[o]]||Array.isArray(e[arguments[o]]))&&(e[arguments[o]]={}),e=e[arguments[o]];e[arguments[arguments.length-2]]=arguments[arguments.length-1]},e}(s.EventEmitter);Object.defineProperty(o,"__esModule",{value:!0}),o.default=c},{ensureDir:void 0,events:void 0,fs:void 0,osenv:void 0,path:void 0}],30:[function(t,e,o){"use strict";function n(t,e,o){o("The debug command is deprecated, use http://"+t.ip+":9191")}Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{}],31:[function(t,e,o){"use strict";function n(t,e,o){r.deleteSkill(t.ip,e,function(t,e){o(t,e)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],32:[function(t,e,o){"use strict";function n(t,e,o,n,r){var i={dirName:o};g(t,j,i,function(o,i){if(o)r(o,i);else{var s=t+":"+k,a=!1;w.uploadToServer(s,e,a,n,r)}})}function r(t,e){var o=t+":"+k;w.closeServer(o,e)}function i(t,e,o){var n={dirName:e};g(t,P,n,o)}function s(t,e){g(t,x,void 0,e)}function a(t,e){g(t,N,void 0,e)}function u(t,e){g(t,T,void 0,e)}function l(t,e,o){if(!e)return void o("No volume specified. Please specify a volume in the range [0.0-1.0].",null);var n=parseFloat(e);if(Number.isNaN(n))return void o('Volume "'+e+'" is not a number.',null);if(n<0||n>1)return void o("Volume must be in the range [0.0-1.0]. Was "+n+".",null);var r={volume:n};g(t,M,r,o)}function c(t,e){g(t,S,void 0,e)}function d(t,e){g(t,R,void 0,e)}function p(t,e){g(t,E,void 0,e)}function f(t,e){g(t,D,void 0,e)}function h(t,e,o){var n={dirName:e
|
|
};g(t,A,n,o)}function v(t,e,o){var n={filter:e};g(t,I,n,o)}function m(t,e,o){var n={ids:e};g(t,C,n,function(t,e){return t||"failed"===e.status||e.error?o(t||e.reason||e.error):void o(null,e)})}function b(t){return"ws://"+t+":"+O+"/download-update"}function y(t,e,o){var n={ids:e};g(t,L,n,function(t,e){return t||"failed"===e.status||e.error?o(t||e.reason||e.error):void o(null,e)})}function g(t,e,o,n){var r=o?o:{};try{r=JSON.stringify(r)}catch(t){return void n("Attempting to send invalid data to dev shell. Request is not valid JSON",null)}var i={hostname:t,port:O,path:e,method:"POST",headers:{"Content-Type":"application/json"}},s=_.request(i,function(t){var e="";t.on("data",function(t){e+=t}),t.on("end",function(){var t=void 0;try{t=JSON.parse(e)}catch(t){return void n("Invalid request to dev shell. Request body is not valid JSON: "+e,null)}"ERROR"===t.Status?n(t.Message,null):n(null,t.Message)})});s.on("error",function(){n("Dev shell is not available on "+t,null)}),s.write(r),s.end()}var _=t("http"),w=t("jibo-sync"),O=8686,k=8989,j="/sync-skill",P="/run",x="/stop",S="/diskspace",R="/reboot",E="/poweroff",N="/version",D="/index",M="/setvolume",T="/getvolume",A="/delete-skill",I="/check-update",C="/download-update",L="/install-update";o.syncSkill=n,o.stopSync=r,o.runSkill=i,o.stopSkill=s,o.getBuildVersion=a,o.getVolume=u,o.setVolume=l,o.getDiskSpace=c,o.rebootRobot=d,o.powerOffRobot=p,o.indexRobot=f,o.deleteSkill=h,o.checkForUpdates=v,o.downloadUpdates=m,o.getOTASocketUrl=b,o.installUpdates=y},{http:void 0,"jibo-sync":void 0}],33:[function(t,e,o){"use strict";function n(t,e){r.getDiskSpace(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],34:[function(t,e,o){"use strict";function n(t,e){r.indexRobot(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],35:[function(t,e,o){"use strict";var n=t("child_process"),r={isRobotReachable:function(t,e){var o=!1,r="-t 10";"win32"===process.platform&&(r="-4");var i=n.spawn("ping",[r,t.ip],["pipe"]),s="";i.on("close",function(){o||(i.kill("SIGKILL"),e(null,!1),o=!0)}),i.on("exit",function(){o||(i.kill("SIGKILL"),e(null,!1),o=!0)}),i.stderr.on("data",function(t){if(s+=t.toString(),s.search("No route to host")!==-1||s.search("Host is down")!==-1)return void(o||(i.kill("SIGKILL"),e(null,!1),o=!0))});var a="";i.stdout.on("data",function(t){a+=t.toString();var n="bytes from";if("win32"===process.platform&&(n="bytes="),a.search(n)!==-1)return void(o||(i.kill("SIGKILL"),e(null,!0),o=!0))})}};Object.defineProperty(o,"__esModule",{value:!0}),o.default=r},{child_process:void 0}],36:[function(t,e,o){"use strict";function n(t,e){r.powerOffRobot(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],37:[function(t,e,o){"use strict";function n(t,e){r.rebootRobot(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],38:[function(t,e,o){"use strict";function n(t){var e=new i.default;e.load(function(o){return o?void t(o):void t(null,e)})}function r(t){return!!t}var i=t("./config"),s=t("lodash"),a={list:function(t){n(function(e,o){if(e)return void t(e);var n=o.get("robots");return Array.isArray(n)?void t(null,n):void t(null,[])})},add:function(t,e,o){n(function(n,i){if(n)return void o(n);if(!t||0===t.length)return void o(new Error("Robot's name must be at least one character long"));if(r(e)===!1)return void o(new Error("IP address is not a valid ("+e+")"));var a=i.get("robots");return"undefined"!=typeof a&&Array.isArray(a)!==!1||(a=[]),s.findIndex(a,function(e){return e.name===t})!==-1?void o(new Error("A robot with the name "+t+" already exists. Delete it first if you want to update it's information ")):(a.push({name:t,ip:e}),a.sort(function(t,e){return t>e}),i.set("robots",a),i.set("defaultRobot",t),void i.save(function(t){o(t)}))})},remove:function(t,e){console.log(""),n(function(o,n){if(o)return void e(o);if(!t||0===t.length)return void e(new Error("Robot's name must be at least one character long"));var r=n.get("robots");if("undefined"==typeof r||Array.isArray(r)===!1)return void e(new Error("There are no robots to delete"));var i=s.findIndex(r,function(e){return e.name===t});return i===-1?void e(new Error("No robot with the name "+t+" exists.")):(s.pullAt(r,i),n.set("robots",r),n.get("defaultRobot")===t&&n.set("defaultRobot",void 0),void n.save(function(t){e(t)}))})},setDefault:function(t,e){n(function(o,n){if(o)return void e(o);if(!t||0===t.length)return void e(new Error("Robot's name must be at least one character long"));var r=n.get("robots");return Array.isArray(r)===!1||s.findIndex(r,function(e){return e.name===t})===-1?void e(new Error(t+" doesn't exist in the list of robots. Run to 'jibo robot-list' to see the list of robots")):(n.set("defaultRobot",t),void n.save(function(t){e(t)}))})},getDefault:function(t){n(function(e,o){if(e)return void t(e);var n=o.get("defaultRobot");return"undefined"==typeof n?void t(null,null):void t(null,n)})},getInfo:function(t,e){return 0===t.length?void e(new Error("Robot's name must be at least one character long")):void this.list(function(o,n){if(o)return void e(o);var r=s.findIndex(n,function(e){return e.name===t});return r===-1?void e(new Error("No robot by the name "+t+" exists in the robot list")):void e(null,n[r])})}};Object.defineProperty(o,"__esModule",{value:!0}),o.default=a},{"./config":29,lodash:void 0}],39:[function(t,e,o){"use strict";function n(t,e,o){r.runSkill(t.ip,e,function(t,e){o(t,e)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],40:[function(t,e,o){"use strict";function n(t,e){r.stopSkill(t.ip,function(t,o){e(t,o)})}var r=t("./dev-shell");Object.defineProperty(o,"__esModule",{value:!0}),o.default=n},{"./dev-shell":32}],41:[function(t,e,o){"use strict";var n=t("./validate-skill-path"),r=t("./dev-shell"),i=function(){function t(){}return t.start=function(t,e,o){n.default(e,function(e,n,i){if(e)return void o(e,null);var s=!0;r.syncSkill(t.ip,n,i,s,function(t,e){o(t,e)})})},t.stop=function(t,e){r.stopSync(t.ip,function(t,o){e(t,o)})},t}();Object.defineProperty(o,"__esModule",{value:!0}),o.default=i},{"./dev-shell":32,"./validate-skill-path":43}],42:[function(t,e,o){"use strict";var n=t("./dev-shell"),r={get:function(t,e,o){n.checkForUpdates(t.ip,e,o)},download:function(t,e,o){n.downloadUpdates(t.ip,e,o)},install:function(t,e,o){n.installUpdates(t.ip,e,o)},getOTASocketUrl:function(t){return n.getOTASocketUrl(t.ip)}};Object.defineProperty(o,"__esModule",{value:!0}),o.default=r},{"./dev-shell":32}],43:[function(t,e,o){"use strict";function n(t){return"string"==typeof t?i.resolve(process.cwd(),t):process.cwd()}function r(t,e){t=n(t),s.lstat(t,function(o,n){return o?o.errno===-2?void e(new Error("No folder exists at "+t)):void e(o):n.isDirectory()===!1?void e(new Error(t+" is a file not a directory")):void s.readFile(i.resolve(t,"package.json"),"utf8",function(o,n){if(o)return o.errno===-2?void e(new Error("No 'package.json' exists at "+t+"/package.json")):void e(o);var r;try{r=JSON.parse(n)}catch(o){return void e(new Error("Error parsing skill's 'package.json' at "+t+"/package.json"))}if("string"!=typeof r.name&&0!==r.name.length)return void e(new Error('Skill hasn\'t properly set the "name" field in '+t+"/package.json"));var i=r.name;e(null,t,i)})})}var i=t("path"),s=t("fs");Object.defineProperty(o,"__esModule",{value:!0}),o.default=r},{fs:void 0,path:void 0}],44:[function(t,e,o){"use strict";var n=t("./dev-shell"),r={get:function(t,e){n.getVolume(t.ip,function(t,o){e(t,o)})},set:function(t,e,o){n.setVolume(t.ip,e,function(t,e){o(t,e)})}};Object.defineProperty(o,"__esModule",{value:!0}),o.default=r},{"./dev-shell":32}],45:[function(t,e,o){"use strict";var n=t("./jibo-tools");e.exports=n.default},{"./jibo-tools":25}]},{},[45])(45)}); |