technical standard
- react、redux、reducer
- antd
- less
- type-script
- webpack
guide
- npm install cli-redux-ts // pull npm scaffold
- cd node_modules // to scaffold path
- npm install -g // install npm scaffold
- my-cli // initialize scaffold
- npm install // install package
- npm start // start project
https://www.npmjs.com/package/cli-redux-ts
KEY CODE
#! node
console.log("hello cli!")
const fileManager = require("./file-manager")
const path = require("path")
fileManager.init()
let fromdir = path.join(__dirname, 'templates')
let todir = path.join(__dirname, 'src')
fileManager.mkdir('./src', function () {
fileManager.copyFolder(fromdir, todir)
})
copyFolder(from, to) {
let folder = fs.readdirSync(from)
folder.forEach((file) => {
let fromPathname = path.join(from, file)
let toPathname = path.join(to, file)
if (fs.statSync(fromPathname).isDirectory()) {
fs.mkdir(toPathname, (err) => {
if (err) throw { err, fromPathname, toPathname };
else {
this.copyFolder(fromPathname,toPathname)
console.log("mkdirCircle")
}
});
} else {
this.copyFile(fromPathname, toPathname)
}
})
},
## key word
commander
exec
fs.mkdir
本地实现了npm 执行
npm login
npm publish
npm install 拉取命令行工具
my-cli
my cli note
node编写自己的cli:
https://www.cnblogs.com/Leo_wl/p/6901603.html
cli原理解析:
https://blog.youkuaiyun.com/weixin_33795743/article/details/91428525
echo $PATH 查看配置的环境变量
myCli 地址: C:\Users\sesa528506\AppData\Roaming\npm
ref['http://www.ruanyifeng.com/blog/2015/05/command-line-with-node.html']