git-contributor
Advanced tools
Comparing version 1.1.0 to 2.1.5
@@ -6,3 +6,2 @@ #!/usr/bin/env node | ||
const fs = require('fs'); | ||
const _ = require('xutil'); | ||
const path = require('path'); | ||
@@ -25,12 +24,17 @@ const program = require('commander'); | ||
const cwd = process.cwd(); | ||
gen.getAuthor(options) | ||
.then(list => { | ||
const res = gen.genMarkDown(list); | ||
if (options.markdown) { | ||
const readmes = [ 'README.md', 'readme.md', 'README.zh-CN.md' ]; | ||
readmes.forEach(readmeName => { | ||
const readmeFile = path.join(process.cwd(), readmeName); | ||
if (_.isExistedFile(readmeFile)) { | ||
fs.readdirSync(cwd) | ||
.filter(item => { | ||
return path.extname(item) === '.md' && item.toLowerCase().includes('readme'); | ||
}) | ||
.map(item => path.resolve(cwd, item)) | ||
.map(readmeFile => { | ||
let readmeContent = fs.readFileSync(readmeFile, 'utf8'); | ||
const res = gen.genMarkDown(list.slice(), readmeContent); | ||
const reg = new RegExp(`${res.startToken}[^]*${res.endToken}`); | ||
if (reg.test(readmeContent)) { | ||
@@ -41,9 +45,10 @@ readmeContent = readmeContent.replace(reg, res.content); | ||
} | ||
fs.writeFileSync(readmeFile, readmeContent); | ||
} | ||
}); | ||
if (options.print) { | ||
console.log(res.content); | ||
} | ||
}); | ||
} | ||
if (options.print) { | ||
console.log(res.content); | ||
} | ||
}) | ||
@@ -50,0 +55,0 @@ .catch(e => { |
@@ -11,4 +11,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const Promise = require('bluebird'); | ||
const request = require('request-promise'); | ||
const httpclient = require('urllib'); | ||
@@ -30,8 +29,9 @@ const pkg = require('../package'); | ||
const tasks = maillist.map(email => { | ||
const uri = `${api}${encodeURIComponent(email + ' in:email type:user')}`; | ||
const options = { | ||
uri: `${api}${encodeURIComponent(email + ' in:email type:user')}`, | ||
json: true, | ||
dataType: 'json', | ||
headers: { | ||
'user-agent': Date.now() | ||
} | ||
}, | ||
timeout: 30E3 | ||
}; | ||
@@ -41,3 +41,3 @@ if (process.env.OAUTH_TOKEN) { | ||
} | ||
return request(options); | ||
return httpclient.request(uri, options).then(res => res.data); | ||
}); | ||
@@ -58,7 +58,7 @@ | ||
const options = { | ||
uri, | ||
json: true, | ||
dataType: 'json', | ||
headers: { | ||
'user-agent': Date.now() | ||
} | ||
}, | ||
timeout: 30000 | ||
}; | ||
@@ -68,3 +68,3 @@ if (process.env.OAUTH_TOKEN) { | ||
} | ||
return request(options); | ||
return httpclient.request(uri, options).then(res => res.data); | ||
}; | ||
@@ -130,3 +130,11 @@ | ||
exports.genMarkDown = list => { | ||
const ifHasZh = (readMeContext) => { | ||
let count = 0; | ||
readMeContext.split('').forEach(char => { | ||
if (/[\u4e00-\u9fa5]/.test(char)) count++; | ||
}); | ||
return count / readMeContext.length >= 0.1; | ||
}; | ||
exports.genMarkDown = (list, readMeContext = '') => { | ||
const startToken = '<!-- GITCONTRIBUTOR_START -->'; | ||
@@ -164,6 +172,12 @@ const endToken = '<!-- GITCONTRIBUTOR_END -->'; | ||
const isZH = ifHasZh(readMeContext); | ||
const contributorTitle = isZH ? '贡献者' : 'Contributors'; | ||
const footer = isZH ? | ||
`[git-contributor 说明](${pkg.homepage}),自动生成时间:\`${_.moment()}\`。` : | ||
`This project follows the git-contributor [spec](${pkg.homepage}), auto updated at \`${_.moment()}\`.`; | ||
const res = [ | ||
startToken, | ||
'', | ||
'## Contributors', | ||
`## ${contributorTitle}`, | ||
'', | ||
@@ -174,3 +188,3 @@ contentFirstLine.join('|'), | ||
'', | ||
`This project follows the git-contributor [spec](${pkg.homepage}), auto updated at \`${_.moment()}\`.`, | ||
footer, | ||
'', | ||
@@ -177,0 +191,0 @@ endToken |
{ | ||
"name": "git-contributor", | ||
"version": "1.1.0", | ||
"version": "2.1.5", | ||
"description": "git contributor", | ||
@@ -23,6 +23,4 @@ "keywords": [ | ||
"dependencies": { | ||
"bluebird": "^3.5.1", | ||
"commander": "^2.15.1", | ||
"request": "^2.85.0", | ||
"request-promise": "^4.2.2", | ||
"urllib": "^3.10.0", | ||
"xutil": "^1.0.11" | ||
@@ -32,7 +30,6 @@ }, | ||
"babel-eslint": "^8.2.2", | ||
"co-mocha": "*", | ||
"c8": "^7.12.0", | ||
"eslint": "*", | ||
"eslint-plugin-mocha": "^4.11.0", | ||
"mocha": "*", | ||
"nyc": "^11.6.0", | ||
"mocha": "^10.2.0", | ||
"pre-commit": "*" | ||
@@ -42,5 +39,5 @@ }, | ||
"ci": "npm run lint && npm run test", | ||
"test": "nyc --reporter=lcov --reporter=text mocha", | ||
"test": "c8 --reporter=lcov --reporter=text mocha", | ||
"lint": "eslint . --fix", | ||
"contributor": "./bin/git-contributor" | ||
"contributor": "./bin/git-contributor.js" | ||
}, | ||
@@ -47,0 +44,0 @@ "pre-commit": [ |
# git-contributor | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![build status][CI-image]][CI-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![node version][node-image]][node-url] | ||
@@ -11,6 +11,6 @@ [![npm download][download-image]][download-url] | ||
[npm-url]: https://npmjs.org/package/git-contributor | ||
[travis-image]: https://img.shields.io/travis/xudafeng/git-contributor.svg | ||
[travis-url]: https://travis-ci.org/xudafeng/git-contributor | ||
[coveralls-image]: https://img.shields.io/coveralls/xudafeng/git-contributor.svg | ||
[coveralls-url]: https://coveralls.io/r/xudafeng/git-contributor?branch=master | ||
[CI-image]: https://github.com/xudafeng/git-contributor/actions/workflows/ci.yml/badge.svg | ||
[CI-url]: https://github.com/xudafeng/git-contributor/actions/workflows/ci.yml | ||
[codecov-image]: https://img.shields.io/codecov/c/github/xudafeng/git-contributor.svg?logo=codecov | ||
[codecov-url]: https://app.codecov.io/gh/xudafeng/git-contributor | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg | ||
@@ -27,7 +27,7 @@ [node-url]: http://nodejs.org/download/ | ||
|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>| | ||
| :---: | :---: | :---: | | ||
|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>| | ||
| :---: | :---: | :---: | :---: | | ||
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Mar 24 2022 23:56:33 GMT+0800`. | ||
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Fri May 19 2023 00:20:47 GMT+0800`. | ||
@@ -34,0 +34,0 @@ <!-- GITCONTRIBUTOR_END --> |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13410
3
6
219
1
+ Addedurllib@^3.10.0
+ Added@fastify/busboy@2.1.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefault-user-agent@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddigest-header@1.1.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedform-data-encoder@1.9.0(transitive)
+ Addedformdata-node@4.4.1(transitive)
+ Addedformstream@1.5.1(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedmime@2.6.0(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-hex@1.0.1(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedos-name@1.0.3(transitive)
+ Addedosx-release@1.1.0(transitive)
+ Addedpause-stream@0.0.11(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtype-fest@4.26.1(transitive)
+ Addedundici@5.28.4(transitive)
+ Addedurllib@3.27.0(transitive)
+ Addedweb-streams-polyfill@4.0.0-beta.3(transitive)
+ Addedwin-release@1.1.1(transitive)
+ Addedylru@1.4.0(transitive)
- Removedbluebird@^3.5.1
- Removedrequest@^2.85.0
- Removedrequest-promise@^4.2.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedverror@1.10.0(transitive)