Skip to content

Commit

Permalink
Chore: Fix Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Sapegin committed Nov 22, 2019
1 parent bad794b commit 6cba7ea
Show file tree
Hide file tree
Showing 9 changed files with 1,054 additions and 488 deletions.
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "es5",
"overrides": [
{
"files": "*.md",
"options": {
"printWidth": 70,
"useTabs": false,
"trailingComma": "none",
"proseWrap": "never"
}
}
]
}
12 changes: 6 additions & 6 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ I love pull requests. And following this simple guidelines will make your pull r

## Submitting pull requests

1. Create a new branch, please don’t work in master directly.
2. Add failing tests (if there’re any tests in project) for the change you want to make. Run tests (see below) to see the tests fail.
3. Hack on.
4. Run tests to see if the tests pass. Repeat steps 2–4 until done.
5. Update the documentation to reflect any changes.
6. Push to your fork and submit a pull request.
1. Create a new branch, please don’t work in master directly.
2. Add failing tests (if there’re any tests in project) for the change you want to make. Run tests (see below) to see the tests fail.
3. Hack on.
4. Run tests to see if the tests pass. Repeat steps 2–4 until done.
5. Update the documentation to reflect any changes.
6. Push to your fork and submit a pull request.

## JavaScript code style

Expand Down
22 changes: 4 additions & 18 deletions License.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
The MIT License
===============
# The MIT License

