Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tikkhun/create

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tikkhun/create - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

17

dist/cli-question.js
#!/usr/bin/env node
'use strict';
var T = require('inquirer');
var v = require('inquirer');
var path = require('path');
var j = require('ejs');
var d = require('ejs');
var logger = require('@tikkhun/logger');
var D = require('fs-extra');
var x = require('lodash');
var w = require('lodash');
var minimatch = require('minimatch');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var T__default = /*#__PURE__*/_interopDefault(T);
var j__default = /*#__PURE__*/_interopDefault(j);
var v__default = /*#__PURE__*/_interopDefault(v);
var d__default = /*#__PURE__*/_interopDefault(d);
var D__default = /*#__PURE__*/_interopDefault(D);
var x__default = /*#__PURE__*/_interopDefault(x);
var w__default = /*#__PURE__*/_interopDefault(w);
/**
@tikkhun/create-tools
@tikkhun/create
*/
var a=(e,t,i)=>new Promise((c,l)=>{var o=p=>{try{s(i.next(p));}catch(g){l(g);}},r=p=>{try{s(i.throw(p));}catch(g){l(g);}},s=p=>p.done?c(p.value):Promise.resolve(p.value).then(o,r);s((i=i.apply(e,t)).next());});var{merge:w}=x__default.default,{copy:O,readFile:N,writeFile:P,remove:y,move:E,pathExists:F}=D__default.default,n=new logger.Logger("Creator"),h={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:b}},f=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=w({},h,t);}start(){return a(this,null,function*(){var t,i;try{if(n.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield F(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),n.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"\\");if(yield O(this.options.template,this.projectDir,{filter:o=>{var s;if(this.options.template===o)return !0;let r=(s=o.split(l))==null?void 0:s[1];if(r){for(let p of this.options.templateExclude)if(r.includes(p))return !1}return !0}}),n.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let o of this.options.templateFiles)o&&(n.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+o),yield k(path.join(this.projectDir,o),this.options),n.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+o));if((i=this.options.replaces)!=null&&i.length){let o=this.options.replaces.filter(r=>r);for(let{sourcePath:r,targetPath:s}of o)!r||!s||(n.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+s),yield E(path.join(this.projectDir,r),path.join(this.projectDir,s)),n.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+s));}n.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){n.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return a(this,null,function*(){n.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield y(this.projectDir),n.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function b(e,t){return [t.prefix,e,t.suffix].join(t.delimiter)}function k(e,t){return a(this,null,function*(){let i=(yield N(e)).toString();i=j__default.default.render(i,t),yield P(e,i);})}function u(e=16){parseInt(process.version.slice(1))<e?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${e} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}u(12);var v=[{type:"input",name:"projectName",default:h.projectName,message:"\u9879\u76EE\u540D\u79F0"}];function S(){return a(this,null,function*(){let e=yield T__default.default.prompt(v);yield new f(e).start();})}S();
var a=(i,t,o)=>new Promise((c,l)=>{var r=p=>{try{s(o.next(p));}catch(f){l(f);}},e=p=>{try{s(o.throw(p));}catch(f){l(f);}},s=p=>p.done?c(p.value):Promise.resolve(p.value).then(r,e);s((o=o.apply(i,t)).next());});var{merge:O}=w__default.default,{copy:P,readFile:N,writeFile:y,remove:E,move:F,pathExists:b}=D__default.default,n=new logger.Logger("Creator"),g={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:k}},h=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=O({},g,t);}start(){return a(this,null,function*(){var t,o;try{if(n.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield b(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),n.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"\\");if(yield P(this.options.template,this.projectDir,{filter:r=>{var s;if(this.options.template===r)return !0;let e=(s=r.split(l))==null?void 0:s[1].replace(/\\/g,"/");if(console.log("theRelativePath",e),e){for(let p of this.options.templateExclude)if(console.log("minimatch(theRelativePath, exclude)",minimatch.minimatch(e,p)),minimatch.minimatch(e,p))return !1}return !0}}),n.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let r of this.options.templateFiles)r&&(n.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+r),yield T(path.join(this.projectDir,r),this.options),n.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+r));if((o=this.options.replaces)!=null&&o.length){let r=this.options.replaces.filter(e=>e);for(let{sourcePath:e,targetPath:s}of r)!e||!s||(n.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s),yield F(path.join(this.projectDir,e),path.join(this.projectDir,s)),n.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+s));}n.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(c){n.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+c.stack);}})}clear(){return a(this,null,function*(){n.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield E(this.projectDir),n.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function k(i,t){return [t.prefix,i,t.suffix].join(t.delimiter)}function T(i,t){return a(this,null,function*(){let o=(yield N(i)).toString();o=d__default.default.render(o,t),yield y(i,o);})}function j(i=16){parseInt(process.version.slice(1))<i?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${i} \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:g.projectName,message:"\u9879\u76EE\u540D\u79F0"}];function S(){return a(this,null,function*(){let i=yield v__default.default.prompt(R);yield new h(i).start();})}S();

@@ -8,3 +8,4 @@ #!/usr/bin/env node

var I = require('fs-extra');
var R = require('lodash');
var A = require('lodash');
var minimatch = require('minimatch');
var commander = require('commander');

@@ -16,9 +17,9 @@

var I__default = /*#__PURE__*/_interopDefault(I);
var R__default = /*#__PURE__*/_interopDefault(R);
var A__default = /*#__PURE__*/_interopDefault(A);
/**
@tikkhun/create-tools
@tikkhun/create
*/
var v=Object.defineProperty,N=Object.defineProperties;var S=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var x=(e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,D=(e,t)=>{for(var i in t||(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)=>N(e,S(t));var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var m=(e,t,i)=>new Promise((a,l)=>{var r=n=>{try{o(i.next(n));}catch(u){l(u);}},s=n=>{try{o(i.throw(n));}catch(u){l(u);}},o=n=>n.done?a(n.value):Promise.resolve(n.value).then(r,s);o((i=i.apply(e,t)).next());});function H(e,t){return [t.prefix,e,t.suffix].join(t.delimiter)}function K(e,t){return m(this,null,function*(){let i=(yield U(e)).toString();i=q__default.default.render(i,t),yield $(e,i);})}var A,J,U,$,z,B,G,p,c,g,y=f(()=>{(({merge:A}=R__default.default)),{copy:J,readFile:U,writeFile:$,remove:z,move:B,pathExists:G}=I__default.default,p=new logger.Logger("Creator"),c={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:H}},g=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=A({},c,t);}start(){return m(this,null,function*(){var t,i;try{if(p.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield G(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),p.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"\\");if(yield J(this.options.template,this.projectDir,{filter:r=>{var o;if(this.options.template===r)return !0;let s=(o=r.split(l))==null?void 0:o[1];if(s){for(let n of this.options.templateExclude)if(s.includes(n))return !1}return !0}}),p.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let r of this.options.templateFiles)r&&(p.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+r),yield K(path.join(this.projectDir,r),this.options),p.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+r));if((i=this.options.replaces)!=null&&i.length){let r=this.options.replaces.filter(s=>s);for(let{sourcePath:s,targetPath:o}of r)!s||!o||(p.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+s+" => "+o),yield B(path.join(this.projectDir,s),path.join(this.projectDir,o)),p.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+s+" => "+o));}p.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){p.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return m(this,null,function*(){p.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield z(this.projectDir),p.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};});var h,O=f(()=>{h={name:"@tikkhun/create-tools",version:"0.1.0",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"}};});function P(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${h.name}`),logger.Logger.log("\u7248\u672C: "+h.version);}var E=f(()=>{O();});var Q=_(b=>{y();E();P();commander.program.description("\u6253\u5305").option("--template <template>","\u6A21\u677F\u8DEF\u5F84",c.template).option("--templateExclude <templateExclude>","\u4E0D\u5305\u542B\u7684\u4E00\u4E9B\u6587\u4EF6",c.templateExclude.toString()).option("--projectName <projectName>","\u9879\u76EE\u540D",c.projectName).option("--workspace <workspace>","\u6839\u8DEF\u5F84",c.workspace).option("--templateFiles <templateFiles>","\u9700\u6A21\u677F\u66FF\u6362\u7684\u6587\u4EF6",c.templateFiles.toString()).option("--replaces <replaces>","\u66FF\u6362\u540D\u79F0\u7684\u8DEF\u5F84","").action(e=>m(b,null,function*(){let t=w(D({},e),{templateExclude:e.templateExclude.split(","),templateFiles:e.templateFiles.split(","),replaces:e.replaces?e.replaces.split(",").map(a=>{if(!a)return;let[l,r]=a.split("=");if(!(!l||!r))return {sourcePath:l,targetPath:r}}):[]});yield new g(t).start();}));commander.program.parse(process.argv);});var cli = Q();
var N=Object.defineProperty,S=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var R=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={}))R.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 u=(e,t)=>()=>(e&&(t=e(e=0)),t);var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var m=(e,t,i)=>new Promise((a,l)=>{var r=n=>{try{o(i.next(n));}catch(h){l(h);}},s=n=>{try{o(i.throw(n));}catch(h){l(h);}},o=n=>n.done?a(n.value):Promise.resolve(n.value).then(r,s);o((i=i.apply(e,t)).next());});function K(e,t){return [t.prefix,e,t.suffix].join(t.delimiter)}function M(e,t){return m(this,null,function*(){let i=(yield $(e)).toString();i=q__default.default.render(i,t),yield z(e,i);})}var J,U,$,z,B,G,H,p,c,g,y=u(()=>{(({merge:J}=A__default.default)),{copy:U,readFile:$,writeFile:z,remove:B,move:G,pathExists:H}=I__default.default,p=new logger.Logger("Creator"),c={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],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(t){this.options=J({},c,t);}start(){return m(this,null,function*(){var t,i;try{if(p.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(),p.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let l=this.options.template.replace(/\\\\/g,"\\");if(yield U(this.options.template,this.projectDir,{filter:r=>{var o;if(this.options.template===r)return !0;let s=(o=r.split(l))==null?void 0:o[1].replace(/\\/g,"/");if(console.log("theRelativePath",s),s){for(let n of this.options.templateExclude)if(console.log("minimatch(theRelativePath, exclude)",minimatch.minimatch(s,n)),minimatch.minimatch(s,n))return !1}return !0}}),p.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let r of this.options.templateFiles)r&&(p.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+r),yield M(path.join(this.projectDir,r),this.options),p.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+r));if((i=this.options.replaces)!=null&&i.length){let r=this.options.replaces.filter(s=>s);for(let{sourcePath:s,targetPath:o}of r)!s||!o||(p.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+s+" => "+o),yield G(path.join(this.projectDir,s),path.join(this.projectDir,o)),p.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+s+" => "+o));}p.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){p.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return m(this,null,function*(){p.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield B(this.projectDir),p.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};});var f,O=u(()=>{f={name:"@tikkhun/create",version:"0.1.1",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 v=u(()=>{O();});var V=_(b=>{y();v();E();commander.program.description("\u6253\u5305").option("--template <template>","\u6A21\u677F\u8DEF\u5F84",c.template).option("--templateExclude <templateExclude>","\u4E0D\u5305\u542B\u7684\u4E00\u4E9B\u6587\u4EF6",c.templateExclude.toString()).option("--projectName <projectName>","\u9879\u76EE\u540D",c.projectName).option("--workspace <workspace>","\u6839\u8DEF\u5F84",c.workspace).option("--templateFiles <templateFiles>","\u9700\u6A21\u677F\u66FF\u6362\u7684\u6587\u4EF6",c.templateFiles.toString()).option("--replaces <replaces>","\u66FF\u6362\u540D\u79F0\u7684\u8DEF\u5F84","").action(e=>m(b,null,function*(){let t=w(D({},e),{templateExclude:e.templateExclude.split(","),templateFiles:e.templateFiles.split(","),replaces:e.replaces?e.replaces.split(",").map(a=>{if(!a)return;let[l,r]=a.split("=");if(!(!l||!r))return {sourcePath:l,targetPath:r}}):[]});yield new g(t).start();}));commander.program.parse(process.argv);});var cli = V();
module.exports = cli;
'use strict';
var path = require('path');
var f = require('ejs');
var u = require('ejs');
var logger = require('@tikkhun/logger');
var j = require('fs-extra');
var D = require('lodash');
var D = require('fs-extra');
var x = require('lodash');
var minimatch = require('minimatch');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var f__default = /*#__PURE__*/_interopDefault(f);
var j__default = /*#__PURE__*/_interopDefault(j);
var u__default = /*#__PURE__*/_interopDefault(u);
var D__default = /*#__PURE__*/_interopDefault(D);
var x__default = /*#__PURE__*/_interopDefault(x);
/**
@tikkhun/create-tools
@tikkhun/create
*/
var l=(n,t,e)=>new Promise((a,c)=>{var i=p=>{try{o(e.next(p));}catch(g){c(g);}},r=p=>{try{o(e.throw(p));}catch(g){c(g);}},o=p=>p.done?a(p.value):Promise.resolve(p.value).then(i,r);o((e=e.apply(n,t)).next());});var {merge:x}=D__default.default,{copy:d,readFile:O,writeFile:w,remove:P,move:E,pathExists:y}=j__default.default,s=new logger.Logger("Creator"),F={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:N}},h=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=x({},F,t);}start(){return l(this,null,function*(){var t,e;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield y(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,"\\");if(yield d(this.options.template,this.projectDir,{filter:i=>{var o;if(this.options.template===i)return !0;let r=(o=i.split(c))==null?void 0:o[1];if(r){for(let p of this.options.templateExclude)if(r.includes(p))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)for(let i of this.options.templateFiles)i&&(s.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+i),yield b(path.join(this.projectDir,i),this.options),s.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+i));if((e=this.options.replaces)!=null&&e.length){let i=this.options.replaces.filter(r=>r);for(let{sourcePath:r,targetPath:o}of i)!r||!o||(s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+o),yield E(path.join(this.projectDir,r),path.join(this.projectDir,o)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+r+" => "+o));}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return l(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield P(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function N(n,t){return [t.prefix,n,t.suffix].join(t.delimiter)}function b(n,t){return l(this,null,function*(){let e=(yield O(n)).toString();e=f__default.default.render(e,t),yield w(n,e);})}
var l=(n,e,i)=>new Promise((a,c)=>{var o=p=>{try{r(i.next(p));}catch(h){c(h);}},t=p=>{try{r(i.throw(p));}catch(h){c(h);}},r=p=>p.done?a(p.value):Promise.resolve(p.value).then(o,t);r((i=i.apply(n,e)).next());});var {merge:d}=x__default.default,{copy:O,readFile:w,writeFile:P,remove:E,move:y,pathExists:F}=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"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:b}},f=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(e){this.options=d({},N,e);}start(){return l(this,null,function*(){var e,i;try{if(s.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield F(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,"\\");if(yield O(this.options.template,this.projectDir,{filter:o=>{var r;if(this.options.template===o)return !0;let t=(r=o.split(c))==null?void 0:r[1].replace(/\\/g,"/");if(console.log("theRelativePath",t),t){for(let p of this.options.templateExclude)if(console.log("minimatch(theRelativePath, exclude)",minimatch.minimatch(t,p)),minimatch.minimatch(t,p))return !1}return !0}}),s.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(e=this.options.templateFiles)!=null&&e.length)for(let o of this.options.templateFiles)o&&(s.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+o),yield k(path.join(this.projectDir,o),this.options),s.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+o));if((i=this.options.replaces)!=null&&i.length){let o=this.options.replaces.filter(t=>t);for(let{sourcePath:t,targetPath:r}of o)!t||!r||(s.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+r),yield y(path.join(this.projectDir,t),path.join(this.projectDir,r)),s.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+t+" => "+r));}s.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){s.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return l(this,null,function*(){s.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield E(this.projectDir),s.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function b(n,e){return [e.prefix,n,e.suffix].join(e.delimiter)}function k(n,e){return l(this,null,function*(){let i=(yield w(n)).toString();i=u__default.default.render(i,e),yield P(n,i);})}
exports.Creator = h;
exports.DEFAULT_OPTIONS = F;
exports.Creator = f;
exports.DEFAULT_OPTIONS = N;
'use strict';
var path = require('path');
var u = require('ejs');
var x = require('ejs');
var logger = require('@tikkhun/logger');
var j = require('fs-extra');
var D = require('lodash');
var D = require('fs-extra');
var w = require('lodash');
var minimatch = require('minimatch');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var u__default = /*#__PURE__*/_interopDefault(u);
var j__default = /*#__PURE__*/_interopDefault(j);
var x__default = /*#__PURE__*/_interopDefault(x);
var D__default = /*#__PURE__*/_interopDefault(D);
var w__default = /*#__PURE__*/_interopDefault(w);
/**
@tikkhun/create-tools
@tikkhun/create
*/
var l=(i,t,e)=>new Promise((a,c)=>{var s=p=>{try{r(e.next(p));}catch(d){c(d);}},o=p=>{try{r(e.throw(p));}catch(d){c(d);}},r=p=>p.done?a(p.value):Promise.resolve(p.value).then(s,o);r((e=e.apply(i,t)).next());});var {merge:w}=D__default.default,{copy:y,readFile:O,writeFile:k,remove:P,move:b,pathExists:v}=j__default.default,n=new logger.Logger("Creator"),N={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:E}},g=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=w({},N,t);}start(){return l(this,null,function*(){var t,e;try{if(n.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield v(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),n.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let c=this.options.template.replace(/\\\\/g,"\\");if(yield y(this.options.template,this.projectDir,{filter:s=>{var r;if(this.options.template===s)return !0;let o=(r=s.split(c))==null?void 0:r[1];if(o){for(let p of this.options.templateExclude)if(o.includes(p))return !1}return !0}}),n.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let s of this.options.templateFiles)s&&(n.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+s),yield F(path.join(this.projectDir,s),this.options),n.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+s));if((e=this.options.replaces)!=null&&e.length){let s=this.options.replaces.filter(o=>o);for(let{sourcePath:o,targetPath:r}of s)!o||!r||(n.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+o+" => "+r),yield b(path.join(this.projectDir,o),path.join(this.projectDir,r)),n.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+o+" => "+r));}n.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){n.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return l(this,null,function*(){n.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield P(this.projectDir),n.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function E(i,t){return [t.prefix,i,t.suffix].join(t.delimiter)}function F(i,t){return l(this,null,function*(){let e=(yield O(i)).toString();e=u__default.default.render(e,t),yield k(i,e);})}function $(i="",t,e){}function U(i=16){parseInt(process.version.slice(1))<i?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${i} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}var f={name:"@tikkhun/create-tools",version:"0.1.0",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"}};function H(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${f.name}`),logger.Logger.log("\u7248\u672C: "+f.version);}
var l=(o,t,i)=>new Promise((a,c)=>{var s=p=>{try{r(i.next(p));}catch(d){c(d);}},e=p=>{try{r(i.throw(p));}catch(d){c(d);}},r=p=>p.done?a(p.value):Promise.resolve(p.value).then(s,e);r((i=i.apply(o,t)).next());});var {merge:y}=w__default.default,{copy:O,readFile:P,writeFile:k,remove:v,move:b,pathExists:N}=D__default.default,n=new logger.Logger("Creator"),E={workspace:process.cwd(),template:"./template",templateExclude:[".git","node_modules","dist"],projectName:"project-name",templateFiles:["package.json"],replaces:[],projectDirOptions:{prefix:"",suffix:"",delimiter:"",build:F}},h=class{get projectDir(){return path.join(this.options.workspace,this.options.projectDirOptions.build(this.options.projectName,this.options.projectDirOptions))}constructor(t){this.options=y({},E,t);}start(){return l(this,null,function*(){var t,i;try{if(n.log("[\u5F00\u59CB] \u521B\u5EFA\u9879\u76EE, \u9009\u9879\u4E3A\uFF1A "+JSON.stringify(this.options,null,2)),!(yield N(this.options.template)))throw new Error("\u6A21\u677F\u8DEF\u5F84\u4E0D\u5B58\u5728: "+this.options.template);yield this.clear(),n.log("[\u5F00\u59CB] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir);let c=this.options.template.replace(/\\\\/g,"\\");if(yield O(this.options.template,this.projectDir,{filter:s=>{var r;if(this.options.template===s)return !0;let e=(r=s.split(c))==null?void 0:r[1].replace(/\\/g,"/");if(console.log("theRelativePath",e),e){for(let p of this.options.templateExclude)if(console.log("minimatch(theRelativePath, exclude)",minimatch.minimatch(e,p)),minimatch.minimatch(e,p))return !1}return !0}}),n.log("[\u5B8C\u6BD5] \u62F7\u8D1D\u6A21\u677F\u5230\u9879\u76EE\u4E2D "+this.projectDir),(t=this.options.templateFiles)!=null&&t.length)for(let s of this.options.templateFiles)s&&(n.log("[\u5F00\u59CB] \u66FF\u6362\u6587\u4EF6 "+s),yield R(path.join(this.projectDir,s),this.options),n.log("[\u5B8C\u6BD5] \u66FF\u6362\u6587\u4EF6 "+s));if((i=this.options.replaces)!=null&&i.length){let s=this.options.replaces.filter(e=>e);for(let{sourcePath:e,targetPath:r}of s)!e||!r||(n.log("[\u5F00\u59CB] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+r),yield b(path.join(this.projectDir,e),path.join(this.projectDir,r)),n.log("[\u5B8C\u6BD5] \u8FC1\u79FB\u6587\u4EF6 "+e+" => "+r));}n.log("[\u5B8C\u6BD5] \u521B\u5EFA\u9879\u76EE "+this.projectDir);}catch(a){n.error("[\u5931\u8D25] \u521B\u5EFA\u9879\u76EE\u5931\u8D25 "+a.stack);}})}clear(){return l(this,null,function*(){n.log("[\u5F00\u59CB] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir),yield v(this.projectDir),n.log("[\u5B8C\u6BD5] \u5220\u9664\u9879\u76EE\u6587\u4EF6 "+this.projectDir);})}};function F(o,t){return [t.prefix,o,t.suffix].join(t.delimiter)}function R(o,t){return l(this,null,function*(){let i=(yield P(o)).toString();i=x__default.default.render(i,t),yield k(o,i);})}function V(o="",t,i){}function B(o=16){parseInt(process.version.slice(1))<o?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${o} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}var f={name:"@tikkhun/create",version:"0.1.1",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 Q(){logger.Logger.log(`[\u6B22\u8FCE\u4F7F\u7528] ${f.name}`),logger.Logger.log("\u7248\u672C: "+f.version);}
exports.Creator = g;
exports.DEFAULT_OPTIONS = N;
exports.checkNodeVersion = U;
exports.echoPackage = H;
exports.replaceJsonField = $;
exports.Creator = h;
exports.DEFAULT_OPTIONS = E;
exports.checkNodeVersion = B;
exports.echoPackage = Q;
exports.replaceJsonField = V;
'use strict';
/**
@tikkhun/create-tools
@tikkhun/create
*/

@@ -6,0 +6,0 @@ function n(e="",i,l){}

'use strict';
/**
@tikkhun/create-tools
@tikkhun/create
*/

@@ -6,0 +6,0 @@ function o(e=16){parseInt(process.version.slice(1))<e?(console.error(`\u4F60\u7684 Node.js \u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u5230 Node.js ${e} \u6216\u66F4\u9AD8\u7248\u672C\u3002`),process.exit(1)):console.log("Node.js \u7248\u672C\u7B26\u5408\u8981\u6C42\uFF01");}

@@ -6,6 +6,6 @@ 'use strict';

/**
@tikkhun/create-tools
@tikkhun/create
*/
var e={name:"@tikkhun/create-tools",version:"0.1.0",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"}};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.1",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.1",
"version": "0.1.2",
"description": "",

@@ -49,3 +49,4 @@ "main": "dist/index.js",

"inquirer": "^9.2.23",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"minimatch": "^9.0.4"
},

@@ -52,0 +53,0 @@ "scripts": {

@@ -8,3 +8,3 @@ # create-tools

```bash
yarn global add @tikkhun/create-tools
yarn global add @tikkhun/create
```

@@ -11,0 +11,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc