Projects that derived from the same scaffolding, have evolved over time and become different. Scaffolding lost control of the subsequent development of the project. When we need to improve some of the basic functions of scaffolding(e.g. eslint rules), we need to modify each project, and even have to design a customized solution for some old projects.
Therefore, in order to improve the control ability of scaffolding for the subsequent development of the project,template can modified some files and release new template version, then project can upgrade the template version.
It is useful for team project management.
The basic principle of mili.
npx mili init template_path.
npx mili upgrade, when template is out of date.
milirun the handler of file that set by tempalte, when
Let's use a existed template.
mkdir project_path cd project_path # template in github npx mili init github:Val-istar-Guo/mili-template # template in npm npx mili init npm:mili-template # template in private git repository npx mili init https://github.com/Val-istar-Guo/mili.git
The upgrade operation is very simple to use.The effect of the upgrade is determined by the handlers configured for each file in the template configuration.
npx run upgrade
The handler can extract the data of the project file, or use the template file as a mustache template to render a new project file that will cover old one.
The handlers can be flexibly and freely combined to implement a variety of initialization and upgrade modes.
With husky, it is easy to verify whether the project file meets the template before commit. Thereby ensuring the specification of the project code.
Run in terminal:
npx mili check --diff --fold
Or configuration in husky:
hooks: pre-commit: 'npx mili check --diff --fold'
npx mili upgrade command will auto modify code according to the diff.
Support code development on patron.