├── labels ├── README.md └── index.js ├── .npmrc ├── eslint ├── README.md └── index.js ├── readme ├── templates │ ├── README.md │ └── README_CORE.md ├── README.md └── index.js ├── .gitignore ├── probot ├── README.md ├── templates │ ├── stale.yml │ └── lock.yml ├── index.js ├── lock.js └── stale.js ├── prettier ├── README.md └── index.js ├── np ├── README.md └── index.js ├── readme-toc ├── README.md └── index.js ├── utils ├── saveFile.js ├── mergeConfig.js ├── ghAttributes.js ├── buildJapaFile.js └── Services.js ├── github ├── README.md ├── templates │ ├── issues.md │ ├── features.md │ ├── bugs.md │ └── pr.md ├── standard.js ├── index.js └── core.js ├── gitignore ├── README.md └── index.js ├── license ├── README.md └── index.js ├── config.json ├── editorconfig ├── README.md └── index.js ├── appveyor ├── README.md └── index.js ├── circleci ├── README.md └── index.js ├── .editorconfig ├── validate-commit ├── README.md ├── conventional │ ├── validate.js │ └── template.md └── index.js ├── _tsconfig.json ├── github-actions ├── README.md └── index.js ├── .snyk ├── contributing ├── README.md ├── templates │ ├── CONTRIBUTING.md │ ├── CONTRIBUTING_TS.md │ └── CONTRIBUTING_CORE.md └── index.js ├── package ├── README.md ├── index.js └── TsPreset.js ├── package.json ├── bin └── readme.js ├── gh-labels.json ├── init └── index.js ├── README.md └── CHANGELOG.md /labels/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | "chore(release): %s" 2 | -------------------------------------------------------------------------------- /eslint/README.md: -------------------------------------------------------------------------------- 1 | ### Eslint 2 | 3 | Installs `eslint` and `eslint-plugin-adonis`. Also it will remove tslint and it's related dependencies from the project. 4 | -------------------------------------------------------------------------------- /readme/templates/README.md: -------------------------------------------------------------------------------- 1 | # ${packageName} 2 | > Tagline 3 | 4 | ${servicesBadges} 5 | 6 | A short brief 7 | 8 | ## Installation 9 | 10 | ## Usage 11 | 12 | ${servicesUrls} 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | Thumbs.db 4 | .idea/ 5 | .vscode/ 6 | *.sublime-project 7 | *.sublime-workspace 8 | *.log 9 | yarn.lock 10 | shrinkwrap.yaml 11 | package-lock.json 12 | -------------------------------------------------------------------------------- /readme/README.md: -------------------------------------------------------------------------------- 1 | ### Readme file 2 | 3 | Generates 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. -------------------------------------------------------------------------------- /probot/README.md: -------------------------------------------------------------------------------- 1 | ### Probot applications 2 | 3 | Configures certain probot application templates inside the `.github` directory. Currently, following apps are supported. 4 | 5 | - https://probot.github.io/apps/stale/ 6 | - https://probot.github.io/apps/lock/ 7 | -------------------------------------------------------------------------------- /prettier/README.md: -------------------------------------------------------------------------------- 1 | ### Prettier 2 | 3 | Installs `prettier` and `eslint-plugin-prettier` and `eslint-config-prettier` to setup prettier along side with `eslint`. Also the task will check, if `.eslintrc.json` file exists and then only performs the eslint specific setup 4 | -------------------------------------------------------------------------------- /np/README.md: -------------------------------------------------------------------------------- 1 | ### Np release management 2 | 3 | [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. 4 | 5 | We recommend reading their README too https://github.com/sindresorhus/np. 6 | -------------------------------------------------------------------------------- /readme-toc/README.md: -------------------------------------------------------------------------------- 1 | ### Readme file TOC 2 | 3 | Generates table of contents for the readme file. This tasks registers a `git hook` to automatically generate the TOC before every commit. 4 | 5 | Under 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. 6 | -------------------------------------------------------------------------------- /utils/saveFile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | module.exports = function (file, forced) { 11 | if (file.exists() && !forced) { 12 | return 13 | } 14 | file.save() 15 | } 16 | -------------------------------------------------------------------------------- /github/README.md: -------------------------------------------------------------------------------- 1 | ### Github templates 2 | 3 | Creates 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. 4 | 5 | 1. [Issues template content](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/issues.md) 6 | 2. [PR template](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/pr.md) 7 | -------------------------------------------------------------------------------- /gitignore/README.md: -------------------------------------------------------------------------------- 1 | ### Gitignore template 2 | 3 | Creates `.gitignore` file in the root of your project. Following files and folders are ignored by default. However, you can add more to the template. 4 | 5 | ``` 6 | node_modules 7 | coverage 8 | test/__app 9 | .DS_STORE 10 | .nyc_output 11 | .idea 12 | .vscode/ 13 | *.sublime-project 14 | *.sublime-workspace 15 | *.log 16 | build 17 | docs 18 | dist 19 | shrinkwrap.yaml 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /readme/templates/README_CORE.md: -------------------------------------------------------------------------------- 1 | ${banner} 2 | # ${packageName} 3 | > Tagline 4 | 5 | ${servicesBadges} 6 | 7 | A short brief 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Purpose 15 | 16 | ## Features 17 | 18 | ${servicesUrls} 19 | -------------------------------------------------------------------------------- /license/README.md: -------------------------------------------------------------------------------- 1 | ### License template 2 | 3 | Creates `LICENSE.md` file in the root of your project. 4 | 5 | You 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. 6 | 7 | ```json 8 | { 9 | "license": "MIT" 10 | } 11 | ``` 12 | 13 | If not defined, will fallback to `package.json` file or `MIT`. 14 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "aliases": { 3 | "setup": ["init", "all"], 4 | "all": [ 5 | "appveyor", 6 | "circleci", 7 | "github-actions", 8 | "contributing", 9 | "editorconfig", 10 | "probot", 11 | "github", 12 | "gitignore", 13 | "license", 14 | "package", 15 | "eslint", 16 | "prettier", 17 | "readme", 18 | "readme-toc", 19 | "validate-commit", 20 | "np", 21 | "labels" 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /editorconfig/README.md: -------------------------------------------------------------------------------- 1 | ### Editorconfig file 2 | Creates 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. 3 | 4 | You may need a [plugin](https://editorconfig.org/#download) for your editor to make `editorconfig` work. 5 | 6 | The 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. -------------------------------------------------------------------------------- /appveyor/README.md: -------------------------------------------------------------------------------- 1 | ### Appveyor 2 | Appveyor 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. 3 | 4 | ```json 5 | { 6 | "services": ["appveyor"], 7 | "minNodeVersion": "12.0.0" 8 | } 9 | ``` 10 | 11 | To remove support for `appveyor` from your project, just `npm run mrm appveyor` task by removing the `appveyor` keyword from the `services` array. 12 | 13 | ```json 14 | { 15 | "services": [] 16 | } 17 | ``` 18 | 19 | ```sh 20 | npm run mrm appveyor 21 | ``` 22 | -------------------------------------------------------------------------------- /circleci/README.md: -------------------------------------------------------------------------------- 1 | ### Circle CI 2 | Circle 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. 3 | 4 | ```json 5 | { 6 | "services": ["circleci"], 7 | "minNodeVersion": "12.0.0" 8 | } 9 | ``` 10 | 11 | To remove support for `circleci` from your project, just `npm run mrm circleci` task by removing the `circleci` keyword from the `services` array. 12 | 13 | ```json 14 | { 15 | "services": [] 16 | } 17 | ``` 18 | 19 | ```sh 20 | npm run mrm circleci 21 | ``` 22 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | # The JSON files contain newlines inconsistently 13 | [*.json] 14 | insert_final_newline = ignore 15 | 16 | # Minified JavaScript files shouldn't be changed 17 | [**.min.js] 18 | indent_style = ignore 19 | insert_final_newline = ignore 20 | 21 | # Makefiles always use tabs for indentation 22 | [Makefile] 23 | indent_style = tab 24 | 25 | [*.md] 26 | trim_trailing_whitespace = false 27 | -------------------------------------------------------------------------------- /validate-commit/README.md: -------------------------------------------------------------------------------- 1 | ### Validate commit 2 | 3 | Configures 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. 4 | 5 | The 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/validate-commit/conventional/template.md), which is copied over to your project `.github` folder for readers reference. 6 | 7 | -------------------------------------------------------------------------------- /_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "lib": ["es2020"], 6 | "noUnusedLocals": true, 7 | "noUnusedParameters": true, 8 | "removeComments": false, 9 | "declaration": true, 10 | "moduleResolution": "node", 11 | "rootDir": "../../../", 12 | "outDir": "../../../build", 13 | "strictNullChecks": true, 14 | "allowSyntheticDefaultImports": true, 15 | "esModuleInterop": true 16 | }, 17 | "include": [ 18 | "../../../**/*" 19 | ], 20 | "exclude": [ 21 | "../../../node_modules", 22 | "../../../build" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /github-actions/README.md: -------------------------------------------------------------------------------- 1 | ### Github Actions 2 | 3 | Github actions tasks creates a configuration file `(.github/workflows/test.yml)` in the root of your project. The tasks depends on the config file `config.json` and requires following key/value pairs. 4 | 5 | ```json 6 | { 7 | "services": ["github-actions"], 8 | "minNodeVersion": "14.15.4" 9 | } 10 | ``` 11 | 12 | To remove support for `github-actions` from your project, just `npm run mrm github-actions` task by removing the `github-actions` keyword from the `services` array. 13 | 14 | ```json 15 | { 16 | "services": [] 17 | } 18 | ``` 19 | 20 | ```sh 21 | npm run mrm github-actions 22 | ``` 23 | -------------------------------------------------------------------------------- /utils/mergeConfig.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const path = require('path') 11 | const deepExtend = require('deep-extend') 12 | 13 | module.exports = function (config, defaults) { 14 | try { 15 | const pkgFile = require(path.join(process.cwd(), 'package.json')) 16 | const projectConfigFile = pkgFile.mrmConfig 17 | deepExtend(config, defaults, projectConfigFile || {}) 18 | } catch { 19 | deepExtend(config, defaults, {}) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. 2 | version: v1.13.5 3 | ignore: {} 4 | # patches apply the minimum changes required to fix a vulnerability 5 | patch: 6 | SNYK-JS-LODASH-450202: 7 | - inquirer > lodash: 8 | patched: '2019-07-04T07:04:43.816Z' 9 | - mrm-core > lodash: 10 | patched: '2019-07-04T07:04:43.816Z' 11 | - mrm-core > webpack-merge > lodash: 12 | patched: '2019-07-04T07:04:43.816Z' 13 | - mrm-task-license > mrm-core > lodash: 14 | patched: '2019-07-04T07:04:43.816Z' 15 | - mrm-task-license > mrm-core > webpack-merge > lodash: 16 | patched: '2019-07-04T07:04:43.816Z' 17 | -------------------------------------------------------------------------------- /license/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const gitUserName = require('git-user-name') 11 | const gitUserEmail = require('git-user-email') 12 | const createLicense = require('mrm-task-license') 13 | 14 | const mergeConfig = require('../utils/mergeConfig') 15 | 16 | function task (config) { 17 | mergeConfig(config, { 18 | licenseFile: 'LICENSE.md', 19 | name: gitUserName(), 20 | license: 'Unlicensed', 21 | email: gitUserEmail() || 'virk' 22 | }) 23 | createLicense(config) 24 | } 25 | 26 | task.description = 'Adds LICENSE.md file' 27 | module.exports = task 28 | -------------------------------------------------------------------------------- /github/templates/issues.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Prerequisites 4 | 5 | We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster. 6 | 7 | - Ensure the issue isn't already reported. 8 | - Ensure you are reporting the bug in the correct repo. 9 | 10 | *Delete the above section and the instructions in the sections below before submitting* 11 | 12 | ## Description 13 | 14 | If this is a feature request, explain why it should be added. Specific use-cases are best. 15 | 16 | For bug reports, please provide as much *relevant* info as possible. 17 | 18 | ## Package version 19 | 20 | 21 | ## Error Message & Stack Trace 22 | 23 | ## Relevant Information 24 | -------------------------------------------------------------------------------- /probot/templates/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | 4 | # Number of days of inactivity before a stale issue is closed 5 | daysUntilClose: 7 6 | 7 | # Issues with these labels will never be considered stale 8 | exemptLabels: 9 | - "Type: Security" 10 | 11 | # Label to use when marking an issue as stale 12 | staleLabel: "Status: Abandoned" 13 | 14 | # Comment to post when marking an issue as stale. Set to `false` to disable 15 | markComment: > 16 | This issue has been automatically marked as stale because it has not had 17 | recent activity. It will be closed if no further activity occurs. Thank you 18 | for your contributions. 19 | 20 | # Comment to post when closing a stale issue. Set to `false` to disable 21 | closeComment: false 22 | -------------------------------------------------------------------------------- /contributing/README.md: -------------------------------------------------------------------------------- 1 | ### Contributing.md template 2 | Creates `.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). 3 | 4 | The 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. 5 | 6 | 1. Template for Typescript 7 | 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. 8 | 9 | ```json 10 | { 11 | "ts": true 12 | } 13 | ``` 14 | 15 | 2. Otherwise the [default template](https://github.com/adonisjs/mrm-preset/blob/master/contributing/templates/CONTRIBUTING.md) will be used. -------------------------------------------------------------------------------- /utils/ghAttributes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { ini, MrmError } = require('mrm-core') 11 | const gh = require('parse-github-url') 12 | 13 | module.exports = function (action) { 14 | /** 15 | * Ensure .git/config file exists 16 | */ 17 | const ghFile = ini('.git/config') 18 | if (!ghFile.exists()) { 19 | throw new MrmError(`Initiate git repo before ${action}`) 20 | } 21 | 22 | /** 23 | * Ensure origin is defined 24 | */ 25 | const origin = ghFile.get('remote "origin"') 26 | if (!origin || !origin.url) { 27 | throw new MrmError(`Add remote origin before ${action}`) 28 | } 29 | 30 | return gh(origin.url) 31 | } 32 | -------------------------------------------------------------------------------- /github/templates/features.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Propose changes for adding a new feature 4 | --- 5 | 6 | 7 | 8 | ## Prerequisites 9 | 10 | We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster. 11 | 12 | ## Consider an RFC 13 | 14 | Please create an [RFC](https://github.com/adonisjs/rfcs) instead, if 15 | 16 | - Feature introduces a breaking change 17 | - Demands lots of time and changes in the current code base. 18 | 19 | *Delete the above section and the instructions in the sections below before submitting* 20 | 21 | ## Why this feature is required (specific use-cases will be appreciated)? 22 | 23 | 24 | ## Have you tried any other work arounds? 25 | 26 | 27 | ## Are you willing to work on it with little guidance? 28 | 29 | -------------------------------------------------------------------------------- /package/README.md: -------------------------------------------------------------------------------- 1 | ### Package file generation 2 | 3 | This tasks does lots of work to install handful of packages and update `package.json` file. 4 | 5 | The list of operations is based on my personal learnings while maintaining open source projects. 6 | 7 | #### Testing 8 | 9 | The [japa](https://github.com/thetutlage/japa) test runner is installed along side with `japaFile.js`. 10 | 11 | #### Typescript setup 12 | 13 | We create a `tsconfig.json` file and install following dependencies. 14 | 15 | 1. `@types/node` 16 | 2. `typescript` 17 | 3. `@adonisjs/require-ts` 18 | 19 | #### Scripts 20 | The following scripts are defined inside the `package.json` file. 21 | 22 | 1. `clean` to clean the build folder before starting the build. We also install `del-cli` npm package for this script to work 23 | 2. `compile` to compile the TypeScript code to JavaScript 24 | 3. `build` runs compile 25 | 4. `prePublishOnly` to compile before publishing to npm. 26 | -------------------------------------------------------------------------------- /probot/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const stale = require('./stale') 11 | const lock = require('./lock') 12 | const mergeConfig = require('../utils/mergeConfig') 13 | 14 | /** 15 | * Configuring probot apps 16 | * 17 | * @method task 18 | * 19 | * @param {Object} config 20 | * 21 | * @return {void} 22 | */ 23 | function task (config) { 24 | mergeConfig(config, { 25 | probotApps: [] 26 | }) 27 | 28 | if (config.probotApps.includes('stale')) { 29 | stale.up() 30 | } else { 31 | stale.down() 32 | } 33 | 34 | if (config.probotApps.includes('lock')) { 35 | lock.up() 36 | } else { 37 | lock.down() 38 | } 39 | } 40 | 41 | task.description = 'Configures certain probot applications' 42 | module.exports = task 43 | -------------------------------------------------------------------------------- /probot/templates/lock.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Lock Threads - https://github.com/dessant/lock-threads-app 2 | 3 | # Number of days of inactivity before a closed issue or pull request is locked 4 | daysUntilLock: 60 5 | 6 | # Skip issues and pull requests created before a given timestamp. Timestamp must 7 | # follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable 8 | skipCreatedBefore: false 9 | 10 | # Issues and pull requests with these labels will be ignored. Set to `[]` to disable 11 | exemptLabels: ['Type: Security'] 12 | 13 | # Label to add before locking, such as `outdated`. Set to `false` to disable 14 | lockLabel: false 15 | 16 | # Comment to post before locking. Set to `false` to disable 17 | lockComment: > 18 | This thread has been automatically locked since there has not been 19 | any recent activity after it was closed. Please open a new issue for 20 | related bugs. 21 | 22 | # Assign `resolved` as the reason for locking. Set to `false` to disable 23 | setLockReason: false 24 | -------------------------------------------------------------------------------- /labels/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { install, packageJson } = require('mrm-core') 11 | const gh = require('../utils/ghAttributes') 12 | const mergeConfig = require('../utils/mergeConfig') 13 | 14 | function task (config) { 15 | const ghAttributes = gh('syncing github labels') 16 | mergeConfig(config, { repo: ghAttributes.repo }) 17 | 18 | /** 19 | * Update package file 20 | */ 21 | const pkgFile = packageJson() 22 | pkgFile 23 | .setScript( 24 | 'sync-labels', 25 | `github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json ${config.repo}` 26 | ) 27 | .save() 28 | 29 | /** 30 | * Install required dependencies 31 | */ 32 | install(['github-label-sync']) 33 | } 34 | 35 | task.description = 'Adds a script to sync labels with Github' 36 | module.exports = task 37 | -------------------------------------------------------------------------------- /gitignore/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { lines } = require('mrm-core') 11 | const debug = require('debug')('adonis:mrm-gitignore') 12 | 13 | /** 14 | * Creates `.gitignore` file. The template is same regardless of 15 | * config. 16 | * 17 | * @return {void} 18 | */ 19 | function task () { 20 | const file = lines('.gitignore') 21 | const linesToWrite = [ 22 | 'node_modules', 23 | 'coverage', 24 | 'test/__app', 25 | '.DS_STORE', 26 | '.nyc_output', 27 | '.idea', 28 | '.vscode/', 29 | '*.sublime-project', 30 | '*.sublime-workspace', 31 | '*.log', 32 | 'build', 33 | 'dist', 34 | 'shrinkwrap.yaml' 35 | ] 36 | 37 | debug('.gitignore %o', linesToWrite) 38 | 39 | file.add(linesToWrite) 40 | file.save() 41 | } 42 | 43 | task.description = 'Adds Gitignore file' 44 | module.exports = task 45 | -------------------------------------------------------------------------------- /eslint/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { json, install, packageJson, lines } = require('mrm-core') 11 | 12 | function task () { 13 | /** 14 | * Delete old eslintrc files 15 | */ 16 | const eslintRc = json('.eslintrc.json') 17 | const eslintIgnore = lines('.eslintignore') 18 | eslintRc.delete() 19 | eslintIgnore.delete() 20 | 21 | /** 22 | * Update package file 23 | */ 24 | const pkgFile = packageJson() 25 | pkgFile.setScript('lint', 'eslint . --ext=.ts') 26 | pkgFile.set('eslintConfig', { 27 | extends: ['plugin:adonis/typescriptPackage'] 28 | }) 29 | pkgFile.set('eslintIgnore', ['build']) 30 | pkgFile.save() 31 | 32 | /** 33 | * Install required dependencies 34 | */ 35 | install(['eslint', 'eslint-plugin-adonis']) 36 | } 37 | 38 | task.description = 'Adds eslint to the project' 39 | module.exports = task 40 | -------------------------------------------------------------------------------- /np/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { install, packageJson, ini } = require('mrm-core') 11 | 12 | function task () { 13 | /** 14 | * Install required dev-dependencies 15 | */ 16 | install(['np']) 17 | 18 | const pkgFile = packageJson() 19 | 20 | /** 21 | * Set npm config 22 | */ 23 | pkgFile.set('np', { 24 | contents: '.', 25 | anyBranch: false 26 | }) 27 | 28 | /** 29 | * Set release script 30 | */ 31 | pkgFile.setScript('release', 'np --message="chore(release): %s"') 32 | pkgFile.setScript('version', 'npm run build') 33 | 34 | /** 35 | * Save the package file 36 | */ 37 | pkgFile.save() 38 | 39 | /** 40 | * Remove old npmrc file 41 | */ 42 | const npmrc = ini('.npmrc') 43 | npmrc.delete() 44 | } 45 | 46 | task.description = 'Adds np to do release management' 47 | module.exports = task 48 | -------------------------------------------------------------------------------- /contributing/templates/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We love pull requests. And following this guidelines will make your pull request easier to merge 4 | 5 | ## Prerequisites 6 | 7 | - Install [EditorConfig](http://editorconfig.org/) plugin for your code editor to make sure it uses correct settings. 8 | - Fork the repository and clone your fork. 9 | - Install dependencies: `npm install`. 10 | 11 | ## Coding style 12 | 13 | We make use of [standard](https://standardjs.com/) to lint our code. Standard does not need a config file and comes with set of non-configurable rules. 14 | 15 | ## Development work-flow 16 | 17 | Always make sure to lint and test your code before pushing it to the GitHub. 18 | 19 | ```bash 20 | npm test 21 | ``` 22 | 23 | Just lint the code 24 | 25 | ```bash 26 | npm run lint 27 | ``` 28 | 29 | **Make sure you add sufficient tests for the change**. 30 | 31 | ## Other notes 32 | 33 | - Do not change version number inside the `package.json` file. 34 | - Do not update `CHANGELOG.md` file. 35 | 36 | ## Need help? 37 | 38 | Feel free to ask. 39 | -------------------------------------------------------------------------------- /github/templates/bugs.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report identified bugs 4 | --- 5 | 6 | 7 | 8 | ## Prerequisites 9 | 10 | We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster. 11 | 12 | - Lots of raised issues are directly not bugs but instead are design decisions taken by us. 13 | - Make use of our [GH discussions](https://github.com/adonisjs/core/discussions), or [discord server](https://discord.me/adonisjs), if you are not sure that you are reporting a bug. 14 | - Ensure the issue isn't already reported. 15 | - Ensure you are reporting the bug in the correct repo. 16 | 17 | *Delete the above section and the instructions in the sections below before submitting* 18 | 19 | ## Package version 20 | 21 | 22 | ## Node.js and npm version 23 | 24 | 25 | ## Sample Code (to reproduce the issue) 26 | 27 | 28 | ## BONUS (a sample repo to reproduce the issue) 29 | 30 | -------------------------------------------------------------------------------- /github/standard.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template, deleteFiles } = require('mrm-core') 11 | const { join } = require('path') 12 | const debug = require('debug')('adonis:mrm-github') 13 | 14 | class StandardTemplate { 15 | constructor () { 16 | this.issues = '.github/ISSUE_TEMPLATE.md' 17 | } 18 | 19 | /** 20 | * Create required templates 21 | * 22 | * @method up 23 | * 24 | * @return {void} 25 | */ 26 | up () { 27 | debug('using template: %s', this.issues) 28 | template(this.issues, join(__dirname, 'templates', 'issues.md')).apply().save() 29 | } 30 | 31 | /** 32 | * Remove previously created template 33 | * 34 | * @method down 35 | * 36 | * @return {void} 37 | */ 38 | down () { 39 | debug('removing template: %s', this.issues) 40 | deleteFiles(this.issues) 41 | } 42 | } 43 | 44 | module.exports = new StandardTemplate() 45 | -------------------------------------------------------------------------------- /contributing/templates/CONTRIBUTING_TS.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We love pull requests. And following this guidelines will make your pull request easier to merge 4 | 5 | ## Prerequisites 6 | 7 | - Install [EditorConfig](http://editorconfig.org/) plugin for your code editor to make sure it uses correct settings. 8 | - Fork the repository and clone your fork. 9 | - Install dependencies: `npm install`. 10 | 11 | ## Coding style 12 | 13 | We make use of Typescript along with [ESLint](https://eslint.org) to ensure a consistent coding style. All of the rules are defined inside the `.eslintrc.json` file. 14 | 15 | ## Development work-flow 16 | 17 | Always make sure to lint and test your code before pushing it to the GitHub. 18 | 19 | ```bash 20 | npm test 21 | ``` 22 | 23 | Just lint the code 24 | 25 | ```bash 26 | npm run lint 27 | ``` 28 | 29 | **Make sure you add sufficient tests for the change**. 30 | 31 | ## Other notes 32 | 33 | - Do not change version number inside the `package.json` file. 34 | - Do not update `CHANGELOG.md` file. 35 | - Do not update `.eslintrc.json` file. If something prevents you writing code, please create an issue for same. 36 | 37 | ## Need help? 38 | 39 | Feel free to ask. 40 | -------------------------------------------------------------------------------- /github/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template } = require('mrm-core') 11 | const { join } = require('path') 12 | 13 | const gh = require('../utils/ghAttributes') 14 | const mergeConfig = require('../utils/mergeConfig') 15 | const core = require('./core') 16 | const standard = require('./standard') 17 | 18 | const prTemplate = '.github/PULL_REQUEST_TEMPLATE.md' 19 | 20 | /** 21 | * Creating required github templates 22 | * 23 | * @method task 24 | * 25 | * @param {Object} config 26 | * 27 | * @return {void} 28 | */ 29 | function task (config) { 30 | const ghAttributes = gh('creating github templates') 31 | mergeConfig(config, { repo: ghAttributes.repo }) 32 | 33 | if (config.core) { 34 | core.up() 35 | standard.down() 36 | } else { 37 | standard.up() 38 | core.down() 39 | } 40 | 41 | template(prTemplate, join(__dirname, 'templates', 'pr.md')).apply(ghAttributes).save() 42 | } 43 | 44 | task.description = 'Adds Github related templates' 45 | module.exports = task 46 | -------------------------------------------------------------------------------- /probot/lock.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template, deleteFiles } = require('mrm-core') 11 | const { join } = require('path') 12 | const debug = require('debug')('adonis:mrm-probot') 13 | 14 | /** 15 | * Creates the `.github/lock.yml` file 16 | */ 17 | class LockTemplate { 18 | constructor () { 19 | this.template = '.github/lock.yml' 20 | this.message = 'Make sure to also install https://probot.github.io/apps/lock app.' 21 | } 22 | 23 | /** 24 | * Create required templates 25 | * 26 | * @method up 27 | * 28 | * @return {void} 29 | */ 30 | up () { 31 | debug('using template: %s', this.template) 32 | template(this.template, join(__dirname, 'templates', 'lock.yml')).apply().save() 33 | } 34 | 35 | /** 36 | * Remove previously created templates 37 | * 38 | * @method down 39 | * 40 | * @return {void} 41 | */ 42 | down () { 43 | debug('removing template: %s', this.template) 44 | deleteFiles([this.template]) 45 | } 46 | } 47 | 48 | module.exports = new LockTemplate() 49 | -------------------------------------------------------------------------------- /probot/stale.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template, deleteFiles } = require('mrm-core') 11 | const { join } = require('path') 12 | const debug = require('debug')('adonis:mrm-probot') 13 | 14 | /** 15 | * Creates the `.github/stale.yml` file 16 | */ 17 | class StaleTemplate { 18 | constructor () { 19 | this.template = '.github/stale.yml' 20 | this.message = 'Make sure to also install https://probot.github.io/apps/stale app.' 21 | } 22 | 23 | /** 24 | * Create required templates 25 | * 26 | * @method up 27 | * 28 | * @return {void} 29 | */ 30 | up () { 31 | debug('using template: %s', this.template) 32 | template(this.template, join(__dirname, 'templates', 'stale.yml')).apply().save() 33 | } 34 | 35 | /** 36 | * Remove previously created templates 37 | * 38 | * @method down 39 | * 40 | * @return {void} 41 | */ 42 | down () { 43 | debug('removing template: %s', this.template) 44 | deleteFiles([this.template]) 45 | } 46 | } 47 | 48 | module.exports = new StaleTemplate() 49 | -------------------------------------------------------------------------------- /github/core.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template, deleteFiles } = require('mrm-core') 11 | const { join } = require('path') 12 | const debug = require('debug')('adonis:mrm-github') 13 | 14 | class CoreTemplates { 15 | constructor () { 16 | this.issues = '.github/ISSUE_TEMPLATE/bug_report.md' 17 | this.features = '.github/ISSUE_TEMPLATE/feature_request.md' 18 | } 19 | 20 | /** 21 | * Create required templates 22 | * 23 | * @method up 24 | * 25 | * @return {void} 26 | */ 27 | up () { 28 | debug('using templates: %o', [this.issues, this.features]) 29 | 30 | template(this.issues, join(__dirname, 'templates', 'bugs.md')).apply().save() 31 | template(this.features, join(__dirname, 'templates', 'features.md')).apply().save() 32 | } 33 | 34 | /** 35 | * Remove previously created templates 36 | * 37 | * @method down 38 | * 39 | * @return {void} 40 | */ 41 | down () { 42 | debug('removing templates: %o', [this.issues, this.features]) 43 | 44 | deleteFiles([this.issues, this.features]) 45 | } 46 | } 47 | 48 | module.exports = new CoreTemplates() 49 | -------------------------------------------------------------------------------- /validate-commit/conventional/validate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | /** 11 | * Copied from https://github.com/vuejs/vue-cli/blob/dev/scripts/verifyCommitMsg.js 12 | */ 13 | const chalk = require('chalk') 14 | const msgPath = process.env.HUSKY_GIT_PARAMS 15 | const msg = require('fs').readFileSync(msgPath, 'utf-8').trim() 16 | 17 | const commitRE = /^(revert: )?(feat|improvement|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build)(\(.+\))?: .{1,50}/ 18 | 19 | if (!commitRE.test(msg)) { 20 | console.log() 21 | console.error( 22 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red('invalid commit message format.')}\n\n` + 23 | chalk.red(' Proper commit message format is required for automated changelog generation. Examples:\n\n') + 24 | ` ${chalk.green('feat(route): add support for prefix')}\n` + 25 | ` ${chalk.green('fix(model): make primaryKey getter camelcase (close #28)')}\n\n` + 26 | chalk.red(' See .github/COMMIT_CONVENTION.md for more details.\n') + 27 | chalk.red(` You can also use ${chalk.cyan('npm run commit')} to interactively generate a commit message.\n`) 28 | ) 29 | process.exit(1) 30 | } 31 | -------------------------------------------------------------------------------- /appveyor/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { yaml, deleteFiles } = require('mrm-core') 11 | const mergeConfig = require('../utils/mergeConfig') 12 | 13 | function task (config) { 14 | mergeConfig(config, { 15 | services: [], 16 | minNodeVersion: '17.0.0' 17 | }) 18 | 19 | const appveyor = config.services.indexOf('appveyor') > -1 20 | 21 | /** 22 | * Remove `appveyor.yml` file when `appveyor` is missing inside 23 | * services array. 24 | */ 25 | if (!appveyor) { 26 | deleteFiles(['appveyor.yml']) 27 | return 28 | } 29 | 30 | const appveyorFile = yaml('appveyor.yml') 31 | .set('environment.matrix', [{ nodejs_version: 'Stable' }, { nodejs_version: config.minNodeVersion }]) 32 | .set('init', 'git config --global core.autocrlf true') 33 | .set('install', [{ ps: 'Install-Product node $env:nodejs_version' }, 'npm install']) 34 | .set('test_script', ['node --version', 'npm --version', 'npm run test']) 35 | .set('build', 'off') 36 | .set('clone_depth', 1) 37 | .set('matrix.fast_finish', true) 38 | 39 | appveyorFile.save() 40 | } 41 | 42 | task.description = 'Adds appveyor.yml file' 43 | module.exports = task 44 | -------------------------------------------------------------------------------- /github/templates/pr.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Proposed changes 4 | 5 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 6 | 7 | ## Types of changes 8 | 9 | What types of changes does your code introduce? 10 | 11 | _Put an `x` in the boxes that apply_ 12 | 13 | - [ ] Bugfix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 16 | 17 | ## Checklist 18 | 19 | _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._ 20 | 21 | - [ ] I have read the [CONTRIBUTING](https://github.com/${repo}/blob/${branch}/.github/CONTRIBUTING.md) doc 22 | - [ ] Lint and unit tests pass locally with my changes 23 | - [ ] I have added tests that prove my fix is effective or that my feature works. 24 | - [ ] I have added necessary documentation (if appropriate) 25 | 26 | ## Further comments 27 | 28 | If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... 29 | -------------------------------------------------------------------------------- /package/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { packageJson, file } = require('mrm-core') 11 | const { execSync } = require('child_process') 12 | 13 | const TsPreset = require('./TsPreset') 14 | const mergeConfig = require('../utils/mergeConfig') 15 | const buildJapaFile = require('../utils/buildJapaFile') 16 | 17 | const baseDependencies = [] 18 | 19 | function task (config) { 20 | mergeConfig(config, { services: [], license: 'UNLICENSED' }) 21 | 22 | /** 23 | * Create package.json file, if missing 24 | */ 25 | const initialPkgFile = packageJson() 26 | if (!initialPkgFile.exists()) { 27 | execSync('npm init --yes') 28 | } 29 | 30 | TsPreset.install(baseDependencies) 31 | 32 | const pkgFile = packageJson() 33 | 34 | /** 35 | * Below are common scripts for both Typescript and Javascript 36 | * projects. 37 | */ 38 | pkgFile.setScript('mrm', 'mrm --preset=@adonisjs/mrm-preset') 39 | pkgFile.setScript('test', 'node -r @adonisjs/require-ts/build/register bin/test.ts') 40 | pkgFile.setScript('pretest', 'npm run lint') 41 | pkgFile.set('license', config.license) 42 | 43 | TsPreset.up(pkgFile) 44 | 45 | /** 46 | * Save the package file 47 | */ 48 | pkgFile.save() 49 | } 50 | 51 | task.description = 'Adds package.json file and configures/installs dependencies' 52 | module.exports = task 53 | -------------------------------------------------------------------------------- /contributing/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { template } = require('mrm-core') 11 | const { join } = require('path') 12 | const debug = require('debug')('adonis:mrm-contributing') 13 | 14 | const mergeConfig = require('../utils/mergeConfig') 15 | const saveFile = require('../utils/saveFile') 16 | 17 | /** 18 | * Creates CONTRIBUTING.md file. The `in template` is dependent 19 | * upon various config values. However, the `out template` is 20 | * always `CONTRIBUTING.md` file. 21 | * 22 | * @method task 23 | * 24 | * @param {Object} config 25 | * 26 | * @return {void} 27 | */ 28 | function task (config) { 29 | mergeConfig(config, { force: false }) 30 | 31 | /** 32 | * Choosing which template to use 33 | */ 34 | let templateFile = 'CONTRIBUTING.md' 35 | if (config.core) { 36 | templateFile = 'CONTRIBUTING_CORE.md' 37 | } else if (config.ts) { 38 | templateFile = 'CONTRIBUTING_TS.md' 39 | } 40 | 41 | debug('template file %s', templateFile) 42 | 43 | const existingContributingFile = template('CONTRIBUTING.md') 44 | existingContributingFile.delete() 45 | 46 | const file = template('.github/CONTRIBUTING.md', join(__dirname, 'templates', templateFile)) 47 | file.apply() 48 | 49 | saveFile(file, config.force) 50 | } 51 | 52 | task.description = 'Adds CONTRIBUTING.md file' 53 | module.exports = task 54 | -------------------------------------------------------------------------------- /readme-toc/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { join } = require('path') 11 | const { chmodSync } = require('fs') 12 | const { execSync } = require('child_process') 13 | const mergeConfig = require('../utils/mergeConfig') 14 | const { packageJson, install, lines } = require('mrm-core') 15 | 16 | function task (config) { 17 | mergeConfig(config, { 18 | generateToc: false 19 | }) 20 | 21 | /** 22 | * Remove existing pre commit hook from the package file 23 | */ 24 | const pkgFile = packageJson() 25 | pkgFile.unset('husky.hooks.pre-commit') 26 | pkgFile.save() 27 | 28 | if (!config.generateToc) { 29 | return 30 | } 31 | 32 | /** 33 | * Setup husky 34 | */ 35 | execSync('npx husky install') 36 | 37 | /** 38 | * Create pre-commit file 39 | */ 40 | const commitFile = lines('.husky/pre-commit') 41 | .add('#!/bin/sh') 42 | .add('. "$(dirname "$0")/_/husky.sh"') 43 | .add('npx doctoc README.md --title=\'## Table of contents\'') 44 | .add('git add README.md') 45 | 46 | const fileAlreadyExists = commitFile.exists() 47 | commitFile.save() 48 | 49 | /** 50 | * Change mode when file not already exists 51 | */ 52 | if (!fileAlreadyExists) { 53 | chmodSync(join(process.cwd(), '.husky/pre-commit'), 0o0755) 54 | } 55 | 56 | /** 57 | * Install required dependencies 58 | */ 59 | install(['doctoc', 'husky']) 60 | } 61 | 62 | task.description = 'Generate TOC for readme.md file' 63 | module.exports = task 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adonisjs/mrm-preset", 3 | "version": "5.0.3", 4 | "description": "MRM preset used by adonisjs for all core packages", 5 | "main": "config.json", 6 | "files": [ 7 | "*" 8 | ], 9 | "scripts": { 10 | "lint": "standard", 11 | "release": "np" 12 | }, 13 | "keywords": [ 14 | "mrm", 15 | "mrm-tasks" 16 | ], 17 | "author": "virk", 18 | "license": "MIT", 19 | "dependencies": { 20 | "chalk": "^4.1.1", 21 | "debug": "^4.3.4", 22 | "deep-extend": "^0.6.0", 23 | "git-user-email": "^0.2.2", 24 | "git-user-name": "^2.0.0", 25 | "inquirer": "^8.2.2", 26 | "mrm-core": "^7.0.0", 27 | "mrm-task-license": "^5.0.0", 28 | "parse-github-url": "^1.0.2", 29 | "recast": "^0.20.4" 30 | }, 31 | "devDependencies": { 32 | "cz-conventional-changelog": "^3.3.0", 33 | "doctoc": "^2.1.0", 34 | "fs-extra": "^10.0.1", 35 | "klaw": "^4.0.1", 36 | "mrm": "^4.0.0", 37 | "np": "^7.6.1", 38 | "standard": "^16.0.4", 39 | "yorkie": "^2.0.0" 40 | }, 41 | "config": { 42 | "commitizen": { 43 | "path": "./node_modules/cz-conventional-changelog" 44 | } 45 | }, 46 | "gitHooks": { 47 | "pre-commit": "node bin/readme.js && doctoc README.md --title='## Table of contents' && git add README.md" 48 | }, 49 | "np": { 50 | "tests": false, 51 | "branch": "master" 52 | }, 53 | "repository": { 54 | "type": "git", 55 | "url": "git+https://github.com/adonisjs/mrm-preset.git" 56 | }, 57 | "bugs": { 58 | "url": "https://github.com/adonisjs/mrm-preset/issues" 59 | }, 60 | "homepage": "https://github.com/adonisjs/mrm-preset#readme", 61 | "snyk": true 62 | } 63 | -------------------------------------------------------------------------------- /editorconfig/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { ini } = require('mrm-core') 11 | const debug = require('debug')('adonis:mrm-editorconfig') 12 | 13 | /** 14 | * The defaults has precedence over the contents inside 15 | * the user config file. This is the only way we can 16 | * keep the config files updates 17 | * 18 | * @type {Object} 19 | */ 20 | const defaults = { 21 | '_global': { 22 | root: true 23 | }, 24 | '*': { 25 | indent_style: 'space', 26 | indent_size: 2, 27 | end_of_line: 'lf', 28 | charset: 'utf-8', 29 | trim_trailing_whitespace: true, 30 | insert_final_newline: true 31 | }, 32 | '*.json': { 33 | insert_final_newline: false 34 | }, 35 | '**.min.js': { 36 | insert_final_newline: false 37 | }, 38 | MakeFile: { 39 | indent_style: 'space' 40 | }, 41 | '*.md': { 42 | trim_trailing_whitespace: false 43 | } 44 | } 45 | 46 | /** 47 | * Merge section with the default config 48 | * 49 | * @param {String} 50 | * @param {Object} 51 | * @return {Object} 52 | */ 53 | function mergeSection (section, existing = {}) { 54 | const defaultConfig = defaults[section] || {} 55 | return Object.assign(existing, defaultConfig) 56 | } 57 | 58 | /** 59 | * Creates `.editorconfig` file. The config file is same for 60 | * all projects and doesn't divert on the basis of config 61 | * 62 | * @return {void} 63 | */ 64 | function task () { 65 | const file = ini('.editorconfig', 'http://editorconfig.org') 66 | 67 | Object.keys(defaults).forEach((name) => { 68 | const values = mergeSection(name, file.get(name)) 69 | debug('section %s: %o', name, values) 70 | file.set(name, values) 71 | }) 72 | 73 | file.save() 74 | } 75 | 76 | task.description = 'Adds EditorConfig file' 77 | 78 | module.exports = task 79 | -------------------------------------------------------------------------------- /validate-commit/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { join } = require('path') 11 | const { chmodSync } = require('fs') 12 | const { execSync } = require('child_process') 13 | const { packageJson, install, template, lines } = require('mrm-core') 14 | 15 | const prTemplate = '.github/COMMIT_CONVENTION.md' 16 | 17 | function task () { 18 | const pkgFile = packageJson() 19 | 20 | /** 21 | * Below is the script for interactively creating a commit 22 | */ 23 | pkgFile.setScript('commit', 'git-cz') 24 | pkgFile.set('config.commitizen.path', 'cz-conventional-changelog') 25 | 26 | /** 27 | * Save the package file 28 | */ 29 | pkgFile.save() 30 | 31 | /** 32 | * Install required dependencies 33 | */ 34 | install(['cz-conventional-changelog', 'commitizen', 'husky']) 35 | 36 | /** 37 | * Setup husky 38 | */ 39 | execSync('npx husky install') 40 | 41 | /** 42 | * Create commit-msg file 43 | */ 44 | const commitFile = lines('.husky/commit-msg') 45 | .add('#!/bin/sh') 46 | .add('. "$(dirname "$0")/_/husky.sh"') 47 | .add('HUSKY_GIT_PARAMS=$1 node ./node_modules/@adonisjs/mrm-preset/validate-commit/conventional/validate.js') 48 | 49 | const fileAlreadyExists = commitFile.exists() 50 | commitFile.save() 51 | 52 | /** 53 | * Change mode when file not already exists 54 | */ 55 | if (!fileAlreadyExists) { 56 | chmodSync(join(process.cwd(), '.husky/commit-msg'), 0o0755) 57 | } 58 | 59 | /** 60 | * Remove old husky hooks block 61 | */ 62 | pkgFile.unset( 63 | 'husky.hooks.commit-msg', 64 | 'node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js' 65 | ) 66 | 67 | /** 68 | * Copy commit convention template 69 | */ 70 | template(prTemplate, join(__dirname, 'conventional', 'template.md')).apply({}).save() 71 | } 72 | 73 | task.description = 'Enforces commit message convention' 74 | module.exports = task 75 | -------------------------------------------------------------------------------- /bin/readme.js: -------------------------------------------------------------------------------- 1 | const klaw = require('klaw') 2 | const { join, sep } = require('path') 3 | const { readFile, writeFile } = require('fs-extra') 4 | 5 | const BASE_DIR = join(__dirname, '..') 6 | 7 | /** 8 | * Ensures the path is for a task directory 9 | */ 10 | function isAllowed (itemPath) { 11 | if (itemPath === BASE_DIR) { 12 | return false 13 | } 14 | 15 | const tokens = itemPath.split(sep) 16 | return ['node_modules', '.git', 'bin', 'init', 'utils'].indexOf(tokens[tokens.length - 1]) === -1 17 | } 18 | 19 | /** 20 | * Scans for all directories that have mrm tasks. Later we 21 | * read `README.md` files from them and each task must 22 | * have readme file 23 | */ 24 | function scanTasksDirs () { 25 | return new Promise((resolve, reject) => { 26 | const tasksDirs = [] 27 | 28 | klaw(BASE_DIR, { depthLimit: 0 }) 29 | .on('data', (item) => { 30 | if (item.stats.isDirectory() && isAllowed(item.path)) { 31 | tasksDirs.push(item.path) 32 | } 33 | }) 34 | .on('end', () => resolve(tasksDirs)) 35 | .on('error', reject) 36 | }) 37 | } 38 | 39 | function getReadmeContents (taskDir) { 40 | return readFile(join(taskDir, 'README.md'), 'utf-8') 41 | } 42 | 43 | async function patchReadmeFile (tasksDocs) { 44 | const readmeFile = await readFile(join(BASE_DIR, 'README.md'), 'utf-8') 45 | const [mainFile] = readmeFile.split('') 46 | 47 | const newContents = [ 48 | mainFile, 49 | '', 50 | '\n', 51 | '', 52 | '\n', 53 | '\n', 54 | tasksDocs.join('\n'), 55 | '\n', 56 | '' 57 | ] 58 | 59 | await writeFile(join(BASE_DIR, 'README.md'), newContents.join('')) 60 | } 61 | 62 | scanTasksDirs() 63 | .then((tasksDirs) => { 64 | return Promise.all(tasksDirs.map(getReadmeContents)) 65 | }) 66 | .then(patchReadmeFile) 67 | .then(() => { 68 | console.log('done') 69 | process.exit(0) 70 | }) 71 | .catch((error) => { 72 | console.log(error.message) 73 | process.exit(1) 74 | }) 75 | -------------------------------------------------------------------------------- /circleci/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { yaml, deleteFiles } = require('mrm-core') 11 | const mergeConfig = require('../utils/mergeConfig') 12 | 13 | function task (config) { 14 | mergeConfig(config, { 15 | services: ['circleci'], 16 | minNodeVersion: 'latest', 17 | core: false 18 | }) 19 | 20 | const hasCircleCi = config.services.indexOf('circleci') > -1 21 | if (!hasCircleCi) { 22 | deleteFiles(['.circleci/config.yml']) 23 | return 24 | } 25 | 26 | const circleCiFile = yaml('.circleci/config.yml').set('version', 2) 27 | const versions = config.minNodeVersion === 'latest' ? ['latest'] : [config.minNodeVersion, 'latest'] 28 | 29 | /** 30 | * Define build for each nodejs version. Later we will use workflows to 31 | * run each version 32 | */ 33 | const jobs = versions.reduce((result, version) => { 34 | result[`build_${version}`] = { 35 | docker: [{ 36 | image: `circleci/node:${version}` 37 | }], 38 | working_directory: '~/app', 39 | steps: [ 40 | 'checkout', 41 | { 42 | restore_cache: { 43 | keys: ['v1-dependencies-{{ checksum "package.json" }}', 'v1-dependencies-'] 44 | } 45 | }, 46 | { 47 | run: 'npm install' 48 | }, 49 | { 50 | save_cache: { 51 | paths: ['node_modules'], 52 | key: 'v1-dependencies-{{ checksum "package.json" }}' 53 | } 54 | }, 55 | { 56 | run: 'npm test' 57 | } 58 | ] 59 | } 60 | 61 | return result 62 | }, {}) 63 | 64 | circleCiFile.set('jobs', jobs) 65 | circleCiFile.set('workflows', { 66 | version: 2, 67 | workflow: { 68 | jobs: versions.map((version) => `build_${version}`) 69 | } 70 | }) 71 | 72 | circleCiFile.save() 73 | } 74 | 75 | task.description = 'Adds .circleci/config.yml file' 76 | module.exports = task 77 | -------------------------------------------------------------------------------- /package/TsPreset.js: -------------------------------------------------------------------------------- 1 | /* 2 | * adonis-mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { json, install, uninstall } = require('mrm-core') 11 | const debug = require('debug')('adonis:mrm-package') 12 | 13 | class TsPreset { 14 | constructor () { 15 | this.dependencies = [ 16 | '@adonisjs/require-ts', 17 | 'typescript', 18 | '@types/node', 19 | 'del-cli' 20 | ] 21 | } 22 | 23 | /** 24 | * Installing dependencies for a Typescript project 25 | * 26 | * @method install 27 | * 28 | * @param {Array} baseDependencies 29 | * 30 | * @return {void} 31 | */ 32 | install (baseDependencies) { 33 | const dependencies = baseDependencies.concat(this.dependencies) 34 | 35 | debug('installing dependencies %o', dependencies) 36 | install(dependencies) 37 | } 38 | 39 | /** 40 | * Removing dependencies for a Typescript project 41 | * 42 | * @method uninstall 43 | * 44 | * @return {void} 45 | */ 46 | uninstall () { 47 | debug('removing dependencies %o', this.dependencies) 48 | uninstall(this.dependencies) 49 | } 50 | 51 | /** 52 | * Mutating the package file for a typescript project 53 | * 54 | * @method up 55 | * 56 | * @param {Object} pkgFile 57 | * 58 | * @return {void} 59 | */ 60 | up (pkgFile) { 61 | pkgFile.setScript('clean', 'del-cli build') 62 | pkgFile.setScript('compile', 'npm run lint && npm run clean && tsc') 63 | pkgFile.setScript('build', 'npm run compile') 64 | pkgFile.setScript('prepublishOnly', 'npm run build') 65 | 66 | /** 67 | * Set files to publish along with the main file 68 | */ 69 | if (!pkgFile.get('main')) { 70 | pkgFile.set('main', 'build/index.js') 71 | } 72 | 73 | if (!pkgFile.get('files')) { 74 | pkgFile.set('files', [ 75 | 'build/src', 76 | 'build/index.d.ts', 77 | 'build/index.js' 78 | ]) 79 | } 80 | 81 | debug('creating files %o', ['tsconfig.json']) 82 | json('tsconfig.json').merge({ extends: './node_modules/@adonisjs/mrm-preset/_tsconfig' }).save() 83 | } 84 | } 85 | 86 | module.exports = new TsPreset() 87 | -------------------------------------------------------------------------------- /github-actions/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { yaml, deleteFiles } = require('mrm-core') 11 | const mergeConfig = require('../utils/mergeConfig') 12 | 13 | function getJobsPayload(os, nodeVersions) { 14 | return { 15 | 'runs-on': os, 16 | strategy: { 17 | matrix: { 18 | 'node-version': [].concat(nodeVersions) 19 | } 20 | }, 21 | steps: [ 22 | { 23 | uses: 'actions/checkout@v2' 24 | }, 25 | { 26 | name: 'Use Node.js ${{ matrix.node-version }}', 27 | uses: 'actions/setup-node@v1', 28 | with: { 29 | 'node-version': '${{ matrix.node-version }}' 30 | } 31 | }, 32 | { 33 | name: 'Install', 34 | run: 'npm install' 35 | }, 36 | { 37 | name: 'Run tests', 38 | run: 'npm test' 39 | } 40 | ] 41 | } 42 | } 43 | 44 | function task (config) { 45 | mergeConfig(config, { 46 | services: ['github-actions'], 47 | minNodeVersion: 'latest', 48 | core: false 49 | }) 50 | 51 | const hasGithubActions = config.services.indexOf('github-actions') > -1 52 | if (!hasGithubActions) { 53 | deleteFiles(['.github/workflows/test.yml']) 54 | return 55 | } 56 | 57 | /** 58 | * Versions to test against. Github actions doesn't allow 59 | * "latest" keyword as of now 60 | */ 61 | const versions = config.minNodeVersion === 'latest' 62 | ? ['17.x'] 63 | : [config.minNodeVersion, '17.x'] 64 | 65 | const githubActionsFile = yaml('.github/workflows/test.yml') 66 | githubActionsFile.set('name', 'test') 67 | githubActionsFile.set('on', ['push', 'pull_request']) 68 | 69 | /** 70 | * Define build for each nodejs version. Later we will use workflows to 71 | * run each version 72 | */ 73 | const jobs = { 74 | linux: getJobsPayload('ubuntu-latest', versions), 75 | ...(config.runGhActionsOnWindows ? { windows: getJobsPayload('windows-latest', versions) } : {}), 76 | } 77 | 78 | githubActionsFile.set('jobs', jobs) 79 | githubActionsFile.save() 80 | } 81 | 82 | task.description = 'Adds .github/workflows/test.yml file' 83 | module.exports = task 84 | -------------------------------------------------------------------------------- /prettier/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { json, install, packageJson, lines } = require('mrm-core') 11 | 12 | function task () { 13 | /** 14 | * Delete old prettierrc file 15 | */ 16 | const prettierRc = json('.prettierrc') 17 | prettierRc.delete() 18 | 19 | /** 20 | * Update package file 21 | */ 22 | const pkgFile = packageJson() 23 | pkgFile.setScript('format', 'prettier --write .') 24 | pkgFile.set('prettier', { 25 | trailingComma: 'es5', 26 | semi: false, 27 | singleQuote: true, 28 | useTabs: false, 29 | quoteProps: 'consistent', 30 | bracketSpacing: true, 31 | arrowParens: 'always', 32 | printWidth: 100 33 | }) 34 | 35 | const existingEslintConfig = pkgFile.get('eslintConfig') 36 | 37 | /** 38 | * Push to existing config 39 | */ 40 | if (existingEslintConfig) { 41 | existingEslintConfig.extends = existingEslintConfig.extends || [] 42 | existingEslintConfig.extends.push('prettier') 43 | 44 | existingEslintConfig.plugins = existingEslintConfig.plugins || [] 45 | existingEslintConfig.plugins.push('prettier') 46 | 47 | existingEslintConfig.rules = Object.assign({}, existingEslintConfig.rules, { 48 | 'prettier/prettier': ['error', { endOfLine: 'auto' }] 49 | }) 50 | } 51 | 52 | pkgFile.save() 53 | 54 | /** 55 | * Add .prettierignore file 56 | */ 57 | const prettierIgnore = lines('.prettierignore') 58 | prettierIgnore.add('build') 59 | prettierIgnore.add('docs') 60 | prettierIgnore.add('*.md') 61 | prettierIgnore.add('config.json') 62 | prettierIgnore.add('.eslintrc.json') 63 | prettierIgnore.add('package.json') 64 | prettierIgnore.add('*.html') 65 | prettierIgnore.add('*.txt') 66 | prettierIgnore.save() 67 | 68 | const plugins = ['prettier'] 69 | 70 | /** 71 | * Only install when using eslint 72 | */ 73 | if (existingEslintConfig) { 74 | plugins.push('eslint-plugin-prettier') 75 | plugins.push('eslint-config-prettier') 76 | } 77 | 78 | /** 79 | * Install required dependencies 80 | */ 81 | install(plugins) 82 | } 83 | 84 | task.description = 'Adds prettier to the project' 85 | module.exports = task 86 | -------------------------------------------------------------------------------- /readme/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const path = require('path') 11 | const { template, packageJson } = require('mrm-core') 12 | const gitUserName = require('git-user-name') 13 | 14 | const gh = require('../utils/ghAttributes') 15 | const Services = require('../utils/Services') 16 | const saveFile = require('../utils/saveFile') 17 | const mergeConfig = require('../utils/mergeConfig') 18 | 19 | function task (config) { 20 | const ghAttributes = gh('creating README.md file') 21 | 22 | mergeConfig(config, { 23 | packageName: packageJson().get('name') || 'Anonymous', 24 | repoName: ghAttributes.name, 25 | owner: ghAttributes.owner, 26 | ghUsername: gitUserName(), 27 | force: false, 28 | appveyorUsername: ghAttributes.owner 29 | }) 30 | 31 | const servicesList = config.services || [] 32 | 33 | /** 34 | * Adding npm, license and typescript services 35 | */ 36 | servicesList.push('npm', 'license', 'typescript') 37 | 38 | const services = new Services(servicesList, { 39 | owner: config.owner, 40 | appveyorUsername: config.appveyorUsername, 41 | repoName: config.repoName, 42 | packageName: config.packageName 43 | }) 44 | 45 | const templateFile = config.core ? 'README_CORE.md' : 'README.md' 46 | const readme = template('README.md', path.join(__dirname, 'templates', templateFile)) 47 | let banner = '' 48 | 49 | /** 50 | * AdonisJS banner 51 | */ 52 | if (config.packageName.startsWith('@adonisjs')) { 53 | banner = '
' 54 | } 55 | 56 | /** 57 | * Poppinss banner 58 | */ 59 | if (config.packageName.startsWith('@poppinss')) { 60 | banner = '
' 61 | } 62 | 63 | const badges = services.getReferences() 64 | 65 | readme.apply(Object.assign({ 66 | servicesUrls: services.getUrls(), 67 | servicesBadges: badges, 68 | banner: banner 69 | }, config)) 70 | 71 | /** 72 | * Create readme file 73 | */ 74 | saveFile(readme, config.force) 75 | } 76 | 77 | task.description = 'Add README.md file' 78 | 79 | module.exports = task 80 | -------------------------------------------------------------------------------- /utils/buildJapaFile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const recast = require('recast') 11 | 12 | /** 13 | * Added to japaFile.js 14 | */ 15 | const japaFileContents = `const { configure } = require('japa') 16 | 17 | configure({ 18 | files: ['test/**/*.spec.ts'], 19 | })` 20 | 21 | /** 22 | * Add to japaFile.js when project uses Typescript 23 | */ 24 | const tsRegisterContent = 'require(\'@adonisjs/require-ts/build/register\')\n\n' 25 | 26 | /** 27 | * Returns the name of the require module. It is the job 28 | * of the consumer to pass the `CallExpression` node 29 | * to this method. 30 | * 31 | * @method getRequireName 32 | * 33 | * @param {Object} node 34 | * 35 | * @return {String|Null} 36 | */ 37 | function getRequireName (node) { 38 | if (!node.callee || node.callee.name !== 'require') { 39 | return null 40 | } 41 | 42 | if (node.arguments[0].type !== 'Literal') { 43 | return null 44 | } 45 | 46 | return node.arguments[0].value 47 | } 48 | 49 | module.exports = function (existingContent, ts) { 50 | let usingRequireTs = false 51 | let usingJapa = false 52 | 53 | const ast = recast.parse(existingContent) 54 | 55 | /** 56 | * Looking for all callExpressions and finding neccessary `require` 57 | * calls. 58 | */ 59 | recast.types.visit(ast, { 60 | visitCallExpression ({ node }) { 61 | if (getRequireName(node) === 'japa') { 62 | usingJapa = true 63 | } 64 | 65 | if (getRequireName(node) === '@adonisjs/require-ts/build/register') { 66 | usingRequireTs = true 67 | } 68 | 69 | return false 70 | } 71 | }) 72 | 73 | /** 74 | * Add japa file contents 75 | */ 76 | if (!usingJapa) { 77 | if (!usingRequireTs) { 78 | ast.program.body = recast.parse(japaFileContents).program.body.concat(ast.program.body) 79 | } else { 80 | ast.program.body = ast.program.body.concat(recast.parse(`\n\n${japaFileContents}`).program.body) 81 | } 82 | } 83 | 84 | /** 85 | * Add ts related code when missing. Also make sure this is added 86 | * as the first line inside the japaFile.js file 87 | */ 88 | if (!usingRequireTs) { 89 | ast.program.body = recast.parse(tsRegisterContent).program.body.concat(ast.program.body) 90 | } 91 | 92 | /** 93 | * Print and return a string back 94 | */ 95 | return recast.print(ast).code 96 | } 97 | -------------------------------------------------------------------------------- /validate-commit/conventional/template.md: -------------------------------------------------------------------------------- 1 | ## Git Commit Message Convention 2 | 3 | > This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). 4 | 5 | Using conventional commit messages, we can automate the process of generating the CHANGELOG file. All commits messages will automatically be validated against the following regex. 6 | 7 | ``` js 8 | /^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build|improvement)(\(.+\))?: .{1,50}/ 9 | ``` 10 | 11 | ## Commit Message Format 12 | A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: 13 | 14 | > The **scope** is optional 15 | 16 | ``` 17 | feat(router): add support for prefix 18 | 19 | Prefix makes it easier to append a path to a group of routes 20 | ``` 21 | 22 | 1. `feat` is type. 23 | 2. `router` is scope and is optional 24 | 3. `add support for prefix` is the subject 25 | 4. The **body** is followed by a blank line. 26 | 5. The optional **footer** can be added after the body, followed by a blank line. 27 | 28 | ## Types 29 | Only one type can be used at a time and only following types are allowed. 30 | 31 | - feat 32 | - fix 33 | - docs 34 | - style 35 | - refactor 36 | - perf 37 | - test 38 | - workflow 39 | - ci 40 | - chore 41 | - types 42 | - build 43 | 44 | If a type is `feat`, `fix` or `perf`, then the commit will appear in the CHANGELOG.md file. However if there is any BREAKING CHANGE, the commit will always appear in the changelog. 45 | 46 | ### Revert 47 | If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit `., where the hash is the SHA of the commit being reverted. 48 | 49 | ## Scope 50 | The scope could be anything specifying place of the commit change. For example: `router`, `view`, `querybuilder`, `database`, `model` and so on. 51 | 52 | ## Subject 53 | The subject contains succinct description of the change: 54 | 55 | - use the imperative, present tense: "change" not "changed" nor "changes". 56 | - don't capitalize first letter 57 | - no dot (.) at the end 58 | 59 | ## Body 60 | 61 | Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". 62 | The body should include the motivation for the change and contrast this with previous behavior. 63 | 64 | ## Footer 65 | 66 | The footer should contain any information about **Breaking Changes** and is also the place to 67 | reference GitHub issues that this commit **Closes**. 68 | 69 | **Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. 70 | 71 | -------------------------------------------------------------------------------- /contributing/templates/CONTRIBUTING_CORE.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | AdonisJS is a community driven project. You are free to contribute in any of the following ways. 4 | 5 | - [Coding style](coding-style) 6 | - [Fix bugs by creating PR's](fix-bugs-by-creating-prs) 7 | - [Share an RFC for new features or big changes](share-an-rfc-for-new-features-or-big-changes) 8 | - [Report security issues](report-security-issues) 9 | - [Be a part of the community](be-a-part-of-community) 10 | 11 | ## Coding style 12 | 13 | Majority of AdonisJS core packages are written in Typescript. Having a brief knowledge of Typescript is required to contribute to the core. 14 | 15 | ## Fix bugs by creating PR's 16 | 17 | We appreciate every time you report a bug in the framework or related libraries. However, taking time to submit a PR can help us in fixing bugs quickly and ensure a healthy and stable eco-system. 18 | 19 | Go through the following points, before creating a new PR. 20 | 21 | 1. Create an issue discussing the bug or short-coming in the framework. 22 | 2. Once approved, go ahead and fork the REPO. 23 | 3. Make sure to start from the `develop`, since this is the upto date branch. 24 | 4. Make sure to keep commits small and relevant. 25 | 5. We follow [conventional-commits](https://github.com/conventional-changelog/conventional-changelog) to structure our commit messages. Instead of running `git commit`, you must run `npm commit`, which will show you prompts to create a valid commit message. 26 | 6. Once done with all the changes, create a PR against the `develop` branch. 27 | 28 | ## Share an RFC for new features or big changes 29 | 30 | Sharing PR's for small changes works great. However, when contributing big features to the framework, it is required to go through the RFC process. 31 | 32 | ### What is an RFC? 33 | 34 | RFC stands for **Request for Commits**, a standard process followed by many other frameworks including [Ember](https://github.com/emberjs/rfcs), [yarn](https://github.com/yarnpkg/rfcs) and [rust](https://github.com/rust-lang/rfcs). 35 | 36 | In brief, RFC process allows you to talk about the changes with everyone in the community and get a view of the core team before dedicating your time to work on the feature. 37 | 38 | The RFC proposals are created as Pull Request on [adonisjs/rfcs](https://github.com/adonisjs/rfcs) repo. Make sure to read the README to learn about the process in depth. 39 | 40 | ## Report security issues 41 | 42 | All of the security issues, must be reported via [email](mailto:virk@adonisjs.com) and not using any of the public channels. 43 | 44 | ## Be a part of community 45 | 46 | We welcome you to participate in [GitHub Discussion](https://github.com/adonisjs/core/discussions) and the AdonisJS [Discord Server](https://discord.gg/vDcEjq6). You are free to ask your questions and share your work or contributions made to AdonisJS eco-system. 47 | -------------------------------------------------------------------------------- /utils/Services.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const { MrmError } = require('mrm-core') 11 | 12 | /** 13 | * Build URL's for badges to be used inside the README.md file 14 | * 15 | * @class Services 16 | * 17 | * @param {Array} list Array of services from the config file 18 | * @param {Object} metaData Git and package.json file metaData 19 | */ 20 | class Services { 21 | constructor (list, { owner, appveyorUsername, repoName, packageName }) { 22 | this.list = list 23 | this.appveyorUsername = appveyorUsername 24 | this.repoName = repoName 25 | this.repo = `${owner}/${repoName}` 26 | this.packageName = packageName 27 | } 28 | 29 | /** 30 | * Returns an object with the URL and IMAGE for a given 31 | * service. 32 | * 33 | * @method getServiceData 34 | * 35 | * @param {String} service 36 | * 37 | * @return {Object} 38 | */ 39 | getServiceData (service) { 40 | switch (service) { 41 | case 'appveyor': 42 | return { 43 | url: `https://ci.appveyor.com/project/${this.appveyorUsername}/${this.repoName}`, 44 | image: `https://img.shields.io/appveyor/ci/${this.appveyorUsername}/${this.repoName}/master.svg?style=for-the-badge&logo=appveyor` 45 | } 46 | case 'circleci': 47 | return { 48 | url: `https://circleci.com/gh/${this.repo}`, 49 | image: `https://img.shields.io/circleci/project/github/${this.repo}/master.svg?style=for-the-badge&logo=circleci` 50 | } 51 | case 'npm': 52 | return { 53 | url: `https://npmjs.org/package/${this.packageName}`, 54 | image: `https://img.shields.io/npm/v/${this.packageName}.svg?style=for-the-badge&logo=npm` 55 | } 56 | case 'license': 57 | return { 58 | url: 'LICENSE.md', 59 | image: `https://img.shields.io/npm/l/${this.packageName}?color=blueviolet&style=for-the-badge` 60 | } 61 | case 'github-actions': 62 | return { 63 | url: `https://img.shields.io/github/workflow/status/${this.repoName}/test?style=for-the-badge`, 64 | image: `https://github.com/${this.repoName}/actions/workflows/test.yml` 65 | } 66 | case 'typescript': 67 | return { 68 | url: '', 69 | image: 'https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript' 70 | } 71 | default: 72 | throw new MrmError(`${service} is not supported. Please remove it from config.json file`) 73 | } 74 | } 75 | 76 | /** 77 | * Returns a multiline markdown formatted string of URL 78 | * definations to be used in README.md file. 79 | * 80 | * @method getUrls 81 | * 82 | * @return {String} 83 | */ 84 | getUrls () { 85 | return this.list.map((item) => { 86 | const { url, image } = this.getServiceData(item) 87 | return `[${item}-image]: ${image}\n[${item}-url]: ${url} "${item}"` 88 | }).join('\n\n') 89 | } 90 | 91 | /** 92 | * Returns a markdown formatted reference url 93 | * to the badges URL's obtained using `this.getUrls()` 94 | * 95 | * @method getReferences 96 | * 97 | * @return {String} 98 | */ 99 | getReferences () { 100 | return this.list.map((item) => { 101 | return `[![${item}-image]][${item}-url]` 102 | }).join(' ') 103 | } 104 | } 105 | 106 | module.exports = Services 107 | -------------------------------------------------------------------------------- /gh-labels.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Priority: Critical", 4 | "color": "ea0056", 5 | "description": "The issue needs urgent attention", 6 | "aliases": [] 7 | }, 8 | { 9 | "name": "Priority: High", 10 | "color": "5666ed", 11 | "description": "Look into this issue before picking up any new work", 12 | "aliases": [] 13 | }, 14 | { 15 | "name": "Priority: Medium", 16 | "color": "f4ff61", 17 | "description": "Try to fix the issue for the next patch/minor release", 18 | "aliases": [] 19 | }, 20 | { 21 | "name": "Priority: Low", 22 | "color": "87dfd6", 23 | "description": "Something worth considering, but not a top priority for the team", 24 | "aliases": [] 25 | }, 26 | { 27 | "name": "Semver: Alpha", 28 | "color": "008480", 29 | "description": "Will make it's way to the next alpha version of the package", 30 | "aliases": [] 31 | }, 32 | { 33 | "name": "Semver: Major", 34 | "color": "ea0056", 35 | "description": "Has breaking changes", 36 | "aliases": [] 37 | }, 38 | { 39 | "name": "Semver: Minor", 40 | "color": "fbe555", 41 | "description": "Mainly new features and improvements", 42 | "aliases": [] 43 | }, 44 | { 45 | "name": "Semver: Next", 46 | "color": "5666ed", 47 | "description": "Will make it's way to the bleeding edge version of the package", 48 | "aliases": [] 49 | }, 50 | { 51 | "name": "Semver: Patch", 52 | "color": "87dfd6", 53 | "description": "A bug fix", 54 | "aliases": [] 55 | }, 56 | { 57 | "name": "Status: Abandoned", 58 | "color": "ffffff", 59 | "description": "Dropped and not into consideration", 60 | "aliases": ["wontfix"] 61 | }, 62 | { 63 | "name": "Status: Accepted", 64 | "color": "e5fbf2", 65 | "description": "The proposal or the feature has been accepted for the future versions", 66 | "aliases": [] 67 | }, 68 | { 69 | "name": "Status: Blocked", 70 | "color": "ea0056", 71 | "description": "The work on the issue or the PR is blocked. Check comments for reasoning", 72 | "aliases": [] 73 | }, 74 | { 75 | "name": "Status: Completed", 76 | "color": "008672", 77 | "description": "The work has been completed, but not released yet", 78 | "aliases": [] 79 | }, 80 | { 81 | "name": "Status: In Progress", 82 | "color": "73dbc4", 83 | "description": "Still banging the keyboard", 84 | "aliases": ["in progress"] 85 | }, 86 | { 87 | "name": "Status: On Hold", 88 | "color": "f4ff61", 89 | "description": "The work was started earlier, but is on hold now. Check comments for reasoning", 90 | "aliases": ["On Hold"] 91 | }, 92 | { 93 | "name": "Status: Review Needed", 94 | "color": "fbe555", 95 | "description": "Review from the core team is required before moving forward", 96 | "aliases": [] 97 | }, 98 | { 99 | "name": "Status: Awaiting More Information", 100 | "color": "89f8ce", 101 | "description": "Waiting on the issue reporter or PR author to provide more information", 102 | "aliases": [] 103 | }, 104 | { 105 | "name": "Status: Need Contributors", 106 | "color": "7057ff", 107 | "description": "Looking for contributors to help us move forward with this issue or PR", 108 | "aliases": [] 109 | }, 110 | { 111 | "name": "Type: Bug", 112 | "color": "ea0056", 113 | "description": "The issue has indentified a bug", 114 | "aliases": ["bug"] 115 | }, 116 | { 117 | "name": "Type: Security", 118 | "color": "ea0056", 119 | "description": "Spotted security vulnerability and is a top priority for the core team", 120 | "aliases": [] 121 | }, 122 | { 123 | "name": "Type: Duplicate", 124 | "color": "00837e", 125 | "description": "Already answered or fixed previously", 126 | "aliases": ["duplicate"] 127 | }, 128 | { 129 | "name": "Type: Enhancement", 130 | "color": "89f8ce", 131 | "description": "Improving an existing feature", 132 | "aliases": ["enhancement"] 133 | }, 134 | { 135 | "name": "Type: Feature Request", 136 | "color": "483add", 137 | "description": "Request to add a new feature to the package", 138 | "aliases": [] 139 | }, 140 | { 141 | "name": "Type: Invalid", 142 | "color": "dbdbdb", 143 | "description": "Doesn't really belong here. Maybe use discussion threads?", 144 | "aliases": ["invalid"] 145 | }, 146 | { 147 | "name": "Type: Question", 148 | "color": "eceafc", 149 | "description": "Needs clarification", 150 | "aliases": ["help wanted", "question"] 151 | }, 152 | { 153 | "name": "Type: Documentation Change", 154 | "color": "7057ff", 155 | "description": "Documentation needs some improvements", 156 | "aliases": ["documentation"] 157 | }, 158 | { 159 | "name": "Type: Dependencies Update", 160 | "color": "00837e", 161 | "description": "Bump dependencies", 162 | "aliases": ["dependencies"] 163 | }, 164 | { 165 | "name": "Good First Issue", 166 | "color": "008480", 167 | "description": "Want to contribute? Just filter by this label", 168 | "aliases": ["good first issue"] 169 | } 170 | ] -------------------------------------------------------------------------------- /init/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @adonisjs/mrm-preset 3 | * 4 | * (c) Harminder Virk 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | const chalk = require('chalk') 11 | const inquirer = require('inquirer') 12 | const { json, ini, packageJson } = require('mrm-core') 13 | const { execSync } = require('child_process') 14 | const debug = require('debug')('adonis:mrm-init') 15 | 16 | const gitOrigin = { 17 | type: 'input', 18 | message: 'Enter git origin url', 19 | validate (input) { 20 | return !input ? 'Please create a git project and enter it\'s remote origin' : true 21 | }, 22 | when () { 23 | const gitFile = ini('.git/config') 24 | if (!gitFile.exists()) { 25 | return true 26 | } 27 | const origin = gitFile.get('remote "origin"') 28 | return !origin || !origin.url 29 | }, 30 | name: 'gitOrigin' 31 | } 32 | 33 | /** 34 | * Whether written by the core team or not 35 | * 36 | * @type {Object} 37 | */ 38 | const isCore = { 39 | type: 'confirm', 40 | message: 'Is it a package written by the AdonisJS core team', 41 | name: 'core' 42 | } 43 | 44 | /** 45 | * Generate readme toc or not 46 | * 47 | * @type {Object} 48 | */ 49 | const generateToc = { 50 | type: 'confirm', 51 | message: 'Automatically generate TOC for the README file', 52 | name: 'generateToc' 53 | } 54 | 55 | /** 56 | * The minimum node version supported by the project. 57 | * 58 | * @type {Object} 59 | */ 60 | const minNodeVersion = { 61 | type: 'list', 62 | message: 'Select the minimum node version your project will support', 63 | name: 'minNodeVersion', 64 | choices: [ 65 | { 66 | name: '16.13.1 (LTS)', 67 | value: '16.13.1', 68 | }, 69 | { 70 | name: 'latest', 71 | value: 'latest' 72 | } 73 | ] 74 | } 75 | 76 | /** 77 | * The project license 78 | * 79 | * @type {Object} 80 | */ 81 | const license = { 82 | type: 'list', 83 | choices: ['Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'MIT', 'Unlicense'], 84 | message: 'Select project license. Select Unlicense if not sure', 85 | name: 'license' 86 | } 87 | 88 | /** 89 | * Services to be used by the project 90 | * 91 | * @type {Object} 92 | */ 93 | const services = { 94 | type: 'checkbox', 95 | message: 'Select the CI services you want to use', 96 | choices: [ 97 | { 98 | name: 'Appveyor', 99 | value: 'appveyor' 100 | }, 101 | { 102 | name: 'Circle CI', 103 | value: 'circleci' 104 | }, 105 | { 106 | name: 'Github actions', 107 | value: 'github-actions' 108 | }, 109 | ], 110 | name: 'services' 111 | } 112 | 113 | /** 114 | * The appveyor username. Only asked when services 115 | * has `appveyor` in it 116 | * 117 | * @type {Object} 118 | */ 119 | const appveyorUsername = { 120 | type: 'input', 121 | message: 'Enter appveyor username', 122 | when: function (answers) { 123 | return answers.services.indexOf('appveyor') > -1 124 | }, 125 | name: 'appveyorUsername' 126 | } 127 | 128 | /** 129 | * Ask if should configure github actions to run on windows too. 130 | * 131 | * @type {Object} 132 | */ 133 | const runGhActionsOnWindows = { 134 | type: 'confirm', 135 | message: 'Run github actions on windows?', 136 | when: function (answers) { 137 | return answers.services.indexOf('github-actions') > -1 138 | }, 139 | name: 'runGhActionsOnWindows' 140 | } 141 | 142 | /** 143 | * The probot applications to use 144 | * @type {Object} 145 | */ 146 | const probotApps = { 147 | type: 'checkbox', 148 | message: 'Select the probot applications you want to use', 149 | choices: [ 150 | { 151 | name: 'Stale Issues', 152 | value: 'stale' 153 | }, 154 | { 155 | name: 'Lock Issues', 156 | value: 'lock' 157 | } 158 | ], 159 | name: 'probotApps' 160 | } 161 | 162 | /** 163 | * Running the task, asking questions and create a project 164 | * specific config file. 165 | * 166 | * @method task 167 | * 168 | * @return {void} 169 | */ 170 | async function task () { 171 | const oldConfig = json('config.json') 172 | /** 173 | * Move config file to package json 174 | */ 175 | if (oldConfig.exists()) { 176 | packageJson().set('mrmConfig', oldConfig.get()).save() 177 | oldConfig.delete() 178 | } 179 | 180 | const pkg = packageJson() 181 | const existingAnswers = pkg.get('mrmConfig', {}) 182 | 183 | /** 184 | * Fill existing values 185 | */ 186 | if (existingAnswers.minNodeVersion) { 187 | minNodeVersion.choices.unshift({ 188 | name: `${existingAnswers.minNodeVersion} (from existing config)`, 189 | value: existingAnswers.minNodeVersion, 190 | }) 191 | minNodeVersion.default = 0 192 | } 193 | 194 | isCore.default = existingAnswers.core 195 | generateToc.default = existingAnswers.generateToc 196 | license.default = existingAnswers.license 197 | services.default = existingAnswers.services 198 | appveyorUsername.default = existingAnswers.appveyorUsername 199 | runGhActionsOnWindows.default = existingAnswers.runGhActionsOnWindows 200 | probotApps.default = existingAnswers.probotApps 201 | 202 | const answers = await inquirer.prompt([ 203 | gitOrigin, 204 | minNodeVersion, 205 | isCore, 206 | generateToc, 207 | license, 208 | services, 209 | appveyorUsername, 210 | probotApps, 211 | runGhActionsOnWindows 212 | ]) 213 | 214 | const fileContent = { 215 | core: answers.core, 216 | license: answers.license, 217 | services: answers.services, 218 | appveyorUsername: answers.appveyorUsername, 219 | minNodeVersion: answers.minNodeVersion, 220 | probotApps: answers.probotApps, 221 | runGhActionsOnWindows: answers.runGhActionsOnWindows 222 | } 223 | 224 | debug('init %o', fileContent) 225 | 226 | pkg.set('mrmConfig', fileContent) 227 | pkg.save() 228 | 229 | /** 230 | * Initiate git repo, when answers has gitOrigin 231 | */ 232 | if (answers.gitOrigin) { 233 | console.log(chalk.yellow('git init')) 234 | execSync('git init') 235 | 236 | console.log(chalk.yellow(`git remote add origin ${answers.gitOrigin}`)) 237 | execSync(`git remote add origin ${answers.gitOrigin}`) 238 | } 239 | } 240 | 241 | task.description = 'Initiate the project config file' 242 | module.exports = task 243 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://res.cloudinary.com/adonisjs/image/upload/q_100/v1547549861/mrm_entbte.png) 2 | 3 | AdonisJS preset for [mrm](https://github.com/sapegin/mrm) to keep the project configuration files **in-sync** and **consistent across** various projects. 4 | 5 | 6 | 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 | - [Github templates](#github-templates) 19 | - [Github Actions](#github-actions) 20 | - [Gitignore template](#gitignore-template) 21 | - [License template](#license-template) 22 | - [Np release management](#np-release-management) 23 | - [Package file generation](#package-file-generation) 24 | - [Testing](#testing) 25 | - [Typescript setup](#typescript-setup) 26 | - [Scripts](#scripts) 27 | - [Prettier](#prettier) 28 | - [Probot applications](#probot-applications) 29 | - [Readme file](#readme-file) 30 | - [Readme file TOC](#readme-file-toc) 31 | - [Validate commit](#validate-commit) 32 | 33 | 34 | 35 | ## What is MRM? 36 | 37 | **You might be curious to know what the heck is MRM?** 38 | 39 | MRM 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. 40 | 41 | For better explanation, I recommend reading [this article](https://blog.sapegin.me/all/mrm) by the project author. 42 | 43 | ## What is MRM Preset? 44 | 45 | This module is a custom preset of tasks for MRM and is used by [AdonisJS](https://adonisjs.com) and many other projects I author. 46 | 47 | You 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. 48 | 49 | ## Getting started 50 | 51 | Let's quickly learn how to use this preset, before we dig into the specifics of tasks. 52 | 53 | ```sh 54 | npm i --save-dev mrm @adonisjs/mrm-preset 55 | ``` 56 | 57 | Add script to `package.json` file 58 | 59 | ```sh 60 | { 61 | "scripts": { 62 | "mrm": "mrm --preset=@adonisjs/mrm-preset" 63 | } 64 | } 65 | ``` 66 | 67 | and then run it as follows 68 | 69 | ```sh 70 | ## Initiate by creating config file 71 | npm run mrm init 72 | ``` 73 | 74 | ```sh 75 | ## Execute all tasks (for new projects) 76 | npm run mrm all 77 | ``` 78 | 79 | ## Tasks 80 | 81 | Let's focus on all the tasks supported by AdonisJS preset. 82 | 83 | 84 | 85 | 86 | ### Appveyor 87 | Appveyor 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. 88 | 89 | ```json 90 | { 91 | "services": ["appveyor"], 92 | "minNodeVersion": "12.0.0" 93 | } 94 | ``` 95 | 96 | To remove support for `appveyor` from your project, just `npm run mrm appveyor` task by removing the `appveyor` keyword from the `services` array. 97 | 98 | ```json 99 | { 100 | "services": [] 101 | } 102 | ``` 103 | 104 | ```sh 105 | npm run mrm appveyor 106 | ``` 107 | 108 | ### Circle CI 109 | Circle 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. 110 | 111 | ```json 112 | { 113 | "services": ["circleci"], 114 | "minNodeVersion": "12.0.0" 115 | } 116 | ``` 117 | 118 | To remove support for `circleci` from your project, just `npm run mrm circleci` task by removing the `circleci` keyword from the `services` array. 119 | 120 | ```json 121 | { 122 | "services": [] 123 | } 124 | ``` 125 | 126 | ```sh 127 | npm run mrm circleci 128 | ``` 129 | 130 | ### Contributing.md template 131 | Creates `.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). 132 | 133 | The 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. 134 | 135 | 1. Template for Typescript 136 | 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. 137 | 138 | ```json 139 | { 140 | "ts": true 141 | } 142 | ``` 143 | 144 | 2. Otherwise the [default template](https://github.com/adonisjs/mrm-preset/blob/master/contributing/templates/CONTRIBUTING.md) will be used. 145 | ### Editorconfig file 146 | Creates 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. 147 | 148 | You may need a [plugin](https://editorconfig.org/#download) for your editor to make `editorconfig` work. 149 | 150 | The 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. 151 | ### Eslint 152 | 153 | Installs `eslint` and `eslint-plugin-adonis`. Also it will remove tslint and it's related dependencies from the project. 154 | 155 | ### Github templates 156 | 157 | Creates 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. 158 | 159 | 1. [Issues template content](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/issues.md) 160 | 2. [PR template](https://github.com/adonisjs/mrm-preset/blob/master/github/templates/pr.md) 161 | 162 | ### Github Actions 163 | 164 | Github actions tasks creates a configuration file `(.github/workflows/test.yml)` in the root of your project. The tasks depends on the config file `config.json` and requires following key/value pairs. 165 | 166 | ```json 167 | { 168 | "services": ["github-actions"], 169 | "minNodeVersion": "14.15.4" 170 | } 171 | ``` 172 | 173 | To remove support for `github-actions` from your project, just `npm run mrm github-actions` task by removing the `github-actions` keyword from the `services` array. 174 | 175 | ```json 176 | { 177 | "services": [] 178 | } 179 | ``` 180 | 181 | ```sh 182 | npm run mrm github-actions 183 | ``` 184 | 185 | ### Gitignore template 186 | 187 | Creates `.gitignore` file in the root of your project. Following files and folders are ignored by default. However, you can add more to the template. 188 | 189 | ``` 190 | node_modules 191 | coverage 192 | test/__app 193 | .DS_STORE 194 | .nyc_output 195 | .idea 196 | .vscode/ 197 | *.sublime-project 198 | *.sublime-workspace 199 | *.log 200 | build 201 | docs 202 | dist 203 | shrinkwrap.yaml 204 | ``` 205 | 206 | 207 | 208 | ### License template 209 | 210 | Creates `LICENSE.md` file in the root of your project. 211 | 212 | You 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. 213 | 214 | ```json 215 | { 216 | "license": "MIT" 217 | } 218 | ``` 219 | 220 | If not defined, will fallback to `package.json` file or `MIT`. 221 | 222 | ### Np release management 223 | 224 | [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. 225 | 226 | We recommend reading their README too https://github.com/sindresorhus/np. 227 | 228 | ### Package file generation 229 | 230 | This tasks does lots of work to install handful of packages and update `package.json` file. 231 | 232 | The list of operations is based on my personal learnings while maintaining open source projects. 233 | 234 | #### Testing 235 | 236 | The [japa](https://github.com/thetutlage/japa) test runner is installed along side with `japaFile.js`. 237 | 238 | #### Typescript setup 239 | 240 | We create a `tsconfig.json` file and install following dependencies. 241 | 242 | 1. `@types/node` 243 | 2. `typescript` 244 | 3. `@adonisjs/require-ts` 245 | 246 | #### Scripts 247 | The following scripts are defined inside the `package.json` file. 248 | 249 | 1. `clean` to clean the build folder before starting the build. We also install `del-cli` npm package for this script to work 250 | 2. `compile` to compile the TypeScript code to JavaScript 251 | 3. `build` runs compile 252 | 4. `prePublishOnly` to compile before publishing to npm. 253 | 254 | ### Prettier 255 | 256 | Installs `prettier` and `eslint-plugin-prettier` and `eslint-config-prettier` to setup prettier along side with `eslint`. Also the task will check, if `.eslintrc.json` file exists and then only performs the eslint specific setup 257 | 258 | ### Probot applications 259 | 260 | Configures certain probot application templates inside the `.github` directory. Currently, following apps are supported. 261 | 262 | - https://probot.github.io/apps/stale/ 263 | - https://probot.github.io/apps/lock/ 264 | 265 | ### Readme file 266 | 267 | Generates 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. 268 | ### Readme file TOC 269 | 270 | Generates table of contents for the readme file. This tasks registers a `git hook` to automatically generate the TOC before every commit. 271 | 272 | Under 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. 273 | 274 | ### Validate commit 275 | 276 | Configures 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. 277 | 278 | The 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/validate-commit/conventional/template.md), which is copied over to your project `.github` folder for readers reference. 279 | 280 | 281 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [2.4.0](https://github.com/adonisjs/mrm-preset/compare/2.3.7...2.4.0) (2020-07-18) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * prompt name ([e5f4842](https://github.com/adonisjs/mrm-preset/commit/e5f4842bd38f913627bb6810ab0bc44faaa0eb6e)) 7 | 8 | 9 | ### Features 10 | 11 | * add probot task ([f08a7a7](https://github.com/adonisjs/mrm-preset/commit/f08a7a7370284281470ecb7912432bbe875bd6ff)) 12 | * add task for syncing labels ([429c980](https://github.com/adonisjs/mrm-preset/commit/429c9800fb65a779f2d3354cb0d24bdfcb34db8b)) 13 | 14 | 15 | 16 | ## [2.3.7](https://github.com/adonisjs/mrm-preset/compare/2.3.6...2.3.7) (2020-07-05) 17 | 18 | 19 | ### Bug Fixes 20 | 21 | * audit report should commit the html file ([6b0d511](https://github.com/adonisjs/mrm-preset/commit/6b0d511f62168ddb7fcdf6682d3c6ed36695fb92)) 22 | 23 | 24 | 25 | ## [2.3.6](https://github.com/adonisjs/mrm-preset/compare/2.3.5...2.3.6) (2020-07-03) 26 | 27 | 28 | ### Bug Fixes 29 | 30 | * do not overwrite existing pre-commit hook ([1177fca](https://github.com/adonisjs/mrm-preset/commit/1177fcab43a7c7617aa93a102f853fdb5b661adf)) 31 | 32 | 33 | 34 | ## [2.3.5](https://github.com/adonisjs/mrm-preset/compare/2.3.4...2.3.5) (2020-07-03) 35 | 36 | 37 | ### Features 38 | 39 | * add task to generate npm audit report ([6b05242](https://github.com/adonisjs/mrm-preset/commit/6b05242d442f7d0cc8a807d451b7cea8e2cc6d3e)) 40 | 41 | 42 | 43 | ## [2.3.4](https://github.com/adonisjs/mrm-preset/compare/2.3.3...2.3.4) (2020-06-28) 44 | 45 | 46 | ### Bug Fixes 47 | 48 | * use tabs in editorconfig to be consistent with prettier settings ([626467b](https://github.com/adonisjs/mrm-preset/commit/626467be69e6e06eea5a29860844a64679fa3905)) 49 | 50 | 51 | 52 | ## [2.3.3](https://github.com/adonisjs/mrm-preset/compare/2.3.2...2.3.3) (2020-06-28) 53 | 54 | 55 | ### Features 56 | 57 | * **Prettier:** use tabs over spaces and increase line length ([#12](https://github.com/adonisjs/mrm-preset/issues/12)) ([840561a](https://github.com/adonisjs/mrm-preset/commit/840561a156f4a2fa1f648b58b9eeca3940ff6aeb)) 58 | 59 | 60 | 61 | ## [2.3.2](https://github.com/adonisjs/mrm-preset/compare/2.3.1...2.3.2) (2020-06-24) 62 | 63 | 64 | 65 | ## [2.3.1](https://github.com/adonisjs/mrm-preset/compare/v2.3.0...v2.3.1) (2020-06-24) 66 | 67 | 68 | ### Features 69 | 70 | * add prettier ([384bd97](https://github.com/adonisjs/mrm-preset/commit/384bd97e43b8d9e0b126a2364fe5f493cdde3996)) 71 | 72 | 73 | 74 | # [2.3.0](https://github.com/adonisjs/mrm-preset/compare/2.2.4...2.3.0) (2020-04-08) 75 | 76 | 77 | 78 | ## [2.2.4](https://github.com/adonisjs/mrm-preset/compare/2.2.3...2.2.4) (2020-02-06) 79 | 80 | 81 | 82 | ## [2.2.3](https://github.com/adonisjs/mrm-preset/compare/2.2.2...2.2.3) (2019-12-19) 83 | 84 | 85 | ### Bug Fixes 86 | 87 | * **eslint:** set file extensions for the lint task ([d4af279](https://github.com/adonisjs/mrm-preset/commit/d4af279)) 88 | 89 | 90 | 91 | ## [2.2.2](https://github.com/adonisjs/mrm-preset/compare/2.2.1...2.2.2) (2019-12-02) 92 | 93 | 94 | ### Bug Fixes 95 | 96 | * **readme-task:** access packageName from values object ([a172d00](https://github.com/adonisjs/mrm-preset/commit/a172d00)) 97 | 98 | 99 | 100 | # [2.2.0](https://github.com/adonisjs/mrm-preset/compare/v2.1.0...v2.2.0) (2019-11-29) 101 | 102 | 103 | ### Features 104 | 105 | * add support eslint ([61332d1](https://github.com/adonisjs/mrm-preset/commit/61332d1)) 106 | 107 | 108 | 109 | # [2.1.0](https://github.com/adonisjs/mrm-preset/compare/v2.0.3...v2.1.0) (2019-08-29) 110 | 111 | 112 | 113 | ## [2.0.3](https://github.com/adonisjs/mrm-preset/compare/v2.0.2...v2.0.3) (2019-05-17) 114 | 115 | 116 | ### Bug Fixes 117 | 118 | * **np:** formatting of .npmrc file ([96199d2](https://github.com/adonisjs/mrm-preset/commit/96199d2)) 119 | 120 | 121 | 122 | ## [2.0.2](https://github.com/adonisjs/mrm-preset/compare/v2.0.1...v2.0.2) (2019-05-14) 123 | 124 | 125 | ### Features 126 | 127 | * **np:** add npmrc file with commit message standard ([efd77d6](https://github.com/adonisjs/mrm-preset/commit/efd77d6)) 128 | * **package:** define main and files array ([55b4cab](https://github.com/adonisjs/mrm-preset/commit/55b4cab)) 129 | 130 | 131 | 132 | ## [2.0.1](https://github.com/adonisjs/mrm-preset/compare/v2.0.0...v2.0.1) (2019-05-14) 133 | 134 | 135 | ### Bug Fixes 136 | 137 | * **commit-hook:** use HUSKY_GIT_PARAMS over GIT_PARAMS ([ea65852](https://github.com/adonisjs/mrm-preset/commit/ea65852)) 138 | 139 | 140 | 141 | # [1.1.0](https://github.com/adonisjs/mrm-preset/compare/1.0.21...1.1.0) (2019-05-10) 142 | 143 | 144 | ### Features 145 | 146 | * add support for np release management ([611661d](https://github.com/adonisjs/mrm-preset/commit/611661d)) 147 | 148 | 149 | 150 | ## [1.0.21](https://github.com/adonisjs/mrm-preset/compare/1.0.20...1.0.21) (2019-04-06) 151 | 152 | 153 | ### Bug Fixes 154 | 155 | * **circleci:** fix yaml parsing errors ([cd9d1e6](https://github.com/adonisjs/mrm-preset/commit/cd9d1e6)) 156 | * **init:** use correct node version on prompt selection ([22097a2](https://github.com/adonisjs/mrm-preset/commit/22097a2)) 157 | * **services:** return badge for circleci service ([98b1902](https://github.com/adonisjs/mrm-preset/commit/98b1902)) 158 | 159 | 160 | 161 | ## [1.0.20](https://github.com/adonisjs/mrm-preset/compare/1.0.19...1.0.20) (2019-04-02) 162 | 163 | 164 | ### Bug Fixes 165 | 166 | * **package:** get rid of bin path ([9dc102f](https://github.com/adonisjs/mrm-preset/commit/9dc102f)) 167 | 168 | 169 | 170 | ## [1.0.19](https://github.com/adonisjs/mrm-preset/compare/1.0.18...1.0.19) (2019-04-02) 171 | 172 | 173 | ### Features 174 | 175 | * **tslint:** allow pascal-case and ignore regex from line length limit ([7c9cc01](https://github.com/adonisjs/mrm-preset/commit/7c9cc01)) 176 | 177 | 178 | 179 | ## [1.0.18](https://github.com/adonisjs/mrm-preset/compare/1.0.17...1.0.18) (2019-04-02) 180 | 181 | 182 | 183 | ## [1.0.17](https://github.com/adonisjs/mrm-preset/compare/1.0.16...1.0.17) (2019-04-02) 184 | 185 | 186 | ### Features 187 | 188 | * **circleci:** add circleci task ([5b9a805](https://github.com/adonisjs/mrm-preset/commit/5b9a805)) 189 | 190 | 191 | 192 | 193 | ## [1.0.16](https://github.com/adonisjs/mrm-preset/compare/1.0.15...1.0.16) (2019-01-17) 194 | 195 | 196 | ### Reverts 197 | 198 | * **tsconfig:** remove `test` from `excludes` array ([398d008](https://github.com/adonisjs/mrm-preset/commit/398d008)) 199 | 200 | 201 | 202 | 203 | ## [1.0.15](https://github.com/adonisjs/mrm-preset/compare/v1.0.14...v1.0.15) (2019-01-16) 204 | 205 | 206 | ### Bug Fixes 207 | 208 | * **tsconfig:** add test folder ([#6](https://github.com/adonisjs/mrm-preset/issues/6)) ([902cdf3](https://github.com/adonisjs/mrm-preset/commit/902cdf3)) 209 | * **tsconfig:** correct lib value ([#7](https://github.com/adonisjs/mrm-preset/issues/7)) ([3a9a0ae](https://github.com/adonisjs/mrm-preset/commit/3a9a0ae)) 210 | 211 | 212 | ### Features 213 | 214 | * **readme-toc:** add new task to generate readme file toc ([2df5606](https://github.com/adonisjs/mrm-preset/commit/2df5606)) 215 | * **tslint:** add new rules ([3df7de4](https://github.com/adonisjs/mrm-preset/commit/3df7de4)) 216 | 217 | 218 | 219 | 220 | ## [1.0.14](https://github.com/adonisjs/mrm-preset/compare/v1.0.13...v1.0.14) (2018-10-03) 221 | 222 | 223 | ### Bug Fixes 224 | 225 | * **github:** make correct url inside pr.md template ([3737993](https://github.com/adonisjs/mrm-preset/commit/3737993)) 226 | 227 | 228 | ### Features 229 | 230 | * **config:** add validateCommit task to all tasks array ([4fa127b](https://github.com/adonisjs/mrm-preset/commit/4fa127b)) 231 | * **task:** add validateCommit task to keep commits consistent ([ac73d37](https://github.com/adonisjs/mrm-preset/commit/ac73d37)) 232 | 233 | 234 | 235 | 236 | ## [1.0.13](https://github.com/adonisjs/mrm-preset/compare/v1.0.12...v1.0.13) (2018-09-27) 237 | 238 | 239 | ### Features 240 | 241 | * **japa:** adjust npm scripts as per japa@2 ([a4d686e](https://github.com/adonisjs/mrm-preset/commit/a4d686e)) 242 | 243 | 244 | 245 | 246 | ## [1.0.12](https://github.com/adonisjs/mrm-preset/compare/v1.0.11...v1.0.12) (2018-09-27) 247 | 248 | 249 | ### Features 250 | 251 | * **japa:** create blueprint for japa 2 ([0120ca9](https://github.com/adonisjs/mrm-preset/commit/0120ca9)) 252 | 253 | 254 | 255 | 256 | ## [1.0.11](https://github.com/adonisjs/mrm-preset/compare/v1.0.10...v1.0.11) (2018-08-22) 257 | 258 | 259 | 260 | 261 | ## [1.0.10](https://github.com/adonisjs/mrm-preset/compare/v1.0.9...v1.0.10) (2018-07-23) 262 | 263 | 264 | ### Features 265 | 266 | * **gitignore:** add package-lock.json file to task ([785dbcc](https://github.com/adonisjs/mrm-preset/commit/785dbcc)) 267 | 268 | 269 | 270 | 271 | ## [1.0.9](https://github.com/adonisjs/mrm-preset/compare/v1.0.8...v1.0.9) (2018-07-15) 272 | 273 | 274 | ### Bug Fixes 275 | 276 | * **package:** fix test:win command ([ce3e16d](https://github.com/adonisjs/mrm-preset/commit/ce3e16d)) 277 | 278 | 279 | 280 | 281 | ## [1.0.8](https://github.com/adonisjs/mrm-preset/compare/v1.0.7...v1.0.8) (2018-07-13) 282 | 283 | 284 | ### Features 285 | 286 | * **task:** add typedoc task ([400cf46](https://github.com/adonisjs/mrm-preset/commit/400cf46)) 287 | * **tslint:** add rule for max-line-length ([d790704](https://github.com/adonisjs/mrm-preset/commit/d790704)) 288 | 289 | 290 | 291 | 292 | ## [1.0.7](https://github.com/adonisjs/mrm-preset/compare/v1.0.6...v1.0.7) (2018-06-30) 293 | 294 | 295 | ### Bug Fixes 296 | 297 | * **github:** fix github template for core bugs ([6e05e2c](https://github.com/adonisjs/mrm-preset/commit/6e05e2c)) 298 | 299 | 300 | 301 | 302 | ## [1.0.6](https://github.com/adonisjs/mrm-preset/compare/v1.0.5...v1.0.6) (2018-06-30) 303 | 304 | 305 | ### Bug Fixes 306 | 307 | * **license:** fix license task to pull github username ([6e6f29d](https://github.com/adonisjs/mrm-preset/commit/6e6f29d)) 308 | 309 | 310 | 311 | 312 | ## [1.0.5](https://github.com/adonisjs/mrm-preset/compare/v1.0.4...v1.0.5) (2018-06-30) 313 | 314 | 315 | ### Features 316 | 317 | * **typescript:** set nyc extensions to .ts ([9b96a99](https://github.com/adonisjs/mrm-preset/commit/9b96a99)) 318 | 319 | 320 | 321 | 322 | ## [1.0.4](https://github.com/adonisjs/mrm-preset/compare/v1.0.3...v1.0.4) (2018-06-29) 323 | 324 | 325 | 326 | 327 | ## [1.0.3](https://github.com/adonisjs/mrm-preset/compare/v1.0.2...v1.0.3) (2018-06-29) 328 | 329 | 330 | ### Features 331 | 332 | * **package:** add pkg-ok script as prepublishOnly ([2ce48f2](https://github.com/adonisjs/mrm-preset/commit/2ce48f2)) 333 | 334 | 335 | 336 | 337 | ## [1.0.2](https://github.com/adonisjs/mrm-preset/compare/v1.0.1...v1.0.2) (2018-06-29) 338 | 339 | 340 | ### Bug Fixes 341 | 342 | * **gitignore:** ignore build directory for typescript ([c54e414](https://github.com/adonisjs/mrm-preset/commit/c54e414)) 343 | 344 | 345 | ### Features 346 | 347 | * **aliases:** add task aliases ([79f568f](https://github.com/adonisjs/mrm-preset/commit/79f568f)) 348 | * **appveyor:** add task for appveyor ([e536df9](https://github.com/adonisjs/mrm-preset/commit/e536df9)) 349 | * **init:** ask for git origin url ([4e2c114](https://github.com/adonisjs/mrm-preset/commit/4e2c114)) 350 | * **package:** add new scripts for typescript projects ([3a5b7f4](https://github.com/adonisjs/mrm-preset/commit/3a5b7f4)) 351 | * **travis:** add travis task ([eeeeaa0](https://github.com/adonisjs/mrm-preset/commit/eeeeaa0)) 352 | 353 | 354 | 355 | 356 | ## [1.0.1](https://github.com/adonisjs/mrm-preset/compare/v1.0.0...v1.0.1) (2018-06-26) 357 | 358 | 359 | ### Bug Fixes 360 | 361 | * **github:** export instance of standardtemplate ([37a7cd6](https://github.com/adonisjs/mrm-preset/commit/37a7cd6)) 362 | * **test:** use `.js` glob when using javascript as source ([0cf978e](https://github.com/adonisjs/mrm-preset/commit/0cf978e)) 363 | 364 | 365 | 366 | 367 | # 1.0.0 (2018-06-19) 368 | 369 | 370 | ### Features 371 | 372 | * initiate project with couple of tasks ([5234a26](https://github.com/adonisjs/mrm-preset/commit/5234a26)) 373 | * **contributing:** add contributing task ([b1552b7](https://github.com/adonisjs/mrm-preset/commit/b1552b7)) 374 | * **github:** add github task ([40a26be](https://github.com/adonisjs/mrm-preset/commit/40a26be)) 375 | * **license:** add task for the license file ([fe9bf07](https://github.com/adonisjs/mrm-preset/commit/fe9bf07)) 376 | * **package:** add package task ([1a15d81](https://github.com/adonisjs/mrm-preset/commit/1a15d81)) 377 | * **readme:** add new readme task ([a18be80](https://github.com/adonisjs/mrm-preset/commit/a18be80)) 378 | * **task:** add init task ([9144015](https://github.com/adonisjs/mrm-preset/commit/9144015)) 379 | 380 | 381 | 382 | --------------------------------------------------------------------------------