all-contributors-cli
Advanced tools
Comparing version 1.0.2 to 2.0.0-beta1
61
cli.js
@@ -6,8 +6,6 @@ #!/usr/bin/env node | ||
var path = require('path'); | ||
var assign = require('lodash.assign'); | ||
var generate = require('./lib/generate'); | ||
var markdown = require('./lib/markdown'); | ||
var getUserInfo = require('./lib/github'); | ||
var defaultEmojis = require('./lib/emoji'); | ||
var addContributor = require('./lib/addContributor'); | ||
var updateContributors = require('./lib/contributors'); | ||
@@ -18,7 +16,13 @@ var cwd = process.cwd(); | ||
var argv = require('yargs') | ||
.help('help') | ||
.alias('h', 'help') | ||
.command('generate', 'Generate the list of contributors') | ||
.usage('Usage: $0 generate') | ||
.command('add', 'add a new contributor') | ||
.usage('Usage: $0 add <username> <contribution>') | ||
.demand(2) | ||
.default('files', ['README.md']) | ||
.default('contributorsPerLine', 7) | ||
.default('contributors', []) | ||
.default('config', defaultRCFile) | ||
.default('file', 'README.md') | ||
.config('config', function(configPath) { | ||
@@ -34,26 +38,41 @@ try { | ||
}) | ||
.default('emoji', {}) | ||
.pkgConf('all-contributors') | ||
.argv; | ||
argv.emoji = assign({}, defaultEmojis, argv.emoji); | ||
argv.username = argv._[1]; | ||
argv.contributions = argv._[2].split(','); | ||
argv.file = path.join(cwd, argv.file); | ||
function startGeneration(argv, cb) { | ||
argv.files | ||
.map(function(file) { | ||
return path.join(cwd, file); | ||
}) | ||
.forEach(function(file) { | ||
markdown.read(file, function(error, fileContent) { | ||
if (error) { | ||
return cb(error); | ||
} | ||
var newFileContent = generate(argv, argv.contributors, fileContent); | ||
markdown.write(file, newFileContent, cb); | ||
}); | ||
}); | ||
} | ||
getUserInfo(argv.username, function(error, user) { | ||
function onError(error) { | ||
if (error) { | ||
return console.error(error); | ||
} | ||
markdown.read(argv.file, function(error, fileContent) { | ||
} | ||
var command = argv._[0]; | ||
if (command === 'generate') { | ||
startGeneration(argv, onError); | ||
} else if (command === 'add') { | ||
var username = argv._[1]; | ||
var contributions = argv._[2]; | ||
// Add or update contributor in the config file | ||
updateContributors(argv, username, contributions, function(error, contributors) { | ||
if (error) { | ||
return console.error(error); | ||
return onError(error); | ||
} | ||
var newFileContent = addContributor(argv, user, fileContent); | ||
markdown.write(argv.file, newFileContent, function(error, fileContent) { | ||
if (error) { | ||
return console.error(error); | ||
} | ||
}); | ||
argv.contributors = contributors; | ||
startGeneration(argv, onError); | ||
}); | ||
}); | ||
} |
{ | ||
"name": "all-contributors-cli", | ||
"version": "1.0.2", | ||
"version": "2.0.0-beta1", | ||
"description": "Tool to easily add recognition for new contributors", | ||
@@ -9,3 +9,3 @@ "bin": { | ||
"scripts": { | ||
"test": "ava lib/**/*.test.js", | ||
"test": "ava \"lib/**/*.test.js\"", | ||
"test:w": "npm test -- --watch" | ||
@@ -28,15 +28,6 @@ }, | ||
"dependencies": { | ||
"lodash.assign": "^4.0.4", | ||
"lodash.findindex": "^4.2.0", | ||
"lodash.template": "^4.2.1", | ||
"lodash.uniq": "^4.2.0", | ||
"lodash.values": "^4.1.0", | ||
"lodash": "^4.6.1", | ||
"request": "^2.69.0", | ||
"yargs": "^4.2.0" | ||
}, | ||
"all-contributors": { | ||
"projectOwner": "jfmengels", | ||
"projectName": "all-contributors-cli", | ||
"imageSize": 100 | ||
}, | ||
"devDependencies": { | ||
@@ -43,0 +34,0 @@ "ava": "^0.12.0" |
114
README.md
# all-contributors-cli | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
This is a tool to help automate adding contributor acknowledgements according to the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. | ||
@@ -8,9 +12,74 @@ | ||
You can install it via `npm`: | ||
``` | ||
```console | ||
npm install all-contributors-cli | ||
``` | ||
## Configuration | ||
### Create a `.all-contributorsrc` file | ||
You must create a `.all-contributorsrc` JSON file. The data used to generate the contributors list will be stored in here, and you can configure how you want `all-contributors-cli` to generate the list. | ||
```json | ||
{ | ||
"files": ["README.md"], | ||
"owner": "jfmengels", | ||
"types": { | ||
"cheerful": { | ||
"symbol": ":smiley:" | ||
} | ||
}, | ||
"contributors": [{ | ||
"login": "jfmengels", | ||
"...": "..." | ||
}] | ||
} | ||
``` | ||
These are the keys you can specify: | ||
- `files`: Array of files to update. Default: `['README.md']` | ||
- `projectOwner`: Name of the user the project is hosted by. Example: `jfmengels/all-contributor-cli` --> `jfmengels`. Mandatory. | ||
- `projectName`: Name of the project. Example: `jfmengels/all-contributor-cli` --> `all-contributor-cli`. Mandatory. | ||
- `types`: Specify custom symbols or link templates for contribution types. Can override the documented types. | ||
- `imageSize`: Size (in px) of the user's avatar. Default: `100`. | ||
- `contributorsPerLine`: Maximum number of columns for the contributors table. Default: `7`. | ||
- `contributorTemplate`: Define your own template to generate the contributor list. | ||
- `badgeTemplate`: Define your own template to generate the badge. | ||
### Add contributors section | ||
If you don't already have a Contributors section in a Markdown file, create one. Then add the comment tags section below to it. Don't worry, they're visible only to those that read the raw file. The tags **must** be at the beginning of the line, and each on their separate line. | ||
```md | ||
## Contributors | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
``` | ||
If you wish to add a badge ( [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors) ) indicating the number of collaborators, add the following tags (again, at the beginning of the line and each on their separate line): | ||
```md | ||
some-badge | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
some-other-badge | ||
``` | ||
## Usage | ||
### Generating the contributors list | ||
Use `generate` to generate the contributors list and inject it into your contributors file. Contributors will be read from your configuration file. | ||
``` | ||
all-contributors generate | ||
``` | ||
### Add new contributor | ||
Use `add` to add new contributors to your project. They will be added to your configuration file. The contributors file will then be updated just as if you used the `generate` command. | ||
```console | ||
# Add new contributor <username>, who made a contribution of type <contribution> | ||
@@ -21,2 +90,3 @@ all-contributors add <username> <contribution> | ||
``` | ||
Where: | ||
@@ -35,2 +105,3 @@ - `username` is the user's GitHub username | ||
- tutorial: ✅ | ||
- translate: 🌍 | ||
- video: 📹 | ||
@@ -41,37 +112,3 @@ - talk: 📢 | ||
## Configuration | ||
You can configure the project by creating a `.all-contributorsrc` JSON file. | ||
```json | ||
{ | ||
"file": "README.md", | ||
"owner": "jfmengels", | ||
"emoji": { | ||
"cheerful": ":smiley:" | ||
} | ||
} | ||
``` | ||
or creating a `all-contributors` updating the `package.json` file: | ||
```json | ||
{ | ||
"name": "all-contributors-cli", | ||
"...": "...", | ||
"all-contributors": { | ||
"file": "README.md", | ||
"owner": "jfmengels" | ||
} | ||
} | ||
``` | ||
These are the keys you can specify: | ||
- `emoji`: Specify custom emoji, can override the documented emojis. It doesn't really have to be emojis really. | ||
- `file`: File to write the list of contributors in. Default: 'README.md' | ||
- `imageSize`: Size (in px) of the user's avatar. Default: 100. | ||
- `owner`: Name of the user the project is hosted by. Example: `jfmengels/all-contributor-cli` --> `jfmengels`. By default will be parsed from the repo's homepage in `package.json` (TODO). | ||
- `project`: Name of the project. Example: `jfmengels/all-contributor-cli` --> `all-contributor-cli`. Default: Name of the project written in the `package.json` file (TODO). | ||
- `template`: Define your own contributor template. Please read the code to see what you can define (**warning**: not sure it will work well after several tries). | ||
## Contributors | ||
@@ -81,5 +118,6 @@ | ||
Contributor | Contributions | ||
:---: | :---: | ||
[![Jeroen Engels](https://avatars.githubusercontent.com/u/3869412?v=3&s=100)<br />Jeroen Engels](https://github.com/jfmengels) | [💻📖⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
| [![Jeroen Engels](https://avatars.githubusercontent.com/u/3869412?v=3&s=100)<br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | [![Kent C. Dodds](https://avatars.githubusercontent.com/u/1500684?v=3&s=100)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com/)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) | | ||
| :---: | :---: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -86,0 +124,0 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33656
3
20
813
125
1
3
1
+ Addedlodash@^4.6.1
+ Addedlodash@4.17.21(transitive)
- Removedlodash.assign@^4.0.4
- Removedlodash.findindex@^4.2.0
- Removedlodash.template@^4.2.1
- Removedlodash.uniq@^4.2.0
- Removedlodash.values@^4.1.0
- Removedlodash._reinterpolate@3.0.0(transitive)
- Removedlodash.findindex@4.6.0(transitive)
- Removedlodash.template@4.5.0(transitive)
- Removedlodash.templatesettings@4.2.0(transitive)
- Removedlodash.uniq@4.5.0(transitive)
- Removedlodash.values@4.3.0(transitive)