Socket
Socket
Sign inDemoInstall

all-contributors-cli

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

all-contributors-cli - npm Package Compare versions

Comparing version 2.0.0-beta1 to 2.0.0-beta10

.eslintrc

88

cli.js
#!/usr/bin/env node
/* eslint-disable no-console */
'use strict';

@@ -6,5 +7,8 @@

var path = require('path');
var yargs = require('yargs');
var inquirer = require('inquirer');
var init = require('./lib/init');
var generate = require('./lib/generate');
var markdown = require('./lib/markdown');
var util = require('./lib/util');
var updateContributors = require('./lib/contributors');

@@ -15,3 +19,3 @@

var argv = require('yargs')
var argv = yargs
.help('help')

@@ -23,3 +27,5 @@ .alias('h', 'help')

.usage('Usage: $0 add <username> <contribution>')
.demand(2)
.command('init', 'Prepare the project to be used with this tool')
.usage('Usage: $0 init')
.boolean('commit')
.default('files', ['README.md'])

@@ -29,3 +35,3 @@ .default('contributorsPerLine', 7)

.default('config', defaultRCFile)
.config('config', function(configPath) {
.config('config', function (configPath) {
try {

@@ -44,7 +50,7 @@ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));

argv.files
.map(function(file) {
.map(function (file) {
return path.join(cwd, file);
})
.forEach(function(file) {
markdown.read(file, function(error, fileContent) {
.forEach(function (file) {
util.markdown.read(file, function (error, fileContent) {
if (error) {

@@ -54,3 +60,3 @@ return cb(error);

var newFileContent = generate(argv, argv.contributors, fileContent);
markdown.write(file, newFileContent, cb);
util.markdown.write(file, newFileContent, cb);
});

@@ -60,2 +66,23 @@ });

function addContribution(argv, cb) {
var username = argv._[1];
var contributions = argv._[2];
// Add or update contributor in the config file
updateContributors(argv, username, contributions, function (error, data) {
if (error) {
return onError(error);
}
argv.contributors = data.contributors;
startGeneration(argv, function (error) {
if (error) {
return cb(error);
}
if (!argv.commit) {
return cb();
}
return util.git.commit(argv, data, cb);
});
});
}
function onError(error) {

@@ -67,17 +94,36 @@ if (error) {

var command = argv._[0];
function promptForCommand(argv, cb) {
try {
fs.statSync(argv.config);
} catch (error) { // No config file --> first time using the command
return cb('init');
}
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 onError(error);
}
argv.contributors = contributors;
startGeneration(argv, onError);
var questions = [{
type: 'list',
name: 'command',
message: "What do you want to do?",
choices: [{
name: 'Add a new contributor or add a new contribution type',
value: 'add'
}, {
name: 'Re-generate the contributors list',
value: 'generate'
}],
when: !argv._[0],
default: 0
}];
inquirer.prompt(questions, function treatAnswers(answers) {
return cb(answers.command || argv._[0]);
});
}
promptForCommand(argv, function (command) {
if (command === 'init') {
init(onError);
} else if (command === 'generate') {
startGeneration(argv, onError);
} else if (command === 'add') {
addContribution(argv, onError);
}
});

@@ -5,8 +5,2 @@ 'use strict';

function matchContribution(type) {
return function(existing) {
return type === existing || type === existing.type;
};
}
function uniqueTypes(contribution) {

@@ -16,10 +10,9 @@ return contribution.type || contribution;

function formatContributions(options, existing, newTypes) {
var types = newTypes.split(',');
function formatContributions(options, existing, types) {
if (options.url) {
return (existing || []).concat(types.map(function(type) {
return { type: type, url: options.url };
return (existing || []).concat(types.map(function (type) {
return {type: type, url: options.url};
}));
}
return _.uniqBy(uniqueTypes, (existing || []).concat(types));
return _.uniqBy(uniqueTypes, (existing || []).concat(types));
}

@@ -34,3 +27,3 @@

function updateExistingContributor(options, username, contributions) {
return options.contributors.map(function(contributor, index) {
return options.contributors.map(function (contributor) {
if (username !== contributor.login) {

@@ -44,3 +37,3 @@ return contributor;

function addNewContributor(options, username, contributions, infoFetcher, cb) {
infoFetcher(username, function(error, userData) {
infoFetcher(username, function (error, userData) {
if (error) {

@@ -61,2 +54,2 @@ return cb(error);

return addNewContributor(options, username, contributions, infoFetcher, cb);
}
};

@@ -9,3 +9,3 @@ import test from 'ava';

avatar_url: 'www.avatar.url',
html_url: 'www.html.url'
profile: 'www.profile.url'
});

@@ -20,3 +20,3 @@ }

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [

@@ -29,5 +29,5 @@ 'code'

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
{ type: 'blog', url: 'www.blog.url/path' },
{type: 'blog', url: 'www.blog.url/path'},
'code'

@@ -48,3 +48,3 @@ ]

return addContributor(options, username, contributions, infoFetcher, function(error) {
return addContributor(options, username, contributions, infoFetcher, function (error) {
t.is(error.message, 'infoFetcher error');

@@ -58,5 +58,5 @@ t.end();

const username = 'login3';
const contributions = 'doc';
const contributions = ['doc'];
return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);

@@ -68,3 +68,3 @@ t.is(contributors.length, 3);

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [

@@ -81,6 +81,6 @@ 'doc'

const username = 'login3';
const contributions = 'doc';
const contributions = ['doc'];
options.url = 'www.foo.bar';
return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);

@@ -92,5 +92,5 @@ t.is(contributors.length, 3);

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
{ type: 'doc', url: 'www.foo.bar' }
{type: 'doc', url: 'www.foo.bar'}
]

@@ -105,5 +105,5 @@ });

const username = 'login2';
const contributions = 'blog,code';
const contributions = ['blog', 'code'];
return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);

@@ -118,5 +118,4 @@ t.same(contributors, options.contributors);

const username = 'login1';
const contributions = 'bug';
return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
const contributions = ['bug'];
return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);

@@ -128,3 +127,3 @@ t.is(contributors.length, 2);

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [

@@ -142,6 +141,6 @@ 'code',

const username = 'login1';
const contributions = 'bug';
const contributions = ['bug'];
options.url = 'www.foo.bar';
return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);

@@ -153,6 +152,6 @@ t.is(contributors.length, 2);

avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
'code',
{ type: 'bug', url: 'www.foo.bar' },
{type: 'bug', url: 'www.foo.bar'}
]

@@ -159,0 +158,0 @@ });

'use strict';
var _ = require('lodash/fp');
var request = require('request');

@@ -12,9 +11,15 @@

}
}, function(error, res) {
}, function (error, res) {
if (error) {
return cb(error);
}
var user = JSON.parse(res.body);
return cb(null, _.pick(['login', 'name', 'avatar_url', 'html_url'], user));
var body = JSON.parse(res.body);
var user = {
login: body.login,
name: body.name,
avatar_url: body.avatar_url,
profile: body.blog || body.html_url
};
return cb(null, user);
});
}
};
'use strict';
var _ = require('lodash/fp');
var util = require('../util');
var add = require('./add');
var github = require('./github');
var configFile = require('../configFile');
var prompt = require('./prompt');
function isNewContributor(contributorList, username) {
return !_.find({login: username}, contributorList);
}
module.exports = function addContributor(options, username, contributions, cb) {
add(options, username, contributions, github, function(error, contributors) {
if (error) {
return cb(error);
}
configFile.writeContributors(options.config, contributors, function(error) {
return cb(error, contributors);
prompt(options, username, contributions, function (answers) {
add(options, answers.username, answers.contributions, github, function (error, contributors) {
if (error) {
return cb(error);
}
util.configFile.writeContributors(options.config, contributors, function (error) {
return cb(error, {
username: answers.username,
contributions: answers.contributions,
contributors: contributors,
newContributor: isNewContributor(options.contributors, answers.username)
});
});
});
});
};

@@ -5,3 +5,3 @@ {

"name": "Kent C. Dodds",
"html_url": "http://kentcdodds.com",
"profile": "http://kentcdodds.com",
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",

@@ -17,3 +17,3 @@ "contributions": [

"name": "Divjot Singh",
"html_url": "http://bogas04.github.io",
"profile": "http://bogas04.github.io",
"avatar_url": "https://avatars1.githubusercontent.com/u/6177621",

@@ -20,0 +20,0 @@ "contributions": [

@@ -8,5 +8,5 @@ 'use strict';

module.exports = function formatBadge(options, contributors) {
return _.template(options.badgeTemplate || defaultTemplate)({
return _.template(options.badgeTemplate || defaultTemplate)({
contributors: contributors
});
};

@@ -5,11 +5,2 @@ import test from 'ava';

const fixtures = () => {
const options = {
projectOwner: 'jfmengels',
projectName: 'all-contributors-cli',
imageSize: 100
};
return {options};
}
test('should return badge with the number of contributors', t => {

@@ -16,0 +7,0 @@ const options = {};

'use strict';
var _ = require('lodash/fp');
var util = require('../util');
var linkToCommits = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>'
var linkToIssues = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>';
var linkTemplate = _.template('[<%= symbol %>](<%= url %>)');
var defaultTypes = {
blog: { symbol: '📝' },
bug: {
symbol: '🐛',
link: linkToIssues
},
code: {
symbol: '💻',
link: linkToCommits
},
design: { symbol: '🎨' },
doc: {
symbol: '📖',
link: linkToCommits
},
example: { symbol: '💡' },
plugin: { symbol: '🔌' },
question: { symbol: '❓' },
review: { symbol: '👀' },
talk: { symbol: '📢' },
test: {
symbol: '⚠️',
link: linkToCommits
},
translation: { symbol: '🌍' },
tool: { symbol: '🔧' },
tutorial: { symbol: '✅' },
video: { symbol: '📹' }
};
function getType(options, contribution) {
var types = _.assign(defaultTypes, options.types);
var types = util.contributionTypes(options);
return types[contribution.type || contribution];

@@ -42,0 +11,0 @@ }

import test from 'ava';
import contributors from './fixtures/contributors.json';
import formatContributionType from './formatContributionType';
import contributors from './fixtures/contributors.json';

@@ -12,3 +12,3 @@ const fixtures = () => {

return {options};
}
};

@@ -67,3 +67,3 @@ test('should return corresponding symbol', t => {

options.types = {
cheerful: { symbol: ':smiley:' }
cheerful: {symbol: ':smiley:'}
};

@@ -95,3 +95,3 @@

options.types = {
code: { symbol: ':smiley:' }
code: {symbol: ':smiley:'}
};

@@ -98,0 +98,0 @@

'use strict';
var _ = require('lodash/fp');
var formatContributionType = require('./formatContributionType');
var avatarTemplate = _.template('![<%= contributor.name %>](<%= contributor.avatar_url %>)');
var avatarBlockTemplate = _.template('[<%= avatar %><br /><sub><%= contributor.name %></sub>](<%= contributor.html_url %>)');
var avatarBlockTemplate = _.template('[<%= avatar %><br /><sub><%= contributor.name %></sub>](<%= contributor.profile %>)');
var contributorTemplate = _.template('<%= avatarBlock %><br /><%= contributions %>');
var defaultImageSize = 100;
function defaultTemplate(templateData) {
var avatar = avatarTemplate(templateData);
var avatarBlock = avatarBlockTemplate(_.assign({ avatar: avatar }, templateData));
return contributorTemplate(_.assign({ avatarBlock: avatarBlock }, templateData));
var avatarBlock = avatarBlockTemplate(_.assign({avatar: avatar}, templateData));
return contributorTemplate(_.assign({avatarBlock: avatarBlock}, templateData));
}

@@ -20,6 +21,6 @@

var paramJoiner = _.includes('?', avatarUrl) ? '&' : '?';
var imageSize = options.imageSize || defaultImageSize;
return _.assign(contributor, {
avatar_url: avatarUrl + paramJoiner + 's=' + options.imageSize
avatar_url: avatarUrl + paramJoiner + 's=' + imageSize
});
'<%= contributor.avatar_url %>?s=<%= options.imageSize %>'
}

@@ -26,0 +27,0 @@

@@ -10,3 +10,3 @@ import test from 'ava';

projectName: 'all-contributors-cli',
imageSize: 100
imageSize: 150
};

@@ -17,6 +17,6 @@ return {options};

test('should format a simple contributor', t => {
const contributor = _.assign(contributors.kentcdodds, { contributions: ['review'] });
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
const {options} = fixtures();
const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=100)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />👀';
const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=150)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />👀';

@@ -30,3 +30,3 @@ t.is(formatContributor(options, contributor), expected);

const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=100)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 ❓';
const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=150)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 ❓';

@@ -39,3 +39,3 @@ t.is(formatContributor(options, contributor), expected);

const {options} = fixtures();
options.contributorTemplate = '<%= contributor.name %> is awesome!'
options.contributorTemplate = '<%= contributor.name %> is awesome!';

@@ -50,3 +50,3 @@ const expected = 'Kent C. Dodds is awesome!';

const contributor = contributors.kentcdodds;
options.contributorTemplate = '<%= contributor.name %> at <%= contributor.avatar_url %>'
options.contributorTemplate = '<%= contributor.name %> at <%= contributor.avatar_url %>';

@@ -61,7 +61,18 @@ var contributionWithoutQuestionMarkUrl = _.assign(contributor, {

t.is(formatContributor(options, contributionWithoutQuestionMarkUrl),
'Kent C. Dodds at www.some-url-without-question-mark.com?s=100'
'Kent C. Dodds at www.some-url-without-question-mark.com?s=150'
);
t.is(formatContributor(options, contributionWithQuestionMarkUrl),
'Kent C. Dodds at www.some-url-with-question-mark.com?v=3&s=100'
'Kent C. Dodds at www.some-url-with-question-mark.com?v=3&s=150'
);
});
test('should default image size to 100', t => {
const {options} = fixtures();
const contributor = contributors.kentcdodds;
options.contributorTemplate = '<%= contributor.name %> at <%= contributor.avatar_url %>';
delete options.imageSize;
t.is(formatContributor(options, contributor),
'Kent C. Dodds at https://avatars1.githubusercontent.com/u/1500684?s=100'
);
});
'use strict';
var _ = require('lodash/fp');
var injectContentBetween = require('../util').markdown.injectContentBetween;
var formatBadge = require('./formatBadge');
var formatContributor = require('./formatContributor');
function injectContentBetween(lines, content, startIndex, endIndex) {
return [].concat(
lines.slice(0, startIndex),
content,
lines.slice(endIndex)
);
var badgeRegex = /\[\!\[All Contributors\]\([a-zA-Z0-9\-\.\/_\:\?=]+\)\]\(\#\w+\)/;
function injectListBetweenTags(newContent) {
return function (previousContent) {
var tagToLookFor = '<!-- ALL-CONTRIBUTORS-LIST:';
var closingTag = '-->';
var startOfOpeningTagIndex = previousContent.indexOf(tagToLookFor + 'START');
var endOfOpeningTagIndex = previousContent.indexOf(closingTag, startOfOpeningTagIndex);
var startOfClosingTagIndex = previousContent.indexOf(tagToLookFor + 'END', endOfOpeningTagIndex);
if (startOfOpeningTagIndex === -1 || endOfOpeningTagIndex === -1 || startOfClosingTagIndex === -1) {
return previousContent;
}
return previousContent.slice(0, endOfOpeningTagIndex + closingTag.length) +
'\n' + newContent + '\n' +
previousContent.slice(startOfClosingTagIndex);
};
}
var injectBetweenTags = _.curry(function(tag, newContent, previousContent) {
var lines = previousContent.split('\n');
var openingTagIndex = _.findIndex(_.startsWith('<!-- ALL-CONTRIBUTORS-' + tag + ':START '), lines);
var closingTagIndex = _.findIndex(_.startsWith('<!-- ALL-CONTRIBUTORS-' + tag + ':END '), lines);
if (openingTagIndex === -1 || closingTagIndex === -1) {
return previousContent;
}
return injectContentBetween(lines, newContent, openingTagIndex + 1, closingTagIndex)
.join('\n');
});
function formatLine(contributors) {

@@ -50,2 +50,14 @@ return '| ' + contributors.join(' | ') + ' |';

function replaceBadge(newContent) {
return function (previousContent) {
var regexResult = badgeRegex.exec(previousContent);
if (!regexResult) {
return previousContent;
}
return previousContent.slice(0, regexResult.index) +
newContent +
previousContent.slice(regexResult.index + regexResult[0].length);
};
}
module.exports = function generate(options, contributors, fileContent) {

@@ -55,5 +67,5 @@ var contributorsList = generateContributorsList(options, contributors);

return _.flow(
injectBetweenTags('LIST', contributorsList),
injectBetweenTags('BADGE', badge)
injectListBetweenTags(contributorsList),
replaceBadge(badge)
)(fileContent);
};
import test from 'ava';
import contributors from './fixtures/contributors.json';
import generate from './';
import contributors from './fixtures/contributors.json';
function getUserLine(content, {login}) {
return content
.split('\n')
.filter(line => line.indexOf(login) !== -1)
[0];
}
function fixtures() {

@@ -37,5 +30,3 @@ const options = {

'These people contributed to the project:',
'<!-- ALL-CONTRIBUTORS-LIST:START -->',
'###Some content that will be replaced###',
'<!-- ALL-CONTRIBUTORS-LIST:END -->',
'<!-- ALL-CONTRIBUTORS-LIST:START -->FOO BAR BAZ<!-- ALL-CONTRIBUTORS-LIST:END -->',
'',

@@ -149,3 +140,3 @@ 'Thanks a lot guys!'

test('should inject badge if the ALL-CONTRIBUTORS-BADGE tag is present', t => {
test('should replace all-contributors badge if present', t => {
const {kentcdodds} = contributors;

@@ -157,6 +148,7 @@ const {options} = fixtures();

'',
'Badges',
'<!-- ALL-CONTRIBUTORS-BADGE:START -->',
'###Some content that will be replaced###',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->',
'Badges', [
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
'[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors)',
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)'
].join(''),
'',

@@ -168,6 +160,7 @@ 'License: MIT'

'',
'Badges',
'<!-- ALL-CONTRIBUTORS-BADGE:START -->',
'[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->',
'Badges', [
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
'[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)',
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)'
].join(''),
'',

@@ -178,3 +171,4 @@ 'License: MIT'

const result = generate(options, contributorList, content);
t.is(result, expected);
});
{
"name": "all-contributors-cli",
"version": "2.0.0-beta1",
"version": "2.0.0-beta10",
"description": "Tool to easily add recognition for new contributors",

@@ -9,4 +9,6 @@ "bin": {

"scripts": {
"test": "ava \"lib/**/*.test.js\"",
"test:w": "npm test -- --watch"
"lint": "eslint cli.js \"lib/**/*.js\" && xo",
"test": "npm run lint && npm run test-unit",
"test-unit": "ava",
"test-unit:w": "ava --watch"
},

@@ -28,9 +30,30 @@ "repository": {

"dependencies": {
"async": "^2.0.0-rc.1",
"inquirer": "^0.12.0",
"lodash": "^4.6.1",
"request": "^2.69.0",
"yargs": "^4.2.0"
"yargs": "^4.3.2"
},
"devDependencies": {
"ava": "^0.12.0"
"ava": "^0.13.0",
"eslint": "^2.4.0",
"eslint-plugin-ava": "^1.2.1",
"xo": "^0.13.0"
},
"ava": {
"files": [
"lib/**/*.test.js"
]
},
"xo": {
"space": 2,
"rules": {
"camelcase": [
2,
{
"properties": "never"
}
]
}
}
}
# 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 -->
[![version](https://img.shields.io/npm/v/all-contributors-cli.svg)](http://npm.im/all-contributors-cli)[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)

@@ -13,58 +11,26 @@ This is a tool to help automate adding contributor acknowledgements according to the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.

```console
npm install all-contributors-cli
npm install all-contributors-cli -g
```
## 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.
Then init the project using `init` and answering a few questions:
```console
all-contributors init
```
Once initialized, you don't need to have `all-contributors-cli` installed globally. You can instead save it as a devDependency of your project and add it to your `package.json` scripts:
```console
npm install --save-dev all-contributors-cli
```
```json
{
"files": ["README.md"],
"owner": "jfmengels",
"types": {
"cheerful": {
"symbol": ":smiley:"
}
},
"contributors": [{
"login": "jfmengels",
"...": "..."
}]
"scripts": {
"add": "all-contributors add",
"generate": "all-contributors generate"
}
}
```
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 -->
and use them via `npm run`:
```console
npm run add -- jfmengels doc
npm run generate
```
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

@@ -76,9 +42,9 @@

```
```console
all-contributors generate
```
### Add new contributor
### Add/update contributors
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.
Use `add` to add new contributors to your project, or add new ways in which they contributed. They will be added to your configuration file. The contributors file will then be updated just as if you used the `generate` command.

@@ -91,6 +57,3 @@ ```console

```
Where:
- `username` is the user's GitHub username
- `contribution` is a `,`-separated list of ways to contribute, from the following list ([see the specs](https://github.com/kentcdodds/all-contributors#emoji-key)):
Where `username` is the user's GitHub username, and `contribution` is a `,`-separated list of ways to contribute, from the following list ([see the specs](https://github.com/kentcdodds/all-contributors#emoji-key)):
- code: 💻

@@ -112,3 +75,16 @@ - plugin: 🔌

## Configuration
You can configure the project by updating the `.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.
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.
## Contributors

@@ -115,0 +91,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc