UNPKG

10.7 kBMarkdownView Raw
1![](https://res.cloudinary.com/adonisjs/image/upload/q_100/v1547549861/mrm_entbte.png)
2
3AdonisJs preset for [mrm](https://github.com/sapegin/mrm) to keep the project configuration files **in-sync** and **consistent across** various projects.
4
5<!-- START doctoc generated TOC please keep comment here to allow auto update -->
6<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
7## Table of contents
8
9- [What is MRM?](#what-is-mrm)
10- [What is MRM Preset?](#what-is-mrm-preset)
11- [Getting started](#getting-started)
12- [Tasks](#tasks)
13 - [Appveyor](#appveyor)
14 - [Circle CI](#circle-ci)
15 - [Contributing.md template](#contributingmd-template)
16 - [Editorconfig file](#editorconfig-file)
17 - [Eslint](#eslint)
18 - [Gitflow](#gitflow)
19 - [release:start](#releasestart)
20 - [release:end](#releaseend)
21 - [Github templates](#github-templates)
22 - [Gitignore template](#gitignore-template)
23 - [License template](#license-template)
24 - [Np release management](#np-release-management)
25 - [Package file generation](#package-file-generation)
26 - [Testing](#testing)
27 - [Linter](#linter)
28 - [Coverage reporting](#coverage-reporting)
29 - [Typescript setup](#typescript-setup)
30 - [Pkg ok](#pkg-ok)
31 - [Readme file](#readme-file)
32 - [Readme file TOC](#readme-file-toc)
33 - [Travis](#travis)
34 - [TypeDoc](#typedoc)
35 - [Validate commit](#validate-commit)
36
37<!-- END doctoc generated TOC please keep comment here to allow auto update -->
38
39## What is MRM?
40
41**You might be curious to know what the heck is MRM?**
42
43MRM is a command line tool to scaffold new projects. But instead of just creating the initial set of files, it has powerful utilities to update them as well.
44
45For better explanation, I recommend reading [this article](https://blog.sapegin.me/all/mrm) by the project author.
46
47## What is MRM Preset?
48
49This module is a custom preset of tasks for MRM and is used by [AdonisJs](https://adonisjs.com) and many other projects I author.
50
51You can also create a preset for your own needs. However, just go through the tasks once to see if they fit your needs and that way you can avoid creating your own tasks.
52
53## Getting started
54
55Let's quickly learn how to use this preset, before we dig into the specifics of tasks.
56
57```sh
58npm i --save-dev mrm @adonisjs/mrm-preset
59```
60
61Add script to `package.json` file
62
63```sh
64{
65 "scripts": {
66 "mrm": "mrm --preset=@adonisjs/mrm-preset"
67 }
68}
69```
70
71and then run it as follows
72
73```sh
74## Initiate by creating config file
75npm run mrm init
76```
77
78```sh
79## Execute all tasks (for new projects)
80npm run mrm all
81```
82
83## Tasks
84Let's focus on all the tasks supported by AdonisJs preset.
85
86<!-- TASKS START -->
87<!-- DO NOT MODIFY MANUALLY. INSTEAD RUN `npm run docs` TO REGENERATE IT -->
88
89### Appveyor
90Appveyor tasks creates a configuration file `(appveyor.yml)` in the root of your project. The tasks depends on the config file `config.json` and requires following key/value pairs.
91
92```json
93{
94 "services": ["appveyor"],
95 "minNodeVersion": "12.0.0"
96}
97```
98
99To remove support for `appveyor` from your project, just `npm run mrm appveyor` task by removing the `appveyor` keyword from the `services` array.
100
101```json
102{
103 "services": []
104}
105```
106
107```sh
108npm run mrm appveyor
109```
110
111### Circle CI
112Circle CI tasks creates a configuration file `(.circleci/config.yml)` in the root of your project. The tasks depends on the config file `config.json` and requires following key/value pairs.
113
114```json
115{
116 "services": ["circleci"],
117 "minNodeVersion": "12.0.0"
118}
119```
120
121To remove support for `circleci` from your project, just `npm run mrm circleci` task by removing the `circleci` keyword from the `services` array.
122
123```json
124{
125 "services": []
126}
127```
128
129```sh
130npm run mrm circleci
131```
132
133### Contributing.md template
134Creates `.github/CONTRIBUTING.md` file. This file is shown by Github to users [creating new issues](https://help.github.com/articles/setting-guidelines-for-repository-contributors).
135
136The content of the template is pre-defined and is not customizable. If you want custom template, then it's better to create the file by hand.
137
1381. Template for Typescript
139 The [typescript template](https://github.com/adonisjs/mrm-preset/blob/master/contributing/templates/CONTRIBUTING_TS.md) is used when `ts=true` inside the config file.
140
141 ```json
142 {
143 "ts": true
144 }
145 ```
146
1472. Otherwise the [default template](https://github.com/adonisjs/mrm-preset/blob/master/contributing/templates/CONTRIBUTING.md) will be used.
148### Editorconfig file
149Creates a `.editorconfig` file inside the project root. The editor config file is a way to keep the editor settings consistent regardless of the the editor you open the files in.
150
151You may need a [plugin](https://editorconfig.org/#download) for your editor to make `editorconfig` work.
152
153The file is generated with settings defined inside the [task file](https://github.com/adonisjs/mrm-preset/blob/master/editorconfig/index.js#L20) and again is not customizable.
154### Eslint
155
156Installs `eslint` and `eslint-plugin-adonis`. Also it will remove tslint and it's related dependencies from the project.
157
158### Gitflow
159Adds git flow based release commands to npm scripts.
160
161#### release:start
162Starts the **git flow** release by running `git flow release start $1` under the hood.
163
164```
165npm run release:start 1.0.0
166```
167
168#### release:end
169Ends the **git flow** release by running multiple commands to create and merge release branches with git tags. Commands executed under the hood will use `--no-verify` flag to ignore git hooks, which can conflict with release commit messages style.
170
171```
172npm run release:end 1.0.0
173```
174
175Before running the above command, do make sure to update the **npm version**, **generate the changelog** and **commit these changes**.
176
177### Github templates
178
179Creates issues and PR template for Github. The contents of these templates will be pre-filled anytime someone wants to create a new issue or PR.
180
1811. [Issues template content](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/issues.md)
1822. [PR template](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/pr.md)
183### Gitignore template
184
185Creates `.gitignore` file in the root of your project. Following files and folders are ignored by default. However, you can add more to the template.
186
187```
188node_modules
189coverage
190.DS_STORE
191.nyc_output
192.idea
193.vscode/
194*.sublime-project
195*.sublime-workspace
196*.log
197build
198docs
199dist
200shrinkwrap.yaml
201```
202
203
204### License template
205
206Creates `LICENSE.md` file in the root of your project.
207
208You can choose from one of the [available licenses](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-license/templates) when running `npm run init` command or define it by hand inside `config.json` file.
209
210```json
211{
212 "license": "MIT"
213}
214```
215
216If not defined, will fallback to `package.json` file or `MIT`.
217
218### Np release management
219
220[np](https://github.com/sindresorhus/np) is a sick (👌) tool to publish your npm packages by ensuring that your package is in healthy state for release.
221
222We recommend reading their README too https://github.com/sindresorhus/np.
223
224### Package file generation
225
226This tasks does lots of work to install handful of packages and update `package.json` file.
227
228The list of operations is based on my personal learnings while maintaining open source projects.
229
230> If your project decides to move between **Javascript** and **Typescript** in between, then this task will take care of removing the unwanted dependencies and install the correct one's.
231
232#### Testing
233The [japa](https://github.com/thetutlage/japa) test runner is installed along side with `japaFile.js`. If your project makes use of Typescript, then the test runner will configured to run `.ts` files.
234
235#### Linter
236If using Javascript then [standard](https://standardjs.com/) will be configured, otherwise for Typescript projects [tslint](https://palantir.github.io/tslint/) is used.
237
238#### Coverage reporting
239If you select `coveralls` in the list of `services`, then coverage reporting dependencies will be installed and `after_test` hooks are set.
240
2411. `nyc` is used for collecting coverage report.
2422. `coveralls` node module is used to pipe the coverage report to Coveralls.
243
244#### Typescript setup
245Typescript projects will have additional setup and dependencies to work out of the box.
246
247Following dependencies are installed.
248
2491. ts-node
2502. typescript
2513. @types/node
2524. tslint
2535. tslint-eslint-rules
254
255
256And following scripts are defined
257
2581. `clean` to clean the build folder before starting the build.
2592. `compile` to compile the Typescript code to Javascript.
2603. `prePublishOnly` to compile before publishing to npm.
261
262
263Also `tsconfig.json` and `tslint.json` files will be created. You are free to modify these files
264
265#### Pkg ok
266
267[pkg-ok](https://npm.im/pkg-ok) is installed to ensure that files that get published to npm does exists. Make sure to read their README file for more info.
268
269
270### Readme file
271
272Generates a Readme file using a [pre-defined template](https://github.com/adonisjs/mrm-preset/blob/master/readme/templates/README.md). Feel free to change the contents of the file, since it's just a starting point.
273### Readme file TOC
274
275Generates table of contents for the readme file. This tasks registers a `git hook` to automatically generate the TOC before every commit.
276
277Under the hood npm package [doctoc](https://npm.im/doctoc) is used for generating the TOC, so make sure to read their readme file as well.
278
279### Travis
280Travis tasks creates a configuration file `(.travis.yml)` in the root of your project. The tasks depends on the config file `config.json` and requires following key/value pairs.
281
282```json
283{
284 "services": ["travis"],
285 "minNodeVersion": "10.0"
286}
287```
288
289To remove support for `travis` from your project, just `npm run mrm travis` task by removing the `travis` keyword from the `services` array.
290
291```json
292{
293 "services": []
294}
295```
296
297```sh
298npm run mrm travis
299```
300### TypeDoc
301
302Configures [typedoc](http://typedoc.org/) to generate API documentation for Typescript projects. Along with that, two additional plugins are installed.
303
304- typedoc-plugin-external-module-name
305- typedoc-plugin-single-line-tags
306### Validate commit
307
308Configures a git hook to validate the commit messages. This is great, if you want to ensure that contributors to your project must form commit messages as per a given standard.
309
310The default standard used is [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular) and rules are defined inside this [template](https://github.com/adonisjs/mrm-preset/blob/develop/validateCommit/conventional/template.md), which is copied over to your project `.github` folder for readers reference.
311
312
313<!-- TASKS END -->
\No newline at end of file