@tanyueran/cli 0.0.20 → 0.0.22-beta.0

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,a=require("commander"),s=require("prompts"),o=require("node:path"),n=require("fs-extra"),r=require("handlebars");!function(e){e.ViteVueTs="vite-vue-ts",e.WebpackVueTs="webpack-vue-ts"}(e||(e={})),function(e){e.VueTsPageTemplate="vue-ts-page-template",e.VueTsDetailTemplate="vue-ts-detail-template",e.VueTsEmpty="vue-ts-empty"}(t||(t={}));const c=[{label:"vite + vue + ts项目",value:e.ViteVueTs,path:"./src/template/project/vue/vite-vue-ts"},{label:"webpack + vue + ts项目",value:e.WebpackVueTs,path:"./src/template/project/vue/webpack-vue-ts"}],i=[{label:"vue-ts的空模板",value:t.VueTsEmpty,path:"./template/module/vue/vue-ts-empty"}];const l=require("node:path");function p(e){const{targetPath:t,sourcePath:a,templateData:s}=e;if(n.statSync(a).isDirectory()){n.readdirSync(a).forEach(e=>{p({targetPath:l.join(t,e),sourcePath:l.join(a,e),templateData:s})})}else if(a.endsWith(".hbs")){const e=n.readFileSync(a),o=r.compile(e.toString())(s);n.writeFileSync(t.replace(".hbs",""),o)}else n.copyFileSync(a,t)}function m(e){const{targetPath:t,sourcePath:a}=e;if(!n.statSync(a).isDirectory())throw new Error("源文件路劲必须是一个目录");n.existsSync(t)&&n.removeSync(t),n.mkdirSync(t,{recursive:!0}),p(e)}r.registerHelper("toPascalCase",function(e){return function(e){return e&&"string"==typeof e?e.split(/[\s-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(""):e}(e)});const u=require("picocolors"),v=new a.Command;v.name("tx cli").description("一个简单CLI 工具").version("0.0.20"),v.option("-m, --module-name <moduleName>","模块名称").option("-p, --project-name <projectName>","项目名称"),v.command("create").description("创建项目").action(async()=>{let e=v.opts().projectName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入模块名"}]);e=t.name?t.name:"test-project-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:c.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green()),console.log(u.green(t.template)),console.log(u.red("项目模板正在建设中,请稍后"))}),v.command("add").description("添加模块").action(async()=>{let e=v.opts().moduleName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入模块名"}]);e=t.name?t.name:"test-module-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:i.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green("模板名称:"+e)),console.log(u.green("选择模板:"+t.template));const a=i.find(e=>e.value===t.template);m({targetPath:o.resolve(process.cwd(),e),sourcePath:o.resolve(__dirname,a.path),templateData:{name:e}})}),exports.start=function(){v.parse(process.argv)};
1
+ "use strict";var e,t,a=require("commander"),s=require("prompts"),o=require("node:path"),n=require("fs-extra"),r=require("handlebars");!function(e){e.ViteVueTs="vite-vue-ts",e.WebpackVueTs="webpack-vue-ts"}(e||(e={})),function(e){e.VueTsPageTemplate="vue-ts-page-template",e.VueTsDetailTemplate="vue-ts-detail-template",e.VueTsEmpty="vue-ts-empty"}(t||(t={}));const c=[{label:"vite + vue + ts项目",value:e.ViteVueTs,path:"./src/template/project/vue/vite-vue-ts"},{label:"webpack + vue + ts项目",value:e.WebpackVueTs,path:"./src/template/project/vue/webpack-vue-ts"}],i=[{label:"vue-ts的空模板",value:t.VueTsEmpty,path:"./template/module/vue/vue-ts-empty"}];const l=require("node:path");function p(e){const{targetPath:t,sourcePath:a,templateData:s}=e;if(n.statSync(a).isDirectory()){n.readdirSync(a).forEach(e=>{p({targetPath:l.join(t,e),sourcePath:l.join(a,e),templateData:s})})}else if(a.endsWith(".hbs")){const e=n.readFileSync(a),o=r.compile(e.toString())(s);n.writeFileSync(t.replace(".hbs",""),o)}else n.copyFileSync(a,t)}function m(e){const{targetPath:t,sourcePath:a}=e;if(!n.statSync(a).isDirectory())throw new Error("源文件路劲必须是一个目录");n.existsSync(t)&&n.removeSync(t),n.mkdirSync(t,{recursive:!0}),p(e)}r.registerHelper("toPascalCase",function(e){return function(e){return e&&"string"==typeof e?e.split(/[\s-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(""):e}(e)});const u=require("picocolors"),v=new a.Command;v.name("tx cli").description("一个简单CLI 工具").version("0.0.22-beta.0"),v.option("-m, --module-name <moduleName>","模块名称").option("-p, --project-name <projectName>","项目名称"),v.command("create").description("创建项目").action(async()=>{let e=v.opts().projectName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入模块名"}]);e=t.name?t.name:"test-project-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:c.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green()),console.log(u.green(t.template)),console.log(u.red("项目模板正在建设中,请稍后"))}),v.command("add").description("添加模块").action(async()=>{let e=v.opts().moduleName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入模块名"}]);e=t.name?t.name:"test-module-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:i.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green("模板名称:"+e)),console.log(u.green("选择模板:"+t.template));const a=i.find(e=>e.value===t.template);m({targetPath:o.resolve(process.cwd(),e),sourcePath:o.resolve(__dirname,a.path),templateData:{name:e}})}),exports.start=function(){v.parse(process.argv)};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanyueran/cli",
3
- "version": "0.0.20",
4
- "description": "一个cli工具",
3
+ "version": "0.0.22-beta.0",
4
+ "description": "一个cli工具,支持创建项目,添加模版",
5
5
  "main": "./src/index.ts",
6
6
  "bin": {
7
7
  "tx-cli": "./bin/tx-cli"