Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-04-07 09:25:58 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-04-09 07:38:41 +0300
commiteaf75acb718611ad5cfb360084ec86938d9c66c5 (patch)
treef1a7ceb4c5e4c6ba2980ffd4f0d851513bb4eb32 /node_modules/normalize-package-data
parent23a1d5a540e8db27f5cd0245de7c3694e2bddad1 (diff)
normalize-package-data@2.0.0
Diffstat (limited to 'node_modules/normalize-package-data')
-rw-r--r--node_modules/normalize-package-data/README.md6
-rw-r--r--node_modules/normalize-package-data/lib/fixer.js42
-rw-r--r--node_modules/normalize-package-data/package.json38
-rw-r--r--node_modules/normalize-package-data/test/normalize.js17
-rw-r--r--node_modules/normalize-package-data/test/typo.js13
5 files changed, 62 insertions, 54 deletions
diff --git a/node_modules/normalize-package-data/README.md b/node_modules/normalize-package-data/README.md
index 1429e4042..4b159126d 100644
--- a/node_modules/normalize-package-data/README.md
+++ b/node_modules/normalize-package-data/README.md
@@ -1,4 +1,4 @@
-# normalize-package-data [![Build Status](https://travis-ci.org/meryn/normalize-package-data.png?branch=master)](https://travis-ci.org/meryn/normalize-package-data)
+# normalize-package-data [![Build Status](https://travis-ci.org/npm/normalize-package-data.png?branch=master)](https://travis-ci.org/npm/normalize-package-data)
normalize-package data exports a function that normalizes package metadata. This data is typically found in a package.json file, but in principle could come from any source - for example the npm registry.
@@ -68,9 +68,11 @@ If the supplied data has an invalid name or version vield, `normalizeData` will
* If `bundledDependencies` field (a typo) exists and `bundleDependencies` field does not, `bundledDependencies` will get renamed to `bundleDependencies`.
* If the value of any of the dependencies fields (`dependencies`, `devDependencies`, `optionalDependencies`) is a string, it gets converted into an object with familiar `name=>value` pairs.
* The values in `optionalDependencies` get added to `dependencies`. The `optionalDependencies` array is left untouched.
+* As of v2: Dependencies that point at known hosted git providers (currently: github, bitbucket, gitlab) will have their URLs canonicalized, but protocols will be preserved.
+* As of v2: Dependencies that use shortcuts for hosted git providers (`org/proj`, `github:org/proj`, `bitbucket:org/proj`, `gitlab:org/proj`, `gist:docid`) will have the shortcut left in place. (In the case of github, the `org/proj` form will be expanded to `github:org/proj`.) THIS MARKS A BREAKING CHANGE FROM V1, where the shorcut was previously expanded to a URL.
* If `description` field does not exist, but `readme` field does, then (more or less) the first paragraph of text that's found in the readme is taken as value for `description`.
* If `repository` field is a string, it will become an object with `url` set to the original string value, and `type` set to `"git"`.
-* If `repository.url` is not a valid url, but in the style of "[owner-name]/[repo-name]", `repository.url` will be set to git://github.com/[owner-name]/[repo-name]
+* If `repository.url` is not a valid url, but in the style of "[owner-name]/[repo-name]", `repository.url` will be set to https://github.com/[owner-name]/[repo-name]
* If `bugs` field is a string, the value of `bugs` field is changed into an object with `url` set to the original string value.
* If `bugs` field does not exist, but `repository` field points to a repository hosted on GitHub, the value of the `bugs` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]/issues . If the repository field points to a GitHub Gist repo url, the associated http url is chosen.
* If `bugs` field is an object, the resulting value only has email and url properties. If email and url properties are not strings, they are ignored. If no valid values for either email or url is found, bugs field will be removed.
diff --git a/node_modules/normalize-package-data/lib/fixer.js b/node_modules/normalize-package-data/lib/fixer.js
index 14c0abc8e..59cd05f75 100644
--- a/node_modules/normalize-package-data/lib/fixer.js
+++ b/node_modules/normalize-package-data/lib/fixer.js
@@ -1,11 +1,10 @@
var semver = require("semver")
-var parseGitHubURL = require("github-url-from-git")
+var hostedGitInfo = require("hosted-git-info")
var depTypes = ["dependencies","devDependencies","optionalDependencies"]
var extractDescription = require("./extract_description")
var url = require("url")
var typos = require("./typos")
var coreModuleNames = require("./core_module_names")
-var githubUserRepo = require("github-url-from-username-repo")
var fixer = module.exports = {
// default warning function
@@ -25,12 +24,10 @@ var fixer = module.exports = {
}
var r = data.repository.url || ""
if (r) {
- var ghurl = parseGitHubURL(r)
- if (ghurl) {
- r = ghurl.replace(/^https?:\/\//, 'git://')
- } else if (githubUserRepo(r)) {
- // repo has 'user/reponame' filled in as repo
- data.repository.url = githubUserRepo(r)
+ var hosted = hostedGitInfo.fromUrl(r)
+ if (hosted) {
+ r = data.repository.url
+ = hosted.getDefaultRepresentation() == "shortcut" ? hosted.https() : hosted.toString()
}
}
@@ -57,7 +54,7 @@ var fixer = module.exports = {
if (typeof data.scripts[k] !== "string") {
this.warn("nonStringScript")
delete data.scripts[k]
- } else if (typos.script[k]) {
+ } else if (typos.script[k] && !data.scripts[typos.script[k]]) {
this.warn("typo", k, typos.script[k], "scripts")
}
}, this)
@@ -143,11 +140,8 @@ var fixer = module.exports = {
this.warn("nonStringDependency", d, JSON.stringify(r))
delete data[deps][d]
}
- // "/" is not allowed as packagename for publishing, but for git-urls
- // normalize shorthand-urls
- if (githubUserRepo(data[deps][d])) {
- data[deps][d] = 'git+' + githubUserRepo(data[deps][d])
- }
+ var hosted = hostedGitInfo.fromUrl(data[deps][d])
+ if (hosted) data[deps][d] = hosted.toString()
}, this)
}, this)
}
@@ -234,12 +228,9 @@ var fixer = module.exports = {
, fixBugsField: function(data) {
if (!data.bugs && data.repository && data.repository.url) {
- var gh = parseGitHubURL(data.repository.url)
- if(gh) {
- if(gh.match(/^https:\/\/github.com\//))
- data.bugs = {url: gh + "/issues"}
- else // gist url
- data.bugs = {url: gh}
+ var hosted = hostedGitInfo.fromUrl(data.repository.url)
+ if(hosted && hosted.bugs()) {
+ data.bugs = {url: hosted.bugs()}
}
}
else if(data.bugs) {
@@ -278,13 +269,10 @@ var fixer = module.exports = {
, fixHomepageField: function(data) {
if (!data.homepage && data.repository && data.repository.url) {
- var gh = parseGitHubURL(data.repository.url)
- if (gh)
- data.homepage = gh
- else
- return true
- } else if (!data.homepage)
- return true
+ var hosted = hostedGitInfo.fromUrl(data.repository.url)
+ if (hosted && hosted.docs()) data.homepage = hosted.docs()
+ }
+ if (!data.homepage) return
if(typeof data.homepage !== "string") {
this.warn("nonUrlHomepage")
diff --git a/node_modules/normalize-package-data/package.json b/node_modules/normalize-package-data/package.json
index 6da54694c..8f4aeadca 100644
--- a/node_modules/normalize-package-data/package.json
+++ b/node_modules/normalize-package-data/package.json
@@ -1,6 +1,6 @@
{
"name": "normalize-package-data",
- "version": "1.0.3",
+ "version": "2.0.0",
"author": {
"name": "Meryn Stol",
"email": "merynstol@gmail.com"
@@ -8,15 +8,14 @@
"description": "Normalizes data that can be found in package.json files.",
"repository": {
"type": "git",
- "url": "git://github.com/meryn/normalize-package-data.git"
+ "url": "git://github.com/npm/normalize-package-data.git"
},
"main": "lib/normalize.js",
"scripts": {
"test": "tap test/*.js"
},
"dependencies": {
- "github-url-from-git": "^1.3.0",
- "github-url-from-username-repo": "^1.0.0",
+ "hosted-git-info": "^2.0.2",
"semver": "2 || 3 || 4"
},
"devDependencies": {
@@ -38,19 +37,19 @@
"email": "rok@kowalski.gd"
}
],
- "gitHead": "8c30091c83b1a41e113757148c4543ef61ff863d",
+ "gitHead": "ea0b959633e4803685bae2283d3d79a0115e6f8a",
"bugs": {
- "url": "https://github.com/meryn/normalize-package-data/issues"
+ "url": "https://github.com/npm/normalize-package-data/issues"
},
- "homepage": "https://github.com/meryn/normalize-package-data",
- "_id": "normalize-package-data@1.0.3",
- "_shasum": "8be955b8907af975f1a4584ea8bb9b41492312f5",
- "_from": "normalize-package-data@>=1.0.3 <1.1.0",
- "_npmVersion": "2.1.0",
- "_nodeVersion": "0.10.31",
+ "homepage": "https://github.com/npm/normalize-package-data",
+ "_id": "normalize-package-data@2.0.0",
+ "_shasum": "8795d0d5c70c0e9ca36f419548aac0abf1f638bc",
+ "_from": "normalize-package-data@>=2.0.0 <2.1.0",
+ "_npmVersion": "2.7.5",
+ "_nodeVersion": "1.6.2",
"_npmUser": {
- "name": "isaacs",
- "email": "i@izs.me"
+ "name": "iarna",
+ "email": "me@re-becca.org"
},
"maintainers": [
{
@@ -64,12 +63,17 @@
{
"name": "othiym23",
"email": "ogd@aoaioxxysz.net"
+ },
+ {
+ "name": "iarna",
+ "email": "me@re-becca.org"
}
],
"dist": {
- "shasum": "8be955b8907af975f1a4584ea8bb9b41492312f5",
- "tarball": "http://registry.npmjs.org/normalize-package-data/-/normalize-package-data-1.0.3.tgz"
+ "shasum": "8795d0d5c70c0e9ca36f419548aac0abf1f638bc",
+ "tarball": "http://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.0.0.tgz"
},
"directories": {},
- "_resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-1.0.3.tgz"
+ "_resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.0.0.tgz",
+ "readme": "ERROR: No README data found!"
}
diff --git a/node_modules/normalize-package-data/test/normalize.js b/node_modules/normalize-package-data/test/normalize.js
index b35eed765..96b254453 100644
--- a/node_modules/normalize-package-data/test/normalize.js
+++ b/node_modules/normalize-package-data/test/normalize.js
@@ -9,6 +9,7 @@ var warningMessages = require("../lib/warning_messages.json")
var safeFormat = require("../lib/safe_format")
var rpjPath = path.resolve(__dirname,"./fixtures/read-package-json.json")
+
tap.test("normalize some package data", function(t) {
var packageData = require(rpjPath)
var warnings = []
@@ -143,7 +144,7 @@ tap.test("gist bugs url", function(t) {
repository: "git@gist.github.com:123456.git"
}
normalize(d)
- t.same(d.repository, { type: 'git', url: 'git@gist.github.com:123456.git' })
+ t.same(d.repository, { type: 'git', url: 'git+ssh://git@gist.github.com/123456.git' })
t.same(d.bugs, { url: 'https://gist.github.com/123456' })
t.end();
});
@@ -151,21 +152,21 @@ tap.test("gist bugs url", function(t) {
tap.test("singularize repositories", function(t) {
var d = {repositories:["git@gist.github.com:123456.git"]}
normalize(d)
- t.same(d.repository, { type: 'git', url: 'git@gist.github.com:123456.git' })
+ t.same(d.repository, { type: 'git', url: 'git+ssh://git@gist.github.com/123456.git' })
t.end()
});
tap.test("treat visionmedia/express as github repo", function(t) {
var d = {repository: {type: "git", url: "visionmedia/express"}}
normalize(d)
- t.same(d.repository, { type: "git", url: "https://github.com/visionmedia/express" })
+ t.same(d.repository, { type: "git", url: "https://github.com/visionmedia/express.git" })
t.end()
});
tap.test("treat isaacs/node-graceful-fs as github repo", function(t) {
var d = {repository: {type: "git", url: "isaacs/node-graceful-fs"}}
normalize(d)
- t.same(d.repository, { type: "git", url: "https://github.com/isaacs/node-graceful-fs" })
+ t.same(d.repository, { type: "git", url: "https://github.com/isaacs/node-graceful-fs.git" })
t.end()
});
@@ -174,7 +175,7 @@ tap.test("homepage field will set to github url if repository is a github repo",
normalize(a={
repository: { type: "git", url: "https://github.com/isaacs/node-graceful-fs" }
})
- t.same(a.homepage, 'https://github.com/isaacs/node-graceful-fs')
+ t.same(a.homepage, 'https://github.com/isaacs/node-graceful-fs#readme')
t.end()
})
@@ -192,14 +193,14 @@ tap.test("homepage field will set to github gist url if repository is a shorthan
normalize(a={
repository: { type: "git", url: "sindresorhus/chalk" }
})
- t.same(a.homepage, 'https://github.com/sindresorhus/chalk')
+ t.same(a.homepage, 'https://github.com/sindresorhus/chalk#readme')
t.end()
})
-tap.test("treat isaacs/node-graceful-fs as github repo in dependencies", function(t) {
+tap.test("don't mangle github shortcuts in dependencies", function(t) {
var d = {dependencies: {"node-graceful-fs": "isaacs/node-graceful-fs"}}
normalize(d)
- t.same(d.dependencies, {"node-graceful-fs": "git+https://github.com/isaacs/node-graceful-fs" })
+ t.same(d.dependencies, {"node-graceful-fs": "github:isaacs/node-graceful-fs" })
t.end()
});
diff --git a/node_modules/normalize-package-data/test/typo.js b/node_modules/normalize-package-data/test/typo.js
index eda75545e..dfa2b90e5 100644
--- a/node_modules/normalize-package-data/test/typo.js
+++ b/node_modules/normalize-package-data/test/typo.js
@@ -102,6 +102,19 @@ test('typos', function(t) {
t.same(warnings, expect)
warnings.length = 0
+ expect =
+ [ warningMessages.missingDescription,
+ warningMessages.missingRepository,
+ warningMessages.missingReadme ]
+
+ normalize({name:"name"
+ ,version:"1.2.5"
+ ,scripts:{server:"start",tests:"test"
+ ,start:"start",test:"test"}}, warn)
+
+ t.same(warnings, expect)
+
+ warnings.length = 0
expect = []
normalize({private: true