UNPKG

4.22 kBMarkdownView Raw
1<!-- title -->
2<p align="center" style="padding-top: 40px">
3 <img src="./docs/images/logo.svg?sanitize=true" width="60" alt="logo" />
4</p>
5
6<h1 align="center" style="text-align: center">Mili</h1>
7<!-- title -->
8
9[![version](https://img.shields.io/npm/v/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
10[![downloads](https://img.shields.io/npm/dm/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
11[![license](https://img.shields.io/npm/l/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
12[![dependencies](https://img.shields.io/david/Val-istar-Guo/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
13[![coveralls](https://img.shields.io/coveralls/github/Val-istar-Guo/mili.svg?style=flat-square)](https://coveralls.io/github/Val-istar-Guo/mili)
14
15
16
17<!-- description -->
18[简体中文](./docs/zh-cn/readme.md)
19
20**Projects that derived from the same scaffolding, have evolved over time and become different.**
21Scaffolding lost control of the subsequent development of the project.
22When 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.
23
24Therefore, 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.
25
26It is useful for team project management.
27<!-- description -->
28
29## Usage
30
31<!-- usage -->
32The basic principle of mili.
33
34<p align="center">
35 <img src="./docs/images/handlers.svg?sanitize=true" width="80%" />
36</p>
37
381. First, you need to design your own template or use someone else's template.
392. Make project directory and run `npx mili init template_path`.
403. Run `npx mili upgrade`, when template is out of date.
414. `mili` run the handler of file that set by tempalte, when `init` or `upgrade` template
42
43### Init Project
44
45Let's use a existed template.
46
47```shell
48mkdir project_path
49cd project_path
50
51# template in github
52npx mili init github:Val-istar-Guo/mili-template
53# template in npm
54npx mili init npm:mili-template
55# template in private git repository
56npx mili init https://github.com/Val-istar-Guo/mili.git
57```
58
59### Upgrade
60
61The 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.
62
63```shell
64npx run upgrade
65```
66
67The handler can extract the data of the project file, or use the template file as a [mustache](https://github.com/janl/mustache.js) template to render a new project file that will cover old one.
68
69The handlers can be flexibly and freely combined to implement a variety of initialization and upgrade modes.
70
71
72### Check Before Commit
73
74With [husky](https://www.npmjs.com/package/husky),
75it is easy to verify whether the project file meets the template before commit.
76Thereby ensuring the specification of the project code.
77
78Run in terminal:
79```shell
80npx mili check --diff --fold
81```
82
83Or configuration in husky:
84
85```yaml
86hooks:
87 pre-commit: 'npx mili check --diff --fold'
88```
89
90An example:
91
92![mili check](./docs/images/check.png)
93
94Run `npx mili upgrade` command will auto modify code according to the diff.
95
96> When use git repository as template source,
97> don't run `mili check` at pre-commit hook.
98> This will throw a confusing error.
99<!-- usage -->
100
101<!-- addition -->
102## See More
103
104- [Command Line Interface](./docs/en/cli.md)
105- [Node Interface](./docs/en/node-interface.md)
106- [Template Development](./docs/en/template.md)
107- [Handler](./docs/en/handler/index.md)
108- Reference
109 + [mili-template](https://github.com/Val-istar-Guo/mili-template): An simple mili template. This can be used as a reference for first time template writing.
110
111<!-- addition -->
112
113## Sponsor
114
115Support code development on patron.
116
117[![patron](https://c5.patreon.com/external/logo/become_a_patron_button@2x.png)](https://www.patreon.com/bePatron?u=22478507)
118
119## Contributing & Development
120
121If there is any doubt, it is very welcome to discuss the issue together.
122Please read [Contributor Covenant Code of Conduct](.github/CODE_OF_CONDUCT.md) and [CONTRIBUTING](.github/CONTRIBUTING.md).