Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

all-contributors-cli

Package Overview
Dependencies
Maintainers
2
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 5.10.1 to 5.10.2

dist/contributors/__tests__/add.js

5

dist/api.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,6 +7,6 @@ // All Contributors Node JS API

// These Node API's are intended to be network and side effect free, everything should be in memory with no io to network/disk
var chalk = require('chalk');
var addContributorWithDetails = require('./contributors/addWithDetails');
var generate = require('./generate');

@@ -19,3 +19,2 @@

process.stdout.write(chalk.yellow(`${chalk.bold('WARNING')} :: Using the all-contributors node-api comes with zero guarantees of stability and may contain breaking changes without warning\n`));
module.exports = {

@@ -22,0 +21,0 @@ addContributorWithDetails,

22

dist/cli.js
#!/usr/bin/env node
'use strict';
/* eslint-disable no-console */
"use strict";
var path = require('path');
var yargs = require('yargs');
var chalk = require('chalk');
var inquirer = require('inquirer');
var init = require('./init');
var generate = require('./generate');
var util = require('./util');
var repo = require('./repo');
var updateContributors = require('./contributors');

@@ -19,3 +26,2 @@

var defaultRCFile = path.join(cwd, '.all-contributorsrc');
var yargv = yargs.help('help').alias('h', 'help').alias('v', 'version').version().command('generate', 'Generate the list of contributors').usage('Usage: $0 generate').command('add', 'add a new contributor').usage('Usage: $0 add <username> <contribution>').command('init', 'Prepare the project to be used with this tool').usage('Usage: $0 init').command('check', 'Compares contributors from the repository with the ones credited in .all-contributorsrc').usage('Usage: $0 check').boolean('commit').default('files', ['README.md']).default('contributorsPerLine', 7).default('contributors', []).default('config', defaultRCFile).config('config', function (configPath) {

@@ -43,4 +49,4 @@ try {

var username = argv._[1];
var contributions = argv._[2];
// Add or update contributor in the config file
var contributions = argv._[2]; // Add or update contributor in the config file
return updateContributors(argv, username, contributions).then(function (data) {

@@ -58,3 +64,2 @@ argv.contributors = data.contributors;

var configData = util.configFile.readConfig(argv.config);
return repo.getContributors(configData.projectOwner, configData.projectName, configData.repoType, configData.repoHost).then(function (repoContributors) {

@@ -69,3 +74,2 @@ var checkKey = repo.getCheckKey(configData.repoType);

});
var missingInConfig = repoContributors.filter(function (key) {

@@ -95,2 +99,3 @@ return !knownContributors.includes(key);

}
process.exit(0);

@@ -117,3 +122,2 @@ }

}];
return inquirer.prompt(questions).then(function (answers) {

@@ -128,8 +132,12 @@ return answers.command || argv._[0];

return init();
case 'generate':
return startGeneration(yargv);
case 'add':
return addContribution(yargv);
case 'check':
return checkContributors(yargv);
default:

@@ -136,0 +144,0 @@ throw new Error(`Unknown command ${command}`);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -9,7 +9,9 @@ var _ = require('lodash/fp');

function formatContributions(options) {
var existing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var types = arguments[2];
function formatContributions(options, existing, types) {
if (existing === void 0) {
existing = [];
}
var same = _.intersectionBy(uniqueTypes, existing, types);
var remove = types.length < existing.length && same.length;

@@ -19,3 +21,6 @@

return existing.concat(types.map(function (type) {
return { type, url: options.url };
return {
type,
url: options.url
};
}));

@@ -42,2 +47,3 @@ }

}
return updateContributor(options, contributor, contributions);

@@ -52,2 +58,3 @@ });

});
return options.contributors.concat(contributor);

@@ -66,3 +73,4 @@ });

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

@@ -1,6 +0,6 @@

