Skip to content

Commit

Permalink
feature(madrun) add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 25, 2019
0 parents commit a036700
Show file tree
Hide file tree
Showing 20 changed files with 704 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"@putout",
"plugin:node/recommended"
],
"plugins": [
"node"
]
}
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
Thank you for reporting an issue. Please fill in the template below. If unsure
about something, just do as best as you're able.
-->

* **Version** (`redrun -v`):
* **Node Version** `node -v`:
* **OS** (`uname -a` on Linux):
* **Browser name/version**:
* **Used Command Line Parameters**:

9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--
Thank you for making pull request. Please fill in the template below. If unsure
about something, just do as best as you're able.
-->

- [ ] commit message named according to [Contributing Guide](https://github.com/coderaiser/cloudcmd/blob/master/CONTRIBUTING.md "Contributting Guide")
- [ ] `npm run codestyle` is OK
- [ ] `npm test` is OK

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.*.swp
node_modules
package-lock.json
npm-debug.log
.nyc_output

yarn-error.log

32 changes: 32 additions & 0 deletions .madrun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const {
run,
parallel
} = require('.');

module.exports = {
'lint': () => parallel('lint:*'),
'lint:eslint-bin': () => `eslint --rule 'no-console:0,no-process-exit:0' bin`,
'lint:eslint-lib': () => 'eslint lib test',
'lint:eslint-dot': () => `eslint --ignore-pattern '!.madrun.js' .madrun.js`,
'lint:putout': () => 'putout bin lib test .madrun.js',
'fix:lint': () => {
const putout = run('lint:putout', '--fix');
const eslint = parallel('lint:e*', '--fix');

return `${putout} && ${eslint}`;
},
'test': () => 'tape test/**/*.js',
'watch:test': () => run('watcher', run('test')),
'watch:tape': () => 'nodemon -w test -w lib --exec tape',
'watch:coverage:base': () => run('watcher', `nyc ${run('test')}`),
'watch:coverage:tape': () => 'npm run watcher -- nyc tape',
'watch:coverage': () => run('watch:coverage:base'),
'watch:lint': () => run('watcher', run('lint:eslint*')),
'watcher': () => 'nodemon -w test -w lib --exec',
'coverage': () => `nyc ${run('test')}`,
'report': () => 'nyc report --reporter=text-lcov | coveralls',
'postpublish': () => 'npm i -g'
};

9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.*
test
redrun.png
redrun.ai
*.md
!README.md

yarn-error.log

7 changes: 7 additions & 0 deletions .putout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"match": {
"bin": {
"remove-console": false
}
}
}
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: node_js
node_js:
- 10
- 8

before_install:
- npm i redrun -g

script:
- npm run lint
- npm run coverage && npm run report

notifications:
email:
on_success: never
on_failure: change

sudo: false

46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Commit
---------------
Format of the commit message: **type(scope) subject**

**Type**:
- feature(scope) subject
- fix(scope) subject
- docs(scope) subject
- refactor(scope) subject
- test(scope) subject
- chore(scope) subject

**Scope**:
Scope could be anything specifying place of the commit change.
For example util, console, view, edit, style etc...

**Subject text**:
- use imperative, present tense: “change” not “changed” nor “changes”
- don't capitalize first letter
- no dot (.) at the end
**Message body**:
- just as in <subject> use imperative, present tense: “change” not “changed” nor “changes”
- includes motivation for the change and contrasts with previous behavior

**Examples**:
- [fix(style) .name{width}: 37% -> 35%](https://github.com/coderaiser/cloudcmd/commit/94b0642e3990c17b3a0ee3efeb75f343e1e7c050)
- [fix(console) dispatch: focus -> mouseup](https://github.com/coderaiser/cloudcmd/commit/f41ec5058d1411e86a881f8e8077e0572e0409ec)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-now coderaiser

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 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.
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Madrun [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

CLI tool to run multiple npm-scripts in a madly comfortable way.

## Install

```
npm i madrun -g
```

# Usage

First thing you should do is create `.madrun.js` file.
Then you can run `madrun` without args to see list of a scripts. Or run:

```
madrun <script>
```

To run specified script.

# Completion

You can enable tab-completion of npm scripts similar to [npm's completion](
https://docs.npmjs.com/cli/completion) using:

```sh
madrun-completion >> ~/.bashrc
madrun-completion >> ~/.zshrc
```

You may also pipe the output of madrun-completion to a file such as `/usr/local/etc/bash_completion.d/madrun` if you have a system that will read that file for you.

## Example

Let's install `madrun` as `devDependency` with:

```sh
npm i madrun -D
```

Let's create file `.madrun.js`:

```js
const {
run,
parallel,
} = require('madrun');

module.exports = {
'lint:lib': 'eslint lib',
'lint:bin': 'eslint bin',
'lint': run('lint:*'),
'fix:lint': parallel(['lint:lib, 'lint:bin'], --fix);
};
```
Now you can call any of listed scripts with help of `madrun cli`:
```sh
$ madrun lint
> eslint lib && eslint bin
```
For parallel fix with can use:
```sh
$ madrun fix:lint
> eslint eslint lib --fix & eslin bin --fix
```
## License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/madrun.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/madrun/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/madrun.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/madrun "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/madrun "Build Status"
[DependencyStatusURL]: https://david-dm.org/coderaiser/madrun "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/coderaiser/madrun?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/madrun/badge.svg?branch=master&service=github
13 changes: 13 additions & 0 deletions bin/madrun-completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node

'use strict';

const fs = require('fs');
const path = require('path');

const filename = path.join(__dirname, '..', 'shell/redrun-completion.sh');
const read = fs.createReadStream(filename);
const write = process.stdout;

read.pipe(write);

73 changes: 73 additions & 0 deletions bin/madrun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node

'use strict';

const {
dirname
} = require('path');

const findUp = require('find-up');

const {series} = require('..');

const {
exit
} = process;

const args = require('yargs-parser')(process.argv.slice(2), {
configuration: {
'populate--': true,
},
});

const names = args._;
const options = getOptions(args['--']);
const [dir, script] = getScript();

if (!names.length) {
console.log(Object.keys(script).join('\n'));
exit();
}

const cmd = series(names, options, script);

console.log(`> ${cmd}`);

execute(cmd);

function execute(cmd) {
const execSync = require('child_process').execSync;
const tryCatch = require('try-catch');

const [e] = tryCatch(execSync, cmd, {
stdio: [0, 1, 2, 'pipe'],
cwd: dir,
});

if (e) {
console.error(e.message);
process.exit(1);
}
}

function getOptions(args) {
if (!args)
return '';

return args.join(' ');
}

function getScript() {
const path = findUp.sync('.madrun.js');

if (!path) {
console.error('file ".madrun.js" not found!');
process.exit(1);
}

return [
dirname(path),
require(path),
];
}

Empty file added lib/find.js
Empty file.
Loading

0 comments on commit a036700

Please sign in to comment.