Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c73034c
Showing
9 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
node_modules/ | ||
|
||
npm-debug.log | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
|
||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<p align="center"><a href="https://www.jeffjade.com?utm_source=github.com" target="_blank"><img width="100"src="https://raw.githubusercontent.com/nicejade/arya-jarvis/master/src/assets/images/logo.png"></a></p> | ||
|
||
<h1 align="center">ARYA JARVIS</h1> | ||
|
||
<div align="center"> | ||
<strong> | ||
Designed to save developers more time and energy | ||
</strong> | ||
</div> | ||
|
||
<br> | ||
|
||
<div align="center"> | ||
<a href="https://nodejs.org/en/"> | ||
<img src="https://img.shields.io/badge/node-%3E%3D%208.0.0-green.svg" alt="Node Version"> | ||
</a> | ||
<a href="https://github.com/nicejade/arya-jarvis"> | ||
<img src="https://img.shields.io/github/license/nicejade/arya-jarvis.svg" alt="LICENSE"> | ||
</a> | ||
<a href="https://nicelinks.site/post/5c16083e819ae45de1453caa"> | ||
<img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat" alt="Prettier"> | ||
</a> | ||
<a href="https://www.jeffjade.com/"> | ||
<img src="https://img.shields.io/badge/chat-on%20blog-brightgreen.svg" alt="Arya Jarvis"> | ||
</a> | ||
<a href="https://weibo.com/jeffjade"> | ||
<img src="https://img.shields.io/badge/WeiBo-jeffjade-red.svg?style=flat" alt="Arya Jarvis"> | ||
</a> | ||
<a href="https://aboutme.lovejade.cn/?utm_source=github.com"> | ||
<img src="https://img.shields.io/badge/Author-nicejade-%23a696c8.svg" alt="Author nicejade"> | ||
</a> | ||
</div> | ||
|
||
## Goal and Philosophy | ||
|
||
The ideal goal is to help us deal with things that can be more precise in the simplest way. `Arya Jarvis` is an attempt to do this, it designed to save developers more time and energy. | ||
|
||
## Prerequisites | ||
|
||
[Node.js](https://nodejs.org/en/) (>= 8.*), Npm version 4+(Yarn preferred), and [Git](https://git-scm.com/). | ||
|
||
## Install | ||
|
||
```bash | ||
npm i arya-jarvis -g | ||
# OR | ||
yarn add global arya-jarvis | ||
``` | ||
|
||
## Usage | ||
|
||
##### List the script commands in package.json. | ||
|
||
```bash | ||
arya ls | ||
# Or | ||
arya l | ||
``` | ||
|
||
##### Prettier the code under the specified path. | ||
|
||
```bash | ||
arya prettier index.js | ||
# Or | ||
arya p src/**/*.js | ||
``` | ||
|
||
##### Listen for code changes in the specified path and prettier them. | ||
|
||
```bash | ||
arya watcher index.js | ||
# Or | ||
arya w src/**/*.js | ||
``` | ||
|
||
## Recommended links | ||
|
||
* [**NICE LINKS**](https://nicelinks.site/?utm_source=github.com) | ||
* [About Me](https://about.me/nicejade/?utm_source=github.com) | ||
* [Hexo Blog](https://jeffjade.com/?utm_source=github.com) | ||
* [VuePress Blog](https://www.lovejade.cn/?utm_source=github.com) | ||
* [VuePress Blog](https://nice.lovejade.cn/?utm_source=github.com) | ||
* [Ghost Blog](https://quickapp.lovejade.cn/?utm_source=github.com) | ||
* [Jekyll blog](https://blog.lovejade.cn/?utm_source=github.com) | ||
* [SegmentFault](https://segmentfault.com/u/jeffjade) | ||
* [Wei bo](http://weibo.com/jeffjade/) | ||
* [Zhi Hu](https://www.zhihu.com/people/yang-qiong-pu/) | ||
* [Jian Shu](http://www.jianshu.com/u/9aae3d8f4c3d) | ||
* [Twitter](https://twitter.com/nicejadeyang) | ||
* [Facebook](https://www.facebook.com/nice.jade.yang) | ||
|
||
## License | ||
|
||
[MIT](http://opensource.org/licenses/MIT) | ||
|
||
Copyright (c) 2019-present, [nicejade](https://aboutme.lovejade.cn/?utm_source=arya-jarvis). |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env node | ||
|
||
const commander = require('commander') | ||
const program = new commander.Command() | ||
const chalk = require('chalk') | ||
const print = require('./../helper/print') | ||
const { exec } = require('child_process') | ||
|
||
const version = require(`./../package.json`).version | ||
program.version(version, '-v, --vers', 'output the current version') | ||
|
||
program | ||
.command('ls') | ||
.alias('l') | ||
.description('List the script commands in package.json.') | ||
.action(() => { | ||
const scripts = require(`${process.cwd()}/package.json`).scripts | ||
print('success', 'List the script commands in package.json:') | ||
for (let key in scripts) { | ||
const colorKey = chalk.magenta(`${key}`) | ||
print('normal', ` ${colorKey}: ${scripts[key]}`) | ||
} | ||
}) | ||
|
||
program | ||
.command('prettier <path>') | ||
.alias('p') | ||
.description('Prettier the code under the specified path.') | ||
.action(params => { | ||
exec(`npx prettier --write ${params}`, (error, stdout, stderr) => { | ||
if (error) return print(`error`, `Something Error: ${error}`) | ||
print(`success`, 'Has successfully prettier your code.') | ||
}) | ||
}) | ||
|
||
program | ||
.command('watcher <path>') | ||
.alias('w') | ||
.description('Listen for code changes in the specified path and prettier them.') | ||
.action(params => { | ||
console.log(params) | ||
exec(`npx onchange ${params} -- prettier --write {{changed}}`, (error, stdout, stderr) => { | ||
print(`normal`, 'Be ready to beautify your changed code.') | ||
console.log(stdout) | ||
console.log(stderr) | ||
if (error) return print(`error`, `Something Error: ${error}`) | ||
}) | ||
}) | ||
|
||
program.parse(process.argv) | ||
|
||
if (program.args.length === 0) { | ||
program.help() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const chalk = require('chalk') | ||
|
||
const colorMapping = { | ||
normal: 'cyan', | ||
success: 'green', | ||
warn: 'yellow', | ||
error: 'red' | ||
} | ||
|
||
module.exports = (type, args) => { | ||
if (typeof args === 'object') { | ||
return console.log(chalk[colorMapping[type]](...args)) | ||
} | ||
const color = colorMapping[type] || 'white' | ||
console.log(chalk[color](args)) | ||
} |
Oops, something went wrong.