'use strict';
"use strict";
var addContributor = require('./add');
var addContributor = require('./add'); // Adds a contributor without going to the network (you supply the additional fields)
// Adds a contributor without going to the network (you supply the additional fields)
module.exports = function (_ref) {

@@ -13,3 +13,2 @@ var options = _ref.options,

profile = _ref.profile;
return addContributor(options, login, contributions, function infoFetcherNoNetwork() {

@@ -16,0 +15,0 @@ return Promise.resolve({

@@ -1,11 +0,17 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var util = require('../util');
var repo = require('../repo');
var add = require('./add');
var prompt = require('./prompt');
function isNewContributor(contributorList, username) {
return !_.find({ login: username }, contributorList);
return !_.find({
login: username
}, contributorList);
}

@@ -18,7 +24,5 @@

});
var writeContributorsP = contributorsP.then(function (contributors) {
return util.configFile.writeContributors(options.config, contributors);
});
return Promise.all([answersP, contributorsP, writeContributorsP]).then(function (res) {

@@ -25,0 +29,0 @@ var answers = res[0];

@@ -1,6 +0,9 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var inquirer = require('inquirer');
var util = require('../util');
var repo = require('../repo');

@@ -51,2 +54,3 @@

}
return true;

@@ -53,0 +57,0 @@ }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -3,0 +3,0 @@ var _ = require('lodash/fp');

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -27,3 +27,2 @@ var _ = require('lodash/fp');

};
var url = getUrl(contribution, contributor);

@@ -37,3 +36,5 @@

return linkTemplate(_.assign({ url }, templateData));
return linkTemplate(_.assign({
url
}, templateData));
};

@@ -40,0 +41,0 @@

@@ -1,9 +0,13 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var formatContributionType = require('./format-contribution-type');
var avatarTemplate = _.template('<img src="<%= contributor.avatar_url %>" width="<%= options.imageSize %>px;" alt="<%= name %>"/>');
var avatarBlockTemplate = _.template('[<%= avatar %><br /><sub><b><%= name %></b></sub>](<%= contributor.profile %>)');
var avatarBlockTemplateNoProfile = _.template('<%= avatar %><br /><sub><b><%= name %></b></sub>');
var contributorTemplate = _.template('<%= avatarBlock %><br /><%= contributions %>');

@@ -18,2 +22,3 @@

}));
var avatarBlockTemplateData = _.assign({

@@ -23,2 +28,3 @@ name,

}, templateData);
var avatarBlock = null;

@@ -32,3 +38,5 @@

return contributorTemplate(_.assign({ avatarBlock }, templateData));
return contributorTemplate(_.assign({
avatarBlock
}, templateData));
}

@@ -42,2 +50,3 @@

var formatter = _.partial(formatContributionType, [options, contributor]);
var contributions = contributor.contributions.map(formatter).join(' ');

@@ -47,6 +56,10 @@ var templateData = {

contributor,
options: _.assign({ imageSize: defaultImageSize }, options)
options: _.assign({
imageSize: defaultImageSize
}, options)
};
var customTemplate = options.contributorTemplate && _.template(options.contributorTemplate);
return (customTemplate || defaultTemplate)(templateData);
};

@@ -1,6 +0,9 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var injectContentBetween = require('../util').markdown.injectContentBetween;
var formatBadge = require('./format-badge');
var formatContributor = require('./format-contributor');

@@ -17,5 +20,7 @@

var startOfClosingTagIndex = previousContent.indexOf(`${tagToLookFor}END`, endOfOpeningTagIndex);
if (startOfOpeningTagIndex === -1 || endOfOpeningTagIndex === -1 || startOfClosingTagIndex === -1) {
return previousContent;
}
return [previousContent.slice(0, endOfOpeningTagIndex + closingTag.length), '\n<!-- prettier-ignore -->', newContent, previousContent.slice(startOfClosingTagIndex)].join('');

@@ -48,5 +53,7 @@ };

var regexResult = badgeRegex.exec(previousContent);
if (!regexResult) {
return previousContent;
}
return previousContent.slice(0, regexResult.index) + newContent + previousContent.slice(regexResult.index + regexResult[0].length);

@@ -53,0 +60,0 @@ };

@@ -1,5 +0,7 @@

'use strict';
"use strict";
var util = require('../util');
var prompt = require('./prompt');
var initContent = require('./init-content');

@@ -6,0 +8,0 @@

@@ -1,4 +0,5 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var injectContentBetween = require('../util').markdown.injectContentBetween;

@@ -25,5 +26,7 @@

var insertionLine = findContributorsSection(lines);
if (insertionLine === -1) {
return lines.concat(['## Contributors', '', headerContent, '', listContent, '', footerContent]);
}
return injectContentBetween(lines, listContent, insertionLine + 2, insertionLine + 2);

@@ -30,0 +33,0 @@ }

@@ -1,5 +0,7 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var inquirer = require('inquirer');
var git = require('../util').git;

@@ -78,2 +80,3 @@

}
return inquirer.prompt(questions);