Copyright 2016 Artem Sapegin (http://sapegin.me), contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
147 changes: 67 additions & 80 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# Mrm

[![Build Status](https://travis-ci.org/sapegin/mrm.svg)](https://travis-ci.org/sapegin/mrm)
[![npm](https://img.shields.io/npm/v/mrm.svg)](https://www.npmjs.com/package/mrm)
[![Build Status](https://travis-ci.org/sapegin/mrm.svg)](https://travis-ci.org/sapegin/mrm) [![npm](https://img.shields.io/npm/v/mrm.svg)](https://www.npmjs.com/package/mrm)

Command line tool to help you keep configuration (`package.json`, `.gitignore`, `.eslintrc`, etc.) of your open source projects in sync.

## Features

* Will not overwrite your data if you don’t want it to
* Minimal changes: will keep the original file formatting or read the style from EditorConfig
* Minimal configuration: will try to infer configuration from the project itself or from the environment
* Bunch of [customizable tasks](#tasks) included
* Tools to work with JSON, YAML, INI, Markdown and new line separated text files
* Easy to write [your own tasks](#writing-your-own-tasks)
* Share tasks via npm and group them into [presets](#custom-presets)
- Will not overwrite your data if you don’t want it to
- Minimal changes: will keep the original file formatting or read the style from EditorConfig
- Minimal configuration: will try to infer configuration from the project itself or from the environment
- Bunch of [customizable tasks](#tasks) included
- Tools to work with JSON, YAML, INI, Markdown and new line separated text files
- Easy to write [your own tasks](#writing-your-own-tasks)
- Share tasks via npm and group them into [presets](#custom-presets)

![](https://d3vv6lp55qjaqc.cloudfront.net/items/1g0e2M3m2Y3j0m3B3n1t/Image%202017-06-20%20at%209.00.39%20PM.png)

Expand All @@ -35,9 +34,9 @@ Command line tool to help you keep configuration (`package.json`, `.gitignore`,
- [Config resolution rules](#config-resolution-rules)
- [Task resolution rules](#task-resolution-rules)
- [FAQ](#faq)
* [How to use Mrm with Lerna?](#how-to-use-mrm-with-lerna)
* [How to infer user metadata, like user name or email?](#how-to-infer-user-metadata-like-user-name-or-email)
* [How to infer GitHub user name?](#how-to-infer-github-user-name)
- [How to use Mrm with Lerna?](#how-to-use-mrm-with-lerna)
- [How to infer user metadata, like user name or email?](#how-to-infer-user-metadata-like-user-name-or-email)
- [How to infer GitHub user name?](#how-to-infer-github-user-name)
- [Change log](#change-log)
- [Contributing](#contributing)
- [Authors and license](#authors-and-license)
Expand Down Expand Up @@ -111,41 +110,42 @@ Create `~/.mrm/config.json` or `~/dotfiles/mrm/config.json`:

```json5
{
"indent": "tab", // "tab" or number of spaces
"readmeFile": "Readme.md", // Name of readme file
"licenseFile": "License.md", // Name of license file
"aliases": { // Aliases to run multiple tasks at once
"node": ["license", "readme", "editorconfig", "gitignore"]
indent: 'tab', // "tab" or number of spaces
readmeFile: 'Readme.md', // Name of readme file
licenseFile: 'License.md', // Name of license file
aliases: {
// Aliases to run multiple tasks at once
node: ['license', 'readme', 'editorconfig', 'gitignore']
}
}
```

See [tasks docs](https://github.com/sapegin/mrm-tasks) for available config options.

*Config file isn’t required, you can also pass config options via command line. Default tasks will try to [read data](https://github.com/sapegin/user-meta) fom your npm and Git configuration.*
_Config file isn’t required, you can also pass config options via command line. Default tasks will try to [read data](https://github.com/sapegin/user-meta) fom your npm and Git configuration._

## Tasks

These tasks are included by default:

<!-- textlint-disable terminology -->

* [codecov](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-codecov)
* [contributing](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-contributing)
* [editorconfig](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-editorconfig)
* [eslint](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-eslint)
* [gitignore](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-gitignore)
* [jest](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-jest)
* [license](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-license)
* [lint-staged](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-lint-staged)
* [package](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-package)
* [prettier](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-prettier)
* [readme](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-readme)
* [semantic-release](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-semantic-release)
* [styleguidist](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-styleguidist)
* [stylelint](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-stylelint)
* [travis](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-travis)
* [typescript](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-typescript)
- [codecov](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-codecov)
- [contributing](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-contributing)
- [editorconfig](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-editorconfig)
- [eslint](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-eslint)
- [gitignore](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-gitignore)
- [jest](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-jest)
- [license](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-license)
- [lint-staged](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-lint-staged)
- [package](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-package)
- [prettier](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-prettier)
- [readme](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-readme)
- [semantic-release](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-semantic-release)
- [styleguidist](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-styleguidist)
- [stylelint](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-stylelint)
- [travis](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-travis)
- [typescript](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-task-typescript)

<!-- textlint-enable -->

Expand Down Expand Up @@ -176,13 +176,11 @@ module.exports = task;
Tasks can also be async by adding the `async` keyword or returning a `Promise`.

```js
async function task () {
}
async function task() {}

// or
function task () {
return new Promise(() => {
})
function task() {
return new Promise(() => {});
}
```

Expand Down Expand Up @@ -287,21 +285,16 @@ The basic file structure of a shared task looks like this:
"name": "Artem Sapegin",
"url": "http://sapegin.me"
},
"homepage": "https://github.com/sapegin/mrm-tasks/packages/mrm-task-unicorn",
"homepage":
"https://github.com/sapegin/mrm-tasks/packages/mrm-task-unicorn",
"repository": "sapegin/mrm-tasks",
"license": "MIT",
"engines": {
"node": ">=4"
},
"main": "index.js",
"files": [
"index.js"
],
"keywords": [
"mrm",
"mrm-task",
"unicorn"
],
"files": ["index.js"],
"keywords": ["mrm", "mrm-task", "unicorn"],
"dependencies": {
"mrm-core": "^2.1.3"
}
Expand Down Expand Up @@ -342,22 +335,16 @@ And the `package.json` would look like this:
"name": "Artem Sapegin",
"url": "http://sapegin.me"
},
"homepage": "https://github.com/sapegin/mrm-tasks/packages/mrm-preset-default",
"homepage":
"https://github.com/sapegin/mrm-tasks/packages/mrm-preset-default",
"repository": "sapegin/mrm-tasks",
"license": "MIT",
"engines": {
"node": ">=4"
},
"main": "config.json",
"files": [
"config.json",
"*/index.js"
],
"keywords": [
"mrm",
"mrm-task",
"mrm-preset"
],
"files": ["config.json", "*/index.js"],
"keywords": ["mrm", "mrm-task", "mrm-preset"],
"dependencies": {
"mrm-core": "^2.1.3",
"mrm-task-gitignore": "^0.1.0"
Expand All @@ -384,25 +371,25 @@ mrm license --preset @mycompany/unicorn-preset # @mycompany/unicorn-preset

## Config resolution rules

* `<DIR>/config.json` if `--dir <DIR>` command line option was passed
* `$HOME/dotfiles/mrm/config.json`
* `$HOME/.mrm/config.json`
- `<DIR>/config.json` if `--dir <DIR>` command line option was passed
- `$HOME/dotfiles/mrm/config.json`
- `$HOME/.mrm/config.json`

if you’re passing a `--preset <PRESET>` command line option, then the only task directory will be:

* `mrm-preset-<PRESET>/config.json`
- `mrm-preset-<PRESET>/config.json`

## Task resolution rules

* `<DIR>/<TASK>/index.js` if `--dir <DIR>` command line option was passed
* `$HOME/dotfiles/mrm/<TASK>/index.js`
* `$HOME/.mrm/<TASK>/index.js`
* `mrm-task-<TASK>/index.js`, where `mrm-task-<TASK>` is an npm package name
* `<TASK>` in [mrm-preset-default](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-preset-default)
- `<DIR>/<TASK>/index.js` if `--dir <DIR>` command line option was passed
- `$HOME/dotfiles/mrm/<TASK>/index.js`
- `$HOME/.mrm/<TASK>/index.js`
- `mrm-task-<TASK>/index.js`, where `mrm-task-<TASK>` is an npm package name
- `<TASK>` in [mrm-preset-default](https://github.com/sapegin/mrm-tasks/tree/master/packages/mrm-preset-default)

if you’re passing a `--preset <PRESET>` command line option, then the only task directory will be:

* `mrm-preset-<PRESET>/<TASK>/index.js`
- `mrm-preset-<PRESET>/<TASK>/index.js`

## FAQ

Expand All @@ -421,12 +408,12 @@ Use the [user-meta](https://github.com/sapegin/user-meta) package to read user n
```js
const meta = require('user-meta');
module.exports = function task(config) {
const { name, email, url } = config
.defaults(meta)
.require('name', 'email', 'url')
.values();
const { name, email, url } = config
.defaults(meta)
.require('name', 'email', 'url')
.values();
/* ... */
}
};
```

### How to infer GitHub user name?
Expand All @@ -436,14 +423,14 @@ Use the [git-username](https://github.com/jonschlinkert/git-username) package:
```js
const gitUsername = require('git-username');
module.exports = function task(config) {
const { github } = config
.defaults({
github: gitUsername(),
})
.require('github')
.values();
const { github } = config
.defaults({
github: gitUsername()
})
.require('github')
.values();
/* ... */
}
};
```

## Change log
Expand Down
34 changes: 26 additions & 8 deletions bin/mrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,27 @@ const updateNotifier = require('update-notifier');
const { padEnd, sortBy } = require('lodash');
const { random } = require('middleearth-names');
const { run, getConfig, getAllTasks, tryResolve } = require('../src/index');
const { MrmUnknownTask, MrmUnknownAlias, MrmUndefinedOption } = require('../src/errors');

let directories = [path.resolve(userHome, 'dotfiles/mrm'), path.resolve(userHome, '.mrm')];
const {
MrmUnknownTask,
MrmUnknownAlias,
MrmUndefinedOption,
} = require('../src/errors');

let directories = [
path.resolve(userHome, 'dotfiles/mrm'),
path.resolve(userHome, '.mrm'),
];

const EXAMPLES = [
['', '', 'List of available tasks'],
['<task>', '', 'Run a task or an alias'],
['<task>', '--dir ~/unicorn', 'Custom config and tasks folder'],
['<task>', '--preset unicorn', 'Load config and tasks from a preset'],
['<task>', '--config:foo coffee --config:bar pizza', 'Override config options'],
[
'<task>',
'--config:foo coffee --config:bar pizza',
'Override config options',
],
];

// Update notifier
Expand All @@ -41,7 +52,8 @@ const argv = minimist(process.argv.slice(2));
const tasks = argv._;

const binaryPath = process.env._;
const binaryName = binaryPath && binaryPath.endsWith('/npx') ? 'npx mrm' : 'mrm';
const binaryName =
binaryPath && binaryPath.endsWith('/npx') ? 'npx mrm' : 'mrm';

// Custom config / tasks directory
if (argv.dir) {
Expand Down Expand Up @@ -103,7 +115,9 @@ Note that when a preset is specified no default search locations are used.`);
} else if (err.constructor === MrmUndefinedOption) {
const { unknown } = err.extra;
const values = unknown.map(name => [name, random()]);
const heading = `Required config options are missed: ${listify(unknown)}.`;
const heading = `Required config options are missed: ${listify(
unknown
)}.`;
const cliHelp = ` ${binaryName} ${tasks.join(' ')} ${values
.map(([n, v]) => `--config:${n} "${v}"`)
.join(' ')}`;
Expand Down Expand Up @@ -177,8 +191,12 @@ function getTasksList() {

return names
.map(name => {
const description = Array.isArray(tasks[name]) ? `Runs ${listify(tasks[name])}` : tasks[name];
return ' ' + kleur.cyan(padEnd(name, nameColWidth)) + ' ' + description;
const description = Array.isArray(tasks[name])
? `Runs ${listify(tasks[name])}`
: tasks[name];
return (
' ' + kleur.cyan(padEnd(name, nameColWidth)) + ' ' + description
);
})
.join('\n');
}
Expand Down
Loading

0 comments on commit 6cba7ea

Please sign in to comment.