简单易用的模版管理工具 — tpl-manager

2年前 (2022) 程序员胖胖胖虎阿
173 0 0

背景

工作中难免会遇到需要新建一些相同或类似的文件,例如在不同的项目中新建.gitignore、package.json、tsconfig.json文件,又或者是在同一个项目的不同目录下新建README.md、index.js文件。每次新建文件都需要思考应配置哪些字段,即使去复制粘贴,在项目之间切换或者查找某个目录下类似的文件,也是有些麻烦的。

介绍

如果有个工具能将常用的文件作为模板暂存起来,在要使用的地方直接创建,会省去上面枯燥乏味的步骤,这就是tpl-manager所做的事情。tpl-manager是受nrm的启发,开发的一个命令行工具,用于快速的新建模板文件,帮你省去复制粘贴这一无聊的步骤提高效率。

安装

$ npm install tpl-manager -g

示例

添加模板文件

$ tpl add README.md

SUCCESS  Add template success!

查看模板文件列表

$ tpl ls

* .gitignore
* README.md
* package.json

使用模板新建文件

$ tpl use

? Please select a template:  (Use arrow keys)
❯ .gitignore 
  README.md 
  package.json 

使用键盘方向键选择所需的模板,然后回车即可在当前所在目录下创建文件

用法

Usage: tpl [options] [command]

Options:
  -V, --version             output the version number
  -h, --help                display help for command

Commands:
  ls                        List all the templates
  use  [name]     Use current template
  add <template> [name]     Add custom template
  rename <template> [name]  Change custom template name
  del <template>            Delete custom template
  view <template>           View the template
  info <template>           Template Info
  help [command]            display help for command

TODO

  • [ ] 用Typescript重写
  • [ ] 补充测试用例

个人经验

例如在某个目录下新建package.json文件,用 npm init -y 创建的模板太简单需要一些别的字段,可以补充下缺失的字段,用 tpl add package.json 命令暂存为模板便于下次使用,.gitignore、tsconfig.json、README.md文件在不同项目中也都类似,也可以暂存下方便下次使用。

版权声明:程序员胖胖胖虎阿 发表于 2022年10月28日 下午4:48。
转载请注明:简单易用的模版管理工具 — tpl-manager | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...