@@ -90,3 +93,4 @@ }).then(function (answers) {

commit: answers.commit,
contributors: []
contributors: [],
contributorsPerLine: 7
},

@@ -93,0 +97,0 @@ contributorFile: answers.contributorFile,

@@ -1,8 +0,11 @@

'use strict';
"use strict";
var pify = require('pify');
var request = pify(require('request'));
function getRequestHeaders() {
var optionalPrivateToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
function getRequestHeaders(optionalPrivateToken) {
if (optionalPrivateToken === void 0) {
optionalPrivateToken = '';
}

@@ -42,2 +45,3 @@ var requestHeaders = {

var body = JSON.parse(res.body);
if (res.statusCode >= 400) {

@@ -47,9 +51,11 @@ if (res.statusCode === 404) {

}
throw new Error(body.message);
}
var contributorsIds = body.map(function (contributor) {
return contributor.login;
});
var nextLink = getNextLink(res.headers.link);
var nextLink = getNextLink(res.headers.link);
if (nextLink) {

@@ -77,5 +83,4 @@ return getContributorsPage(nextLink).then(function (nextContributors) {

var body = JSON.parse(res.body);
var profile = body.blog || body.html_url;
var profile = body.blog || body.html_url; // Github throwing specific errors as 200...
// Github throwing specific errors as 200...
if (!profile && body.message) {

@@ -86,3 +91,2 @@ throw new Error(body.message);

profile = profile.startsWith('http') ? profile : `http://${profile}`;
return {

@@ -103,4 +107,3 @@ login: body.login,

var root = hostname.replace(/:\/\//, '://api.');
var url = `${root}/repos/${owner}/${name}/contributors?per_page=100`;
return getContributorsPage(url, optionalPrivateToken);
return getContributorsPage(`${root}/repos/${owner}/${name}/contributors?per_page=100`, optionalPrivateToken);
};

@@ -107,0 +110,0 @@

@@ -1,11 +0,13 @@

'use strict';
"use strict";
var pify = require('pify');
var request = pify(require('request'));
var addPrivateToken = function (url) {
var privateToken = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var addPrivateToken = function (url, privateToken) {
if (privateToken === void 0) {
privateToken = '';
}
if (privateToken === '') return url;
return `${url}&private_token=${privateToken}`.replace(/\?/g, '&').replace('&', '?');

@@ -26,10 +28,9 @@ };

}).then(function (res) {
var body = JSON.parse(res.body);
var body = JSON.parse(res.body); // Gitlab returns an array of users. If it is empty, it means the username provided does not exist
// Gitlab returns an array of users. If it is empty, it means the username provided does not exist
if (!body || body.length === 0) {
throw new Error(`User ${username} not found`);
}
} // no private token present
// no private token present
if (body.message) {

@@ -40,3 +41,2 @@ throw new Error(body.message);

var user = body[0];
return {

@@ -62,5 +62,4 @@ login: user.username,

}).then(function (res) {
var projects = JSON.parse(res.body);
var projects = JSON.parse(res.body); // Gitlab returns an array of users. If it is empty, it means the username provided does not exist
// Gitlab returns an array of users. If it is empty, it means the username provided does not exist
if (!projects || projects.length === 0) {

@@ -71,2 +70,3 @@ throw new Error(`Project ${owner}/${name} not found`);

var project = null;
for (var i = 0; i < projects.length; i++) {

@@ -90,2 +90,3 @@ if (projects[i].path_with_namespace === `${owner}/${name}`) {

var contributors = JSON.parse(newRes.body);
if (newRes.statusCode >= 400) {

@@ -95,4 +96,6 @@ if (newRes.statusCode === 404) {

}
throw new Error(contributors.message);
}
return contributors.map(function (item) {

@@ -99,0 +102,0 @@ return item.name;

@@ -1,4 +0,5 @@

'use strict';
"use strict";
var githubAPI = require('./github');
var gitlabAPI = require('./gitlab');

@@ -47,2 +48,3 @@

}
return null;

@@ -55,2 +57,3 @@ };

}
return null;

@@ -63,2 +66,3 @@ };

}
return null;

@@ -71,2 +75,3 @@ };

}
return null;

@@ -79,2 +84,3 @@ };

}
return null;

@@ -87,2 +93,3 @@ };

}
return null;

@@ -95,2 +102,3 @@ };

}
return null;

@@ -97,0 +105,0 @@ };

@@ -1,5 +0,7 @@

'use strict';
"use strict";
var fs = require('fs');
var pify = require('pify');
var _ = require('lodash/fp');

@@ -10,5 +12,7 @@

var config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
if (!('repoType' in config)) {
config.repoType = 'github';
}
return config;

@@ -19,5 +23,7 @@ } catch (error) {

}
if (error.code === 'ENOENT') {
throw new Error(`Configuration file not found: ${configPath}`);
}
throw error;

@@ -31,2 +37,3 @@ }

}
if (!content.projectName) {

@@ -39,2 +46,3 @@ throw new Error(`Error! Project name is not set in ${configPath}`);

}
return pify(fs.writeFile)(configPath, `${JSON.stringify(content, null, 2)}\n`);

