yezz-cli 0.0.4 → 0.0.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/README.md CHANGED
@@ -24,6 +24,12 @@ yarn global add yezz-cli
24
24
 
25
25
  ## 🚀 使用
26
26
 
27
+ ### 🔄 更新
28
+
29
+ ```bash
30
+ yezz update
31
+ ```
32
+
27
33
  ### 🔖 查看版本
28
34
 
29
35
  ```bash
@@ -0,0 +1,2 @@
1
+ export default function update(): Promise<void>;
2
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/command/update.ts"],"names":[],"mappings":"AAcA,wBAA8B,MAAM,kBAsBnC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as e}from"commander";import{input as o,select as r}from"@inquirer/prompts";import t from"axios";import n from"chalk";import a from"fs-extra";import i from"lodash";import s from"node:path";import c from"progress-estimator";import l from"simple-git";var m="0.0.2";const p=e=>String(e??""),g={info(e){console.log(n.cyan(p(e)))},success(e){console.log(n.green(`√ ${p(e)}`))},warn(e){console.log(n.yellow(`! ${p(e)}`))},error(e){console.error(n.red(`× ${p(e)}`))}},u=c({spinner:{interval:300,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(e=>n.blue(e))}}),d={baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:6},w=new Map([["Vite4-Vue3-Typescript-template",{name:"admin-template",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术栈开发模板",branch:"dev11"}],["Vite-temp",{name:"admin-template",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术栈开发模板",branch:"dev10"}]]),y=async e=>{const{data:o}=await(async e=>{const o="https://registry.npmjs.org/"+e;let r={};try{r=await t.get(o)}catch(e){g.error(e)}return r})(e);return o["dist-tags"].latest};async function f(e){const t=[...w.entries()].map(e=>{const[o,r]=e;return{name:o,value:o,description:r.description}});e||(e=await o({message:"请输入项目名称"}));const c=s.resolve(process.cwd(),e);if(a.existsSync(c)){if(!await(async e=>(g.warn(`${e} 文件已存在 !`),r({message:"是否覆盖原文件: ",choices:[{name:"覆盖",value:!0},{name:"取消",value:!1}]})))(e))return;await a.remove(c)}const p=await r({message:"请选择模板",choices:t});await(async(e,o)=>{const r=await y(e),t=i.gt(r,o);return t?(g.info(`检测到 yezz 最新版:${n.blueBright(r)} 当前版本:${n.blueBright(o)} ~`),g.info(`可使用 ${n.yellow("pnpm")} install yezz-cli@latest 更新 ~`)):g.info(`当前已是最新版本 ${n.blueBright(o)} ~`),t})("yezz-cli",m);const f=w.get(p);f?await(async(e,o,r)=>{const t=l(d);try{await u(t.clone(e,o,r),"代码下载中: ",{estimate:8e3}),console.log(),console.log(n.blueBright("==================================")),console.log(n.blueBright("=== 欢迎使用 yezz-cli 脚手架 ===")),console.log(n.blueBright("==================================")),console.log(),g.success(`项目创建成功 ${n.blueBright(o)}`),g.success("执行以下命令启动项目:"),g.info(`cd ${n.blueBright(o)}`),g.info(`${n.yellow("pnpm")} install`),g.info(`${n.yellow("pnpm")} run dev`)}catch(e){g.error("下载失败"),g.error(String(e))}})(f.downloadUrl,e,["-b",`${f.branch}`]):g.error(`${p} 模板不存在`)}const h=new e("yezz");h.version(m,"-v, --version"),h.command("create").description("create a new project").argument("[name]","项目名称").action(async e=>{await f(e)}),h.parse();
2
+ import{Command as e}from"commander";import{input as o,select as r}from"@inquirer/prompts";import t from"axios";import n from"chalk";import a from"fs-extra";import i from"lodash";import s from"node:path";import c from"progress-estimator";import l from"simple-git";import{exec as m}from"node:child_process";import p from"ora";var g="0.0.5";const d=e=>String(e??""),u={info(e){console.log(n.cyan(d(e)))},success(e){console.log(n.green(`√ ${d(e)}`))},warn(e){console.log(n.yellow(`! ${d(e)}`))},error(e){console.error(n.red(`× ${d(e)}`))}},w=c({spinner:{interval:300,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(e=>n.blue(e))}}),y={baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:6},f=new Map([["Vite4-Vue3-Typescript-template",{name:"admin-template",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术栈开发模板",branch:"dev11"}],["Vite-temp",{name:"admin-template",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术栈开发模板",branch:"dev10"}]]),h=async e=>{const{data:o}=await(async e=>{const o="https://registry.npmjs.org/"+e;let r={};try{r=await t.get(o)}catch(e){u.error(e)}return r})(e);return o["dist-tags"].latest};async function b(e){const t=[...f.entries()].map(e=>{const[o,r]=e;return{name:o,value:o,description:r.description}});e||(e=await o({message:"请输入项目名称"}));const c=s.resolve(process.cwd(),e);if(a.existsSync(c)){if(!await(async e=>(u.warn(`${e} 文件已存在 !`),r({message:"是否覆盖原文件: ",choices:[{name:"覆盖",value:!0},{name:"取消",value:!1}]})))(e))return;await a.remove(c)}const m=await r({message:"请选择模板",choices:t});await(async(e,o)=>{const r=await h(e),t=i.gt(r,o);return t?(u.info(`检测到 yezz 最新版:${n.blueBright(r)} 当前版本:${n.blueBright(o)} ~`),u.info(`可使用 ${n.yellow("pnpm")} install yezz-cli@latest 更新 ~`)):u.info(`当前已是最新版本 ${n.blueBright(o)} ~`),t})("yezz-cli",g);const p=f.get(m);p?await(async(e,o,r)=>{const t=l(y);try{await w(t.clone(e,o,r),"代码下载中: ",{estimate:8e3}),console.log(),console.log(n.blueBright("==================================")),console.log(n.blueBright("=== 欢迎使用 yezz-cli 脚手架 ===")),console.log(n.blueBright("==================================")),console.log(),u.success(`项目创建成功 ${n.blueBright(o)}`),u.success("执行以下命令启动项目:"),u.info(`cd ${n.blueBright(o)}`),u.info(`${n.yellow("pnpm")} install`),u.info(`${n.yellow("pnpm")} run dev`)}catch(e){u.error("下载失败"),u.error(String(e))}})(p.downloadUrl,e,["-b",`${p.branch}`]):u.error(`${m} 模板不存在`)}const z=p({text:"yezz-cli 正在更新中...",spinner:{interval:300,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(e=>n.blue(e))}});const v=new e("yezz");v.version(g,"-v, --version"),v.command("update").description("更新 yezz 至最新版本").action(async()=>{await async function(){z.start();try{await new Promise((e,o)=>{m("npm install yezz-cli@latest -g",{timeout:12e4},(r,t,n)=>{r?o(new Error(n||r.message)):e()})}),z.succeed("更新成功!")}catch(e){z.fail("更新失败,请稍后重试"),console.error(n.red(String(e)))}}()}),v.command("create").description("create a new project").argument("[name]","项目名称").action(async e=>{await b(e)}),v.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yezz-cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "yezz-cli is a command line tool for scaffolding projects.",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -42,6 +42,7 @@
42
42
  "commander": "^14.0.3",
43
43
  "fs-extra": "^11.3.5",
44
44
  "lodash": "^4.18.1",
45
+ "ora": "^9.4.0",
45
46
  "progress-estimator": "^0.3.1",
46
47
  "simple-git": "^3.36.0"
47
48
  }