update / updater-contributors Goto Github PK
View Code? Open in Web Editor NEWUpdate the contributors array in package.json with the contributors returned by the GitHub API.
License: MIT License
Update the contributors array in package.json with the contributors returned by the GitHub API.
License: MIT License
Wanted to get this into our publishing workflow, but ran into varied difficulties.
First problem is that there's something weird going on in either repo-utils
, expand-pkg
, or parse-git-config
. Was trying to fix this, but once parse-git-config
giving me problems, I crawled back out of the rabbit hole.
To reproduce badness:
npm install -g update update-contributors
update init
, choose contributors
update
in mocha working copyboneskull@lectroid /Volumes/alien/mochajs/mocha [21:19:53]
> $ update ⬡ 7.1.0 [±master ✓]
[21:19:59] using file ~/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/lib/updatefile.js
[21:19:59] starting update.contributors
[21:19:59] starting update.contributors:default task
[21:19:59] ✔ running: contributors
[21:19:59] starting update.contributors:authenticate task
[21:19:59] finished update.contributors:authenticate task 3ms
TypeError: Cannot read property 'split' of undefined
at Object.repo.expandUrl (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/repo-utils/index.js:432:24)
at Schema.module.exports (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/expand-pkg/lib/expanders/git.js:9:36)
at Schema.normalizeField (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/map-schema/index.js:557:16)
at Schema.update (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/map-schema/index.js:246:8)
at Schema.module.exports (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/expand-pkg/lib/expanders/owner.js:14:10)
at Schema.normalizeField (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/map-schema/index.js:557:16)
at Schema.normalize (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/map-schema/index.js:497:27)
at Config.expand (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/expand-pkg/index.js:103:22)
at Pkg.<anonymous> (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/update/node_modules/base-pkg/index.js:55:27)
at Task.fn (/Users/boneskull/.nvm/versions/node/v7.1.0/lib/node_modules/updater-contributors/updatefile.js:23:24)
Mocha's package.json
has a string homepage
value and an object repository
value.
I tracked the problem to the weirdness happening in lib/expanders/git.js
of expand-pkg
:
module.exports = function(val, key, config, schema) {
if (utils.isString(config.repository)) {
utils.merge(config, utils.repo.expandUrl(config.homepage, config));
}
// snip
};
I'm not sure why we're looking at config.repository
and then expanding config.homepage
. The intent of this function is unclear. To convince myself I was sane, I created a failing test:
it('should use the given homepage if repository.url is present', function() {
var pkg = {
homepage: 'https://github.com/jonschlinkert/test-project',
repository: 'git://github.com/jonschlinkert/test-project.git'
};
var res = config.expand(pkg);
assert(res.homepage);
assert(res.homepage, 'https://github.com/jonschlinkert/test-project');
});
Anyhow, there were a bunch of other failing tests here, because of problems in parse-git-config
and its ilk. Here are some:
1) expand-pkg (no git repository) owner should get owner from the git url:
AssertionError: 'Christopher%20Hiller' == 'Christopher Hiller'
+ expected - actual
-Christopher%20Hiller
+Christopher Hiller
at Context.<anonymous> (test/test-no-git.js:271:14)
2) expand (no package.json) homepage should add a homepage from git repository:
AssertionError: 'https://github.com/Christopher%20Hiller/project-no-package' == 'https://github.com/jonschlinkert/project-no-package'
+ expected - actual
-https://github.com/Christopher%20Hiller/project-no-package
+https://github.com/jonschlinkert/project-no-package
at Context.<anonymous> (test/test-no-package.js:275:14)
at test/test-no-package.js:256:9
at node_modules/gitty/lib/repository.js:529:5
at ChildProcess.exithandler (child_process.js:202:7)
at maybeClose (internal/child_process.js:885:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at Pipe._handle.close [as _onclose] (net.js:501:12)
3) expand (no package.json) homepage should add repository when setting hompage:
AssertionError: 'Christopher%20Hiller/project-no-package' == 'jonschlinkert/project-no-package'
+ expected - actual
-Christopher%20Hiller/project-no-package
+jonschlinkert/project-no-package
at Context.<anonymous> (test/test-no-package.js:281:14)
at test/test-no-package.js:256:9
at node_modules/gitty/lib/repository.js:529:5
at ChildProcess.exithandler (child_process.js:202:7)
at maybeClose (internal/child_process.js:885:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
FWIW, this is my .gitconfig. If the format is invalid, Git is not complaining about it.
This is where I gave up and decided to tell you about it. 😄
Anyway, once I disabled the weirdness caused by expand-pkg
's lib/expanders/git.js
, I got some contributors:
{
"contributors": [
"TJ Holowaychuk <[email protected]> (http://tjholowaychuk.com)",
"Christopher Hiller <[email protected]> (https://boneskull.com)",
"Travis Jeffery <[email protected]> (https://twitter.com/travisjeffery)",
"Daniel St. Jules <[email protected]> (http://danielstjules.com)",
"David da Silva <[email protected]> (http://dasilvacont.in)",
"Guillermo Rauch <[email protected]> (http://twitter.com/rauchg)",
"Ariel Mashraki <[email protected]> (https://twitter.com/arielmashraki)",
"Attila Domokos (http://www.adomokos.com)",
"John Firebaugh (https://github.com/jfirebaugh)",
"Nathan Houle <[email protected]> (http://nathanhoule.com)",
"Jo Liss <[email protected]> (https://twitter.com/jo_liss)",
"(https://github.com/jugglinmike)",
"Nathan Rajlich <[email protected]> (http://n8.io)",
"Brendan Nee <[email protected]> (http://blinktag.com)",
"Glen Mailer <[email protected]> (http://stainlessed.co.uk)",
"James Carr <[email protected]> (http://blog.james-carr.org)",
"Domenic Denicola <[email protected]> (https://domenic.me)",
"Scott Santucci <[email protected]> (https://ScottFreeCode.github.io)",
"Aaron Heckmann <[email protected]> (http://twitter.com/aaronheckmann)",
"Mislav Marohnić <[email protected]> (http://mislav.net)",
"Peter Müller <[email protected]> (https://mntr.dk)",
"Ryunosuke Sato <[email protected]> (http://tricknotes.hateblo.jp)",
"Kazuhito Hokamura (http://webtech-walker.com)",
"Forbes Lindesay (http://www.forbeslindesay.co.uk)",
"jongleberry <[email protected]> (twitter.com/jongleberry)",
"Joshua Krall <[email protected]> (https://github.com/jkrall)",
"Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"Jake Verbaten <[email protected]> (http://github.com/Raynos)",
"Xavier Antoviaque <[email protected]> (http://antoviaque.org)",
"Andreas Lind <[email protected]> (https://github.com/papandreou)",
"Ben Bradley (https://github.com/ben-bradley/resume)",
"Benjie Gillam (http://www.benjiegillam.com)",
"Cory Thomas (https://github.com/dump247)",
"Fredrik Enestad <[email protected]> (http://soundtrackyourbrand.com)",
"(https://github.com/jldailey)",
"Merrick Christensen <[email protected]> (http://www.merrickchristensen.com)",
"Michael Demmer (https://github.com/demmer)",
"Nathan Bowser <[email protected]> (nathanbowser.com)",
"Paul Miller <[email protected]> (paulmillr.com)",
"Rico Sta. Cruz <[email protected]> (http://ricostacruz.com)",
"Sindre Sorhus <[email protected]> (https://twitter.com/sindresorhus)",
"Sune Simonsen <[email protected]> (https://github.com/sunesimonsen)",
"Tyson Mote <[email protected]> (http://stovepipestudios.com)",
"Valentin Agachi (http://agachi.name)",
"Wil Moore III <[email protected]> (http://wilmoore.com)",
"eiji.ienaga (http://friendfeed.com/haru01)",
"Zhouxuan Yang <[email protected]> (http://fool2fish.cn)",
"Adam Gruber (https://github.com/adamgruber)",
"Alex Early (http://aeflash.com)",
"Arian Stolwijk <[email protected]> (http://www.aryweb.nl)",
"Avi Vahl (https://github.com/AviVahl)",
"",
"Brian Beck <[email protected]> (http://brianbeck.com)",
"Buck Doyle (https://github.com/backspace)",
"Christian (http://www.rndm.de)",
"",
"",
"Ian Storm Taylor (http://ianstormtaylor.com)",
"",
"Jacob Wejendorp (http://dorp.io)",
"James Nylen <[email protected]> (https://about.me/jnylen)",
"John Reeves (http://jonnyreeves.co.uk)",
"",
"",
"Konstantin Käfer <[email protected]> (https://kkaefer.com)",
"Long Ho <[email protected]> (https://medium.com/@longho)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Simon Gaeremynck (http://www.gaeremynck.com)",
"",
"",
"",
"",
"Xavier Damman <[email protected]> (http://xdamman.com)",
"",
"",
"",
"",
"",
"",
"",
"",
"(https://github.com/aaroncrows)",
"",
"",
"",
"",
"Andrew Nesbitt <[email protected]> (http://nesbitt.io)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Benoit Larroque (https://github.com/zetaben)",
"",
"",
"Berker Peksag <[email protected]> (http://berkerpeksag.com)",
"",
"",
"",
"",
"",
"",
"",
"",
"Charles Lowell <[email protected]> (http://frontside.io)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Dominic Barnes <[email protected]> (http://dbarnes.info)",
"Douglas Wilson <[email protected]> (https://github.com/dougwilson)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Greg Perkins <[email protected]> (https://twitter.com/gregrperkins)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"James Lal <[email protected]> (http://blog.lightsofapollo.com)",
"",
"",
"",
"",
"",
"",
"",
"Jeremy Martin (https://twitter.com/jmar777)",
"",
"João Moreno (http://resume.joaomoreno.com)",
"Joey Cozza <[email protected]> (https://github.com/joeycozza)",
"John Doty <[email protected]> (https://github.com/jrhdoty)",
"",
"Jonas Dohse (https://github.com/dohse)",
"(https://github.com/jcreamer898)",
"",
"",
"Jordan Sexton <[email protected]> (http://jordansexton.com)",
"Josh Eversmann (https://github.com/jeversmann)",
"Josh Lory (https://github.com/joshlory)",
"Julien Wajsberg (http://everlong.org)",
"",
"",
"",
"Keith Cirkel (https://www.keithcirkel.co.uk)",
"Kent C. Dodds <[email protected]> (https://kentcdodds.com)",
"Kevin Burke <[email protected]> (https://kev.inburke.com)",
"Kevin Conway <[email protected]> (https://github.com/kevinconway)",
"Kevin Kirsche <[email protected]> (https://kevinkirsche.com)",
"",
"",
"",
"",
"",
"",
"",
"Mal Graty (https://github.com/mal)",
"Marc Kuo <[email protected]> (https://routific.com)",
"Marcello Bastéa-Forte <[email protected]> (http://marcello.cellosoft.com)",
"",
"",
"",
"",
"",
"Matthew Shanley <[email protected]> (http://littlesecretsrecords.com)",
"(https://github.com/mattias-lw)",
"Michael Jackson <[email protected]> (http://mjackson.me)",
"Mike Olson (http://mwolson.org)",
"",
"",
"Michal Charemza (http://charemza.name)",
"Mick Brooks (http://sinking.in/blog)",
"Nathan Black <[email protected]> (http://nathanblack.org)",
"",
"",
"olegtsyba <[email protected]> (https://github.com/olegabyst)",
"",
"",
"Pete Hawkins (http://phawk.co.uk)",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
}
You can see the current values here.
per this issue update/update#9, from @jamen.
We can add a task that generates the AUTHORS file using the array of authors returned from the GitHub API, and/or directly from package.json authors.
@doowb I know you've done a lot of stuff with the github API recently, I just pushed this up based on the conversation in update/update#10, but there should probably be an auth
task that runs before the default
task. Maybe even a prompt-auth
task as well.
cc @jamen
I just tried this out on a new repo, and it doesn't seem to do anything, while the output looks ok:
[15:44:34] using file ~/home/basti/.node_modules/lib/node_modules/update/lib/updatefile.js
[15:44:35] starting update.contributors
[15:44:35] starting update.contributors:default task
[15:44:35] ✔ running: contributors
[15:44:35] starting update.contributors:authenticate task
[15:44:35] finished update.contributors:authenticate task 2ms
[15:44:36] finished update.contributors:default task 1s
[15:44:36] finished update.contributors ✔ 1s
Here's the repo (which has one contributor atm): https://github.com/67P/kosmos-schemas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.