@@ -44,3 +52,4 @@ }

function writeContributors(configPath, contributors) {
var config = void 0;
var config;
try {

@@ -51,3 +60,7 @@ config = readConfig(configPath);

}
var content = _.assign(config, { contributors });
var content = _.assign(config, {
contributors
});
return writeConfig(configPath, content);

@@ -54,0 +67,0 @@ }

@@ -1,4 +0,5 @@

'use strict';
"use strict";
var _ = require('lodash/fp');
var repo = require('../repo');

@@ -5,0 +6,0 @@

@@ -1,10 +0,12 @@

'use strict';
"use strict";
var path = require('path');
var spawn = require('child_process').spawn;
var _ = require('lodash/fp');
var pify = require('pify');
var commitTemplate = '<%= (newContributor ? "Add" : "Update") %> @<%= username %> as a contributor';
var getRemoteOriginData = pify(function (cb) {

@@ -16,3 +18,2 @@ var output = '';

});
git.stderr.on('data', cb);

@@ -26,2 +27,3 @@ git.on('close', function () {

var result = /:(\w+)\/([A-Za-z0-9-_]+)/.exec(originUrl);
if (!result) {

@@ -64,2 +66,3 @@ return null;

var commitMessage = _.template(options.commitTemplate || commitTemplate)(data);
return spawnGitCommand(['commit', '-m', commitMessage]);

@@ -66,0 +69,0 @@ });

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -3,0 +3,0 @@ module.exports = {

@@ -1,4 +0,5 @@

'use strict';
"use strict";
var fs = require('fs');
var pify = require('pify');

@@ -5,0 +6,0 @@

{
"name": "all-contributors-cli",
"version": "5.10.1",
"version": "5.10.2",
"description": "Tool to easily add recognition for new contributors",

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

"validate": "kcd-scripts validate",
"precommit": "kcd-scripts precommit"
"commit": "npx git-cz"
},
"husky": {
"hooks": {
"pre-commit": "kcd-scripts pre-commit"
}
},
"repository": {

@@ -39,14 +44,17 @@ "type": "git",

"dependencies": {
"@babel/runtime": "^7.2.0",
"async": "^2.0.0-rc.1",
"chalk": "^2.3.0",
"inquirer": "^4.0.0",
"inquirer": "^6.2.1",
"lodash": "^4.11.2",
"pify": "^3.0.0",
"pify": "^4.0.1",
"request": "^2.72.0",
"yargs": "^10.0.3"
"yargs": "^12.0.5"
},
"devDependencies": {
"codecov": "^3.1.0",
"kcd-scripts": "^0.30.4",
"nock": "^9.1.0",
"cz-conventional-changelog": "^2.1.0",
"git-cz": "^1.8.0",
"kcd-scripts": "^0.49.0",
"nock": "^10.0.6",
"semantic-release": "^15.13.2"

@@ -68,3 +76,8 @@ },

}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
}

@@ -12,5 +12,7 @@ > [There is now a GitHub Bot](https://github.com/all-contributors/all-contributors-bot) for automating the maintenance of your contributors table ✨<br />Say goodbye to command line tool dependencies and hello to the [@all-contributors bot πŸ€–](https://github.com/all-contributors/all-contributors-bot)

[![Code Coverage][coverage-badge]][coverage]
[![Greenkeeper badge](https://badges.greenkeeper.io/all-contributors/all-contributors-cli.svg)](https://greenkeeper.io/)
[![version][version-badge]][package] [![downloads][downloads-badge]][downloads]
[![MIT License][license-badge]][license]
[![Chat on Slack][chat-badge]][chat]
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

@@ -17,0 +19,0 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-28-orange.svg?style=flat-square)](#contributors)

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