@tikkhun/create
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -22,2 +22,2 @@ #!/usr/bin/env node | ||
*/ | ||
var p=(t,r,o)=>new Promise((c,l)=>{var a=n=>{try{s(o.next(n));}catch(u){l(u);}},e=n=>{try{s(o.throw(n));}catch(u){l(u);}},s=n=>n.done?c(n.value):Promise.resolve(n.value).then(a,e);s((o=o.apply(t,r)).next());});var{merge:P}=w__default.default,{copy:N,readFile:y,writeFile:E,remove:b,move:F,pathExists:h}=x__default.default,i=new logger.Logger("Creator"),f={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:k}},g=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(r){this.options=P({},f,r);}start(){return p(this,null,function*(){var r,o;try{if(i.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield h(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),i.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield N(this.options.template,this.projectDir,{filter:a=>{if(this.options.template===a)return !0;let e=v(a.replace(/\\/g,"/"),l+"/");if(e){for(let s of this.options.templateExclude)if(minimatch.minimatch(e,s))return !1}return !0}}),i.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(r=this.options.templateFiles)!=null&&r.length){let a=this.options.templateFiles.filter(e=>e);yield Promise.all(a.map(e=>p(this,null,function*(){return yield T(path.join(this.projectDir,e),this.options)})));}if((o=this.options.replaces)!=null&&o.length){let a=this.options.replaces.filter(e=>e?e.sourcePath&&e.targetPath:!1);for(let{sourcePath:e,targetPath:s}of a){i.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s);let n=path.join(this.projectDir,e);if(!(yield h(n))){i.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+e+" =>"+s);continue}yield F(n,path.join(this.projectDir,s)),i.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s);}}i.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){i.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return p(this,null,function*(){i.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield b(this.projectDir),i.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function k(t,r){return [r.prefix,t,r.suffix].join(r.delimiter)}function T(t,r){return p(this,null,function*(){try{i.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t);let o=(yield y(t)).toString();return o=d__default.default.render(o,r),yield E(t,o),i.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!0}catch(o){return i.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!1}})}function v(t,r){return t.startsWith(r)?t.slice(r.length):t}function j(t=16){parseInt(process.version.slice(1))<t?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${t} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}j(12);var R=[{type:"input",name:"projectName",default:f.projectName,message:"\u9879\u76EE\u540D\u79F0"}];function S(){return p(this,null,function*(){let t=yield ___default.default.prompt(R);yield new g(t).start();})}S(); | ||
var p=(t,r,o)=>new Promise((c,l)=>{var a=n=>{try{s(o.next(n));}catch(u){l(u);}},e=n=>{try{s(o.throw(n));}catch(u){l(u);}},s=n=>n.done?c(n.value):Promise.resolve(n.value).then(a,e);s((o=o.apply(t,r)).next());});var{merge:P}=w__default.default,{copy:N,readFile:y,writeFile:E,remove:b,move:F,pathExists:h}=x__default.default,i=new logger.Logger("Creator"),f={workspace:process.cwd(),template:"./templates/default",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:k}},g=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(r){this.options=P({},f,r);}start(){return p(this,null,function*(){var r,o;try{if(i.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield h(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),i.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield N(this.options.template,this.projectDir,{filter:a=>{if(this.options.template===a)return !0;let e=v(a.replace(/\\/g,"/"),l+"/");if(e){for(let s of this.options.templateExclude)if(minimatch.minimatch(e,s))return !1}return !0}}),i.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(r=this.options.templateFiles)!=null&&r.length){let a=this.options.templateFiles.filter(e=>e);yield Promise.all(a.map(e=>p(this,null,function*(){return yield T(path.join(this.projectDir,e),this.options)})));}if((o=this.options.replaces)!=null&&o.length){let a=this.options.replaces.filter(e=>e?e.sourcePath&&e.targetPath:!1);for(let{sourcePath:e,targetPath:s}of a){i.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s);let n=path.join(this.projectDir,e);if(!(yield h(n))){i.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+e+" =>"+s);continue}yield F(n,path.join(this.projectDir,s)),i.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s);}}i.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){i.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return p(this,null,function*(){i.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield b(this.projectDir),i.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function k(t,r){return [r.prefix,t,r.suffix].join(r.delimiter)}function T(t,r){return p(this,null,function*(){try{i.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t);let o=(yield y(t)).toString();return o=d__default.default.render(o,r),yield E(t,o),i.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!0}catch(o){return i.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!1}})}function v(t,r){return t.startsWith(r)?t.slice(r.length):t}function j(t=16){parseInt(process.version.slice(1))<t?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${t} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}j(12);var R=[{type:"input",name:"projectName",default:f.projectName,message:"\u9879\u76EE\u540D\u79F0"}];function S(){return p(this,null,function*(){let t=yield ___default.default.prompt(R);yield new g(t).start();})}S(); |
@@ -21,4 +21,4 @@ #!/usr/bin/env node | ||
*/ | ||
var N=Object.defineProperty,S=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var x=(e,t,i)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,D=(e,t)=>{for(var i in t||(t={}))_.call(t,i)&&x(e,i,t[i]);if(j)for(var i of j(t))L.call(t,i)&&x(e,i,t[i]);return e},w=(e,t)=>S(e,T(t));var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var l=(e,t,i)=>new Promise((p,c)=>{var o=n=>{try{a(i.next(n));}catch(g){c(g);}},r=n=>{try{a(i.throw(n));}catch(g){c(g);}},a=n=>n.done?p(n.value):Promise.resolve(n.value).then(o,r);a((i=i.apply(e,t)).next());});function G(e,t){return [t.prefix,e,t.suffix].join(t.delimiter)}function H(e,t){return l(this,null,function*(){try{s.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e);let i=(yield W(e)).toString();return i=q__default.default.render(i,t),yield $(e,i),s.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e),!0}catch(i){return s.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e),!1}})}function K(e,t){return e.startsWith(t)?e.slice(t.length):e}var U,M,W,$,z,B,P,s,m,d,y=h(()=>{(({merge:U}=I__default.default)),{copy:M,readFile:W,writeFile:$,remove:z,move:B,pathExists:P}=C__default.default,s=new logger.Logger("Creator"),m={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:G}},d=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=U({},m,t);}start(){return l(this,null,function*(){var t,i;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield P(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),s.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let c=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield M(this.options.template,this.projectDir,{filter:o=>{if(this.options.template===o)return !0;let r=K(o.replace(/\\/g,"/"),c+"/");if(r){for(let a of this.options.templateExclude)if(minimatch.minimatch(r,a))return !1}return !0}}),s.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length){let o=this.options.templateFiles.filter(r=>r);yield Promise.all(o.map(r=>l(this,null,function*(){return yield H(path.join(this.projectDir,r),this.options)})));}if((i=this.options.replaces)!=null&&i.length){let o=this.options.replaces.filter(r=>r?r.sourcePath&&r.targetPath:!1);for(let{sourcePath:r,targetPath:a}of o){s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+a);let n=path.join(this.projectDir,r);if(!(yield P(n))){s.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+r+" =>"+a);continue}yield B(n,path.join(this.projectDir,a)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+a);}}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(p){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+p.stack);}})}clear(){return l(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield z(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};});var f,O=h(()=>{f={name:"@tikkhun/create",version:"0.1.3",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};});function E(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${f.name}`),logger.Logger.log("\u7248\u672C: "+f.version);}var F=h(()=>{O();});var V=R(v=>{y();F();E();commander.program.description("\u6253\u5305").option("--template <template>","\u6A21\u677F\u8DEF\u5F84",m.template).option("--templateExclude <templateExclude>","\u4E0D\u5305\u542B\u7684\u4E00\u4E9B\u6587\u4EF6",m.templateExclude.toString()).option("--projectName <projectName>","\u9879\u76EE\u540D",m.projectName).option("--workspace <workspace>","\u6839\u8DEF\u5F84",m.workspace).option("--templateFiles <templateFiles>","\u9700\u6A21\u677F\u66FF\u6362\u7684\u6587\u4EF6",m.templateFiles.toString()).option("--replaces <replaces>","\u66FF\u6362\u540D\u79F0\u7684\u8DEF\u5F84","").action(e=>l(v,null,function*(){let t=w(D({},e),{templateExclude:e.templateExclude.split(","),templateFiles:e.templateFiles.split(","),replaces:e.replaces?e.replaces.split(",").map(p=>{if(!p)return;let[c,o]=p.split("=");if(!(!c||!o))return {sourcePath:c,targetPath:o}}):[]});yield new d(t).start();}));commander.program.parse(process.argv);});var cli = V(); | ||
var N=Object.defineProperty,S=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var x=(e,t,i)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,D=(e,t)=>{for(var i in t||(t={}))_.call(t,i)&&x(e,i,t[i]);if(j)for(var i of j(t))L.call(t,i)&&x(e,i,t[i]);return e},w=(e,t)=>S(e,T(t));var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var l=(e,t,i)=>new Promise((p,c)=>{var o=n=>{try{a(i.next(n));}catch(g){c(g);}},r=n=>{try{a(i.throw(n));}catch(g){c(g);}},a=n=>n.done?p(n.value):Promise.resolve(n.value).then(o,r);a((i=i.apply(e,t)).next());});function G(e,t){return [t.prefix,e,t.suffix].join(t.delimiter)}function H(e,t){return l(this,null,function*(){try{s.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e);let i=(yield W(e)).toString();return i=q__default.default.render(i,t),yield $(e,i),s.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e),!0}catch(i){return s.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+e),!1}})}function K(e,t){return e.startsWith(t)?e.slice(t.length):e}var U,M,W,$,z,B,P,s,m,d,y=h(()=>{(({merge:U}=I__default.default)),{copy:M,readFile:W,writeFile:$,remove:z,move:B,pathExists:P}=C__default.default,s=new logger.Logger("Creator"),m={workspace:process.cwd(),template:"./templates/default",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:G}},d=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=U({},m,t);}start(){return l(this,null,function*(){var t,i;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield P(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),s.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let c=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield M(this.options.template,this.projectDir,{filter:o=>{if(this.options.template===o)return !0;let r=K(o.replace(/\\/g,"/"),c+"/");if(r){for(let a of this.options.templateExclude)if(minimatch.minimatch(r,a))return !1}return !0}}),s.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length){let o=this.options.templateFiles.filter(r=>r);yield Promise.all(o.map(r=>l(this,null,function*(){return yield H(path.join(this.projectDir,r),this.options)})));}if((i=this.options.replaces)!=null&&i.length){let o=this.options.replaces.filter(r=>r?r.sourcePath&&r.targetPath:!1);for(let{sourcePath:r,targetPath:a}of o){s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+a);let n=path.join(this.projectDir,r);if(!(yield P(n))){s.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+r+" =>"+a);continue}yield B(n,path.join(this.projectDir,a)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+a);}}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(p){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+p.stack);}})}clear(){return l(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield z(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};});var f,O=h(()=>{f={name:"@tikkhun/create",version:"0.1.5",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};});function E(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${f.name}`),logger.Logger.log("\u7248\u672C: "+f.version);}var F=h(()=>{O();});var V=R(v=>{y();F();E();commander.program.description("\u6253\u5305").option("--template <template>","\u6A21\u677F\u8DEF\u5F84",m.template).option("--templateExclude <templateExclude>","\u4E0D\u5305\u542B\u7684\u4E00\u4E9B\u6587\u4EF6",m.templateExclude.toString()).option("--projectName <projectName>","\u9879\u76EE\u540D",m.projectName).option("--workspace <workspace>","\u6839\u8DEF\u5F84",m.workspace).option("--templateFiles <templateFiles>","\u9700\u6A21\u677F\u66FF\u6362\u7684\u6587\u4EF6",m.templateFiles.toString()).option("--replaces <replaces>","\u66FF\u6362\u540D\u79F0\u7684\u8DEF\u5F84","").action(e=>l(v,null,function*(){let t=w(D({},e),{templateExclude:e.templateExclude.split(","),templateFiles:e.templateFiles.split(","),replaces:e.replaces?e.replaces.split(",").map(p=>{if(!p)return;let[c,o]=p.split("=");if(!(!c||!o))return {sourcePath:c,targetPath:o}}):[]});yield new d(t).start();}));commander.program.parse(process.argv);});var cli = V(); | ||
module.exports = cli; |
@@ -19,5 +19,5 @@ 'use strict'; | ||
*/ | ||
var p=(i,e,o)=>new Promise((c,l)=>{var a=n=>{try{s(o.next(n));}catch(g){l(g);}},t=n=>{try{s(o.throw(n));}catch(g){l(g);}},s=n=>n.done?c(n.value):Promise.resolve(n.value).then(a,t);s((o=o.apply(i,e)).next());});var {merge:w}=d__default.default,{copy:O,readFile:P,writeFile:E,remove:y,move:F,pathExists:h}=D__default.default,r=new logger.Logger("Creator"),b={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:N}},u=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(e){this.options=w({},b,e);}start(){return p(this,null,function*(){var e,o;try{if(r.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield h(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),r.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield O(this.options.template,this.projectDir,{filter:a=>{if(this.options.template===a)return !0;let t=T(a.replace(/\\/g,"/"),l+"/");if(t){for(let s of this.options.templateExclude)if(minimatch.minimatch(t,s))return !1}return !0}}),r.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(e=this.options.templateFiles)!=null&&e.length){let a=this.options.templateFiles.filter(t=>t);yield Promise.all(a.map(t=>p(this,null,function*(){return yield k(path.join(this.projectDir,t),this.options)})));}if((o=this.options.replaces)!=null&&o.length){let a=this.options.replaces.filter(t=>t?t.sourcePath&&t.targetPath:!1);for(let{sourcePath:t,targetPath:s}of a){r.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+s);let n=path.join(this.projectDir,t);if(!(yield h(n))){r.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+t+" =>"+s);continue}yield F(n,path.join(this.projectDir,s)),r.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+s);}}r.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){r.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return p(this,null,function*(){r.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield y(this.projectDir),r.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function N(i,e){return [e.prefix,i,e.suffix].join(e.delimiter)}function k(i,e){return p(this,null,function*(){try{r.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i);let o=(yield P(i)).toString();return o=f__default.default.render(o,e),yield E(i,o),r.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i),!0}catch(o){return r.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i),!1}})}function T(i,e){return i.startsWith(e)?i.slice(e.length):i} | ||
var p=(i,e,o)=>new Promise((c,l)=>{var a=n=>{try{s(o.next(n));}catch(g){l(g);}},t=n=>{try{s(o.throw(n));}catch(g){l(g);}},s=n=>n.done?c(n.value):Promise.resolve(n.value).then(a,t);s((o=o.apply(i,e)).next());});var {merge:w}=d__default.default,{copy:O,readFile:P,writeFile:E,remove:y,move:F,pathExists:h}=D__default.default,r=new logger.Logger("Creator"),b={workspace:process.cwd(),template:"./templates/default",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:N}},u=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(e){this.options=w({},b,e);}start(){return p(this,null,function*(){var e,o;try{if(r.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield h(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),r.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield O(this.options.template,this.projectDir,{filter:a=>{if(this.options.template===a)return !0;let t=T(a.replace(/\\/g,"/"),l+"/");if(t){for(let s of this.options.templateExclude)if(minimatch.minimatch(t,s))return !1}return !0}}),r.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(e=this.options.templateFiles)!=null&&e.length){let a=this.options.templateFiles.filter(t=>t);yield Promise.all(a.map(t=>p(this,null,function*(){return yield k(path.join(this.projectDir,t),this.options)})));}if((o=this.options.replaces)!=null&&o.length){let a=this.options.replaces.filter(t=>t?t.sourcePath&&t.targetPath:!1);for(let{sourcePath:t,targetPath:s}of a){r.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+s);let n=path.join(this.projectDir,t);if(!(yield h(n))){r.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+t+" =>"+s);continue}yield F(n,path.join(this.projectDir,s)),r.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+s);}}r.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){r.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return p(this,null,function*(){r.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield y(this.projectDir),r.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function N(i,e){return [e.prefix,i,e.suffix].join(e.delimiter)}function k(i,e){return p(this,null,function*(){try{r.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i);let o=(yield P(i)).toString();return o=f__default.default.render(o,e),yield E(i,o),r.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i),!0}catch(o){return r.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+i),!1}})}function T(i,e){return i.startsWith(e)?i.slice(e.length):i} | ||
exports.Creator = u; | ||
exports.DEFAULT_OPTIONS = b; |
@@ -19,3 +19,3 @@ 'use strict'; | ||
*/ | ||
var a=(t,i,r)=>new Promise((c,l)=>{var p=n=>{try{o(r.next(n));}catch(d){l(d);}},e=n=>{try{o(r.throw(n));}catch(d){l(d);}},o=n=>n.done?c(n.value):Promise.resolve(n.value).then(p,e);o((r=r.apply(t,i)).next());});var {merge:P}=w__default.default,{copy:O,readFile:k,writeFile:b,remove:v,move:E,pathExists:u}=D__default.default,s=new logger.Logger("Creator"),N={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:F}},f=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(i){this.options=P({},N,i);}start(){return a(this,null,function*(){var i,r;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield u(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),s.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield O(this.options.template,this.projectDir,{filter:p=>{if(this.options.template===p)return !0;let e=R(p.replace(/\\/g,"/"),l+"/");if(e){for(let o of this.options.templateExclude)if(minimatch.minimatch(e,o))return !1}return !0}}),s.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(i=this.options.templateFiles)!=null&&i.length){let p=this.options.templateFiles.filter(e=>e);yield Promise.all(p.map(e=>a(this,null,function*(){return yield T(path.join(this.projectDir,e),this.options)})));}if((r=this.options.replaces)!=null&&r.length){let p=this.options.replaces.filter(e=>e?e.sourcePath&&e.targetPath:!1);for(let{sourcePath:e,targetPath:o}of p){s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+o);let n=path.join(this.projectDir,e);if(!(yield u(n))){s.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+e+" =>"+o);continue}yield E(n,path.join(this.projectDir,o)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+o);}}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return a(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield v(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function F(t,i){return [i.prefix,t,i.suffix].join(i.delimiter)}function T(t,i){return a(this,null,function*(){try{s.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t);let r=(yield k(t)).toString();return r=x__default.default.render(r,i),yield b(t,r),s.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!0}catch(r){return s.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!1}})}function R(t,i){return t.startsWith(i)?t.slice(i.length):t}function U(t="",i,r){}function W(t=16){parseInt(process.version.slice(1))<t?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${t} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}var g={name:"@tikkhun/create",version:"0.1.3",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};function K(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${g.name}`),logger.Logger.log("\u7248\u672C: "+g.version);} | ||
var a=(t,i,r)=>new Promise((c,l)=>{var p=n=>{try{o(r.next(n));}catch(d){l(d);}},e=n=>{try{o(r.throw(n));}catch(d){l(d);}},o=n=>n.done?c(n.value):Promise.resolve(n.value).then(p,e);o((r=r.apply(t,i)).next());});var {merge:P}=w__default.default,{copy:O,readFile:k,writeFile:b,remove:v,move:E,pathExists:u}=D__default.default,s=new logger.Logger("Creator"),N={workspace:process.cwd(),template:"./templates/default",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json","README.md"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:F}},f=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(i){this.options=P({},N,i);}start(){return a(this,null,function*(){var i,r;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield u(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),s.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"/").replace(/^\.\//,"");if(yield O(this.options.template,this.projectDir,{filter:p=>{if(this.options.template===p)return !0;let e=R(p.replace(/\\/g,"/"),l+"/");if(e){for(let o of this.options.templateExclude)if(minimatch.minimatch(e,o))return !1}return !0}}),s.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(i=this.options.templateFiles)!=null&&i.length){let p=this.options.templateFiles.filter(e=>e);yield Promise.all(p.map(e=>a(this,null,function*(){return yield T(path.join(this.projectDir,e),this.options)})));}if((r=this.options.replaces)!=null&&r.length){let p=this.options.replaces.filter(e=>e?e.sourcePath&&e.targetPath:!1);for(let{sourcePath:e,targetPath:o}of p){s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+o);let n=path.join(this.projectDir,e);if(!(yield u(n))){s.log("[\u51FA\u9519] \u8FC1\u79FB\u6587\u4EF6,\u4F46\u6587\u4EF6\u4E0D\u5B58\u5728 "+e+" =>"+o);continue}yield E(n,path.join(this.projectDir,o)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+o);}}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return a(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield v(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function F(t,i){return [i.prefix,t,i.suffix].join(i.delimiter)}function T(t,i){return a(this,null,function*(){try{s.debug("[\u5F00\u59CB] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t);let r=(yield k(t)).toString();return r=x__default.default.render(r,i),yield b(t,r),s.debug("[\u5B8C\u6BD5] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!0}catch(r){return s.error("[\u9519\u8BEF] \u66FF\u6362\u6A21\u677F\u6587\u672C "+t),!1}})}function R(t,i){return t.startsWith(i)?t.slice(i.length):t}function U(t="",i,r){}function W(t=16){parseInt(process.version.slice(1))<t?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${t} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}var g={name:"@tikkhun/create",version:"0.1.5",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};function K(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${g.name}`),logger.Logger.log("\u7248\u672C: "+g.version);} | ||
@@ -22,0 +22,0 @@ exports.Creator = f; |
@@ -8,4 +8,4 @@ 'use strict'; | ||
*/ | ||
var e={name:"@tikkhun/create",version:"0.1.3",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};function o(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${e.name}`),logger.Logger.log("\u7248\u672C: "+e.version);} | ||
var e={name:"@tikkhun/create",version:"0.1.5",description:"",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",bin:{"tikkhun-create":"./dist/cli.js"},exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{default:"./dist/index.js",types:"./dist/index.d.ts"}}},files:["dist","template"],scripts:{build:"tsup",dev:"ts-node ./lib/cli.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",devDependencies:{"@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.7","@types/lodash":"^4.17.4","@types/node":"^20.14.2","ts-node":"^10.9.1",tsup:"^8.0.2",vitest:"^1.3.1"},dependencies:{"@tikkhun/logger":"^1.0.6",commander:"^12.1.0",ejs:"^3.1.10","fs-extra":"^11.2.0",inquirer:"^9.2.23",lodash:"^4.17.21",minimatch:"^9.0.4"}};function o(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${e.name}`),logger.Logger.log("\u7248\u672C: "+e.version);} | ||
exports.echoPackage = o; |
{ | ||
"name": "@tikkhun/create", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43525
30