1 | <p align="center" style="padding-top: 40px">
|
2 | <img src="./docs/images/logo.svg?sanitize=true" width="60" alt="logo" />
|
3 | </p>
|
4 |
|
5 | <h1 align="center">Mili</h1>
|
6 |
|
7 | [![version](https://img.shields.io/npm/v/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
|
8 | [![downloads](https://img.shields.io/npm/dm/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
|
9 | [![dependencies](https://img.shields.io/david/Val-istar-Guo/mili.svg?style=flat-square)](https://www.npmjs.com/package/mili)
|
10 | [![coveralls](https://img.shields.io/coveralls/github/Val-istar-Guo/mili.svg?style=flat-square)](https://coveralls.io/github/Val-istar-Guo/mili)
|
11 |
|
12 |
|
13 | [简体中文](./docs/zh-cn/readme.md)
|
14 |
|
15 |
|
16 | **Projects that derived from the same scaffolding, have evolved over time and become different.**
|
17 | Scaffolding lost control of the subsequent development of the project.
|
18 | 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.
|
19 |
|
20 | 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.
|
21 |
|
22 | It is useful for team project management.
|
23 |
|
24 | ## Usage
|
25 |
|
26 | The basic principle of mili.
|
27 |
|
28 | <p align="center">
|
29 | <img src="./docs/images/handlers.svg?sanitize=true" width="80%" />
|
30 | </p>
|
31 |
|
32 | 1. First, you need to design your own template or use someone else's template.
|
33 | 2. Make project directory and run `npx mili init template_path`.
|
34 | 3. Run `npx mili upgrade`, when template is out of date.
|
35 | 4. `mili` run the handler of file that set by tempalte, when `init` or `upgrade` template
|
36 |
|
37 | ### Init Project
|
38 |
|
39 | Let's use a existed template.
|
40 |
|
41 | ```shell
|
42 | // template in github
|
43 | npx mili init github:Val-istar-Guo/mili-template.git
|
44 | // template in npm
|
45 | npx mili init npm:mili-template
|
46 | // template in private git repository
|
47 | npx mili init https://github.com/Val-istar-Guo/mili.git
|
48 | ```
|
49 |
|
50 | ### Upgrade
|
51 |
|
52 | 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.
|
53 |
|
54 | ```shell
|
55 | npx run upgrade
|
56 | ```
|
57 |
|
58 | The 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.
|
59 |
|
60 | The handlers can be flexibly and freely combined to implement a variety of initialization and upgrade modes.
|
61 |
|
62 |
|
63 | ### Check Before Commit
|
64 |
|
65 | With [husky](https://www.npmjs.com/package/husky),
|
66 | it is easy to verify whether the project file meets the template before commit.
|
67 | Thereby ensuring the specification of the project code.
|
68 |
|
69 | Run in terminal:
|
70 | ```shell
|
71 | npx mili check --diff --fold
|
72 | ```
|
73 |
|
74 | Or configuration in husky:
|
75 |
|
76 | ```yaml
|
77 | hooks:
|
78 | pre-commit: 'npx mili check --diff --fold'
|
79 | ```
|
80 |
|
81 | An example:
|
82 |
|
83 | ![mili check](./docs/images/check.png)
|
84 |
|
85 | Run `npx mili upgrade` command will auto modify code according to the diff.
|
86 |
|
87 |
|
88 | ## See More
|
89 |
|
90 | - [Command Line Interface](./docs/en/cli.md)
|
91 | - [Node Interface](./docs/en/node-interface.md)
|
92 | - [Template Development](./docs/en/template.md)
|
93 | - [Handler](./docs/en/handler/index.md)
|
94 | - Reference
|
95 | + [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.
|
96 |
|
97 |
|
98 | ## Contributing & Development
|
99 |
|
100 | If there is any doubt, it is very welcome to discuss the issue together.
|
101 | Please read [Contributor Covenant Code of Conduct](.github/CODE_OF_CONDUCT.md) and [CONTRIBUTING](.github/CONTRIBUTING.md).
|
102 | Let's keep a good community environment.
|