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.
@@ -1 +1 @@
1
- var n=this&&this.__awaiter||function(n,t,i,o){return new(i||(i=Promise))(function(e,c){function r(n){try{u(o.next(n))}catch(n){c(n)}}function a(n){try{u(o.throw(n))}catch(n){c(n)}}function u(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i(function(n){n(t)})).then(r,a)}u((o=o.apply(n,t||[])).next())})};import t from"chalk";import{execPromisified as i,processExit as o,wrapLoading as e}from"../utils/index.js";export default c=>n(void 0,void 0,void 0,function*(){let r="npm install -g ";return c?c.includes("@")?r+=c:r+=`ono-cli@${c}`:r+="ono-cli@latest",e(t.green("šŸ“¦ 曓新中..."),()=>n(void 0,void 0,void 0,function*(){try{yield i(r),o("\n\nšŸš€ ę›“ę–°ęˆåŠŸļ¼\n\n")}catch(n){o(t.red(`\n\nāŒ 曓新失蓄: ${n.message}\n\n`))}}))});
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}});
@@ -1 +1 @@
1
- import{existsSync as o,readFileSync as n,writeFileSync as t}from"fs";import{decode as e,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=e(n(s,"utf-8"));Object.assign(c,o)}else t(s,i(c));return{config:c,configPath:s}};let r=null;export const getCachedConfig=()=>(r||(r=c().config),r);
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}});
@@ -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}`)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ono-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "A CLI tool for ono template",
5
5
  "main": "index.js",
6
6
  "bin": "./bin/index.js",