JoshuaKGoldberg / package.json-validator

Tools to validate package.json files
MIT License
107 stars 26 forks source link

Support for shorthand GitHub strings for repository field #29

Closed pdehaan closed 5 months ago

pdehaan commented 10 years ago

I'm getting an error with the following value in my package.json file:

"repository": "mozilla/fxa-profile-server",
package.json is NOT valid
{ valid: false,
  errors: [ 'Type for field repository, was expected to be object, not string' ],
  warnings:
   [ 'Missing recommended field: keywords',
     'Missing recommended field: contributors' ] }

I believe this was added in npm 1.3.10 (per http://dailyjs.com/2013/09/06/npm-updates/). In fact, I think this may be the npm issue: https://github.com/npm/npm/issues/3783

pdehaan commented 9 years ago

I found the github-url-from-username-repo module which beautifully converts a repo shortname to a full URL.

I have this working locally for me (installing globally and using npm link), but the unit tests are failing, but not sure if those were broken locally after I ran npm link).

FWIW, here are my local changes:

  1. var getUrl = require("github-url-from-username-repo");
  2. urlFormat : /^https?.*:\/\/[\w.\-/?=#]+/, 2, "license": {"types": ["string", "object"]},
  3. "repository": {"types": ["object", "string"], warning: true, validate: PJV.validateUrlTypes, or: "repositories"},
  4. if (! PJV.urlFormat.test(getUrl(obj)) && ! PJV.urlFormat.test(obj)) {

UPDATE: Nope, i can definitely confirm that I broke the qunit tests. I guess it doesn't like my Node.js style of using require() at the top of the PJV.js file.

mistadikay commented 8 years ago

Any update on this? This is actually a valid value according to the npm specs: https://docs.npmjs.com/files/package.json#repository

stevenvachon commented 7 years ago

@gorillamania this

Kristinita commented 6 years ago

+1

JoshuaKGoldberg commented 5 months ago

Per https://github.com/npm/cli/issues/7299#issuecomment-2010009355, shorthand strings are now deprecated in favor of long-form objects. npm publish now gives a warning for them. Alas.

Closing this out as no longer something npm encourages. Cheers! 🧡