"use strict";(function(){"use strict";global.Promise=require("bluebird");var e=require("co");var r=require("util");var n=require("fs");var t=require("path");var i=require("./jsUtil");function u(e){try{var r={};if(typeof e==="string"){r=JSON.parse(e)}else{r=e}console.log("in _getVersion, version:",e,"ret:",r);if(r==undefined||r.version==undefined||r.version.versionName==undefined){return null}var n=r.version.versionName.split(".");if(n.length!=4){return null}else{return r.version.versionName}}catch(t){console.err(t);return null}}exports.getInfo=function(r){return e(regeneratorRuntime.mark(function s(){var e,r,o,a;return regeneratorRuntime.wrap(function l(s){while(1){switch(s.prev=s.next){case 0:e=n.readFileSync(t.join(i.getWorkPath(),"version.json"),"utf-8");r=u(e);if(!(r==null)){s.next=4;break}return s.abrupt("return",Promise.reject("currentName is null"));case 4:console.log("upgradeUrl:",i.getPkgInfo().spec.upgradeUrl);s.next=7;return i.commonGet2(i.getPkgInfo().spec.info.upgradeUrl,"version.json");case 7:o=s.sent;a=u(o);if(!(a==null)){s.next=11;break}return s.abrupt("return",Promise.reject("currentName is null"));case 11:if(!i.isNewVersion(r,a)){s.next=15;break}return s.abrupt("return",o);case 15:return s.abrupt("return",{});case 16:case"end":return s.stop()}}},s,this)})).catch(function(e){return Promise.reject(e)}).asCallback(r)}})();