ono-cli 0.1.5 ā 0.1.6
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/bin/commands/update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=this&&this.__awaiter||function(n,t,
|
|
1
|
+
var n=this&&this.__awaiter||function(n,i,t,e){return new(t||(t=Promise))(function(o,r){function d(n){try{a(e.next(n))}catch(n){r(n)}}function s(n){try{a(e.throw(n))}catch(n){r(n)}}function a(n){var i;n.done?o(n.value):(i=n.value,i instanceof t?i:new t(function(n){n(i)})).then(d,s)}a((e=e.apply(n,i||[])).next())})};import i from"chalk";import t from"inquirer";import e from"../pkg.js";import{checkRemotePackageHasVersion as o,compareVersions as r,execPromisified as d,getRemotePackageLatestVersion as s,processExit as a,versionCompare as c,wrapLoading as f}from"../utils/index.js";const u=t=>n(void 0,void 0,void 0,function*(){if(!(yield o(e.name,t)))return a(i.red("\n\nā ę²”ęę¾å°ęå®ēēę¬ļ¼čÆ·č¾å
„ę£ē”®ēēę¬å·ļ¼\n\n"))}),v=(i,t)=>n(void 0,void 0,void 0,function*(){if("latest"===i)return m(t);yield u(i);const n=r(e.version,i);-1===n?m(t):0===n?a("\n\nš ęå®ēę¬äøŗå½åēę¬ļ¼\n\n"):l(t)}),l=i=>n(void 0,void 0,void 0,function*(){const{isUpdate:n}=yield t.prompt([{name:"isUpdate",type:"confirm",message:"å½åå·²å®č£
ēēę¬č¾ę°ć 甮认č¦åę¢/åéå°ęå®ēę§ēę¬åļ¼"}]);n?m(i):a()}),m=t=>n(void 0,void 0,void 0,function*(){return f(i.green("š¦ ę“ę°äø..."),()=>n(void 0,void 0,void 0,function*(){try{yield d(t),a("\n\nš ę“ę°ęåļ¼\n\n")}catch(n){a(i.red(`\n\nā ę“ę°å¤±č“„: ${n.message}\n\n`))}}))});export default t=>n(void 0,void 0,void 0,function*(){let n="npm install -g ";if(t)if(t.includes("@")){const o=t.split("@");if(n+=t,o[0]!==e.name)return a(i.red("\n\nā 请č¾å
„ę£ē”®ēå
åļ¼\n\n"));v(o[1],n)}else{if(n+=`${e.name}@${t}`,"latest"===t)return m(n);v(t,n)}else{n=n+e.name+"@latest";const i=yield s(e.name);if(c(e.version,i,"<"))return m(n);a("\n\nš å½åēę¬äøŗęę°ēę¬ļ¼\n\n")}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=this&&this.__awaiter||function(t,n,e,o){return new(e||(e=Promise))(function(r,c){function i(t){try{s(o.next(t))}catch(t){c(t)}}function a(t){try{s(o.throw(t))}catch(t){c(t)}}function s(t){var n;t.done?r(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(i,a)}s((o=o.apply(t,n||[])).next())})};import n from"ono-fetch";export const checkRemotePackageHasVersion=(e,o)=>t(void 0,void 0,void 0,function*(){try{return 200===(yield n.get(`https://registry.npmjs.org/${e}/${o}`)).status}catch(t){return console.error(`ę£ę„čæēØå
${e} ēę¬ ${o} ååØę§å¤±č“„:`,t.message),!1}});
|
package/bin/utils/getConfig.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as o,readFileSync as
|
|
1
|
+
import{existsSync as o,readFileSync as t,writeFileSync as e}from"fs";import{decode as n,encode as i}from"ini";import{configPath as s}from"../common/index.js";export const baseConfig={username:"",organization:"",access_token:"",repo:"github",mode:"template"};const c=()=>{const c=Object.assign({},baseConfig);if(o(s)){const o=n(t(s,"utf-8"));Object.assign(c,o)}else e(s,i(c));return{config:c,configPath:s}};let r=null;export const getCachedConfig=()=>(r||(r=c()),r);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}s((o=o.apply(t,e||[])).next())})};import e from"ono-fetch";export const getRemotePackageLatestVersion=n=>t(void 0,void 0,void 0,function*(){try{return(yield e.get(`https://registry.npmjs.org/${n}/latest`)).data.version||"0.0.0"}catch(t){throw console.error(`č·åčæēØå
${n} ēę¬å¤±č“„:`,t.message),t}});
|
package/bin/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./execPromisified.js";export*from"./getConfig.js";export*from"./loading.js";export*from"./processExit.js";
|
|
1
|
+
export*from"./checkRemotePackageHasVersion.js";export*from"./execPromisified.js";export*from"./getConfig.js";export*from"./getRemotePackageLatestVersion.js";export*from"./loading.js";export*from"./processExit.js";export*from"./versionCompare.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){const r=e.replace(/^[^0-9]+/,"").split(".");for(;r.length<3;)r.push("0");return r.slice(0,3).join(".")}export function compareVersions(r,t){const n=e(r),s=e(t),o=n.split(".").map(Number),c=s.split(".").map(Number),u=Math.max(o.length,c.length);for(let e=0;e<u;e++){const r=e<o.length?o[e]:0,t=e<c.length?c[e]:0;if(r>t)return 1;if(r<t)return-1}return 0}export function versionCompare(e,r,t){const n=compareVersions(e,r);switch(t){case">":return n>0;case">=":return n>=0;case"<":return n<0;case"<=":return n<=0;case"=":case"==":return 0===n;case"!=":return 0!==n;default:throw new Error(`äøęÆęēęä½ē¬¦: ${t}`)}}
|