Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails for Mocha #3

Open
boneskull opened this issue Nov 17, 2016 · 3 comments
Open

fails for Mocha #3

boneskull opened this issue Nov 17, 2016 · 3 comments

Comments

@boneskull
Copy link

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:

  1. execute npm install -g update update-contributors
  2. execute update init, choose contributors
  3. execute update in mocha working copy
  4. result:
boneskull@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.

  1. The contributors should be sorted alphabetically instead of by contribution, which should eliminate most (not all) modifications to this value, and instead only generate additions.
  2. The homepage should fallback to the user's GitHub profile.
  3. The GitHub profile name should be used in lieu of a real name.
@jonschlinkert
Copy link
Member

jonschlinkert commented Dec 1, 2016

so sorry for the late reply, I was out with a bad cold for a couple of weeks. I'll address this ASAP. thanks for the issue

edit: btw, thanks for the suggestions as well. We'll make those changes. It's awesome that you're looking to use this with mocha, I'm sorry I wasn't able to get this taken care of faster.

@boneskull
Copy link
Author

no rush; I'm well-acquainted with providing free support and bug fixes for software 😄

@doowb
Copy link
Member

doowb commented Dec 2, 2016

@boneskull I updated expand-pkg to use the repository property instead of homepage. Thanks for digging into the code to get to that point.

The error should be gone if you reinstall and run update again.

I'll leave this open to address the other suggestions. We'll probably create individual issues around those and then we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants