yann-vis-cli 1.10.1-beta.3 → 1.10.1-beta.4
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/dist/renew/index.js +1 -1
- package/package.json +1 -1
package/dist/renew/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const{log:e,prompt:t,exit:a,welcomeCli:
|
|
1
|
+
"use strict";const{log:e,prompt:t,exit:a,welcomeCli:i,get_update_log:s,set_update_log:n,runAsyncCmd:c}=require("../utils"),o=(()=>{let e;return()=>{if(""===e||e)return e;const{execSync:t}=require("child_process");try{e=t("npm config get registry",{encoding:"utf8"}).trim()}catch(t){e=""}return e}})(),r=(()=>{let t=!1,a=!1;return async()=>(t||(a=await(async()=>{const t=o(),a=["outdated","yann-vis-cli","-g"];t&&a.push(`--registry=${t}`);const i=await c("npm",a,{disableColor:!0,stdio:"pipe"});return i.success?!!i.stdout.replace(/\s+/g,""):(e.err(i.message),!1)})(),t=!0),a)})(),l=async()=>{const s=await t([{name:"updateFlag",message:"是否更新Cli工具?",type:"toggle",initial:!0,active:"yes",inactive:"no"}]),{updateFlag:r}=s;r?(await(async()=>{const t=["i","-g","yann-vis-cli"],i=o();i&&t.push(`--registry=${i}`);const s=await c("npm",t,{enableSudo:!0,stdio:"inherit",disableColor:!0});s.success?(console.log(),e.success("Cli工具更新成功!")):a("异常错误,请手动执行命令更新Cli工具:“npm i -g yann-vis-cli”"+(s.message?",错误信息:"+s.message:""))})(),await n(),await i(),a()):await n()};async function u(t){await r()?await l():(await n(),t&&e.success("当前版本已是最新!"))}module.exports={renew:u,checkUpdate:async function(){const{time:e,isExpired:t=!1}=await s();if(t)await u();else if(e<=Date.now()){await r()&&await u()}}};
|